2 # Copyright (C) 2001-2009, Parrot Foundation.
7 t/pmc/resizablestringarray.t - testing the ResizableStringArray PMC
11 % prove t/pmc/resizablestringarray.t
15 Tests C<ResizableStringArray> PMC. Checks size, sets various elements, including
16 out-of-bounds test. Checks INT and PMC keys.
23 .include 'test_more.pir'
63 'unshift_string_resize_threshold'()
83 method_shift_integer()
87 method_unshift_string()
88 method_unshift_integer()
89 method_unshift_float()
93 # test the sizing and resizing of the array (including init to 0)
94 # this tests the following vtable functions:
97 # - get_integer_native
98 # - set_integer_native
102 array = new ['ResizableStringArray']
106 is($I0, 0, "initial array size (get_int)")
107 is($I1, 0, "initial array size (elements)")
112 is($I0, 1, "array resize to 1 (get_int)")
113 is($I1, 1, "array resize to 1 (elements)")
118 is($I0, 5, "array resize to 5 (get_int)")
119 is($I1, 5, "array resize to 5 (elements)")
124 is($I0, 9, "array resize to 9 (get_int)")
125 is($I1, 9, "array resize to 9 (elements)")
130 is($I0, 7, "array resize to 7 (get_int)")
131 is($I1, 7, "array resize to 7 (elements)")
133 push_eh neg_exception
136 ok(0, "array resize to -3")
140 ok(1, "array resize to -3")
145 is($I0, 7, "array resize to -3 (get_int)")
146 is($I1, 7, "array resize to -3 (elements)")
150 # test setting different elements of the array with PMCs
153 .local pmc array, elem
154 array = new ['ResizableStringArray']
155 elem = new ['Integer']
162 is($S0, "5", "set_pmc_keyed_int")
167 is($S0, "7", "set_pmc_keyed")
174 is($S0, "4", "set_pmc_keyed_int (negative)")
179 is($S0, "9", "set_pmc_keyed (negative)")
186 is($I0, 5, "set_pmc_keyed_int (out of bounds - length)")
187 is($S0, "8", "set_pmc_keyed_int (out of bounds)")
194 is($I0, 5, "set_pmc_keyed (out of bounds - length)")
195 is($S0, "11", "set_pmc_keyed (out of bounds)")
197 push_eh set_pmc_keyed_int_exception
200 ok(0, "set_pmc_keyed_int (negative, out of bounds)")
203 set_pmc_keyed_int_exception:
204 ok(1, "set_pmc_keyed_int (negative, out of bounds)")
207 push_eh set_pmc_keyed_exception
210 ok(0, "set_pmc_keyed (negative, out of bounds)")
213 set_pmc_keyed_exception:
214 ok(1, "set_pmc_keyed (negative, out of bounds)")
221 # test getting different elements as PMCs
225 array = new ['ResizableStringArray']
234 is($S0, 'String', "get_pmc_keyed_int - type")
235 is($P0, 'first', "get_pmc_keyed_int - value")
240 is($S0, 'String', "get_pmc_keyed - type")
241 is($P0, 'second', "get_pmc_keyed - value")
243 # get_pmc_keyed_int (negative)
246 is($S0, 'String', "get_pmc_keyed_int (negative) - type")
247 is($P0, 'fourth', "get_pmc_keyed_int (negative) - value")
249 # get_pmc_keyed (negative)
252 is($S0, 'String', "get_pmc_keyed (negative) - type")
253 is($P0, 'third', "get_pmc_keyed (negative) - value")
258 is($S0, 'String', "get_pmc_keyed_int (out of bounds) - type")
259 is($P0, '', "get_pmc_keyed_int (out of bounds) - value")
264 is($S0, 'String', "get_pmc_keyed (out of bounds) - type")
265 is($P0, '', "get_pmc_keyed (out of bounds) - value")
267 push_eh get_pmc_keyed_int_exception
270 ok(0, "get_pmc_keyed_int (negative, out of bounds)")
273 get_pmc_keyed_int_exception:
274 ok(1, "get_pmc_keyed_int (negative, out of bounds)")
277 push_eh get_pmc_keyed_exception
280 ok(0, "get_pmc_keyed (negative, out of bounds)")
283 get_pmc_keyed_exception:
284 ok(1, "get_pmc_keyed (negative, out of bounds)")
291 # test setting different elements of the array with STRINGs
293 .sub 'set_string_keyed'
296 array = new ['ResizableStringArray']
303 is($S0, "5", "set_string_keyed_int")
308 is($S0, "7", "set_string_keyed")
315 is($S0, "4", "set_string_keyed_int (negative)")
320 is($S0, "9", "set_string_keyed (negative)")
327 is($I0, 5, "set_string_keyed_int (out of bounds - length)")
328 is($S0, "8", "set_string_keyed_int (out of bounds)")
335 is($I0, 5, "set_string_keyed (out of bounds - length)")
336 is($S0, "11", "set_string_keyed (out of bounds)")
338 push_eh set_pmc_keyed_int_exception
341 ok(0, "set_string_keyed_int (negative, out of bounds)")
344 set_pmc_keyed_int_exception:
345 ok(1, "set_string_keyed_int (negative, out of bounds)")
348 push_eh set_pmc_keyed_exception
351 ok(0, "set_string_keyed (negative, out of bounds)")
354 set_pmc_keyed_exception:
355 ok(1, "set_string_keyed (negative, out of bounds)")
362 # test getting different elements as STRINGs
364 .sub 'get_string_keyed'
366 array = new ['ResizableStringArray']
374 is($S0, 'first', "get_string_keyed_int")
377 is($S0, 'second', "get_string_keyed")
380 is($S0, 'fourth', "get_string_keyed_int (negative)")
383 is($S0, 'third', "get_string_keyed (negative)")
387 is($S0, '', "get_string_keyed_int (out of bounds)")
391 is($S0, '', "get_string_keyed (out of bounds)")
393 push_eh get_string_keyed_int_exception
396 ok(0, "get_string_keyed_int (negative, out of bounds)")
397 goto get_string_keyed
399 get_string_keyed_int_exception:
400 ok(1, "get_string_keyed_int (negative, out of bounds)")
403 push_eh get_string_keyed_exception
406 ok(0, "get_string_keyed (negative, out of bounds)")
409 get_string_keyed_exception:
410 ok(1, "get_string_keyed (negative, out of bounds)")
417 # test setting different elements of the array with INTVALs
419 .sub 'set_integer_keyed'
422 array = new ['ResizableStringArray']
429 is($S0, "5", "set_integer_keyed_int")
434 is($S0, "7", "set_integer_keyed")
441 is($S0, "4", "set_integer_keyed_int (negative)")
446 is($S0, "9", "set_integer_keyed (negative)")
453 is($I0, 5, "set_integer_keyed_int (out of bounds - length)")
454 is($S0, "8", "set_integer_keyed_int (out of bounds)")
461 is($I0, 5, "set_integer_keyed (out of bounds - length)")
462 is($S0, "11", "set_integer_keyed (out of bounds)")
464 push_eh set_pmc_keyed_int_exception
467 ok(0, "set_integer_keyed_int (negative, out of bounds)")
470 set_pmc_keyed_int_exception:
471 ok(1, "set_integer_keyed_int (negative, out of bounds)")
474 push_eh set_pmc_keyed_exception
477 ok(0, "set_integer_keyed (negative, out of bounds)")
480 set_pmc_keyed_exception:
481 ok(1, "set_integer_keyed (negative, out of bounds)")
488 # test getting different elements as INTVALs
490 .sub 'get_integer_keyed'
492 array = new ['ResizableStringArray']
500 is($I0, 1, "get_integer_keyed_int")
503 is($I0, 2, "get_integer_keyed")
506 is($I0, 4, "get_integer_keyed_int (negative)")
509 is($I0, 3, "get_integer_keyed (negative)")
513 is($I0, 0, "get_integer_keyed_int (out of bounds)")
517 is($I0, 0, "get_integer_keyed (out of bounds)")
519 push_eh get_integer_keyed_int_exception
522 ok(0, "get_integer_keyed_int (negative, out of bounds)")
523 goto get_integer_keyed
525 get_integer_keyed_int_exception:
526 ok(1, "get_integer_keyed_int (negative, out of bounds)")
529 push_eh get_integer_keyed_exception
532 ok(0, "get_integer_keyed (negative, out of bounds)")
535 get_integer_keyed_exception:
536 ok(1, "get_integer_keyed (negative, out of bounds)")
543 # test setting different elements of the array with FLOATs
545 .sub 'set_number_keyed'
548 array = new ['ResizableStringArray']
555 is($S0, "5.1", "set_number_keyed_int")
560 is($S0, "7.2", "set_number_keyed")
567 is($S0, "4.3", "set_number_keyed_int (negative)")
572 is($S0, "9.4", "set_number_keyed (negative)")
579 is($I0, 5, "set_number_keyed_int (out of bounds - length)")
580 is($S0, "8.5", "set_number_keyed_int (out of bounds)")
587 is($I0, 5, "set_number_keyed (out of bounds - length)")
588 is($S0, "11.6", "set_number_keyed (out of bounds)")
590 push_eh set_pmc_keyed_int_exception
593 ok(0, "set_number_keyed_int (negative, out of bounds)")
596 set_pmc_keyed_int_exception:
597 ok(1, "set_number_keyed_int (negative, out of bounds)")
600 push_eh set_pmc_keyed_exception
603 ok(0, "set_number_keyed (negative, out of bounds)")
606 set_pmc_keyed_exception:
607 ok(1, "set_number_keyed (negative, out of bounds)")
614 # test getting different elements as FLOATs
616 .sub 'get_number_keyed'
618 array = new ['ResizableStringArray']
626 is($N0, 1.1, "get_number_keyed_int")
629 is($N0, 2.2, "get_number_keyed")
632 is($N0, 4.4, "get_number_keyed_int (negative)")
635 is($N0, 3.3, "get_number_keyed (negative)")
639 is($N0, 0.0, "get_number_keyed_int (out of bounds)")
643 is($N0, 0.0, "get_number_keyed (out of bounds)")
645 push_eh get_number_keyed_int_exception
648 ok(0, "get_number_keyed_int (negative, out of bounds)")
649 goto get_number_keyed
651 get_number_keyed_int_exception:
652 ok(1, "get_number_keyed_int (negative, out of bounds)")
655 push_eh get_number_keyed_exception
658 ok(0, "get_number_keyed (negative, out of bounds)")
661 get_number_keyed_exception:
662 ok(1, "get_number_keyed (negative, out of bounds)")
673 array = new ['ResizableStringArray']
677 $P0 = new ['Integer']
682 is($I0, 2, "delete_keyed - elements")
683 is($S0, "three", "delete_keyed - value")
687 # test pushing PMCs onto the array
691 array = new ['ResizableStringArray']
694 array = new ['ResizableStringArray']
702 is($I0, 1, "push_pmc - elements")
703 is($S0, "one", "push_pmc - value")
710 is($I0, 2, "push_pmc (grow) - elements")
711 is($S0, "two", "push_pmc (grow) - value")
717 is($I0, 2, "push_pmc (shrink, grow) - elements")
718 is($S0, "three", "push_pmc (shrink, grow) - value")
723 # test pushing STRINGs onto the array
727 array = new ['ResizableStringArray']
733 is($I0, 1, "push_string - elements")
734 is($S0, "one", "push_string - value")
739 is($I0, 2, "push_string (grow) - elements")
740 is($S0, "two", "push_string (grow) - value")
746 is($I0, 2, "push_string (shrink, grow) - elements")
747 is($S0, "three", "push_string (shrink, grow) - value")
752 # test pushing INTVALs onto the array
756 array = new ['ResizableStringArray']
762 is($I0, 1, "push_integer - elements")
763 is($S0, "1", "push_integer - value")
768 is($I0, 2, "push_integer (grow) - elements")
769 is($S0, "2", "push_integer (grow) - value")
775 is($I0, 2, "push_integer (shrink, grow) - elements")
776 is($S0, "3", "push_integer (shrink, grow) - value")
781 # test pushing FLOATs onto the array
785 array = new ['ResizableStringArray']
791 is($I0, 1, "push_float - elements")
792 is($S0, "1.1", "push_float - value")
797 is($I0, 2, "push_float (grow) - elements")
798 is($S0, "2.2", "push_float (grow) - value")
804 is($I0, 2, "push_float (shrink, grow) - elements")
805 is($S0, "3.3", "push_float (shrink, grow) - value")
810 array = new ['ResizableStringArray']
817 is($I0, 1, "pop_pmc - elements")
818 is($S0, 'String', "pop_pmc - type")
819 is($S1, 'foo', "pop_pmc - value")
825 ok(0, "pop_pmc - exception")
829 ok(1, "pop_pmc - exception")
835 array = new ['ResizableStringArray']
840 is($I0, 1, "pop_string - elements")
841 is($S0, 'foo', "pop_string - value")
847 ok(0, "pop_string - exception")
851 ok(1, "pop_string - exception")
857 array = new ['ResizableStringArray']
862 is($I0, 1, "pop_integer - elements")
863 is($I1, 2, "pop_integer - value")
869 ok(0, "pop_integer - exception")
873 ok(1, "pop_integer - exception")
879 array = new ['ResizableStringArray']
884 is($I0, 1, "pop_float - elements")
885 is($N0, 2.2, "pop_float - value")
891 ok(0, "pop_float - exception")
895 ok(1, "pop_float - exception")
901 array = new ['ResizableStringArray']
909 is($I0, 1, "shift_pmc - elements")
910 is($S0, 'String', "shift_pmc - type")
911 is($S1, 'foo', "shift_pmc - value")
917 ok(0, "shift_pmc - exception")
921 ok(1, "shift_pmc - exception")
927 array = new ['ResizableStringArray']
933 is($I0, 1, "shift_string - elements")
934 is($S0, 'foo', "shift_string - value")
940 ok(0, "shift_string - exception")
944 ok(1, "shift_string - exception")
950 array = new ['ResizableStringArray']
956 is($I0, 1, "shift_integer - elements")
957 is($I1, 2, "shift_integer - value")
963 ok(0, "shift_integer - exception")
967 ok(1, "shift_integer - exception")
973 array = new ['ResizableStringArray']
979 is($I0, 1, "shift_float - elements")
980 is($N0, 2.2, "shift_float - value")
986 ok(0, "shift_float - exception")
990 ok(1, "shift_float - exception")
995 # test unshifting PMCs onto the array
999 array = new ['ResizableStringArray']
1002 $P0 = new ['String']
1005 $I0 = elements array
1007 is($I0, 1, "unshift_pmc - elements")
1008 is($S0, "one", "unshift_pmc - value")
1010 $P0 = new ['String']
1013 $I0 = elements array
1015 is($I0, 2, "unshift_pmc (grow) - elements")
1016 is($S0, "two", "unshift_pmc (grow) - value")
1019 unshift array, "three"
1020 $I0 = elements array
1022 is($I0, 2, "unshift_pmc (shrink, grow) - elements")
1023 is($S0, "three", "unshift_pmc (shrink, grow) - value")
1028 # test unshifting STRINGs onto the array
1030 .sub 'unshift_string'
1032 array = new ['ResizableStringArray']
1035 unshift array, "one"
1036 $I0 = elements array
1038 is($I0, 1, "unshift_string - elements")
1039 is($S0, "one", "unshift_string - value")
1041 unshift array, "two"
1042 $I0 = elements array
1044 is($I0, 2, "unshift_string (grow) - elements")
1045 is($S0, "two", "unshift_string (grow) - value")
1048 unshift array, "three"
1049 $I0 = elements array
1051 is($I0, 2, "unshift_string (shrink, grow) - elements")
1052 is($S0, "three", "unshift_string (shrink, grow) - value")
1057 # Test unshifting STRINGs onto an array
1058 # that is at the default resize_threshold(8).
1061 .sub 'unshift_string_resize_threshold'
1063 rsarray = new ['ResizableStringArray']
1073 # rsarray is now: 1 2 3 4 5 6 7 8
1075 # This unshift will cause a resize larger than the
1076 # initial resize_threshold (8), triggering the bug.
1077 unshift rsarray, "0"
1079 # rsarray should now be : 0 1 2 3 4 5 6 7 8
1080 # The bug causes it to be : 0 2 3 4 5 6 7 8 ""
1102 is( $S9, "012345678", 'Unshift prepends at array instead of overlaying' )
1107 # test unshifting INTVALs onto the array
1109 .sub 'unshift_integer'
1111 array = new ['ResizableStringArray']
1116 $I0 = elements array
1118 is($I0, 1, "unshift_integer - elements")
1119 is($S0, "1", "unshift_integer - value")
1122 $I0 = elements array
1124 is($I0, 2, "unshift_integer (grow) - elements")
1125 is($S0, "2", "unshift_integer (grow) - value")
1129 $I0 = elements array
1131 is($I0, 2, "unshift_integer (shrink, grow) - elements")
1132 is($S0, "3", "unshift_integer (shrink, grow) - value")
1137 # test unshifting FLOATs onto the array
1139 .sub 'unshift_float'
1141 array = new ['ResizableStringArray']
1145 $I0 = elements array
1147 is($I0, 1, "unshift_float - elements")
1148 is($S0, "1.1", "unshift_float - value")
1151 $I0 = elements array
1153 is($I0, 2, "unshift_float (grow) - elements")
1154 is($S0, "2.2", "unshift_float (grow) - value")
1158 $I0 = elements array
1160 is($I0, 2, "unshift_float (shrink, grow) - elements")
1161 is($S0, "3.3", "unshift_float (shrink, grow) - value")
1169 array = new ['ResizableStringArray']
1176 cloned = clone array
1178 $I0 = elements cloned
1179 is($I0, 3, 'cloned array - size')
1182 is($S0, 'ResizableStringArray', 'cloned array - type')
1184 is_deeply(cloned, array, 'cloned array - deep comparison')
1189 array = new ['ResizablePMCArray']
1195 is($S0, 3, "get_string")
1200 array = new ['ResizableStringArray']
1202 $I0 = does array, 'array'
1203 is($I0, 1, "does array")
1205 $I0 = does array, 'scalar'
1206 is($I0, 0, "doesn't do scalar")
1210 # a test with a sparse array. this converted from PASM from the original
1211 # ResizableStringArray tests.
1215 array = new ['ResizableStringArray']
1234 if $I0 <= $I10 goto lp1
1243 if $I2 != $I9 goto err_1
1251 if $I9 != $I4 goto err_1
1255 if $I0 <= $I10 goto lp2
1258 # now repeat and fill some holes
1268 if $I0 <= $I10 goto lp3
1276 if $I2 != $I9 goto err_2
1279 if $I0 <= $I10 goto lp4
1297 $P1 = new ['ResizableStringArray']
1302 $P2 = new ['ResizableStringArray']
1305 splice $P1, $P2, 0, 2
1307 is($S0, "A3", "splice replace")
1309 $P1 = new ['ResizableStringArray']
1314 $P2 = new ['ResizableStringArray']
1317 splice $P1, $P2, 1, 2
1319 is($S0, "1A", "splice replace")
1321 .macro SpliceMadeEasy(code, out, testing)
1322 $P1 = new ['ResizableStringArray']
1328 $P2 = new ['ResizableStringArray']
1336 is($S0, .out, .testing)
1339 .SpliceMadeEasy({ splice $P1, $P2, 0, 5 }, "ABCDE", "splice, complete replace")
1340 .SpliceMadeEasy({ splice $P1, $P2, 5, 0 }, "12345ABCDE", "splice, append")
1341 .SpliceMadeEasy({ splice $P1, $P2, 4, 0 }, "1234ABCDE5", "splice, insert before last element")
1342 .SpliceMadeEasy({ splice $P1, $P2, 3, 0 }, "123ABCDE45", "splice, append-in-middle")
1343 .SpliceMadeEasy({ splice $P1, $P2, 0, 2 }, "ABCDE345", "splice, replace at beginning")
1344 .SpliceMadeEasy({ splice $P1, $P2, 2, 2 }, "12ABCDE5", "splice, replace in middle")
1345 .SpliceMadeEasy({ splice $P1, $P2, 3, 2 }, "123ABCDE", "splice, replace at end")
1346 .SpliceMadeEasy({ splice $P1, $P2, -3, 2 }, "12ABCDE5", "splice, replace in middle start from end")
1348 $P2 = new ['ResizableStringArray']
1349 splice $P1, $P2, 2, 2
1350 }, "125", "splice, empty replacement")
1352 $P2 = new ['ResizableStringArray']
1354 splice $P1, $P2, 2, 1
1355 }, "12A45", "splice, equal size replacement")
1357 $P1 = new ['ResizableStringArray']
1359 $P2 = new ['ResizableStringArray']
1362 push_eh handle_negtoobig
1363 splice $P1, $P2, -10, 1
1364 goto after_negtoobig
1369 is($I0, 1, 'splice, negative offset too long throws')
1371 $P1 = new ['ResizableStringArray']
1377 $P2 = new ['ResizablePMCArray']
1385 splice $P1, $P2, 1, 0
1389 .local pmc exception
1390 .local string message
1393 .get_results (exception)
1396 message = substr message, 22, 23
1397 is(message, 'illegal type for splice', "splice with a different type")
1401 # test pushing PMCs onto the array
1403 .sub method_push_pmc
1405 array = new ['ResizableStringArray']
1408 $P0 = new ['String']
1411 $I0 = elements array
1413 is($I0, 1, "method_push_pmc - elements")
1414 is($S0, "one", "method_push_pmc - value")
1416 $P0 = new ['String']
1419 $I0 = elements array
1421 is($I0, 2, "method_push_pmc (grow) - elements")
1422 is($S0, "two", "method_push_pmc (grow) - value")
1425 array.'push'('three')
1426 $I0 = elements array
1428 is($I0, 2, "method_push_pmc (shrink, grow) - elements")
1429 is($S0, "three", "method_push_pmc (shrink, grow) - value")
1434 # test pushing STRINGs onto the array
1436 .sub method_push_string
1438 array = new ['ResizableStringArray']
1442 $I0 = elements array
1444 is($I0, 1, "method_push_string - elements")
1445 is($S0, "one", "method_push_string - value")
1448 $I0 = elements array
1450 is($I0, 2, "method_push_string (grow) - elements")
1451 is($S0, "two", "method_push_string (grow) - value")
1454 array.'push'("three")
1455 $I0 = elements array
1457 is($I0, 2, "method_push_string (shrink, grow) - elements")
1458 is($S0, "three", "method_push_string (shrink, grow) - value")
1463 # test pushing INTVALs onto the array
1465 .sub method_push_integer
1467 array = new ['ResizableStringArray']
1471 $I0 = elements array
1473 is($I0, 1, "method_push_integer - elements")
1474 is($S0, "1", "method_push_integer - value")
1477 $I0 = elements array
1479 is($I0, 2, "method_push_integer (grow) - elements")
1480 is($S0, "2", "method_push_integer (grow) - value")
1484 $I0 = elements array
1486 is($I0, 2, "method_push_integer (shrink, grow) - elements")
1487 is($S0, "3", "method_push_integer (shrink, grow) - value")
1492 # test pushing FLOATs onto the array
1494 .sub method_push_float
1496 array = new ['ResizableStringArray']
1500 $I0 = elements array
1502 is($I0, 1, "method_push_float - elements")
1503 is($S0, "1.1", "method_push_float - value")
1506 $I0 = elements array
1508 is($I0, 2, "method_push_float (grow) - elements")
1509 is($S0, "2.2", "method_push_float (grow) - value")
1513 $I0 = elements array
1515 is($I0, 2, "method_push_float (shrink, grow) - elements")
1516 is($S0, "3.3", "method_push_float (shrink, grow) - value")
1522 array = new ['ResizableStringArray']
1526 $I0 = elements array
1529 is($I0, 1, "method_pop_pmc - elements")
1530 is($S0, 'String', "method_pop_pmc - type")
1531 is($S1, 'foo', "method_pop_pmc - value")
1537 ok(0, "method_pop_pmc - exception")
1541 ok(1, "method_pop_pmc - exception")
1545 .sub method_pop_string
1547 array = new ['ResizableStringArray']
1551 $I0 = elements array
1552 is($I0, 1, "method_pop_string - elements")
1553 is($S0, 'foo', "method_pop_string - value")
1559 ok(0, "method_pop_string - exception")
1563 ok(1, "method_pop_string - exception")
1567 .sub method_pop_integer
1569 array = new ['ResizableStringArray']
1573 $I0 = elements array
1574 is($I0, 1, "method_pop_integer - elements")
1575 is($I1, 2, "method_pop_integer - value")
1581 ok(0, "method_pop_integer - exception")
1585 ok(1, "method_pop_integer - exception")
1589 .sub method_pop_float
1591 array = new ['ResizableStringArray']
1595 $I0 = elements array
1596 is($I0, 1, "method_pop_float - elements")
1597 is($N0, 2.2, "method_pop_float - value")
1603 ok(0, "method_pop_float - exception")
1607 ok(1, "method_pop_float - exception")
1611 .sub method_shift_pmc
1613 array = new ['ResizableStringArray']
1617 $P0 = array.'shift'()
1618 $I0 = elements array
1621 is($I0, 1, "method_shift_pmc - elements")
1622 is($S0, 'String', "method_shift_pmc - type")
1623 is($S1, 'foo', "method_shift_pmc - value")
1627 $P0 = array.'shift'()
1629 ok(0, "method_shift_pmc - exception")
1633 ok(1, "method_shift_pmc - exception")
1637 .sub method_shift_string
1639 array = new ['ResizableStringArray']
1643 $S0 = array.'shift'()
1644 $I0 = elements array
1645 is($I0, 1, "method_shift_string - elements")
1646 is($S0, 'foo', "method_shift_string - value")
1650 $S0 = array.'shift'()
1652 ok(0, "method_shift_string - exception")
1656 ok(1, "method_shift_string - exception")
1660 .sub method_shift_integer
1662 array = new ['ResizableStringArray']
1666 $I1 = array.'shift'()
1667 $I0 = elements array
1668 is($I0, 1, "method_shift_integer - elements")
1669 is($I1, 2, "method_shift_integer - value")
1673 $I0 = array.'shift'()
1675 ok(0, "method_shift_integer - exception")
1679 ok(1, "method_shift_integer - exception")
1683 .sub method_shift_float
1685 array = new ['ResizableStringArray']
1689 $N0 = array.'shift'()
1690 $I0 = elements array
1691 is($I0, 1, "method_shift_float - elements")
1692 is($N0, 2.2, "method_shift_float - value")
1696 $N0 = array.'shift'()
1698 ok(0, "method_shift_float - exception")
1702 ok(1, "method_shift_float - exception")
1706 .sub method_unshift_pmc
1708 array = new ['ResizableStringArray']
1711 $P0 = new ['String']
1713 array.'unshift'($P0)
1714 $I0 = elements array
1716 is($I0, 1, "method_unshift_pmc - elements")
1717 is($S0, "one", "method_unshift_pmc - value")
1719 $P0 = new ['String']
1721 array.'unshift'($P0)
1722 $I0 = elements array
1724 is($I0, 2, "method_unshift_pmc (grow) - elements")
1725 is($S0, "two", "method_unshift_pmc (grow) - value")
1728 array.'unshift'("three")
1729 $I0 = elements array
1731 is($I0, 2, "method_unshift_pmc (shrink, grow) - elements")
1732 is($S0, "three", "method_unshift_pmc (shrink, grow) - value")
1737 # test unshifting STRINGs onto the array
1739 .sub method_unshift_string
1741 array = new ['ResizableStringArray']
1744 array.'unshift'("one")
1745 $I0 = elements array
1747 is($I0, 1, "method_unshift_string - elements")
1748 is($S0, "one", "method_unshift_string - value")
1750 array.'unshift'("two")
1751 $I0 = elements array
1753 is($I0, 2, "method_unshift_string (grow) - elements")
1754 is($S0, "two", "method_unshift_string (grow) - value")
1757 array.'unshift'("three")
1758 $I0 = elements array
1760 is($I0, 2, "method_unshift_string (shrink, grow) - elements")
1761 is($S0, "three", "method_unshift_string (shrink, grow) - value")
1766 # test unshifting INTVALs onto the array
1768 .sub method_unshift_integer
1770 array = new ['ResizableStringArray']
1774 $I0 = elements array
1776 is($I0, 1, "method_unshift_integer - elements")
1777 is($S0, "1", "method_unshift_integer - value")
1780 $I0 = elements array
1782 is($I0, 2, "method_unshift_integer (grow) - elements")
1783 is($S0, "2", "method_unshift_integer (grow) - value")
1787 $I0 = elements array
1789 is($I0, 2, "method_unshift_integer (shrink, grow) - elements")
1790 is($S0, "3", "method_unshift_integer (shrink, grow) - value")
1795 # test unshifting FLOATs onto the array
1797 .sub method_unshift_float
1799 array = new ['ResizableStringArray']
1802 array.'unshift'(1.1)
1803 $I0 = elements array
1805 is($I0, 1, "method_unshift_float - elements")
1806 is($S0, "1.1", "method_unshift_float - value")
1808 array.'unshift'(2.2)
1809 $I0 = elements array
1811 is($I0, 2, "method_unshift_float (grow) - elements")
1812 is($S0, "2.2", "method_unshift_float (grow) - value")
1815 array.'unshift'(3.3)
1816 $I0 = elements array
1818 is($I0, 2, "method_unshift_float (shrink, grow) - elements")
1819 is($S0, "3.3", "method_unshift_float (shrink, grow) - value")
1826 # vim: expandtab shiftwidth=4 ft=pir: