2 # Copyright (C) 2006-2008, Parrot Foundation.
7 t/op/cmp-nonbranch.t - Non-branching conditionals
11 % prove t/op/cmp-nonbranch.t
15 Tests all non-branching conditional operators.
52 .include 'test_more.pir'
77 jmpstack = new 'ResizableIntegerArray'
83 local_branch jmpstack, exp_nok
84 local_branch jmpstack, test_it # not ok
86 local_branch jmpstack, test_it # not ok
87 local_branch jmpstack, exp_ok
89 local_branch jmpstack, test_it # ok
92 local_branch jmpstack, test_it # ok -- Null is a singleton
105 jmpstack = new 'ResizableIntegerArray'
106 .SET_DESC('isntsame')
111 local_branch jmpstack, exp_ok
112 local_branch jmpstack, test_it # ok
114 local_branch jmpstack, test_it # ok
116 local_branch jmpstack, exp_nok
117 local_branch jmpstack, test_it # not ok
120 local_branch jmpstack, test_it # not ok -- Null is a singleton
125 res = isntsame $P0, $P1
133 jmpstack = new 'ResizableIntegerArray'
139 local_branch jmpstack, exp_nok
140 local_branch jmpstack, test_it # not ok
142 local_branch jmpstack, exp_ok
143 local_branch jmpstack, test_it # ok
156 jmpstack = new 'ResizableIntegerArray'
162 local_branch jmpstack, exp_ok
163 local_branch jmpstack, test_it # ok
165 local_branch jmpstack, exp_nok
166 local_branch jmpstack, test_it # not ok
179 jmpstack = new 'ResizableIntegerArray'
180 .SET_DESC('isnull pmc')
184 local_branch jmpstack, exp_ok
185 local_branch jmpstack, test_it
186 $S0 = 'Null' # this is a valid pmc type -- you can't trick parrot :)
187 local_branch jmpstack, exp_nok
188 local_branch jmpstack, test_it
190 local_branch jmpstack, test_it
212 is(res, 1, 'isnull string null')
215 is(res, 0, 'isnull string non null')
217 is(res, 0, 'isnull string constant')
221 .local string exp, res
225 .SET_DESC('isgt_i_i_i')
240 .RESET_DESC('isgt_i_ic_i')
252 .RESET_DESC('isgt_i_i_ic')
264 .RESET_DESC('isgt_i_ic_ic')
275 .RESET_DESC('isgt_i_n_n')
290 .RESET_DESC('isgt_i_nc_n')
302 .RESET_DESC('isgt_i_n_nc')
314 .RESET_DESC('isgt_i_nc_nc')
325 .RESET_DESC('isgt_i_s_s')
340 .RESET_DESC('isgt_i_sc_s')
352 .RESET_DESC('isgt_i_s_sc')
364 .RESET_DESC('isgt_i_sc_sc')
366 isgt $I1, "Bbb", "Ccc"
368 isgt $I1, "Bbb", "Bbb"
370 isgt $I1, "Bbb", "Aaa"
377 .local string exp, res
381 .SET_DESC('isge_i_i_i')
396 .RESET_DESC('isge_i_ic_i')
408 .RESET_DESC('isge_i_i_ic')
420 .RESET_DESC('isge_i_ic_ic')
431 .RESET_DESC('isge_i_n_n')
446 .RESET_DESC('isge_i_nc_n')
458 .RESET_DESC('isge_i_n_nc')
470 .RESET_DESC('isge_i_nc_nc')
481 .RESET_DESC('isge_i_s_s')
496 .RESET_DESC('isge_i_sc_s')
508 .RESET_DESC('isge_i_s_sc')
520 .RESET_DESC('isge_i_sc_sc')
522 isge $I1, "Bbb", "Ccc"
524 isge $I1, "Bbb", "Bbb"
526 isge $I1, "Bbb", "Aaa"
533 .local string exp, res
537 .SET_DESC('isle_i_i_i')
552 .RESET_DESC('isle_i_ic_i')
564 .RESET_DESC('isle_i_i_ic')
576 .RESET_DESC('isle_i_ic_ic')
587 .RESET_DESC('isle_i_n_n')
602 .RESET_DESC('isle_i_nc_n')
614 .RESET_DESC('isle_i_n_nc')
626 .RESET_DESC('isle_i_nc_nc')
637 .RESET_DESC('isle_i_s_s')
652 .RESET_DESC('isle_i_sc_s')
664 .RESET_DESC('isle_i_s_sc')
676 .RESET_DESC('isle_i_sc_sc')
678 isle $I1, "Bbb", "Ccc"
680 isle $I1, "Bbb", "Bbb"
682 isle $I1, "Bbb", "Aaa"
689 .local string exp, res
693 .SET_DESC('islt_i_i_i')
708 .RESET_DESC('islt_i_ic_i')
720 .RESET_DESC('islt_i_i_ic')
732 .RESET_DESC('islt_i_ic_ic')
743 .RESET_DESC('islt_i_n_n')
758 .RESET_DESC('islt_i_nc_n')
770 .RESET_DESC('islt_i_n_nc')
782 .RESET_DESC('islt_i_nc_nc')
793 .RESET_DESC('islt_i_s_s')
808 .RESET_DESC('islt_i_sc_s')
820 .RESET_DESC('islt_i_s_sc')
832 .RESET_DESC('islt_i_sc_sc')
834 islt $I1, "Bbb", "Ccc"
836 islt $I1, "Bbb", "Bbb"
838 islt $I1, "Bbb", "Aaa"
845 .local string exp, res
849 .SET_DESC('iseq_i_i_i')
864 .RESET_DESC('iseq_i_ic_i')
876 .RESET_DESC('iseq_i_i_ic')
888 .RESET_DESC('iseq_i_ic_ic')
899 .RESET_DESC('iseq_i_n_n')
914 .RESET_DESC('iseq_i_nc_n')
926 .RESET_DESC('iseq_i_n_nc')
938 .RESET_DESC('iseq_i_nc_nc')
949 .RESET_DESC('iseq_i_s_s')
964 .RESET_DESC('iseq_i_sc_s')
976 .RESET_DESC('iseq_i_s_sc')
988 .RESET_DESC('iseq_i_sc_sc')
990 iseq $I1, "Bbb", "Ccc"
992 iseq $I1, "Bbb", "Bbb"
994 iseq $I1, "Bbb", "Aaa"
1001 .local string exp, res
1005 .SET_DESC('isne_i_i_i')
1020 .RESET_DESC('isne_i_ic_i')
1032 .RESET_DESC('isne_i_i_ic')
1044 .RESET_DESC('isne_i_ic_ic')
1055 .RESET_DESC('isne_i_n_n')
1070 .RESET_DESC('isne_i_nc_n')
1082 .RESET_DESC('isne_i_n_nc')
1094 .RESET_DESC('isne_i_nc_nc')
1096 isne $I1, 2.22, 2.23
1098 isne $I1, 2.22, 2.22
1100 isne $I1, 2.22, 2.21
1105 .RESET_DESC('isne_i_s_s')
1120 .RESET_DESC('isne_i_sc_s')
1123 isne $I1, "Aaa", $S3
1125 isne $I1, "Bbb", $S3
1127 isne $I1, "Ccc", $S3
1132 .RESET_DESC('isne_i_s_sc')
1135 isne $I1, $S2, "Ccc"
1137 isne $I1, $S2, "Bbb"
1139 isne $I1, $S2, "Aaa"
1144 .RESET_DESC('isne_i_sc_sc')
1146 isne $I1, "Bbb", "Ccc"
1148 isne $I1, "Bbb", "Bbb"
1150 isne $I1, "Bbb", "Aaa"
1157 .local string exp, res
1166 cmp $I3, $S0, "Crumbum"
1218 .sub 'cmp_string_null'
1219 .local string s1, s2
1225 is(r, -1, 'cmp snull, snotnull')
1228 is(r, 1, 'cmp snotnull, snull')
1232 is(r, 0, 'cmp snull, snull')
1241 $I0 = issame $P0, $P1
1242 is($I0, 0, 'issame String,Null')
1244 $P1 = split ' ', 'parrot speaks your language'
1245 $I0 = issame $P0, $P1
1246 is($I0, 0, 'issame String,ResizableStringArray')
1254 # vim: expandtab shiftwidth=4 ft=pir: