2 # Copyright (C) 2008, Parrot Foundation.
7 t/op/io.t - Testing io opcodes
15 Tests various io opcodes.
22 .include 'test_more.pir'
26 open_delegates_to_filehandle_pmc()
29 open_pipe_for_reading()
30 open_pipe_for_writing()
33 .sub open_delegates_to_filehandle_pmc
34 load_bytecode 'P6object.pbc'
36 .local pmc p6meta, interp, classes, classid
37 p6meta = get_root_global ["parrot"], "P6metaclass"
38 p6meta.'new_class'('Testing')
42 classid = classes['Testing']
43 $I0 = classes['FileHandle']
44 set classes['FileHandle'], classid
47 is($P1,42,'open opcode delegates to the open method on the FileHandle PMC')
49 # replace the original, so we don't break other tests
50 set classes['FileHandle'], $I0
54 .sub 'open_null_filename'
55 push_eh open_null_filename_failed
58 nok(1, 'open with null filename')
61 open_null_filename_failed:
62 ok(1, 'open with null filename')
66 push_eh open_null_mode_failed
68 $P0 = open 'some_name', $S0
69 nok(1, 'open with null mode')
72 open_null_mode_failed:
73 ok(1, 'open with null mode')
76 .sub 'tt661_todo_test' :anon
77 # As of r41963, these tests need to be todo'ed at least on Win32. Add new
78 # platforms known to fail.
79 .include 'sysinfo.pasm'
80 $S0 = sysinfo .SYSINFO_PARROT_OS
81 if $S0 == 'MSWin32' goto tt661_todo
89 .include 'iglobals.pasm'
91 .sub 'open_pipe_for_reading'
96 conf = interp[.IGLOBALS_CONFIG_HASH]
99 command = conf['build_dir']
104 aux = conf['test_prog']
111 pipe = open command, 'rp'
112 unless pipe goto open_pipe_for_reading_failed
115 line = substr line, 0, 14
116 is('This is Parrot', line, 'open pipe for reading')
119 open_pipe_for_reading_failed:
120 nok(1, 'open pipe for reading')
124 .sub 'open_pipe_for_writing'
125 $I0 = tt661_todo_test()
126 if $I0 goto open_pipe_for_writing_todoed
131 conf = interp[.IGLOBALS_CONFIG_HASH]
133 .local string command
134 command = conf['build_dir']
139 .local string filename
141 filename .= 'examples/pasm/cat.pasm'
142 aux = conf['test_prog']
150 pipe = open command, 'wp'
151 unless pipe goto open_pipe_for_writing_failed
153 pipe.'puts'("ok 5 - open pipe for writing\n")
157 open_pipe_for_writing_failed:
158 nok(1, 'open pipe for writing')
161 open_pipe_for_writing_todoed:
162 todo(0, 'Unimplemented in this platform, TT #661')
166 .namespace ["Testing"]
169 .param pmc args :slurpy
178 # vim: expandtab shiftwidth=4 ft=pir: