Author: allison
Date: Thu Nov 27 17:33:51 2008
New Revision: 33287

Modified:
   branches/pdd22io_part2/t/pmc/io.t

Log:
[pdd22io] Update to new way of setting encoding on a filehandle. Update
'ParrotIO' to 'FileHandle'. Update 'slurp' method to 'readall'. Update for
exception thrown by attempting to open a non-existent file. Update for
exception thrown when attempting to read from a closed filehandle. Remove tests
for layers (layers don't exist anymore).


Modified: branches/pdd22io_part2/t/pmc/io.t
==============================================================================
--- branches/pdd22io_part2/t/pmc/io.t   (original)
+++ branches/pdd22io_part2/t/pmc/io.t   Thu Nov 27 17:33:51 2008
@@ -7,7 +7,7 @@
 use lib qw( . lib ../lib ../../lib );
 
 use Test::More;
-use Parrot::Test tests => 45;
+use Parrot::Test tests => 43;
 use Parrot::Test::Util 'create_tempfile';
 
 =head1 NAME
@@ -157,11 +157,18 @@
 my (undef, $no_such_file) = create_tempfile( UNLINK => 1, OPEN => 0 );
 
 pasm_output_is( <<"CODE", <<'OUTPUT', "get_bool" );
+    push_eh read_non_existent_file
     open P0, "$no_such_file", "<"
-    unless P0, ok1
+
     print "Huh: '$no_such_file' exists? - not "
 ok1:
     say "ok 1"
+
+    open P0, "$temp_file", ">"
+    print P0, "a line\\n"
+    print P0, "a line\\n"
+    close P0
+
     open P0, "$temp_file", "<"
     if P0, ok2
     print "not "
@@ -184,6 +191,9 @@
     print "not "
 ok6:    say "ok 6"
     end
+read_non_existent_file:
+    pop_eh
+    branch ok1
 CODE
 ok 1
 ok 2
@@ -193,34 +203,34 @@
 ok 6
 OUTPUT
 
-pasm_output_is( <<'CODE', <<'OUTPUT', "read on invalid fh should throw 
exception" );
-    open P0, "no_such_file", "<"
-    unless P0, ok1
-    print "Huh: 'no_such_file' exists? - not "
-ok1:
-    print "ok 1\n"
+pasm_output_is( <<"CODE", <<'OUTPUT', "read on invalid fh should throw 
exception" );
+    new P0, 'FileHandle'
+
+    push_eh _readline_handler
+    readline S0, P0
+    print "not "
 
-        push_eh _readline_handler
-        readline S0, P0 # Currently segfaults
-        print "not "
 _readline_handler:
-        print "ok 2\n"
-    branch fin
+        print "ok 1\\n"
+        pop_eh
+
+    push_eh _read_handler
+    read S0, P0, 1
+    print "not "
 
-        push_eh _read_handler
-        read S0, P0, 1
-        print "not "
 _read_handler:
-        print "ok 3\n"
+        print "ok 2\\n"
+        pop_eh
+
+    push_eh _print_handler
+    print P0, "kill me now\\n"
+    print "not "
 
-        push_eh _print_handler
-        print P0, "kill me now\n"
-        print "not "
 _print_handler:
-fin:
-        print "ok 4\n"
+        print "ok 3\\n"
+        pop_eh
 
-        end
+    end
 CODE
 ok 1
 ok 2
@@ -622,47 +632,6 @@
 ok 1
 OUTPUT
 
-pasm_output_like( <<'CODE', <<'OUTPUT', "layer names" );
-    getstdin P0
-    set S0, P0[0]
-    print S0
-    print "-"
-    set S0, P0[1]
-    print S0
-    print "-"
-    set S0, P0[-1]
-    print S0
-    print "-"
-    set S0, P0[-2]
-    print S0
-    print "-"
-    set S0, P0[-3]
-    print S0
-    print "-"
-    end
-CODE
-/^(unix|win32|stdio)-buf-buf-\1--$/
-OUTPUT
-
-pasm_output_is( <<'CODE', <<'OUTPUT', "layer push, pop" );
-    getstdin P0
-    push P0, "utf8"
-    set S0, P0[-1]
-    print S0
-    print "\n"
-    pop S1, P0
-    print S1
-    print "\n"
-    set S0, P0[-1]
-    print S0
-    print "\n"
-    end
-CODE
-utf8
-utf8
-buf
-OUTPUT
-
 pir_output_is( <<"CODE", <<'OUTPUT', "substr after reading from file" );
 
 .sub _main
@@ -746,7 +715,7 @@
 print $FOO "T\xc3\xb6tsch\n";
 close $FOO;
 
-pir_output_is( <<"CODE", <<"OUTPUT", "utf8 read layer" );
+pir_output_is( <<"CODE", <<"OUTPUT", "utf8 read enabled" );
 .sub main :main
     .local pmc pio
     .local int len
@@ -755,7 +724,7 @@
     f = '$temp_file'
     len = stat f, .STAT_FILESIZE
     pio = open f, "<"
-    push pio, "utf8"
+    pio.'encoding("utf8")
     \$S0 = read pio, len
     close pio
     \$I1 = charset \$S0
@@ -776,13 +745,13 @@
 T\xf6tsch
 OUTPUT
 
-pir_output_is( <<"CODE", <<"OUTPUT", "utf8 read layer - readline" );
+pir_output_is( <<"CODE", <<"OUTPUT", "utf8 read enabled - readline" );
 .sub main :main
     .local pmc pio
     .local string f
     f = '$temp_file'
     pio = open f, "<"
-    push pio, "utf8"
+    pio.'encoding'("utf8")
     \$S0 = readline pio
     close pio
     \$I1 = charset \$S0
@@ -803,7 +772,7 @@
 T\xf6tsch
 OUTPUT
 
-pir_output_is( <<"CODE", <<"OUTPUT", "utf8 read layer, read parts" );
+pir_output_is( <<"CODE", <<"OUTPUT", "utf8 read enabled, read parts" );
 .sub main :main
     .local pmc pio
     .local int len
@@ -812,7 +781,7 @@
     f = '$temp_file'
     len = stat f, .STAT_FILESIZE
     pio = open f, "<"
-    push pio, "utf8"
+    pio.'encoding'("utf8")
     \$S0 = read pio, 2
     len -= 2
     \$S1 = read pio, len
@@ -836,7 +805,7 @@
 T\xf6tsch
 OUTPUT
 
-pir_output_is( <<'CODE', <<"OUTPUT", "string read/write layer" );
+pir_output_is( <<'CODE', <<"OUTPUT", "string read/write handle" );
 .sub main :main
     .local pmc    pio
     .local string greeting
@@ -861,7 +830,7 @@
 string
 OUTPUT
 
-pir_output_is( <<"CODE", <<"OUTPUT", "PIO.slurp() - classmeth" );
+pir_output_is( <<"CODE", <<"OUTPUT", "PIO.readall() - classmeth" );
 .sub main :main
     \$S0 = <<"EOS"
 line 1
@@ -872,8 +841,8 @@
     pio = open    "$temp_file", ">"
     print pio, \$S0
     close pio
-    cl = new 'ParrotIO'
-    \$S1 = cl.'slurp'('$temp_file')
+    cl = new 'FileHandle'
+    \$S1 = cl.'readall'('$temp_file')
     if \$S0 == \$S1 goto ok
     print "not "
 ok:
@@ -883,7 +852,7 @@
 ok
 OUTPUT
 
-pir_output_is( <<"CODE", <<"OUTPUT", "PIO.slurp() - object" );
+pir_output_is( <<"CODE", <<"OUTPUT", "PIO.readall() - object" );
 .sub main :main
     \$S0 = <<"EOS"
 line 1
@@ -895,7 +864,7 @@
     print pio, \$S0
     close pio
     pio2 = open    "$temp_file", "<"
-    \$S1 = pio2.'slurp'('dummy')
+    \$S1 = pio2.'readall'()
     if \$S0 == \$S1 goto ok
     print "not "
 ok:

Reply via email to