From 5b5682d04ff75e4dcbf33e81c46ec886c7187992 Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Tue, 26 May 2009 21:48:13 +0200 Subject: [PATCH] add a test of io.popen (mode write) --- t/io.t | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/t/io.t b/t/io.t index f3603db..01e9470 100644 --- a/t/io.t +++ b/t/io.t @@ -25,7 +25,7 @@ use warnings; use FindBin; use lib "$FindBin::Bin/../../../lib", "$FindBin::Bin"; -use Parrot::Test tests => 41; +use Parrot::Test tests => 42; use Test::More; use Parrot::Test::Lua; @@ -149,7 +149,7 @@ CODE OUTPUT unlink("$FindBin::Bin/../../../output.new") if ( -f "$FindBin::Bin/../../../output.new" ); -language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'io.popen' ); +language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'io.popen (read)' ); f = io.popen("perl -e \"print 'standard output'\"") print(io.type(f)) print(f:read()) @@ -159,6 +159,16 @@ file standard output OUTPUT +language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'io.popen (write)' ); +f = io.popen("perl -pe \"s/e/a/\"", "w") +print(io.type(f)) +f:write("hello\n") +f:close() +CODE +file +hallo +OUTPUT + language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'io.read *l', params => '< file.txt' ); print(io.read("*l")) print(io.read("*l"))