[svn:parrot] r47407 - trunk/t/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Sat Jun 5 23:26:24 UTC 2010
Author: bacek
Date: Sat Jun 5 23:26:24 2010
New Revision: 47407
URL: https://trac.parrot.org/parrot/changeset/47407
Log:
Move filehandle test into t/pmc/filehadle.t
Modified:
trunk/t/pmc/filehandle.t
trunk/t/pmc/io.t
Modified: trunk/t/pmc/filehandle.t
==============================================================================
--- trunk/t/pmc/filehandle.t Sat Jun 5 23:26:07 2010 (r47406)
+++ trunk/t/pmc/filehandle.t Sat Jun 5 23:26:24 2010 (r47407)
@@ -7,7 +7,7 @@
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 19;
+use Parrot::Test tests => 20;
use Parrot::Test::Util 'create_tempfile';
use Parrot::Test::Util 'create_tempfile';
@@ -663,6 +663,65 @@
a line
OUTPUT
+my (undef, $no_such_file) = create_tempfile( UNLINK => 1, OPEN => 0 );
+
+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
+ $P0 = new ['FileHandle']
+ $P0.'open'(no_such_file, 'r')
+
+ print "Huh: '"
+ print no_such_file
+ print "' exists? - not "
+ok1:
+ say "ok 1"
+
+ $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"
+ $S0 = $P0.'read'(1024)
+ $S0 = $P0.'read'(1024)
+ unless $P0, ok3
+ print "not "
+ok3: say "ok 3"
+ defined $I0, $P0
+ if $I0, ok4
+ print "not "
+ok4: say "ok 4"
+ $P0.'close'()
+ defined $I0, $P0 # closed file is still defined
+ if $I0, ok5
+ print "not "
+ok5: say "ok 5"
+ unless $P0, ok6 # but false
+ print "not "
+ok6: say "ok 6"
+ .return ()
+read_non_existent_file:
+ pop_eh
+ branch ok1
+.end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+ok 6
+OUTPUT
+
# TT #1178
# L<PDD22/I\/O PMC API/=item get_fd>
# NOTES: this is going to be platform dependent
Modified: trunk/t/pmc/io.t
==============================================================================
--- trunk/t/pmc/io.t Sat Jun 5 23:26:07 2010 (r47406)
+++ trunk/t/pmc/io.t Sat Jun 5 23:26:24 2010 (r47407)
@@ -7,7 +7,7 @@
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 41;
+use Parrot::Test tests => 40;
use Parrot::Test::Util 'create_tempfile';
use Parrot::Test::Util 'create_tempfile';
@@ -59,65 +59,6 @@
a line
OUTPUT
-my (undef, $no_such_file) = create_tempfile( UNLINK => 1, OPEN => 0 );
-
-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
- $P0 = new ['FileHandle']
- $P0.'open'(no_such_file, 'r')
-
- print "Huh: '"
- print no_such_file
- print "' exists? - not "
-ok1:
- say "ok 1"
-
- $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"
- $S0 = $P0.'read'(1024)
- $S0 = $P0.'read'(1024)
- unless $P0, ok3
- print "not "
-ok3: say "ok 3"
- defined $I0, $P0
- if $I0, ok4
- print "not "
-ok4: say "ok 4"
- $P0.'close'()
- defined $I0, $P0 # closed file is still defined
- if $I0, ok5
- print "not "
-ok5: say "ok 5"
- unless $P0, ok6 # but false
- print "not "
-ok6: say "ok 6"
- .return ()
-read_non_existent_file:
- pop_eh
- branch ok1
-.end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-ok 5
-ok 6
-OUTPUT
-
pir_output_is( <<'CODE', <<'OUTPUT', "read on invalid fh should throw exception (ops)" );
.loadlib 'io_ops'
.sub main :main
More information about the parrot-commits
mailing list