Ticket #793: io.t_to_pir.patch
| File io.t_to_pir.patch, 5.4 KB (added by flh, 4 years ago) |
|---|
-
t/op/io.t
1 #!p erl2 # Copyright (C) 2008 , Parrot Foundation.1 #!parrot 2 # Copyright (C) 2008-2009, Parrot Foundation. 3 3 # $Id$ 4 4 5 use strict;6 use warnings;7 use lib qw( . lib ../lib ../../lib );8 9 use Test::More;10 use Parrot::Test tests => 4;11 12 5 =head1 NAME 13 6 14 7 t/op/io.t - Testing io opcodes … … 23 16 24 17 =cut 25 18 26 pir_output_is( <<'CODE', <<'OUTPUT', 'open with null filename' ); 27 .sub main 28 push_eh failed 19 .const int TESTS = 4 20 21 .sub 'main' :main 22 .include 'test_more.pir' 23 24 plan(TESTS) 25 26 open_null_filename() 27 open_null_mode() 28 open_pipe_for_reading() 29 open_pipe_for_writing() 30 .end 31 32 .sub 'open_null_filename' 33 push_eh open_null_filename_failed 29 34 $P0 = open $S0, '<' 30 say 'never'31 goto finish32 failed: 33 say 'Catched'34 finish: 35 nok(1, 'open with null filename') 36 .return () 37 38 open_null_filename_failed: 39 ok(1, 'open with null filename') 35 40 .end 36 CODE37 Catched38 OUTPUT39 41 40 pir_output_is( <<'CODE', <<'OUTPUT', 'open with null mode' ); 41 .sub main 42 push_eh failed 42 .sub 'open_null_mode' 43 push_eh open_null_mode_failed 43 44 $P0 = open 'some_name', $S0 44 say 'never'45 goto finish46 failed: 47 say 'Catched'48 finish: 45 nok(1, 'open with null mode') 46 .return () 47 48 open_null_mode_failed: 49 ok(1, 'open with null mode') 49 50 .end 50 CODE51 Catched52 OUTPUT53 51 54 TODO: { 55 local $TODO = 'Unimplemented in this platform, TT #661' unless $^O =~ /linux|darwin|MSWin32/; 52 .sub 'tt661_todo_test' 53 # Checks whether the platform is linux, MSWin32, darwin: on other 54 # platforms, the following tests are todo'ed. 55 $S0 = sysinfo 4 56 if $S0 == 'linux' goto tt661_ok 57 if $S0 == 'MSWin32' goto tt661_ok 58 if $S0 == 'darwin' goto tt661_ok 56 59 57 pir_output_like( <<'CODE', <<'OUTPUT', 'open pipe for reading' ); 58 .include 'iglobals.pasm' 60 .return (0) 59 61 60 .sub testreadpipe :main 61 .local pmc interp 62 interp = getinterp 63 .local pmc conf 64 conf = interp[.IGLOBALS_CONFIG_HASH] 65 .local string command 66 command = conf['build_dir'] 67 .local string aux 68 aux = conf['slash'] 69 command .= aux 70 aux = conf['test_prog'] 71 command .= aux 72 aux = conf['exe'] 73 command .= aux 74 command .= ' -V' 62 tt661_ok: 63 .return(1) 64 .end 75 65 76 .local pmc pipe 77 pipe = open command, 'rp' 78 unless pipe goto failed 79 .local string line 80 nextline: 81 line = readline pipe 82 print line 83 if pipe goto nextline 84 .return() 85 failed: 86 say 'FAILED' 66 .sub 'open_pipe_for_reading' 67 $I0 = tt661_todo_test() 68 unless $I0 goto open_pipe_for_reading_todoed 69 70 .include 'iglobals.pasm' 71 72 .local pmc interp 73 interp = getinterp 74 75 .local pmc conf 76 conf = interp[.IGLOBALS_CONFIG_HASH] 77 78 .local string command 79 command = conf['build_dir'] 80 81 .local string aux 82 aux = conf['slash'] 83 command .= aux 84 aux = conf['test_prog'] 85 command .= aux 86 aux = conf['exe'] 87 command .= aux 88 command .= ' -V' 89 90 .local pmc pipe 91 pipe = open command, 'rp' 92 unless pipe goto open_pipe_for_reading_failed 93 .local string line 94 line = readline pipe 95 like('This is Parrot', ":s This is Parrot", 'open pipe for reading') 96 .return() 97 98 open_pipe_for_reading_failed: 99 nok(1, 'open pipe for reading') 100 .return () 101 102 open_pipe_for_reading_todoed: 103 todo(1, 'Unimplemented in this platform, TT #661') 87 104 .end 88 CODE89 /This is Parrot.*/90 OUTPUT91 105 92 } 106 .sub 'open_pipe_for_writing' 107 .include 'iglobals.pasm' 108 109 .local pmc interp 110 interp = getinterp 93 111 94 TODO: { 95 local $TODO = 'Unimplemented in this platform, TT #661' unless $^O =~ /linux|darwin|MSWin32/; 112 .local pmc conf 113 conf = interp[.IGLOBALS_CONFIG_HASH] 114 115 .local string command 116 command = conf['build_dir'] 117 118 .local string aux 119 aux = conf['slash'] 120 command .= aux 121 .local string filename 122 filename .= command 123 filename .= 'examples/pasm/cat.pasm' 124 aux = conf['test_prog'] 125 command .= aux 126 aux = conf['exe'] 127 command .= aux 128 command .= ' ' 129 command .= filename 96 130 97 pir_output_is( <<'CODE', <<'OUTPUT', 'open pipe for writing' ); 98 .include 'iglobals.pasm' 131 .local pmc pipe 132 pipe = open command, 'wp' 133 unless pipe goto open_pipe_for_writing_failed 134 pipe.'puts'("ok - open pipe for writing\n") 135 close pipe 136 .return() 99 137 100 .sub testwritepipe :main 101 .local pmc interp 102 interp = getinterp 103 .local pmc conf 104 conf = interp[.IGLOBALS_CONFIG_HASH] 105 .local string command 106 command = conf['build_dir'] 107 .local string aux 108 aux = conf['slash'] 109 command .= aux 110 .local string filename 111 filename .= command 112 filename .= 'examples/pasm/cat.pasm' 113 aux = conf['test_prog'] 114 command .= aux 115 aux = conf['exe'] 116 command .= aux 117 command .= ' ' 118 command .= filename 138 open_pipe_for_writing_failed: 139 nok(1, 'open pipe for writing') 140 .return () 119 141 120 .local pmc pipe 121 pipe = open command, 'wp' 122 unless pipe goto failed 123 pipe.'puts'("Hello, pipe!\n") 124 close pipe 125 .return() 126 failed: 127 say 'FAILED' 142 open_pipe_for_writing_todoed: 143 todo(1, 'Unimplemented in this platform, TT #661') 128 144 .end 129 CODE130 Hello, pipe!131 OUTPUT132 145 133 }134 135 146 # Local Variables: 136 # mode: cperl 137 # cperl-indent-level: 4 147 # mode: pir 138 148 # fill-column: 100 139 149 # End: 140 # vim: expandtab shiftwidth=4 :150 # vim: expandtab shiftwidth=4 ft=pir:
