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

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed Jun 23 15:48:55 UTC 2010


Author: NotFound
Date: Wed Jun 23 15:48:55 2010
New Revision: 47785
URL: https://trac.parrot.org/parrot/changeset/47785

Log:
some more OrderedHashIterator tests

Modified:
   trunk/t/pmc/orderedhashiterator.t

Modified: trunk/t/pmc/orderedhashiterator.t
==============================================================================
--- trunk/t/pmc/orderedhashiterator.t	Wed Jun 23 15:19:57 2010	(r47784)
+++ trunk/t/pmc/orderedhashiterator.t	Wed Jun 23 15:48:55 2010	(r47785)
@@ -17,13 +17,17 @@
 
 =cut
 
+.include 'iterator.pasm'
+.include 'except_types.pasm'
+
 .sub 'main'
     .include 'test_more.pir'
 
-    plan(3)
+    plan(5)
 
     'test_init'()
     'test_bad_type'()
+    'test_shift'()
 .end
 
 .sub 'test_init'
@@ -45,22 +49,69 @@
     i2 = isa it, 'OrderedHashIterator'
     add i, i2
     is(i, 2, 'OrderedHashIterator has proper type')
+
+    # elements and get_integer should both return 0
+    i = elements it
+    i2 = it
+    add i, i2
+    is(i, 0, 'iterator for empty OrderedHash has size 0')
 .end
 
 .sub 'test_bad_type'
-    .local pmc oh, it
+    .local pmc oh, it, eh
     .local int i
     oh = new ['OrderedHash']
     it = iter oh
     i = 1
-    push_eh catch
+    eh = new ['ExceptionHandler']
+    eh.'handle_types'(.EXCEPTION_INVALID_OPERATION)
+    set_addr eh, catch
+    push_eh eh
     it = 9999 # Let's hope it will never be a valid iteration type
     i = 0
   catch:
+    finalize eh
     pop_eh
     ok(i, 'invalid iteration type throws')
 .end
 
+.sub 'test_shift'
+    .local pmc oh, it, eh, p
+    .local int i
+    oh = new ['OrderedHash']
+    it = iter oh
+    i = 1
+    eh = new ['ExceptionHandler']
+    eh.'handle_types'(.EXCEPTION_OUT_OF_BOUNDS)
+    set_addr eh, catch
+    push_eh eh
+    p = shift it
+    i = 0
+  catch:
+    finalize eh
+    pop_eh
+    ok(i, 'shift_pmc in empty OH throws')
+.end
+
+.sub 'test_pop'
+    .local pmc oh, it, eh, p
+    .local int i
+    oh = new ['OrderedHash']
+    it = iter oh
+    it = .ITERATE_FROM_END
+    i = 1
+    eh = new ['ExceptionHandler']
+    eh.'handle_types'(.EXCEPTION_OUT_OF_BOUNDS)
+    set_addr eh, catch
+    push_eh eh
+    p = pop it
+    i = 0
+  catch:
+    finalize eh
+    pop_eh
+    ok(i, 'pop_pmc in empty OH throws')
+.end
+
 # Local Variables:
 #   mode: pir
 #   fill-column: 100


More information about the parrot-commits mailing list