[svn:parrot] r47015 - in branches/ops_massacre/t: dynoplibs op pmc
plobsing at svn.parrot.org
plobsing at svn.parrot.org
Wed May 26 06:16:49 UTC 2010
Author: plobsing
Date: Wed May 26 06:16:49 2010
New Revision: 47015
URL: https://trac.parrot.org/parrot/changeset/47015
Log:
fix many io tests after io ops moved to dynops
Added:
branches/ops_massacre/t/dynoplibs/io.t
Deleted:
branches/ops_massacre/t/op/io.t
Modified:
branches/ops_massacre/t/pmc/io.t
Added: branches/ops_massacre/t/dynoplibs/io.t
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/ops_massacre/t/dynoplibs/io.t Wed May 26 06:16:49 2010 (r47015)
@@ -0,0 +1,200 @@
+#!./parrot
+# Copyright (C) 2008, Parrot Foundation.
+# $Id: io.t 46982 2010-05-25 03:05:26Z plobsing $
+
+=head1 NAME
+
+t/op/io.t - Testing io opcodes
+
+=head1 SYNOPSIS
+
+ % prove t/op/io.t
+
+=head1 DESCRIPTION
+
+Tests various io opcodes.
+
+=cut
+
+.const int TESTS = 5
+
+.loadlib 'io_ops'
+
+.sub 'main' :main
+ .include 'test_more.pir'
+
+ plan(TESTS)
+
+ open_delegates_to_filehandle_pmc()
+ open_null_filename()
+ open_null_mode()
+ open_pipe_for_reading()
+ open_pipe_for_writing()
+.end
+
+.sub open_delegates_to_filehandle_pmc
+ load_bytecode 'P6object.pbc'
+
+ .local pmc p6meta, interp, classes, classid
+ p6meta = get_root_global ["parrot"], "P6metaclass"
+ p6meta.'new_class'('Testing')
+
+ interp = getinterp
+ classes = interp[0]
+ classid = classes['Testing']
+ $I0 = classes['FileHandle']
+ set classes['FileHandle'], classid
+
+ $P1 = open '/foo'
+ is($P1,42,'open opcode delegates to the open method on the FileHandle PMC')
+
+ # replace the original, so we don't break other tests
+ set classes['FileHandle'], $I0
+
+.end
+
+.sub 'open_null_filename'
+ push_eh open_null_filename_failed
+ null $S0
+ $P0 = open $S0, 'r'
+ nok(1, 'open with null filename')
+ .return ()
+
+ open_null_filename_failed:
+ ok(1, 'open with null filename')
+.end
+
+.sub 'open_null_mode'
+ push_eh open_null_mode_failed
+ null $S0
+ $P0 = open 'some_name', $S0
+ nok(1, 'open with null mode')
+ .return ()
+
+ open_null_mode_failed:
+ ok(1, 'open with null mode')
+.end
+
+.loadlib 'sys_ops'
+.sub 'tt661_todo_test' :anon
+ # As of r41963, these tests need to be todo'ed at least on Win32. Add new
+ # platforms known to fail.
+ .include 'sysinfo.pasm'
+ $S0 = sysinfo .SYSINFO_PARROT_OS
+ if $S0 == 'MSWin32' goto tt661_todo
+
+ .return (0)
+
+ tt661_todo:
+ .return (1)
+.end
+
+.include 'iglobals.pasm'
+
+.sub 'open_pipe_for_reading'
+ .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
+ line = substr line, 0, 14
+ is('This is Parrot', line, 'open pipe for reading')
+ .return ()
+
+ open_pipe_for_reading_failed:
+ nok(1, 'open pipe for reading')
+ .return ()
+.end
+
+.sub 'open_pipe_for_writing'
+ $I0 = tt661_todo_test()
+ if $I0 goto open_pipe_for_writing_todoed
+ .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
+
+ .local pmc pipe
+ pipe = open command, 'wp'
+ unless pipe goto open_pipe_for_writing_failed
+
+ pipe.'puts'("ok 5 - open pipe for writing\n")
+ close pipe
+ .return ()
+
+ open_pipe_for_writing_failed:
+ nok(1, 'open pipe for writing')
+ .return ()
+
+ open_pipe_for_writing_todoed:
+ todo(0, 'Unimplemented in this platform, TT #661')
+
+.end
+
+# TT #1178
+.sub main :main
+ getstdout $P0
+ $I0 = $P0.'get_fd'()
+ fdopen $P1, $I0, 'w'
+ $I0 = defined $P1
+ ok($I0, 'get_fd()/fdopen')
+ close $P1
+.end
+
+# TT # 1178
+.sub main :main
+ getstdout $P0
+ $I0 = $P0.'get_fd'()
+ fdopen $P1, $I0, 'w'
+ $I0 = defined $P1
+ ok($I0, 'fdopen - no close')
+.end
+
+.namespace ["Testing"]
+
+.sub open :method
+ .param pmc args :slurpy
+ .return(42)
+.end
+
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
Deleted: branches/ops_massacre/t/op/io.t
==============================================================================
--- branches/ops_massacre/t/op/io.t Wed May 26 06:16:49 2010 (r47014)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,179 +0,0 @@
-#!./parrot
-# Copyright (C) 2008, Parrot Foundation.
-# $Id$
-
-=head1 NAME
-
-t/op/io.t - Testing io opcodes
-
-=head1 SYNOPSIS
-
- % prove t/op/io.t
-
-=head1 DESCRIPTION
-
-Tests various io opcodes.
-
-=cut
-
-.const int TESTS = 5
-
-.sub 'main' :main
- .include 'test_more.pir'
-
- plan(TESTS)
-
- open_delegates_to_filehandle_pmc()
- open_null_filename()
- open_null_mode()
- open_pipe_for_reading()
- open_pipe_for_writing()
-.end
-
-.sub open_delegates_to_filehandle_pmc
- load_bytecode 'P6object.pbc'
-
- .local pmc p6meta, interp, classes, classid
- p6meta = get_root_global ["parrot"], "P6metaclass"
- p6meta.'new_class'('Testing')
-
- interp = getinterp
- classes = interp[0]
- classid = classes['Testing']
- $I0 = classes['FileHandle']
- set classes['FileHandle'], classid
-
- $P1 = open '/foo'
- is($P1,42,'open opcode delegates to the open method on the FileHandle PMC')
-
- # replace the original, so we don't break other tests
- set classes['FileHandle'], $I0
-
-.end
-
-.sub 'open_null_filename'
- push_eh open_null_filename_failed
- null $S0
- $P0 = open $S0, 'r'
- nok(1, 'open with null filename')
- .return ()
-
- open_null_filename_failed:
- ok(1, 'open with null filename')
-.end
-
-.sub 'open_null_mode'
- push_eh open_null_mode_failed
- null $S0
- $P0 = open 'some_name', $S0
- nok(1, 'open with null mode')
- .return ()
-
- open_null_mode_failed:
- ok(1, 'open with null mode')
-.end
-
-.loadlib 'sys_ops'
-.sub 'tt661_todo_test' :anon
- # As of r41963, these tests need to be todo'ed at least on Win32. Add new
- # platforms known to fail.
- .include 'sysinfo.pasm'
- $S0 = sysinfo .SYSINFO_PARROT_OS
- if $S0 == 'MSWin32' goto tt661_todo
-
- .return (0)
-
- tt661_todo:
- .return (1)
-.end
-
-.include 'iglobals.pasm'
-
-.sub 'open_pipe_for_reading'
- .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
- line = substr line, 0, 14
- is('This is Parrot', line, 'open pipe for reading')
- .return ()
-
- open_pipe_for_reading_failed:
- nok(1, 'open pipe for reading')
- .return ()
-.end
-
-.sub 'open_pipe_for_writing'
- $I0 = tt661_todo_test()
- if $I0 goto open_pipe_for_writing_todoed
- .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
-
- .local pmc pipe
- pipe = open command, 'wp'
- unless pipe goto open_pipe_for_writing_failed
-
- pipe.'puts'("ok 5 - open pipe for writing\n")
- close pipe
- .return ()
-
- open_pipe_for_writing_failed:
- nok(1, 'open pipe for writing')
- .return ()
-
- open_pipe_for_writing_todoed:
- todo(0, 'Unimplemented in this platform, TT #661')
-
-.end
-
-.namespace ["Testing"]
-
-.sub open :method
- .param pmc args :slurpy
- .return(42)
-.end
-
-
-# Local Variables:
-# mode: pir
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
Modified: branches/ops_massacre/t/pmc/io.t
==============================================================================
--- branches/ops_massacre/t/pmc/io.t Wed May 26 05:42:07 2010 (r47014)
+++ branches/ops_massacre/t/pmc/io.t Wed May 26 06:16:49 2010 (r47015)
@@ -41,108 +41,107 @@
my (undef, $temp_file) = create_tempfile( UNLINK => 1 );
-pasm_output_is( <<"CODE", <<'OUTPUT', "open/close" );
- open P0, "$temp_file", 'w'
- print P0, "a line\\n"
- close P0
- open P0, "$temp_file", 'r'
- read S0, P0, 20
- print S0
- end
+pir_output_is( <<"CODE", <<'OUTPUT', "open/close" );
+.sub main :main
+ \$P0 = new ['FileHandle']
+ \$P0.'open'("$temp_file", 'w')
+ print \$P0, "a line\\n"
+ \$P0.'close'()
+ \$P0.'open'("$temp_file", 'r')
+ \$S0 = \$P0.'read'(20)
+ print \$S0
+.end
CODE
a line
OUTPUT
-pasm_output_is( <<"CODE", <<'OUTPUT', "timely destruction" );
- interpinfo I0, 2 # GC mark runs
- open P0, "$temp_file", 'w'
- needs_destroy P0
- print P0, "a line\\n"
- null P0 # kill it
+pir_output_is( sprintf(<<'CODE', $temp_file), <<'OUTPUT', "timely destruction (ops)");
+.loadlib 'io_ops'
+.const string temp_file = '%s'
+.sub main :main
+ interpinfo $I0, 2 # GC mark runs
+ $P0 = open temp_file, 'w'
+ needs_destroy $P0
+ print $P0, "a line\n"
+ null $P0 # kill it
sweep 0 # a lazy GC has to close the PIO
- open P0, "$temp_file", 'r'
- read S0, P0, 20
- print S0
- end
-CODE
-a line
-OUTPUT
-
-# TT #1178
-pir_output_is( <<'CODE', <<'OUTPUT', "get_fd()/fdopen" );
-.sub main :main
- getstdout $P0
- $I0 = $P0.'get_fd'()
- fdopen $P1, $I0, 'w'
- defined $I0, $P1
- unless $I0, nok
- print $P1, "ok\n"
- close $P1
- end
-nok:
- print "fdopen failed\n"
+ $P0 = open temp_file, 'r'
+ $S0 = $P0.'read'(20)
+ print $S0
.end
CODE
-ok
+a line
OUTPUT
-# TT #1178
-pir_output_is( <<'CODE', <<'OUTPUT', 'fdopen - no close' );
+pir_output_is( sprintf(<<'CODE', $temp_file), <<'OUTPUT', "timely destruction", todo => 'TT #1659' );
+.const string temp_file = '%s'
.sub main :main
- getstdout $P0
- $I0 = $P0.'get_fd'()
- fdopen $P1, $I0, 'w'
- defined $I0, $P1
- unless $I0, nok
- print $P1, "ok\n"
- end
-nok:
- print "fdopen failed\n"
+ interpinfo $I0, 2 # GC mark runs
+ $P0 = new ['FileHandle']
+ $P0.'open'(temp_file, 'w')
+ needs_destroy $P0
+ print $P0, "a line\n"
+ null $P0 # kill it
+ sweep 0 # a lazy GC has to close the PIO
+ $P0 = new ['FileHandle']
+ $P0.'open'(temp_file, 'r')
+ $S0 = $P0.'read'(20)
+ print $S0
.end
CODE
-ok
+a line
OUTPUT
my (undef, $no_such_file) = create_tempfile( UNLINK => 1, OPEN => 0 );
-pasm_output_is( <<"CODE", <<'OUTPUT', "get_bool" );
+pir_output_is( sprintf( <<'CODE', $no_such_file, $temp_file ), <<'OUTPUT', "get_bool" );
+.const string no_such_file = '%s'
+.const string temp_file = '%s'
+
+.sub main :main
push_eh read_non_existent_file
- open P0, "$no_such_file", 'r'
+ $P0 = new ['FileHandle']
+ $P0.'open'(no_such_file, 'r')
- print "Huh: '$no_such_file' exists? - not "
+ print "Huh: '"
+ print no_such_file
+ print "' exists? - not "
ok1:
say "ok 1"
- open P0, "$temp_file", 'w'
- print P0, "a line\\n"
- print P0, "a line\\n"
- close P0
-
- open P0, "$temp_file", 'r'
- if P0, ok2
+ $P0 = new ['FileHandle']
+ $P0.'open'(temp_file, 'w')
+ $P0.'print'("a line\n")
+ $P0.'print'("a line\n")
+ $P0.'close'()
+
+ $P0 = new ['FileHandle']
+ $P0.'open'(temp_file, 'r')
+ if $P0, ok2
print "not "
ok2: say "ok 2"
- read S0, P0, 1024
- read S0, P0, 1024
- unless P0, ok3
+ $S0 = $P0.'read'(1024)
+ $S0 = $P0.'read'(1024)
+ unless $P0, ok3
print "not "
ok3: say "ok 3"
- defined I0, P0
- if I0, ok4
+ defined $I0, $P0
+ if $I0, ok4
print "not "
ok4: say "ok 4"
- close P0
- defined I0, P0 # closed file is still defined
- if I0, ok5
+ $P0.'close'()
+ defined $I0, $P0 # closed file is still defined
+ if $I0, ok5
print "not "
ok5: say "ok 5"
- unless P0, ok6 # but false
+ unless $P0, ok6 # but false
print "not "
ok6: say "ok 6"
- end
+ .return ()
read_non_existent_file:
pop_eh
branch ok1
+.end
CODE
ok 1
ok 2
@@ -152,34 +151,71 @@
ok 6
OUTPUT
-pasm_output_is( <<"CODE", <<'OUTPUT', "read on invalid fh should throw exception" );
- new P0, ['FileHandle']
+pir_output_is( <<'CODE', <<'OUTPUT', "read on invalid fh should throw exception (ops)" );
+.loadlib 'io_ops'
+.sub main :main
+ new $P0, ['FileHandle']
push_eh _readline_handler
- readline S0, P0
+ $S0 = readline $P0
print "not "
_readline_handler:
- print "ok 1\\n"
+ print "ok 1\n"
pop_eh
push_eh _read_handler
- read S0, P0, 1
+ $S0 = read $P0, 1
print "not "
_read_handler:
- print "ok 2\\n"
+ print "ok 2\n"
pop_eh
push_eh _print_handler
- print P0, "kill me now\\n"
+ print $P0, "kill me now\n"
print "not "
_print_handler:
- print "ok 3\\n"
+ print "ok 3\n"
pop_eh
- end
+.end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+pir_output_is( <<'CODE', <<'OUTPUT', "read on invalid fh should throw exception" );
+.sub main :main
+ new $P0, ['FileHandle']
+
+ push_eh _readline_handler
+ $S0 = $P0.'readline'()
+ print "not "
+
+_readline_handler:
+ print "ok 1\n"
+ pop_eh
+
+ push_eh _read_handler
+ $S0 = $P0.'read'(1)
+ print "not "
+
+_read_handler:
+ print "ok 2\n"
+ pop_eh
+
+ push_eh _print_handler
+ print $P0, "kill me now\n"
+ print "not "
+
+_print_handler:
+ print "ok 3\n"
+ pop_eh
+
+.end
CODE
ok 1
ok 2
@@ -206,6 +242,7 @@
close $FOO;
pasm_output_is( <<"CODE", <<'OUTPUT', "open and readline" );
+.loadlib 'io_ops'
open P0, "$temp_file"
set S0, ""
set S1, ""
@@ -224,6 +261,7 @@
close $FOO;
pasm_output_is( <<"CODE", <<'OUTPUT', "open and readline, no final newline" );
+.loadlib 'io_ops'
open P0, "$temp_file"
set S0, ""
set S1, ""
@@ -240,6 +278,7 @@
close $FOO;
pasm_output_is( <<"CODE", <<'OUTPUT', "open & print" );
+.loadlib 'io_ops'
set I0, -12
set N0, 2.2
set S0, "Foo"
@@ -268,6 +307,7 @@
# write to file opened for reading
pasm_output_is( <<"CODE", <<'OUTPUT', "3-arg open" );
+.loadlib 'io_ops'
open P1, "$temp_file", 'w'
print P1, "Foobar\\n"
close P1
@@ -297,6 +337,7 @@
OUTPUT
pasm_output_is( <<"CODE", <<'OUTPUT', 'open and close' );
+.loadlib 'io_ops'
open P1, "$temp_file", "w"
print P1, "Hello, World!\\n"
close P1
@@ -311,6 +352,7 @@
OUTPUT
pasm_output_is( <<"CODE", '', 'append' );
+.loadlib 'io_ops'
open P1, "$temp_file", 'wa'
print P1, "Parrot flies\\n"
close P1
@@ -323,6 +365,7 @@
OUTPUT
pasm_output_is( <<"CODE", '', 'write to file' );
+.loadlib 'io_ops'
open P1, "$temp_file", 'w'
print P1, "Parrot overwrites\\n"
close P1
@@ -334,6 +377,7 @@
OUTPUT
pasm_output_is( <<"CODE", '', "Parrot_io_flush on buffer full" );
+.loadlib 'io_ops'
set I0, 0
set I1, 10000
@@ -354,22 +398,25 @@
words
OUTPUT
-pir_output_is( <<"CODE", <<'OUTPUT', "turn off buffering" );
+pir_output_is( sprintf(<<'CODE', $temp_file), <<'OUTPUT', "turn off buffering" );
+.const string temp_file = '%s'
+
.sub main :main
- open \$P0, "$temp_file", 'w'
+ $P0 = new ['FileHandle']
+ $P0.'open'(temp_file, 'w')
-# set buffer type
- \$P0.'buffer_type'('unbuffered')
+# set buffer type
+ $P0.'buffer_type'('unbuffered')
-# get buffer type
- \$S0 = \$P0.'buffer_type'()
- print \$S0
- print "\\n"
+# get buffer type
+ $S0 = $P0.'buffer_type'()
+ print $S0
+ print "\n"
- print \$P0, "Howdy World\\n"
+ print $P0, "Howdy World\n"
- close \$P0
- end
+ $P0.'close'()
+ end
.end
CODE
unbuffered
@@ -379,50 +426,54 @@
Howdy World
OUTPUT
-pir_output_is( <<"CODE", <<'OUTPUT', 'I/O buffering' );
+pir_output_is( sprintf(<<'CODE', $temp_file), <<'OUTPUT', 'I/O buffering' );
+.const string temp_file = '%s'
+
.sub main
.local string filename
- filename = "$temp_file"
- \$P1 = open filename, 'w'
+ filename = temp_file
+ $P1 = new ['FileHandle']
+ $P1.'open'(filename, 'w')
.local int count, max, nltest
count = 0
max = 10000
LOOP:
if count > max goto DONE
- \$S1 = count
- \$S1 = concat \$S1, " "
- print \$P1, \$S1
+ $S1 = count
+ $S1 = concat $S1, " "
+ print $P1, $S1
inc count
nltest = mod count, 20
if nltest goto LOOP
- print \$P1, "\\n"
+ print $P1, "\n"
goto LOOP
DONE:
- print \$P1, "\\n"
- close \$P1
+ print $P1, "\n"
+ $P1.'close'()
PART_2:
- \$P1 = open filename
- \$I0 = 0
+ $P1 = new ['FileHandle']
+ $P1.'open'(filename)
+ $I0 = 0
LINE:
- \$S1 = readline \$P1
- unless \$S1 goto SUCCESS
- \$S1 = chopn \$S1, 1
+ $S1 = $P1.'readline'()
+ unless $S1 goto SUCCESS
+ $S1 = chopn $S1, 1
NEXT_NR:
- \$I1 = length \$S1
- if \$I1 <= 1 goto LINE
- \$S2 = ""
+ $I1 = length $S1
+ if $I1 <= 1 goto LINE
+ $S2 = ""
SPLIT:
- \$S3 = substr \$S1, 0, 1
- \$S1 = replace \$S1, 0, 1, ""
- if \$S3 == " " goto GOT_NR
- \$S2 = concat \$S2, \$S3
+ $S3 = substr $S1, 0, 1
+ $S1 = replace $S1, 0, 1, ""
+ if $S3 == " " goto GOT_NR
+ $S2 = concat $S2, $S3
goto SPLIT
GOT_NR:
- \$I1 = \$S2
- if \$I0 != \$I1 goto FAILED
- inc \$I0
+ $I1 = $S2
+ if $I0 != $I1 goto FAILED
+ inc $I0
goto NEXT_NR
FAILED:
@@ -440,17 +491,19 @@
# TT #1178
pir_output_is( <<'CODE', <<'OUT', 'standard file descriptors' );
.sub main :main
- getstdin $P0
- $I0 = $P0.'get_fd'()
+ $P99 = getinterp
+ $P0 = $P99.'stdhandle'(0)
+ $I0 = $P0.'get_fd'()
# I0 is 0 on Unix and non-Null on stdio and win32
print "ok 1\n"
- getstdout $P1
+
+ $P1 = $P99.'stdhandle'(1)
$I1 = $P1.'get_fd'()
if $I1, OK_2
print "not "
OK_2:
say "ok 2"
- getstderr $P2
+ $P2 = $P99.'stdhandle'(2)
$I2 = $P2.'get_fd'()
if $I2, OK_3
print "not "
@@ -463,7 +516,8 @@
ok 3
OUT
-pasm_output_is( <<'CODE', <<'OUTPUT', 'printerr' );
+pasm_output_is( <<'CODE', <<'OUTPUT', 'printerr op' );
+.loadlib 'io_ops'
new P0, ['String']
set P0, "This is a test\n"
printerr 10
@@ -481,15 +535,17 @@
This is a test
OUTPUT
-pasm_output_is( <<'CODE', <<'OUTPUT', 'puts method' );
- getstdout P2
- can I0, P2, "puts"
- if I0, ok1
- print "not "
+pir_output_is( <<'CODE', <<'OUTPUT', 'puts method' );
+.sub main :main
+ $P0 = getinterp
+ $P2 = $P0.'stdhandle'(1)
+ can $I0, $P2, "puts"
+ if $I0, ok1
+ print "not "
ok1: print "ok 1\n"
- set_args "0,0", P2, "ok 2\n"
- callmethodcc P2, "puts"
- end
+ set_args "0,0", $P2, "ok 2\n"
+ callmethodcc $P2, "puts"
+.end
CODE
ok 1
ok 2
@@ -501,7 +557,8 @@
.local string s
s = "ok 2\n"
.local pmc io
- io = getstdout
+ $P0 = getinterp
+ io = $P0.'stdhandle'(1)
$I0 = can io, "puts"
if $I0 goto ok1
print "not "
@@ -515,6 +572,7 @@
OUTPUT
pasm_output_is( <<'CODE', <<'OUTPUT', 'callmethod puts' );
+.loadlib 'io_ops'
getstderr P2 # the object
set S0, "puts" # method
set S5, "ok 1\n" # 2nd param
@@ -530,6 +588,7 @@
OUTPUT
pasm_output_is( <<"CODE", <<'OUTPUT', 'seek/tell' );
+.loadlib 'io_ops'
open P0, "$temp_file", 'w'
print P0, "Hello "
tell I0, P0
More information about the parrot-commits
mailing list