Index: t/op/io.t =================================================================== --- t/op/io.t (révision 39801) +++ t/op/io.t (copie de travail) @@ -1,14 +1,7 @@ -#!perl -# Copyright (C) 2008, Parrot Foundation. +#!parrot +# Copyright (C) 2008-2009, Parrot Foundation. # $Id$ -use strict; -use warnings; -use lib qw( . lib ../lib ../../lib ); - -use Test::More; -use Parrot::Test tests => 4; - =head1 NAME t/op/io.t - Testing io opcodes @@ -23,118 +16,135 @@ =cut -pir_output_is( <<'CODE', <<'OUTPUT', 'open with null filename' ); -.sub main - push_eh failed +.const int TESTS = 4 + +.sub 'main' :main + .include 'test_more.pir' + + plan(TESTS) + + open_null_filename() + open_null_mode() + open_pipe_for_reading() + open_pipe_for_writing() +.end + +.sub 'open_null_filename' + push_eh open_null_filename_failed $P0 = open $S0, '<' - say 'never' - goto finish -failed: - say 'Catched' -finish: + nok(1, 'open with null filename') + .return () + + open_null_filename_failed: + ok(1, 'open with null filename') .end -CODE -Catched -OUTPUT -pir_output_is( <<'CODE', <<'OUTPUT', 'open with null mode' ); -.sub main - push_eh failed +.sub 'open_null_mode' + push_eh open_null_mode_failed $P0 = open 'some_name', $S0 - say 'never' - goto finish -failed: - say 'Catched' -finish: + nok(1, 'open with null mode') + .return () + + open_null_mode_failed: + ok(1, 'open with null mode') .end -CODE -Catched -OUTPUT -TODO: { -local $TODO = 'Unimplemented in this platform, TT #661' unless $^O =~ /linux|darwin|MSWin32/; +.sub 'tt661_todo_test' + # Checks whether the platform is linux, MSWin32, darwin: on other + # platforms, the following tests are todo'ed. + $S0 = sysinfo 4 + if $S0 == 'linux' goto tt661_ok + if $S0 == 'MSWin32' goto tt661_ok + if $S0 == 'darwin' goto tt661_ok -pir_output_like( <<'CODE', <<'OUTPUT', 'open pipe for reading' ); -.include 'iglobals.pasm' + .return (0) -.sub testreadpipe :main - .local pmc interp - interp = getinterp - .local pmc conf - conf = interp[.IGLOBALS_CONFIG_HASH] - .local string command - command = conf['build_dir'] - .local string aux - aux = conf['slash'] - command .= aux - aux = conf['test_prog'] - command .= aux - aux = conf['exe'] - command .= aux - command .= ' -V' + tt661_ok: + .return(1) +.end - .local pmc pipe - pipe = open command, 'rp' - unless pipe goto failed - .local string line -nextline: - line = readline pipe - print line - if pipe goto nextline - .return() -failed: - say 'FAILED' +.sub 'open_pipe_for_reading' + $I0 = tt661_todo_test() + unless $I0 goto open_pipe_for_reading_todoed + + .include 'iglobals.pasm' + + .local pmc interp + interp = getinterp + + .local pmc conf + conf = interp[.IGLOBALS_CONFIG_HASH] + + .local string command + command = conf['build_dir'] + + .local string aux + aux = conf['slash'] + command .= aux + aux = conf['test_prog'] + command .= aux + aux = conf['exe'] + command .= aux + command .= ' -V' + + .local pmc pipe + pipe = open command, 'rp' + unless pipe goto open_pipe_for_reading_failed + .local string line + line = readline pipe + like('This is Parrot', ":s This is Parrot", 'open pipe for reading') + .return() + + open_pipe_for_reading_failed: + nok(1, 'open pipe for reading') + .return () + + open_pipe_for_reading_todoed: + todo(1, 'Unimplemented in this platform, TT #661') .end -CODE -/This is Parrot.*/ -OUTPUT -} +.sub 'open_pipe_for_writing' + .include 'iglobals.pasm' + + .local pmc interp + interp = getinterp -TODO: { -local $TODO = 'Unimplemented in this platform, TT #661' unless $^O =~ /linux|darwin|MSWin32/; + .local pmc conf + conf = interp[.IGLOBALS_CONFIG_HASH] + + .local string command + command = conf['build_dir'] + + .local string aux + aux = conf['slash'] + command .= aux + .local string filename + filename .= command + filename .= 'examples/pasm/cat.pasm' + aux = conf['test_prog'] + command .= aux + aux = conf['exe'] + command .= aux + command .= ' ' + command .= filename -pir_output_is( <<'CODE', <<'OUTPUT', 'open pipe for writing' ); -.include 'iglobals.pasm' + .local pmc pipe + pipe = open command, 'wp' + unless pipe goto open_pipe_for_writing_failed + pipe.'puts'("ok - open pipe for writing\n") + close pipe + .return() -.sub testwritepipe :main - .local pmc interp - interp = getinterp - .local pmc conf - conf = interp[.IGLOBALS_CONFIG_HASH] - .local string command - command = conf['build_dir'] - .local string aux - aux = conf['slash'] - command .= aux - .local string filename - filename .= command - filename .= 'examples/pasm/cat.pasm' - aux = conf['test_prog'] - command .= aux - aux = conf['exe'] - command .= aux - command .= ' ' - command .= filename + open_pipe_for_writing_failed: + nok(1, 'open pipe for writing') + .return () - .local pmc pipe - pipe = open command, 'wp' - unless pipe goto failed - pipe.'puts'("Hello, pipe!\n") - close pipe - .return() -failed: - say 'FAILED' + open_pipe_for_writing_todoed: + todo(1, 'Unimplemented in this platform, TT #661') .end -CODE -Hello, pipe! -OUTPUT -} - # Local Variables: -# mode: cperl -# cperl-indent-level: 4 +# mode: pir # fill-column: 100 # End: -# vim: expandtab shiftwidth=4: +# vim: expandtab shiftwidth=4 ft=pir: