2 # Copyright (C) 2006-2008, Parrot Foundation.
9 $P0 = $P0['TEST_VERBOSE']
10 unless null $P0 goto set_verbose
14 set_global 'TEST_VERBOSE', $P0
17 .include 'test_more.pir'
23 'FixedPMCArray_empty'()
24 'FixedPMCArray_3elem'()
25 'ResizablePMCArray_empty'()
26 'ResizablePMCArray_3elem'()
30 # test library loading
34 push_eh err_load_bytecode
51 # test object initialization
55 $P99 = new 'FixedPMCArray'
62 if null iter goto test_iter_new
65 'ok'($I0, 'created Iter')
68 push_eh err_start_noargs
71 'ok'(0, 'start requires an aggregate')
74 ok(1, 'start requires an aggregate')
78 'ok'(1, ".'start'() runs without exception")
82 'ok'(1, ".'start'() runs again without exception")
86 # test empty FixedPMCArray
87 .sub 'FixedPMCArray_empty'
90 $P99 = new 'FixedPMCArray'
98 .local int is_exhausted
103 is_exhausted = iter.'exhausted'()
104 'is'(is_exhausted, 0, ".'exhausted'() returns false")
107 value = iter.'value'()
109 'ok'($I0, ".'value'() returns PMCNULL")
113 'ok'(1, ".'next'() runs without exception")
116 is_exhausted = iter.'exhausted'()
117 'is'(is_exhausted, 1, ".'exhausted'() returns true")
120 value = iter.'value'()
122 'ok'($I0, ".'value'() returns PMCNULL")
126 'ok'(1, ".'next'() runs without exception after iter exhaustion")
130 # test FixedPMCArray with three elements
131 .sub 'FixedPMCArray_3elem'
134 $P99 = new 'FixedPMCArray'
145 .local int is_exhausted
150 is_exhausted = iter.'exhausted'()
151 'is'(is_exhausted, 0, ".'exhausted'() returns false")
154 value = iter.'value'()
156 'ok'($I0, ".'value'() returns PMCNULL")
160 'ok'(1, ".'next'() runs without exception")
163 is_exhausted = iter.'exhausted'()
164 'is'(is_exhausted, 0, ".'exhausted'() returns false")
167 value = iter.'value'()
169 'is'(value, $P0, ".'next'() and .'value'()")
175 'ok'(1, ".'next'() runs without exception")
178 is_exhausted = iter.'exhausted'()
179 'is'(is_exhausted, 0, ".'exhausted'() returns false")
182 value = iter.'value'()
184 'is'(value, $P0, ".'next'() and .'value'()")
190 'ok'(1, ".'next'() runs without exception")
193 is_exhausted = iter.'exhausted'()
194 'is'(is_exhausted, 0, ".'exhausted'() returns false")
197 value = iter.'value'()
199 'is'(value, $P0, ".'next'() and .'value'()")
205 'ok'(1, ".'next'() runs without exception")
208 is_exhausted = iter.'exhausted'()
209 'is'(is_exhausted, 1, ".'exhausted'() returns true")
214 'is'($I0, 1, ".'value'() returns PMCNULL")
218 'ok'(1, ".'next'() runs without exception after iter exhaustion")
222 # test empty ResizablePMCArray
223 .sub 'ResizablePMCArray_empty'
226 $P99 = new 'ResizablePMCArray'
234 .local int is_exhausted
239 is_exhausted = iter.'exhausted'()
240 'is'(is_exhausted, 0, ".'exhausted'() returns false")
243 value = iter.'value'()
245 'ok'($I0, ".'value'() returns PMCNULL")
249 'ok'(1, ".'next'() runs without exception")
252 is_exhausted = iter.'exhausted'()
253 'is'(is_exhausted, 1, ".'exhausted'() returns true")
256 value = iter.'value'()
258 'ok'($I0, ".'value'() returns PMCNULL")
262 'ok'(1, ".'next'() runs without exception after iter exhaustion")
266 # test ResizablePMCArray with three elements
267 .sub 'ResizablePMCArray_3elem'
270 $P99 = new 'ResizablePMCArray'
281 .local int is_exhausted
286 is_exhausted = iter.'exhausted'()
287 'is'(is_exhausted, 0, ".'exhausted'() returns false")
290 value = iter.'value'()
292 'ok'($I0, ".'value'() returns PMCNULL")
296 'ok'(1, ".'next'() runs without exception")
299 is_exhausted = iter.'exhausted'()
300 'is'(is_exhausted, 0, ".'exhausted'() returns false")
303 value = iter.'value'()
305 'is'(value, $P0, ".'next'() and .'value'()")
311 'ok'(1, ".'next'() runs without exception")
314 is_exhausted = iter.'exhausted'()
315 'is'(is_exhausted, 0, ".'exhausted'() returns false")
318 value = iter.'value'()
320 'is'(value, $P0, ".'next'() and .'value'()")
326 'ok'(1, ".'next'() runs without exception")
329 is_exhausted = iter.'exhausted'()
330 'is'(is_exhausted, 0, ".'exhausted'() returns false")
333 value = iter.'value'()
335 'is'(value, $P0, ".'next'() and .'value'()")
341 'ok'(1, ".'next'() runs without exception")
344 is_exhausted = iter.'exhausted'()
345 'is'(is_exhausted, 1, ".'exhausted'() returns true")
350 'is'($I0, 1, ".'value'() returns PMCNULL")
354 'ok'(1, ".'next'() runs without exception after iter exhaustion")
361 # vim: expandtab shiftwidth=4 ft=pir: