#! /usr/local/bin/apl --script ⍝ ******************************************************************** ⍝ FILE_test.apl Routines to test functions in FILE_IO ⍝ ⍝ ******************************************************************** )copy 1 utf8 )copy 1 find_test_data )copy 1 assert )copy FILE_IO ∇ test∆FIO ⍝⍝ Master test function for FILE_IO workspaces. At present a work in progress. test∆FIO∆pipeto test∆FIO∆pipefrom ∇ test∆pipeto_message ← ⎕inp 'epm' This tests reads test_data/shakespeare.txt and then pipes it to unix command lpr. The proof of the test is a one page print out of shakespeare.txt. epm ∇ test∆FIO∆pipeto ;txt;cmd ⍝⍝ Function to test FIO∆pipeto ⍞←⎕tc[3] utl∆join test∆pipeto_message,⊂'' txt←utf8∆read test_data,'/ls_test/shakespeare.txt' cmd←'pr --form-feed --length=66' cmd←cmd,' --indent=8' cmd←cmd,' --page-width=85' cmd←cmd,'|lpr' 0 assert∆toScreen 'txt FIO∆pipeto cmd' ∇ ∇ test∆FIO∆pipefrom;dir ⍝⍝ Function to test FIO∆pipefrom dir←(FIO∆read_directory test_data,'/ls_test')[;5] dir←dir[⍋dir] dir←⎕tc[3] utl∆join dir,⊂'' dir assert∆toScreen 'FIO∆pipefrom ''ls ',test_data,'/ls_test''' ∇ test∆file_1←⎕inp 'eo1' #title File One #author Bill Daly #date 20200113 Test data for test of FIO∆pipeform. eo1 test∆file_2←⎕inp 'eo2' #title FILE_TWO #author Bill Daly #date 20200113 eo2 test∆file_3←⎕inp 'shake' Duke. No, holy father; throw away that thought; Believe not that the dribbling dart of love Can pierce a complete bosom. Why I desire thee To give me secret harbour, hath a purpose More grave and wrinkled than the alms and ends Of burning youth. Friar Thomas. May your grace speak of it? Duke. My holy sir, none better knows than you How I have ever lov'd the life remov'd, And held in idle price to haunt assemblies Where youth, and cost, and witless bravery keeps. I have deliver'd to Lord Angelo, A man of stricture and firm abstinence, My absolute power and place here in Vienna, And he supposes me travell'd in Poland; For so I have strew'd it in the common ear, And so receiv'd. Now, pious sir, You will demand of me why I do this? shake ∇ test∆FIO∆create_test_data;fh;err ⍝⍝ Function to create a directory to read for test∆FIO∆pipefrom\ →(0≠'F' FIO∆access test_data)/err01 →(0='F' FIO∆access test_data,'/ls_test')/pass_test →(0≠err←FIO∆mkdir_777 test_data,'/ls_test')/err02 fh←'w'FIO∆fopen test_data,'/ls_test/file_one.muse' (⎕ucs ⎕tc[3] utl∆join test∆file_1) FIO∆fwrite fh FIO∆fclose fh fh←'w'FIO∆fopen test_data,'/ls_test/file_two.muse' (⎕ucs ⎕tc[3] utl∆join test∆file_2) FIO∆fwrite fh FIO∆fclose fh fh←'w' FIO∆fopen test_data,'/ls_test/shakespeare.txt' (⎕ucs ⎕tc[3] utl∆join test∆file_3) FIO∆fwrite fh FIO∆fclose fh →0 pass_test: ⍞←(test_data,'/ls_test'),' EXISTS.' →0 err01: ⍞←test_data,' CANNOT BE FOUND.' →0 err02: ⍞←'Attempt to create ',test_data,'/ls_test failed' ⍞←utl∆sterror err →0 ∇