fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / t / pmc / orderedhashiterator.t
blobab49bcbf5682b382a86b7e31b2b9d9fabe12b7d8
1 #!./parrot
2 # Copyright (C) 2001-2010, Parrot Foundation.
3 # $Id$
5 =head1 NAME
7 t/pmc/orderedhashiterator.t - Ordered Hash Iterator
9 =head1 SYNOPSIS
11     % prove t/pmc/orderedhashiterator.t
13 =head1 DESCRIPTION
15 Do almost nothing test. Main purpose of OrderedHashIterator covered by
16 t/pmc/orderedhash.t.
18 =cut
20 .include 'iterator.pasm'
21 .include 'except_types.pasm'
23 .sub 'main'
24     .include 'test_more.pir'
26     plan(7)
28     'test_init'()
29     'test_bad_type'()
30     'test_shift'()
31     'test_pop'()
32     'test_clone'()
33 .end
35 .sub 'test_init'
36     .local pmc oh, it
37     .local int i, i2
38     # We can't create OrderedHashIterator directly
39     i = 1
40     push_eh fail
41     oh = new ['OrderedHashIterator']
42     i = 0
43   fail:
44     pop_eh
45     ok(i, "Can't create OrderedHashIterator directly")
47     oh = new ['OrderedHash']
48     it = iter oh
49     sweep 1 # Make sure the mark vtable is covered
50     i = isa it, 'Iterator'
51     i2 = isa it, 'OrderedHashIterator'
52     add i, i2
53     is(i, 2, 'OrderedHashIterator has proper type')
55     # elements and get_integer should both return 0
56     i = elements it
57     i2 = it
58     add i, i2
59     is(i, 0, 'iterator for empty OrderedHash has size 0')
60 .end
62 .sub 'test_bad_type'
63     .local pmc oh, it, eh
64     .local int i
65     oh = new ['OrderedHash']
66     it = iter oh
67     i = 1
68     eh = new ['ExceptionHandler']
69     eh.'handle_types'(.EXCEPTION_INVALID_OPERATION)
70     set_addr eh, catch
71     push_eh eh
72     it = 9999 # Let's hope it will never be a valid iteration type
73     i = 0
74   catch:
75     finalize eh
76     pop_eh
77     ok(i, 'invalid iteration type throws')
78 .end
80 .sub 'test_shift'
81     .local pmc oh, it, eh, p
82     .local int i
83     oh = new ['OrderedHash']
84     it = iter oh
85     i = 1
86     eh = new ['ExceptionHandler']
87     eh.'handle_types'(.EXCEPTION_OUT_OF_BOUNDS)
88     set_addr eh, catch
89     push_eh eh
90     p = shift it
91     i = 0
92   catch:
93     finalize eh
94     pop_eh
95     ok(i, 'shift_pmc in empty OH throws')
96 .end
98 .sub 'test_pop'
99     .local pmc oh, it, eh, p
100     .local int i
101     oh = new ['OrderedHash']
102     it = iter oh
103     it = .ITERATE_FROM_END
104     i = 1
105     eh = new ['ExceptionHandler']
106     eh.'handle_types'(.EXCEPTION_OUT_OF_BOUNDS)
107     set_addr eh, catch
108     push_eh eh
109     p = pop it
110     i = 0
111   catch:
112     finalize eh
113     pop_eh
114     ok(i, 'pop_pmc in empty OH throws')
115 .end
117 .sub 'test_clone'
118     .local pmc oh, it, cl
119     .local int result
120     oh = new ['OrderedHash']
121     it = iter oh
123     # This chekcs the de facto behavior for code coverage purposes.
124     cl = clone it
125     result = isnull cl
126     ok(result, 'clone of OHI gives null')
127 .end
129 # Local Variables:
130 #   mode: pir
131 #   fill-column: 100
132 # End:
133 # vim: expandtab shiftwidth=4 ft=pir: