[svn:parrot] r47701 - trunk/t/pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Sat Jun 19 09:36:30 UTC 2010


Author: NotFound
Date: Sat Jun 19 09:36:29 2010
New Revision: 47701
URL: https://trac.parrot.org/parrot/changeset/47701

Log:
more StringHandle tests

Modified:
   trunk/t/pmc/stringhandle.t

Modified: trunk/t/pmc/stringhandle.t
==============================================================================
--- trunk/t/pmc/stringhandle.t	Sat Jun 19 08:57:37 2010	(r47700)
+++ trunk/t/pmc/stringhandle.t	Sat Jun 19 09:36:29 2010	(r47701)
@@ -7,7 +7,7 @@
 use lib qw( . lib ../lib ../../lib );
 
 use Test::More;
-use Parrot::Test tests => 20;
+use Parrot::Test tests => 23;
 
 =head1 NAME
 
@@ -69,6 +69,31 @@
 ok 7 - $P7.open($S1, $S2) # new file, write mode succeeds
 OUT
 
+pir_output_is( <<'CODE', <<'OUT', 'get_bool' );
+.sub test :main
+    .local pmc sh
+    .local int b
+    sh = new ['StringHandle']
+    b = 0
+    unless sh goto b_false
+    b = 1
+  b_false:
+    say b
+    sh.'open'('mockname', 'w')
+    sh.'print'('Some content')
+    sh.'close'()
+    sh.'open'()
+    b = 0
+    unless sh goto b_true
+    b = 1
+  b_true:
+    say b
+.end
+CODE
+0
+1
+OUT
+
 SKIP: {
     skip 'no asynch calls yet' => 1;
 
@@ -206,6 +231,45 @@
 ok 6 - read string back from file
 OUT
 
+pir_output_is( <<'CODE', <<'OUT', 'puts' );
+.include 'except_types.pasm'
+.sub 'test' :main
+    .local pmc sh, eh
+    .local int result
+    sh = new ['StringHandle']
+    eh = new ['ExceptionHandler']
+    eh.'handle_types'(.EXCEPTION_PIO_ERROR)
+    
+    push_eh eh
+
+    # puts to SH not opened
+    result = 0
+    set_addr eh, handle1
+    sh.'puts'('something')
+    result = 1
+    goto done1
+handle1:
+    finalize eh
+done1:
+    say result
+
+    # puts to SH opened for reading
+    result = 0
+    set_addr eh, handle2
+    sh.'open'('mockname', 'r')
+    sh.'puts'('something')
+    result = 1
+    goto done2
+handle2:
+    finalize eh
+done2:
+    say result
+.end
+CODE
+0
+0
+OUT
+
 # L<PDD22/I\/O PMC API/=item print.*=item readline>
 pir_output_is( <<"CODE", <<'OUT', 'readline - synchronous' );
 .sub 'test' :main
@@ -520,6 +584,25 @@
 ok
 OUTPUT
 
+pir_output_is( <<"CODE", <<"OUTPUT", "readall - stringhandle with null content" );
+.sub main :main
+    .local pmc sh
+    .local string s
+    sh = new ['StringHandle']
+    sh.'open'('mockname', 'r')
+    # Open sets content to an empty string, flush resets is to null
+    # and that is the case we are testing here.
+    # Also, ensures coverage of the flush method.
+    sh.'flush'()
+    s = sh.'readall'()
+    print '['
+    print s
+    say ']'
+.end
+CODE
+[]
+OUTPUT
+
 pir_output_is( <<"CODE", <<"OUTPUT", "readall() - opened stringhandle" );
 .sub main :main
     \$S0 = <<"EOS"


More information about the parrot-commits mailing list