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

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed Jun 16 17:47:01 UTC 2010


Author: NotFound
Date: Wed Jun 16 17:47:01 2010
New Revision: 47660
URL: https://trac.parrot.org/parrot/changeset/47660

Log:
more StringIterator tests

Modified:
   trunk/t/pmc/stringiterator.t

Modified: trunk/t/pmc/stringiterator.t
==============================================================================
--- trunk/t/pmc/stringiterator.t	Wed Jun 16 17:32:20 2010	(r47659)
+++ trunk/t/pmc/stringiterator.t	Wed Jun 16 17:47:01 2010	(r47660)
@@ -21,13 +21,14 @@
 .sub main :main
     .include 'test_more.pir'
 
-    plan(22)
+    plan(23)
 
     test_clone()
     test_elements()
     iterate_forward() # 10 tests
     iterate_backward() # 8 tests
     iterate_wrong() # 1 test
+    iterate_out() # 1 test
 
 .end
 
@@ -153,6 +154,56 @@
     ok(r, "Caught wrong direction")
 .end
 
+# out of bounds conditions not covered by previous tests
+.sub 'iterate_out'
+    .local pmc s, it, eh
+    s = new ['String']
+    s = 'hi'
+    it = iter s
+    .local string rs
+    rs = pop it
+    rs = pop it
+    eh = new ['ExceptionHandler']
+
+    # pop string
+    set_addr eh, catch1
+    push_eh eh
+    rs = pop it
+    goto fail
+catch1:
+    finalize eh
+
+    # pop integer
+    set_addr eh, catch2
+    .local int ri
+    ri = pop it
+    goto fail
+catch2:
+    finalize eh
+
+    # shift string
+    set_addr eh, catch3
+    .local int ri
+    rs = shift it
+    goto fail
+catch3:
+    finalize eh
+
+    # shift integer
+    set_addr eh, catch4
+    .local int ri
+    ri = shift it
+    goto fail
+catch4:
+    finalize eh
+
+    ok(1, "Caught out of bounds iterations")
+    goto end
+fail:
+    ok(0, "Out of bounds iteration should throw")
+end:
+.end
+
 # Local Variables:
 #   mode: pir
 #   fill-column: 100


More information about the parrot-commits mailing list