[svn:parrot] r47446 - in trunk/t: dynoplibs pmc

plobsing at svn.parrot.org plobsing at svn.parrot.org
Tue Jun 8 03:57:00 UTC 2010


Author: plobsing
Date: Tue Jun  8 03:56:59 2010
New Revision: 47446
URL: https://trac.parrot.org/parrot/changeset/47446

Log:
avoid dynops in one io test and move another to a dynops test

Modified:
   trunk/t/dynoplibs/io.t
   trunk/t/pmc/io.t

Modified: trunk/t/dynoplibs/io.t
==============================================================================
--- trunk/t/dynoplibs/io.t	Tue Jun  8 03:00:36 2010	(r47445)
+++ trunk/t/dynoplibs/io.t	Tue Jun  8 03:56:59 2010	(r47446)
@@ -16,7 +16,7 @@
 
 =cut
 
-.const int TESTS = 5
+.const int TESTS = 6
 
 .loadlib 'io_ops'
 
@@ -25,6 +25,7 @@
 
     plan(TESTS)
 
+    read_on_null()
     open_delegates_to_filehandle_pmc()
     open_null_filename()
     open_null_mode()
@@ -183,6 +184,20 @@
     ok($I0, 'fdopen - no close')
 .end
 
+.sub 'read_on_null'
+    .const string description = "read on null PMC throws exception"
+    push_eh eh
+    null $P1
+    $S0 = read $P1, 1
+    ok(0, description)
+    goto ret
+  eh:
+    ok(1, description)
+  ret:
+    pop_eh
+    .return ()
+.end
+
 .namespace ["Testing"]
 
 .sub open :method

Modified: trunk/t/pmc/io.t
==============================================================================
--- trunk/t/pmc/io.t	Tue Jun  8 03:00:36 2010	(r47445)
+++ trunk/t/pmc/io.t	Tue Jun  8 03:56:59 2010	(r47446)
@@ -7,7 +7,7 @@
 use lib qw( . lib ../lib ../../lib );
 
 use Test::More;
-use Parrot::Test tests => 40;
+use Parrot::Test tests => 39;
 use Parrot::Test::Util 'create_tempfile';
 use Parrot::Test::Util 'create_tempfile';
 
@@ -708,50 +708,33 @@
 sub_2: 345
 OUTPUT
 
-pir_error_output_like( <<'CODE', <<'OUT', 'read on null PMC throws exception');
-.loadlib 'io_ops'
-.sub main :main
-    null $P1
-    $S0 = read $P1, 1
-    end
-.end
-CODE
-/read from null/
-OUT
-
 ($FOO, $temp_file) = create_tempfile( UNLINK => 1 );
 
 print $FOO "T\xc3\xb6tsch\n";
 close $FOO;
 
-pir_output_is( <<"CODE", <<"OUTPUT", "utf8 read enabled, read parts" );
-.loadlib 'io_ops'
+pir_output_is( sprintf(<<'CODE', $temp_file), <<"OUTPUT", "utf8 read enabled, read parts" );
+.const string temp_file = '%s'
 .sub main :main
     .local pmc pio
-    .local int len
-    .include "stat.pasm"
-    .local string f
-    f = '$temp_file'
-    len = stat f, .STAT_FILESIZE
     pio = new ['FileHandle']
-    pio.'open'(f, 'r')
+    pio.'open'(temp_file, 'r')
     pio.'encoding'("utf8")
-    \$S0 = pio.'read'(2)
-    len -= 2
-    \$S1 = pio.'read'(len)
-    \$S0 .= \$S1
+    $S0 = pio.'read'(2)
+    $S1 = pio.'read'(1024) # read the rest of the file (much shorter than 1K)
+    $S0 .= $S1
     pio.'close'()
-    \$I1 = charset \$S0
-    \$S2 = charsetname \$I1
-    say \$S2
-
-    \$I1 = encoding \$S0
-    \$S2 = encodingname \$I1
-    say \$S2
-
-    \$I1 = find_charset 'iso-8859-1'
-    trans_charset \$S1, \$S0, \$I1
-    print \$S1
+    $I1 = charset $S0
+    $S2 = charsetname $I1
+    say $S2
+
+    $I1 = encoding $S0
+    $S2 = encodingname $I1
+    say $S2
+
+    $I1 = find_charset 'iso-8859-1'
+    trans_charset $S1, $S0, $I1
+    print $S1
 .end
 CODE
 unicode


More information about the parrot-commits mailing list