Ticket #1122: number.t.patch
File number.t.patch, 40.6 KB (added by mgrimes, 12 years ago) |
---|
-
t/op/number.t
1 #!p erl2 # Copyright (C) 2001-200 8, Parrot Foundation.1 #!parrot 2 # Copyright (C) 2001-2009, Parrot Foundation. 3 3 # $Id$ 4 4 5 use strict;6 use warnings;7 use lib qw( . lib ../lib ../../lib );8 use Test::More;9 use Parrot::Test tests => 56;10 use Parrot::Config;11 12 5 =head1 NAME 13 6 14 7 t/op/number.t - Number Registers … … 23 16 24 17 =cut 25 18 26 my $output; 19 .sub main :main 20 .include 'test_more.pir' 27 21 28 pasm_output_is( <<CODE, <<OUTPUT, "set_n_nc" ); 29 set N0, 1.0 30 set N1, 4.0 31 set N2, 16.0 32 set N3, 64.0 33 set N4, 256.0 34 set N5, 1024.0 35 set N6, 4096.0 36 set N7, 16384.0 37 set N8, 65536.0 38 set N9, 262144.0 39 set N10, 1048576.0 40 set N11, 4194304.0 41 set N12, 16777216.0 42 set N13, 67108864.0 43 set N14, 268435456.0 44 set N15, 1073741824.0 45 set N16, 4294967296.0 46 set N17, 17179869184.0 47 set N18, 68719476736.0 48 set N19, 274877906944.0 49 set N20, 1099511627776.0 50 set N21, 4398046511104.0 51 set N22, 17592186044416.0 52 set N23, 70368744177664.0 53 set N24, 281474976710656.0 54 set N25, 1.12589990684262e+15 22 plan(173) 23 test_set_n_nc() 24 test_set_n() 25 test_add_n_n_n() 26 test_add_n_n() 27 test_sub_n_n_n() 28 test_sub_n_n() 29 test_abs_n_i_ic_n_nc() 30 test_mul_i() 31 test_div_i() 32 test_mod_n() 33 test_cmod_n() 34 test_eq_n_ic() 35 test_eq_nc_ic() 36 test_ne_n_ic() 37 test_ne_n_nc_ic() 38 test_lt_n_ic() 39 test_lt_nc_ic() 40 test_le_n_ic() 41 test_le_nc_ic() 42 test_gt_n_ic() 43 test_gt_nc_ic() 44 test_ge_n_ic() 45 test_ge_nc_ic() 46 test_if_n_ic() 47 test_inc_n() 48 test_dec_n() 49 test_set_i_n() 50 test_clearn() 51 test_neg_n() 52 test_neg_0_dot_0() 53 test_mul_n_n() 54 test_fact_n_i() 55 test_fact_n_ic() 56 test_exchange() 57 test_op_n_nc_nc() 58 test_lt_nc_nc_ic() 59 test_string_gt_num() 60 test_null() 61 test_dot_dig_parsing() 62 test_sqrt_n_n() 63 test_exception_div_n_n_by_zero() 64 test_exception_div_n_nc_by_zero() 65 test_exception_div_n_n_n_by_zero() 66 test_exception_div_n_nc_n_by_zero() 67 test_exception_div_n_n_nc_by_zero() 68 test_exception_fdiv_n_n_by_zero() 69 test_exception_fdiv_n_nc_by_zero() 70 test_exception_fdiv_n_n_n_by_zero() 71 test_exception_fdiv_n_nc_n_by_zero() 72 test_exception_fdiv_n_n_nc_by_zero() 73 test_exception_cmod_n_n_n_by_zero() 74 test_exception_cmod_n_nc_n_by_zero() 75 test_exception_cmod_n_n_nc_by_zero() 76 test_mod_n_n_n_by_zero() 77 test_mod_n_nc_n_by_zero() 78 test_mod_n_n_nc_by_zero() 79 # END_OF_TESTS 80 .end 55 81 56 print N0 57 print "\\n" 58 print N1 59 print "\\n" 60 print N2 61 print "\\n" 62 print N3 63 print "\\n" 64 print N4 65 print "\\n" 66 print N5 67 print "\\n" 68 print N6 69 print "\\n" 70 print N7 71 print "\\n" 72 print N8 73 print "\\n" 74 print N9 75 print "\\n" 76 print N10 77 print "\\n" 78 print N11 79 print "\\n" 80 print N12 81 print "\\n" 82 print N13 83 print "\\n" 84 print N14 85 print "\\n" 86 print N15 87 print "\\n" 88 print N16 89 print "\\n" 90 print N17 91 print "\\n" 92 print N18 93 print "\\n" 94 print N19 95 print "\\n" 96 print N20 97 print "\\n" 98 print N21 99 print "\\n" 100 print N22 101 print "\\n" 102 print N23 103 print "\\n" 104 print N24 105 print "\\n" 106 print N25 107 print "\\n" 108 end 109 CODE 110 1 111 4 112 16 113 64 114 256 115 1024 116 4096 117 16384 118 65536 119 262144 120 1048576 121 4194304 122 16777216 123 67108864 124 268435456 125 1073741824 126 4294967296 127 17179869184 128 68719476736 129 274877906944 130 1099511627776 131 4398046511104 132 17592186044416 133 70368744177664 134 281474976710656 135 1.12589990684262e+15 136 OUTPUT 82 .macro exception_is ( M ) 83 .local pmc exception 84 .local string message 85 .get_results (exception) 137 86 138 pasm_output_is( <<CODE, <<OUTPUT, "set_n" ); 139 set N0, 42.0 140 set N1, N0 141 print N1 142 print "\\n" 143 end 144 CODE 145 42 146 OUTPUT 87 message = exception['message'] 88 is( message, .M, .M ) 89 .endm 147 90 148 pasm_output_is( <<CODE, <<OUTPUT, "add_n_n_n" ); 149 set N0, 1.0 150 add N1, N0, N0 151 print N1 152 print "\\n" 91 .sub test_set_n_nc 92 set $N0, 1.0 93 set $N1, 4.0 94 set $N2, 16.0 95 set $N3, 64.0 96 set $N4, 256.0 97 set $N5, 1024.0 98 set $N6, 4096.0 99 set $N7, 16384.0 100 set $N8, 65536.0 101 set $N9, 262144.0 102 set $N10, 1048576.0 103 set $N11, 4194304.0 104 set $N12, 16777216.0 105 set $N13, 67108864.0 106 set $N14, 268435456.0 107 set $N15, 1073741824.0 108 set $N16, 4294967296.0 109 set $N17, 17179869184.0 110 set $N18, 68719476736.0 111 set $N19, 274877906944.0 112 set $N20, 1099511627776.0 113 set $N21, 4398046511104.0 114 set $N22, 17592186044416.0 115 set $N23, 70368744177664.0 116 set $N24, 281474976710656.0 117 set $N25, 1.12589990684262e+15 118 is( $N0, "1", 'set_n_nc' ) 119 is( $N1, "4", 'set_n_nc' ) 120 is( $N2, "16", 'set_n_nc' ) 121 is( $N3, "64", 'set_n_nc' ) 122 is( $N4, "256", 'set_n_nc' ) 123 is( $N5, "1024", 'set_n_nc' ) 124 is( $N6, "4096", 'set_n_nc' ) 125 is( $N7, "16384", 'set_n_nc' ) 126 is( $N8, "65536", 'set_n_nc' ) 127 is( $N9, "262144", 'set_n_nc' ) 128 is( $N10, "1048576", 'set_n_nc' ) 129 is( $N11, "4194304", 'set_n_nc' ) 130 is( $N12, "16777216", 'set_n_nc' ) 131 is( $N13, "67108864", 'set_n_nc' ) 132 is( $N14, "268435456", 'set_n_nc' ) 133 is( $N15, "1073741824", 'set_n_nc' ) 134 is( $N16, "4294967296", 'set_n_nc' ) 135 is( $N17, "17179869184", 'set_n_nc' ) 136 is( $N18, "68719476736", 'set_n_nc' ) 137 is( $N19, "274877906944", 'set_n_nc' ) 138 is( $N20, "1099511627776", 'set_n_nc' ) 139 is( $N21, "4398046511104", 'set_n_nc' ) 140 is( $N22, "17592186044416", 'set_n_nc' ) 141 is( $N23, "70368744177664", 'set_n_nc' ) 142 is( $N24, "281474976710656", 'set_n_nc' ) 143 is( $N25, "1.12589990684262e+15", 'set_n_nc' ) 144 .end 153 145 154 add N2, N0, N1 155 print N2 156 print "\\n" 146 .sub test_set_n 147 set $N0, 42.0 148 set $N1, $N0 149 is( $N1, "42", 'set_n' ) 150 .end 157 151 158 add N2, N2, N2 159 print N2160 print "\\n"161 end162 CODE 163 2 164 3 165 6 166 OUTPUT 152 .sub test_add_n_n_n 153 set $N0, 1.0 154 add $N1, $N0, $N0 155 is( $N1, "2", 'add_n_n_n' ) 156 add $N2, $N0, $N1 157 is( $N2, "3", 'add_n_n_n' ) 158 add $N2, $N2, $N2 159 is( $N2, "6", 'add_n_n_n' ) 160 .end 167 161 168 pasm_output_is( <<CODE, <<OUTPUT, "add_n_n" ); 169 set N0, 1.0 170 add N0, N0 171 print N0 172 print "\\n" 162 .sub test_add_n_n 163 set $N0, 1.0 164 add $N0, $N0 165 is( $N0, "2", 'add_n_n' ) 166 set $N1, 1.0 167 add $N0, $N1 168 is( $N0, "3", 'add_n_n' ) 169 add $N0, 3.0 170 is( $N0, "6", 'add_n_n' ) 171 .end 173 172 174 set N1, 1.0 175 add N0, N1 176 print N0 177 print "\\n" 173 .sub test_sub_n_n_n 174 set $N0, 424242.0 175 set $N1, 4200.0 176 sub $N2, $N0, $N1 177 is( $N2, "420042", 'sub_n_n_n' ) 178 .end 178 179 179 add N0, 3.0 180 print N0 181 print "\\n" 182 end 183 CODE 184 2 185 3 186 6 187 OUTPUT 180 .sub test_sub_n_n 181 set $N0, 424242.0 182 set $N1, 4200.0 183 sub $N0, $N1 184 is( $N0, "420042", 'sub_n_n' ) 185 sub $N0, $N0 186 is( $N0, "0", 'sub_n_n' ) 187 .end 188 188 189 pasm_output_is( <<CODE, <<OUTPUT, "sub_n_n_n" ); 190 set N0, 424242.0 191 set N1, 4200.0 192 sub N2, N0, N1 193 print N2 194 print "\\n" 195 end 196 CODE 197 420042 198 OUTPUT 189 .sub test_abs_n_i_ic_n_nc 190 set $I0, -1 191 abs $N0, $I0 192 abs $N1, -1 193 set $I1, 1 194 abs $N2, $I1 195 abs $N3, 1 196 set $N4, -1 197 abs $N4, $N4 198 abs $N5, -1.0 199 set $N6, 1.0 200 abs $N6, $N6 201 abs $N7, 1.0 202 is( $N0, "1", 'abs(n, i|ic|n|nc)' ) 203 is( $N1, "1", 'abs(n, i|ic|n|nc)' ) 204 is( $N2, "1", 'abs(n, i|ic|n|nc)' ) 205 is( $N3, "1", 'abs(n, i|ic|n|nc)' ) 206 is( $N4, "1", 'abs(n, i|ic|n|nc)' ) 207 is( $N5, "1", 'abs(n, i|ic|n|nc)' ) 208 is( $N6, "1", 'abs(n, i|ic|n|nc)' ) 209 is( $N7, "1", 'abs(n, i|ic|n|nc)' ) 210 .end 199 211 200 pasm_output_is( <<CODE, <<OUTPUT, "sub_n_n" ); 201 set N0, 424242.0 202 set N1, 4200.0 203 sub N0, N1 204 print N0 205 print "\\n" 212 .sub test_mul_i 213 set $N0, 2.0 214 mul $N1, $N0, $N0 215 mul $N1, $N1, $N0 216 mul $N1, $N1, $N0 217 mul $N1, $N1, $N0 218 mul $N1, $N1, $N0 219 mul $N1, $N1, $N0 220 mul $N1, $N1, $N0 221 is( $N1, "256", 'mul_i' ) 222 .end 206 223 207 sub N0, N0 208 print N0 209 print "\\n" 210 end 211 CODE 212 420042 213 0 214 OUTPUT 224 .sub test_div_i 225 set $N0, 10.0 226 set $N1, 2.0 227 div $N2, $N0, $N1 228 is( $N2, "5", 'div_i' ) 229 set $N3, 7.0 230 set $N4, 2.0 231 div $N3, $N3, $N4 232 is( $N3, "3.5", 'div_i' ) 233 set $N5, 9.0 234 set $N6, -4.0 235 div $N7, $N5, $N6 236 is( $N7, "-2.25", 'div_i' ) 237 .end 215 238 216 pasm_output_is( <<'CODE', <<'OUTPUT', "abs(n, i|ic|n|nc)" ); 217 set I0, -1 218 abs N0, I0 219 abs N1, -1 220 set I1, 1 221 abs N2, I1 222 abs N3, 1 223 set N4, -1 224 abs N4, N4 225 abs N5, -1.0 226 set N6, 1.0 227 abs N6, N6 228 abs N7, 1.0 239 .sub test_mod_n 240 set $N0, 5.0 241 set $N1, 0.0 242 mod $N2, $N0, $N1 243 is( $N2, "5", 'mod_n' ) 244 set $N0, 0.0 245 set $N1, 3.0 246 mod $N2, $N0, $N1 247 is( $N2, "0", 'mod_n' ) 248 set $N0, 5.0 249 set $N1, 3.0 250 mod $N2, $N0, $N1 251 is( $N2, "2", 'mod_n' ) 252 set $N0, 5.0 253 set $N1, -3.0 254 mod $N2, $N0, $N1 255 is( $N2, "-1", 'mod_n' ) 256 set $N0, -5.0 257 set $N1, 3.0 258 mod $N2, $N0, $N1 259 is( $N2, "1", 'mod_n' ) 260 set $N0, -5.0 261 set $N1, -3.0 262 mod $N2, $N0, $N1 263 is( $N2, "-2", 'mod_n' ) 264 .end 229 265 230 print N0 231 print "\n" 232 print N1 233 print "\n" 234 print N2 235 print "\n" 236 print N3 237 print "\n" 238 print N4 239 print "\n" 240 print N5 241 print "\n" 242 print N6 243 print "\n" 244 print N7 245 print "\n" 246 end 247 CODE 248 1 249 1 250 1 251 1 252 1 253 1 254 1 255 1 256 OUTPUT 266 .sub test_cmod_n 267 set $N0, 5.000 268 set $N1, 3.000 269 cmod $N2, $N0, $N1 270 is( $N2, "2", 'cmod_n' ) 271 .end 257 272 258 pasm_output_is( <<CODE, <<OUTPUT, "mul_i" ); 259 set N0, 2.0 260 mul N1, N0, N0 261 mul N1, N1, N0 262 mul N1, N1, N0 263 mul N1, N1, N0 264 mul N1, N1, N0 265 mul N1, N1, N0 266 mul N1, N1, N0 267 print N1 268 print "\\n" 269 end 270 CODE 271 256 272 OUTPUT 273 .sub test_eq_n_ic 274 set $N0, 5.000001 275 set $N1, 5.000001 276 set $N2, 5.000002 277 eq $N0, $N1, ONE 278 branch ERROR 279 ok( 0, 'test eq_n_ic bad' ) 280 ONE: 281 ok( 1, 'eq_n_ic ok 1') 282 eq $N1, $N2, ERROR 283 branch TWO 284 ok( 0, 'eq_n_ic bad 1' ) 285 TWO: 286 ok( 1, 'eq_n_ic ok 2') 287 goto END 288 ERROR: 289 ok( 0, 'eq_n_ic bad 2' ) 290 END: 291 .end 273 292 274 pasm_output_is( <<CODE, <<OUTPUT, "div_i" ); 275 set N0, 10.0 276 set N1, 2.0 277 div N2, N0, N1 278 print N2 279 print "\\n" 293 .sub test_eq_nc_ic 294 set $N0, 1.000001 295 eq $N0, 1, ERROR 296 branch ONE 297 ok( 0, 'eq_nc_ic') 298 ONE: 299 ok( 1, 'eq_nc_ic ok 1') 300 eq $N0, 1.000001, TWO 301 branch ERROR 302 ok( 0, 'eq_nc_ic') 303 TWO: 304 ok( 1, 'eq_nc_ic ok 2') 305 goto END 306 ERROR: 307 ok( 0, 'eq_nc_ic') 308 END: 309 .end 280 310 281 set N3, 7.0 282 set N4, 2.0 283 div N3, N3, N4 284 print N3 285 print "\\n" 311 .sub test_ne_n_ic 312 set $N0, -22.222222 313 set $N1, -22.222222 314 set $N2, 0.0 315 ne $N0, $N2, ONE 316 branch ERROR 317 ok( 0, 'ne_n_ic') 318 ONE: 319 ok( 1, 'ne_n_ic ok 1') 320 ne $N0, $N1, ERROR 321 branch TWO 322 ok( 0, 'ne_n_ic') 323 TWO: 324 ok( 1, 'ne_n_ic ok 2') 325 goto END 326 ERROR: 327 ok( 0, 'ne_n_ic') 328 END: 329 .end 286 330 287 set N5, 9.0 288 set N6, -4.0 289 div N7, N5, N6 290 print N7 291 print "\\n" 292 end 293 CODE 294 5 295 3.5 296 -2.25 297 OUTPUT 331 .sub test_ne_n_nc_ic 332 set $N0, 1073741824.0 333 ne $N0, 1073741824.0, nok1 334 ok( 1, 'ne_n_nc_ic ok 1') 335 branch ONE 336 nok1: 337 ok( 0, 'ne_n_nc_ic') 338 ONE: 339 ne $N0, 0.0, TWO 340 branch ERROR 341 TWO: 342 ok( 1, 'ne_n_nc_ic ok 2') 343 goto END 344 ERROR: 345 ok( 0, 'ne_n_nc_ic') 346 END: 347 .end 298 348 299 pasm_output_like( <<CODE, <<OUTPUT, "mod_n" ); 300 set N0, 5.0 301 set N1, 0.0 302 mod N2, N0, N1 303 print N2 304 print "\\n" 349 .sub test_lt_n_ic 350 set $N0, 1000.0 351 set $N1, 500.0 352 set $N2, 0.0 353 set $N3, 0.0 354 lt $N1, $N0, ONE 355 branch ERROR 356 ok( 0, 'lt_n_ic') 357 ONE: 358 ok( 1, 'lt_n_ic ok 1') 359 lt $N0, $N1, ERROR 360 branch TWO 361 ok( 0, 'lt_n_ic') 362 TWO: 363 ok( 1, 'lt_n_ic ok 2') 364 lt $N2, $N3, ERROR 365 branch THREE 366 ok( 0, 'lt_n_ic') 367 THREE: 368 ok( 1, 'lt_n_ic ok 3') 369 goto END 370 ERROR: 371 ok( 0, 'lt_n_ic') 372 END: 373 .end 305 374 306 set N0, 0.0 307 set N1, 3.0 308 mod N2, N0, N1 309 print N2 310 print "\\n" 375 .sub test_lt_nc_ic 376 set $N0, 1000.0 377 set $N1, 500.0 378 set $N2, 0.0 379 lt $N0, 500.0, ERROR 380 branch ONE 381 ok( 0, 'lt_nc_ic') 382 ONE: 383 ok( 1, 'lt_nc_ic ok 1') 384 lt $N1, 1000.0, TWO 385 branch ERROR 386 ok( 0, 'lt_nc_ic') 387 TWO: 388 ok( 1, 'lt_nc_ic ok 2') 389 lt $N0, 0.0, ERROR 390 branch THREE 391 ok( 0, 'lt_nc_ic') 392 THREE: 393 ok( 1, 'lt_nc_ic ok 3') 394 goto END 395 ERROR: 396 ok( 0, 'lt_nc_ic') 397 END: 398 .end 311 399 312 set N0, 5.0 313 set N1, 3.0 314 mod N2, N0, N1 315 print N2 316 print "\\n" 400 .sub test_le_n_ic 401 set $N0, 1000.0 402 set $N1, 500.0 403 set $N2, 0.0 404 set $N3, 0.0 405 le $N1, $N0, ONE 406 branch ERROR 407 ok( 0, 'le_n_ic') 408 ONE: 409 ok( 1, 'le_n_ic ok 1') 410 le $N0, $N1, ERROR 411 branch TWO 412 ok( 0, 'le_n_ic') 413 TWO: 414 ok( 1, 'le_n_ic ok 2') 415 le $N2, $N3, THREE 416 branch ERROR 417 ok( 0, 'le_n_ic') 418 THREE: 419 ok( 1, 'le_n_ic ok 3') 420 goto END 421 ERROR: 422 ok( 0, 'le_n_ic') 423 END: 424 .end 317 425 318 set N0, 5.0 319 set N1, -3.0 320 mod N2, N0, N1 321 print N2 322 print "\\n" 426 .sub test_le_nc_ic 427 set $N0, 1000.0 428 set $N1, 500.0 429 set $N2, 0.0 430 le $N0, 500.0, ERROR 431 branch ONE 432 ok( 0, 'le_nc_ic') 433 ONE: 434 ok( 1, 'le_nc_ic ok 1') 435 le $N1, 1000.0, TWO 436 branch ERROR 437 ok( 0, 'le_nc_ic') 438 TWO: 439 ok( 1, 'le_nc_ic ok 2') 440 le $N2, 0.0, THREE 441 branch ERROR 442 ok( 0, 'le_nc_ic') 443 THREE: 444 ok( 1, 'le_nc_ic ok 3') 445 goto END 446 ERROR: 447 ok( 0, 'le_nc_ic') 448 END: 449 .end 323 450 324 set N0, -5.0 325 set N1, 3.0 326 mod N2, N0, N1 327 print N2 328 print "\\n" 451 .sub test_gt_n_ic 452 set $N0, 500.0 453 set $N1, 1000.0 454 set $N2, 0.0 455 set $N3, 0.0 456 gt $N1, $N0, ONE 457 branch ERROR 458 ok( 0, 'gt_n_ic') 459 ONE: 460 ok( 1, 'gt_n_ic ok 1') 461 gt $N0, $N1, ERROR 462 branch TWO 463 ok( 0, 'gt_n_ic') 464 TWO: 465 ok( 1, 'gt_n_ic ok 2') 466 gt $N2, $N3, ERROR 467 branch THREE 468 ok( 0, 'gt_n_ic') 469 THREE: 470 ok( 1, 'gt_n_ic ok 3') 471 goto END 472 ERROR: 473 ok( 0, 'gt_n_ic') 474 END: 475 .end 329 476 330 set N0, -5.0 331 set N1, -3.0 332 mod N2, N0, N1 333 print N2 334 print "\\n" 477 .sub test_gt_nc_ic 478 set $N0, 500.0 479 set $N1, 1000.0 480 set $N2, 0.0 481 gt $N0, 1000.0, ERROR 482 branch ONE 483 ok( 0, 'gt_nc_ic') 484 ONE: 485 ok( 1, 'gt_nc_ic ok 1') 486 gt $N1, 500.0, TWO 487 branch ERROR 488 ok( 0, 'gt_nc_ic') 489 TWO: 490 ok( 1, 'gt_nc_ic ok 2') 491 gt $N2, 0.0, ERROR 492 branch THREE 493 ok( 0, 'gt_nc_ic') 494 THREE: 495 ok( 1, 'gt_nc_ic ok 3') 496 goto END 497 ERROR: 498 ok( 0, 'gt_nc_ic') 499 END: 500 .end 335 501 336 end 337 CODE 338 /5\ 339 -?0\ 340 2\ 341 -1\ 342 1\ 343 -2\ 344 / 345 OUTPUT 502 .sub test_ge_n_ic 503 set $N0, 500.0 504 set $N1, 1000.0 505 set $N2, 0.0 506 set $N3, 0.0 507 ge $N1, $N0, ONE 508 branch ERROR 509 ok( 0, 'ge_n_ic') 510 ONE: 511 ok( 1, 'ge_n_ic ok 1') 512 ge $N0, $N1, ERROR 513 branch TWO 514 ok( 0, 'ge_n_ic') 515 TWO: 516 ok( 1, 'ge_n_ic ok 2') 517 ge $N2, $N3, THREE 518 branch ERROR 519 ok( 0, 'ge_n_ic') 520 THREE: 521 ok( 1, 'ge_n_ic ok 3') 522 goto END 523 ERROR: 524 ok( 0, 'ge_n_ic') 525 END: 526 .end 346 527 347 pasm_output_is( <<CODE, <<OUTPUT, "cmod_n" ); 348 set N0, 5.000 349 set N1, 3.000 350 cmod N2, N0, N1 351 print N2 352 print "\\n" 528 .sub test_ge_nc_ic 529 set $N0, 500.0 530 set $N1, 1000.0 531 set $N2, 0.0 532 ge $N0, 1000.0, ERROR 533 branch ONE 534 ok( 0, 'ge_nc_ic') 535 ONE: 536 ok( 1, 'ge_nc_ic ok 1') 537 ge $N1, 500.0, TWO 538 branch ERROR 539 ok( 0, 'ge_nc_ic') 540 TWO: 541 ok( 1, 'ge_nc_ic ok 2') 542 ge $N2, 0.0, THREE 543 branch ERROR 544 ok( 0, 'ge_nc_ic') 545 THREE: 546 ok( 1, 'ge_nc_ic ok 3') 547 goto END 548 ERROR: 549 ok( 0, 'ge_nc_ic') 550 END: 551 .end 353 552 354 end 355 CODE 356 2 357 OUTPUT 553 .sub test_if_n_ic 554 set $N0, 1000.0 555 set $N1, 500.0 556 set $N2, 0.0 557 if $N0, ONE 558 branch ERROR 559 ok( 0, 'if_n_ic') 560 ONE: 561 ok( 1, 'if_n_ic ok 1') 562 if $N1, TWO 563 branch ERROR 564 ok( 0, 'if_n_ic') 565 TWO: 566 ok( 1, 'if_n_ic ok 2') 567 if $N2, ERROR 568 branch THREE 569 ok( 0, 'if_n_ic') 570 THREE: 571 ok( 1, 'if_n_ic ok 3') 572 goto END 573 ERROR: 574 ok( 0, 'if_n_ic') 575 END: 576 .end 358 577 359 pasm_output_is( <<CODE, <<OUTPUT, "eq_n_ic" ); 360 set N0, 5.000001 361 set N1, 5.000001 362 set N2, 5.000002 578 .sub test_inc_n 579 set $N0, 0.0 580 inc $N0 581 is( $N0, "1", 'inc_n' ) 582 inc $N0 583 inc $N0 584 inc $N0 585 inc $N0 586 is( $N0, "5", 'inc_n' ) 587 .end 363 588 364 eq N0, N1, ONE 365 branch ERROR 366 print "bad\\n" 589 .sub test_dec_n 590 set $N0, 0.0 591 dec $N0 592 is( $N0, "-1", 'dec_n' ) 593 dec $N0 594 dec $N0 595 dec $N0 596 dec $N0 597 is( $N0, "-5", 'dec_n' ) 598 .end 367 599 368 ONE: 369 print "ok 1\\n" 370 eq N1, N2, ERROR 371 branch TWO 372 print "bad\\n" 600 .sub test_set_i_n 601 set $N0, 0.0 602 set $I0, $N0 603 is( $I0, "0", 'set_i_n' ) 604 set $N1, 2147483647.0 605 set $I1, $N1 606 is( $I1, "2147483647", 'set_i_n' ) 607 set $N2, -2147483648.0 608 set $I2, $N2 609 is( $I2, "-2147483648", 'set_i_n' ) 610 .end 373 611 374 TWO: 375 print "ok 2\\n" 376 end 612 .sub test_clearn 613 set $N0, 547972.0 614 set $N1, 547972.0 615 set $N2, 547972.0 616 set $N3, 547972.0 617 set $N4, 547972.0 618 set $N5, 547972.0 619 set $N6, 547972.0 620 set $N7, 547972.0 621 set $N8, 547972.0 622 set $N9, 547972.0 623 set $N10, 547972.0 624 set $N11, 547972.0 625 set $N12, 547972.0 626 set $N13, 547972.0 627 set $N14, 547972.0 628 set $N15, 547972.0 629 set $N16, 547972.0 630 set $N17, 547972.0 631 set $N18, 547972.0 632 set $N19, 547972.0 633 set $N20, 547972.0 634 set $N21, 547972.0 635 set $N22, 547972.0 636 set $N23, 547972.0 637 set $N24, 547972.0 638 set $N25, 547972.0 639 set $N26, 547972.0 640 set $N27, 547972.0 641 set $N28, 547972.0 642 set $N29, 547972.0 643 set $N30, 547972.0 644 set $N31, 547972.0 645 clearn 646 is( $N0, "0", 'clearn' ) 647 is( $N1, "0", 'clearn' ) 648 is( $N2, "0", 'clearn' ) 649 is( $N3, "0", 'clearn' ) 650 is( $N4, "0", 'clearn' ) 651 is( $N5, "0", 'clearn' ) 652 is( $N6, "0", 'clearn' ) 653 is( $N7, "0", 'clearn' ) 654 is( $N8, "0", 'clearn' ) 655 is( $N9, "0", 'clearn' ) 656 is( $N10, "0", 'clearn' ) 657 is( $N11, "0", 'clearn' ) 658 is( $N12, "0", 'clearn' ) 659 is( $N13, "0", 'clearn' ) 660 is( $N14, "0", 'clearn' ) 661 is( $N15, "0", 'clearn' ) 662 is( $N16, "0", 'clearn' ) 663 is( $N17, "0", 'clearn' ) 664 is( $N18, "0", 'clearn' ) 665 is( $N19, "0", 'clearn' ) 666 is( $N20, "0", 'clearn' ) 667 is( $N21, "0", 'clearn' ) 668 is( $N22, "0", 'clearn' ) 669 is( $N23, "0", 'clearn' ) 670 is( $N24, "0", 'clearn' ) 671 is( $N25, "0", 'clearn' ) 672 is( $N26, "0", 'clearn' ) 673 is( $N27, "0", 'clearn' ) 674 is( $N28, "0", 'clearn' ) 675 is( $N29, "0", 'clearn' ) 676 is( $N30, "0", 'clearn' ) 677 is( $N31, "0", 'clearn' ) 678 .end 377 679 378 ERROR: 379 print "bad\\n" 380 end 381 CODE 382 ok 1 383 ok 2 384 OUTPUT 680 .sub test_neg_n 681 neg $N0,3.0 682 neg $N0,$N0 683 neg $N0 684 is( $N0, "-3", 'neg_n' ) 685 .end 385 686 386 pasm_output_is( <<CODE, <<OUTPUT, "eq_nc_ic" ); 387 set N0, 1.000001 687 .sub test_neg_0_dot_0 688 set $N1, 0 689 neg $N1 690 is( $N1, "-0", 'neg 0.0' ) 691 .end 388 692 389 eq N0, 1, ERROR 390 branch ONE 391 print "bad\\n" 693 .sub test_mul_n_n 694 set $N0,3.0 695 set $N1,4.0 696 mul $N0,$N1 697 is( $N0, "12", 'mul_n_n' ) 698 .end 392 699 393 ONE: 394 print "ok 1\\n" 395 eq N0, 1.000001, TWO 396 branch ERROR 397 print "bad\\n" 700 .sub test_fact_n_i 701 set $I0, 3 702 set $I1, 11 703 set $I2, 0 704 set $I3, -563 705 fact $N5, $I0 706 is( $N5, "6", 'fact_n_i' ) 707 fact $N6, $I1 708 is( $N6, "39916800", 'fact_n_i' ) 709 fact $N7, $I2 710 is( $N7, "1", 'fact_n_i' ) 711 fact $N8, $I3 712 is( $N8, "1", 'fact_n_i' ) 713 .end 398 714 399 TWO: 400 print "ok 2\\n" 401 end 715 .sub test_fact_n_ic 716 fact $N5, 3 717 is( $N5, "6", 'fact_n_ic' ) 718 fact $N6, 11 719 is( $N6, "39916800", 'fact_n_ic' ) 720 fact $N7, 0 721 is( $N7, "1", 'fact_n_ic' ) 722 fact $N8, -563 723 is( $N8, "1", 'fact_n_ic' ) 724 .end 402 725 403 ERROR: 404 print "bad\\n" 405 end 406 CODE 407 ok 1 408 ok 2 409 OUTPUT 726 .sub test_exchange 727 set $N1, 1.234560 728 set $N2, 9.876540 729 exchange $N1, $N2 730 is( $N1, "9.87654", 'exchange' ) 731 is( $N2, "1.23456", 'exchange' ) 732 set $N3, -100.200300 733 exchange $N3, $N3 734 is( $N3, "-100.2003", 'exchange' ) 735 .end 410 736 411 pasm_output_is( <<CODE, <<OUTPUT, "ne_n_ic" ); 412 set N0, -22.222222 413 set N1, -22.222222 414 set N2, 0.0 737 .sub test_op_n_nc_nc 738 add $N1, 2.0, 3.0 739 is( $N1, "5", 'op_n_nc_nc' ) 740 sub $N1, 2.0, 4.0 741 is( $N1, "-2", 'op_n_nc_nc' ) 742 .end 415 743 416 ne N0, N2, ONE 417 branch ERROR 418 print "bad\\n" 419 420 ONE: 421 print "ok 1\\n" 422 ne N0, N1, ERROR 423 branch TWO 424 print "bad\\n" 425 426 TWO: 427 print "ok 2\\n" 428 end 429 430 ERROR: 431 print "bad\\n" 432 end 433 CODE 434 ok 1 435 ok 2 436 OUTPUT 437 438 pasm_output_is( <<CODE, <<OUTPUT, "ne_n_nc_ic" ); 439 set N0, 1073741824.0 440 ne N0, 1073741824.0, nok1 441 print "ok 1\\n" 442 branch ONE 443 nok1: 444 print "bad 1\\n" 445 ONE: 446 ne N0, 0.0, TWO 447 branch ERROR 448 TWO: 449 print "ok 2\\n" 450 end 451 ERROR: 452 print "bad 2\\n" 453 end 454 CODE 455 ok 1 456 ok 2 457 OUTPUT 458 459 pasm_output_is( <<CODE, <<OUTPUT, "lt_n_ic" ); 460 set N0, 1000.0 461 set N1, 500.0 462 set N2, 0.0 463 set N3, 0.0 464 465 lt N1, N0, ONE 466 branch ERROR 467 print "bad\\n" 468 469 ONE: 470 print "ok 1\\n" 471 lt N0, N1, ERROR 472 branch TWO 473 print "bad\\n" 474 475 TWO: 476 print "ok 2\\n" 477 lt N2, N3, ERROR 478 branch THREE 479 print "bad\\n" 480 481 THREE: 482 print "ok 3\\n" 483 end 484 485 ERROR: 486 print "bad\\n" 487 end 488 CODE 489 ok 1 490 ok 2 491 ok 3 492 OUTPUT 493 494 pasm_output_is( <<CODE, <<OUTPUT, "lt_nc_ic" ); 495 set N0, 1000.0 496 set N1, 500.0 497 set N2, 0.0 498 499 lt N0, 500.0, ERROR 500 branch ONE 501 print "bad\\n" 502 503 ONE: 504 print "ok 1\\n" 505 lt N1, 1000.0, TWO 506 branch ERROR 507 print "bad\\n" 508 509 TWO: 510 print "ok 2\\n" 511 lt N0, 0.0, ERROR 512 branch THREE 513 print "bad\\n" 514 515 THREE: 516 print "ok 3\\n" 517 end 518 519 ERROR: 520 print "bad\\n" 521 end 522 CODE 523 ok 1 524 ok 2 525 ok 3 526 OUTPUT 527 528 pasm_output_is( <<CODE, <<OUTPUT, "le_n_ic" ); 529 set N0, 1000.0 530 set N1, 500.0 531 set N2, 0.0 532 set N3, 0.0 533 534 le N1, N0, ONE 535 branch ERROR 536 print "bad\\n" 537 538 ONE: 539 print "ok 1\\n" 540 le N0, N1, ERROR 541 branch TWO 542 print "bad\\n" 543 544 TWO: 545 print "ok 2\\n" 546 le N2, N3, THREE 547 branch ERROR 548 print "bad\\n" 549 550 THREE: 551 print "ok 3\\n" 552 end 553 554 ERROR: 555 print "bad\\n" 556 end 557 CODE 558 ok 1 559 ok 2 560 ok 3 561 OUTPUT 562 563 pasm_output_is( <<CODE, <<OUTPUT, "le_nc_ic" ); 564 set N0, 1000.0 565 set N1, 500.0 566 set N2, 0.0 567 568 le N0, 500.0, ERROR 569 branch ONE 570 print "bad\\n" 571 572 ONE: 573 print "ok 1\\n" 574 le N1, 1000.0, TWO 575 branch ERROR 576 print "bad\\n" 577 578 TWO: 579 print "ok 2\\n" 580 le N2, 0.0, THREE 581 branch ERROR 582 print "bad\\n" 583 584 THREE: 585 print "ok 3\\n" 586 end 587 588 ERROR: 589 print "bad\\n" 590 end 591 CODE 592 ok 1 593 ok 2 594 ok 3 595 OUTPUT 596 597 pasm_output_is( <<CODE, <<OUTPUT, "gt_n_ic" ); 598 set N0, 500.0 599 set N1, 1000.0 600 set N2, 0.0 601 set N3, 0.0 602 603 gt N1, N0, ONE 604 branch ERROR 605 print "bad\\n" 606 607 ONE: 608 print "ok 1\\n" 609 gt N0, N1, ERROR 610 branch TWO 611 print "bad\\n" 612 613 TWO: 614 print "ok 2\\n" 615 gt N2, N3, ERROR 616 branch THREE 617 print "bad\\n" 618 619 THREE: 620 print "ok 3\\n" 621 end 622 623 ERROR: 624 print "bad\\n" 625 end 626 CODE 627 ok 1 628 ok 2 629 ok 3 630 OUTPUT 631 632 pasm_output_is( <<CODE, <<OUTPUT, "gt_nc_ic" ); 633 set N0, 500.0 634 set N1, 1000.0 635 set N2, 0.0 636 637 gt N0, 1000.0, ERROR 638 branch ONE 639 print "bad\\n" 640 641 ONE: 642 print "ok 1\\n" 643 gt N1, 500.0, TWO 644 branch ERROR 645 print "bad\\n" 646 647 TWO: 648 print "ok 2\\n" 649 gt N2, 0.0, ERROR 650 branch THREE 651 print "bad\\n" 652 653 THREE: 654 print "ok 3\\n" 655 end 656 657 ERROR: 658 print "bad\\n" 659 end 660 CODE 661 ok 1 662 ok 2 663 ok 3 664 OUTPUT 665 666 pasm_output_is( <<CODE, <<OUTPUT, "ge_n_ic" ); 667 set N0, 500.0 668 set N1, 1000.0 669 set N2, 0.0 670 set N3, 0.0 671 672 ge N1, N0, ONE 673 branch ERROR 674 print "bad\\n" 675 676 ONE: 677 print "ok 1\\n" 678 ge N0, N1, ERROR 679 branch TWO 680 print "bad\\n" 681 682 TWO: 683 print "ok 2\\n" 684 ge N2, N3, THREE 685 branch ERROR 686 print "bad\\n" 687 688 THREE: 689 print "ok 3\\n" 690 end 691 692 ERROR: 693 print "bad\\n" 694 end 695 CODE 696 ok 1 697 ok 2 698 ok 3 699 OUTPUT 700 701 pasm_output_is( <<CODE, <<OUTPUT, "ge_nc_ic" ); 702 set N0, 500.0 703 set N1, 1000.0 704 set N2, 0.0 705 706 ge N0, 1000.0, ERROR 707 branch ONE 708 print "bad\\n" 709 710 ONE: 711 print "ok 1\\n" 712 ge N1, 500.0, TWO 713 branch ERROR 714 print "bad\\n" 715 716 TWO: 717 print "ok 2\\n" 718 ge N2, 0.0, THREE 719 branch ERROR 720 print "bad\\n" 721 722 THREE: 723 print "ok 3\\n" 724 end 725 726 ERROR: 727 print "bad\\n" 728 end 729 CODE 730 ok 1 731 ok 2 732 ok 3 733 OUTPUT 734 735 pasm_output_is( <<CODE, <<OUTPUT, "if_n_ic" ); 736 set N0, 1000.0 737 set N1, 500.0 738 set N2, 0.0 739 740 if N0, ONE 741 branch ERROR 742 print "bad\\n" 743 744 ONE: 745 print "ok 1\\n" 746 if N1, TWO 747 branch ERROR 748 print "bad\\n" 749 750 TWO: 751 print "ok 2\\n" 752 if N2, ERROR 753 branch THREE 754 print "bad\\n" 755 756 THREE: 757 print "ok 3\\n" 758 end 759 760 ERROR: 761 print "bad\\n" 762 end 763 CODE 764 ok 1 765 ok 2 766 ok 3 767 OUTPUT 768 769 pasm_output_is( <<CODE, <<OUTPUT, "inc_n" ); 770 set N0, 0.0 771 772 inc N0 773 print N0 774 print "\\n" 775 776 inc N0 777 inc N0 778 inc N0 779 inc N0 780 print N0 781 print "\\n" 782 end 783 CODE 784 1 785 5 786 OUTPUT 787 788 pasm_output_is( <<CODE, <<OUTPUT, "dec_n" ); 789 set N0, 0.0 790 791 dec N0 792 print N0 793 print "\\n" 794 795 dec N0 796 dec N0 797 dec N0 798 dec N0 799 print N0 800 print "\\n" 801 end 802 CODE 803 -1 804 -5 805 OUTPUT 806 807 pasm_output_is( <<CODE, <<OUTPUT, "set_i_n" ); 808 set N0, 0.0 809 set I0, N0 810 print I0 811 print "\\n" 812 813 set N1, 2147483647.0 814 set I1, N1 815 print I1 816 print "\\n" 817 818 set N2, -2147483648.0 819 set I2, N2 820 print I2 821 print "\\n" 822 end 823 CODE 824 0 825 2147483647 826 -2147483648 827 OUTPUT 828 829 pasm_output_is( <<CODE, <<OUTPUT, "clearn" ); 830 set N0, 547972.0 831 set N1, 547972.0 832 set N2, 547972.0 833 set N3, 547972.0 834 set N4, 547972.0 835 set N5, 547972.0 836 set N6, 547972.0 837 set N7, 547972.0 838 set N8, 547972.0 839 set N9, 547972.0 840 set N10, 547972.0 841 set N11, 547972.0 842 set N12, 547972.0 843 set N13, 547972.0 844 set N14, 547972.0 845 set N15, 547972.0 846 set N16, 547972.0 847 set N17, 547972.0 848 set N18, 547972.0 849 set N19, 547972.0 850 set N20, 547972.0 851 set N21, 547972.0 852 set N22, 547972.0 853 set N23, 547972.0 854 set N24, 547972.0 855 set N25, 547972.0 856 set N26, 547972.0 857 set N27, 547972.0 858 set N28, 547972.0 859 set N29, 547972.0 860 set N30, 547972.0 861 set N31, 547972.0 862 clearn 863 print N0 864 print N1 865 print N2 866 print N3 867 print N4 868 print N5 869 print N6 870 print N7 871 print N8 872 print N9 873 print N10 874 print N11 875 print N12 876 print N13 877 print N14 878 print N15 879 print N16 880 print N17 881 print N18 882 print N19 883 print N20 884 print N21 885 print N22 886 print N23 887 print N24 888 print N25 889 print N26 890 print N27 891 print N28 892 print N29 893 print N30 894 print N31 895 print "\\n" 896 end 897 CODE 898 00000000000000000000000000000000 899 OUTPUT 900 901 pasm_output_is( <<CODE, <<OUTPUT, "neg_n" ); 902 neg N0,3.0 903 neg N0,N0 904 neg N0 905 print N0 906 print "\\n" 907 end 908 CODE 909 -3 910 OUTPUT 911 912 pasm_output_like( <<CODE, <<OUTPUT, "neg 0.0" ); 913 set N1, 0 914 neg N1 915 print N1 916 print "\\n" 917 end 918 CODE 919 /-?0\$/ 920 OUTPUT 921 922 pasm_output_is( <<CODE, <<OUTPUT, "mul_n_n" ); 923 set N0,3.0 924 set N1,4.0 925 mul N0,N1 926 print N0 927 print "\\n" 928 end 929 CODE 930 12 931 OUTPUT 932 933 pasm_output_is( <<CODE, <<OUTPUT, "fact_n_i" ); 934 set I0, 3 935 set I1, 11 936 set I2, 0 937 set I3, -563 938 fact N5, I0 939 print N5 940 print "\\n" 941 fact N6, I1 942 print N6 943 print "\\n" 944 fact N7, I2 945 print N7 946 print "\\n" 947 fact N8, I3 948 print N8 949 print "\\n" 950 end 951 CODE 952 6 953 39916800 954 1 955 1 956 OUTPUT 957 958 pasm_output_is( <<CODE, <<OUTPUT, "fact_n_ic" ); 959 fact N5, 3 960 print N5 961 print "\\n" 962 fact N6, 11 963 print N6 964 print "\\n" 965 fact N7, 0 966 print N7 967 print "\\n" 968 fact N8, -563 969 print N8 970 print "\\n" 971 end 972 CODE 973 6 974 39916800 975 1 976 1 977 OUTPUT 978 979 pasm_output_is( <<'CODE', <<OUTPUT, "exchange" ); 980 set N1, 1.234560 981 set N2, 9.876540 982 exchange N1, N2 983 print N1 984 print "\n" 985 print N2 986 print "\n" 987 988 set N3, -100.200300 989 exchange N3, N3 990 print N3 991 print "\n" 992 end 993 CODE 994 9.87654 995 1.23456 996 -100.2003 997 OUTPUT 998 999 pasm_output_is( <<'CODE', <<OUTPUT, "op_n_nc_nc" ); 1000 add N1, 2.0, 3.0 1001 print N1 1002 print "\n" 1003 sub N1, 2.0, 4.0 1004 print N1 1005 print "\n" 1006 end 1007 CODE 1008 5 1009 -2 1010 OUTPUT 1011 1012 pasm_output_is( <<'CODE', <<OUTPUT, "lt_nc_nc_ic" ); 744 .sub test_lt_nc_nc_ic 1013 745 lt 2.0, 1.0, nok 1014 print "ok 1\n"746 ok( 1, 'lt_nc_nc_ic ok 1') 1015 747 lt 3.0, 4.0, ok_2 1016 nok: 1017 print "nok\n" 1018 end 1019 ok_2: 1020 print "ok 2\n" 1021 end 1022 CODE 1023 ok 1 1024 ok 2 1025 OUTPUT 748 nok: 749 ok( 0, 'lt_nc_nc_ic') 750 goto END 751 ok_2: 752 ok( 1, 'lt_nc_nc_ic ok 2') 753 END: 754 .end 1026 755 1027 pasm_output_is( <<'CODE', <<OUTPUT, "string -> num" ); 1028 set S0, "1" 1029 set S1, "12.0" 1030 set S2, "-2.45" 1031 set S3, "25e2" 1032 set S4, "Banana" 756 .sub test_string_gt_num 757 set $S0, "1" 758 set $S1, "12.0" 759 set $S2, "-2.45" 760 set $S3, "25e2" 761 set $S4, "Banana" 762 set $N0, $S0 763 set $N1, $S1 764 set $N2, $S2 765 set $N3, $S3 766 set $N4, $S4 767 is( $N0, "1", 'string -> num' ) 768 is( $N1, "12", 'string -> num' ) 769 is( $N2, "-2.45", 'string -> num' ) 770 is( $N3, "2500", 'string -> num' ) 771 is( $N4, "0", 'string -> num' ) 772 .end 1033 773 1034 set N0, S0 1035 set N1, S1 1036 set N2, S2 1037 set N3, S3 1038 set N4, S4 774 .sub test_null 775 set $N31, 12.5 776 is( $N31, "12.5", 'null' ) 777 null $N31 778 is( $N31, "0", 'null' ) 779 .end 1039 780 1040 print N0 1041 print "\n" 1042 print N1 1043 print "\n" 1044 print N2 1045 print "\n" 1046 print N3 1047 print "\n" 1048 print N4 1049 print "\n" 781 .sub test_dot_dig_parsing 782 set $N0, .5 783 is( $N0, "0.5", '.dig parsing' ) 784 .end 1050 785 1051 end1052 CODE1053 11054 121055 -2.451056 25001057 01058 OUTPUT1059 1060 pasm_output_is( <<'CODE', <<OUTPUT, "null" );1061 set N31, 12.51062 print N311063 print "\n"1064 1065 null N311066 print N311067 print "\n"1068 1069 end1070 CODE1071 12.51072 01073 OUTPUT1074 1075 pasm_output_is( <<'CODE', <<OUTPUT, ".dig parsing" );1076 set N0, .51077 print N01078 print "\n"1079 end1080 CODE1081 0.51082 OUTPUT1083 1084 786 # Don't check exact string representation. Last digit part can be different */ 1085 pasm_output_like( <<'CODE', <<OUTPUT, "sqrt_n_n" ); 1086 set N1, 2 1087 sqrt N2, N1 1088 say N2 1089 sqrt N2, 2.0 1090 say N2 1091 end 1092 CODE 1093 /^1.414213562373.*\n1.414213562373.*/ 1094 OUTPUT 787 .sub test_sqrt_n_n 788 set $N1, 2 789 sqrt $N2, $N1 790 like( $N2, "^1.414213562373*", 'sqrt_n_n' ) 791 sqrt $N2, 2.0 792 like( $N2, "1.414213562373*", 'sqrt_n_n' ) 793 .end 1095 794 1096 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_n_n by zero" ); 1097 set N0, 01098 set N1, 101099 div N1, N01100 end1101 CODE 1102 /.*Divide by zero.*/ 1103 OUTPUT 795 .sub test_exception_div_n_n_by_zero 796 push_eh handler 797 set $N0, 0 798 set $N1, 10 799 div $N1, $N0 800 handler: 801 .exception_is( 'Divide by zero' ) 802 .end 1104 803 1105 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_n_nc by zero" ); 1106 set N1, 101107 div N1,01108 end1109 CODE 1110 /.*Divide by zero.*/ 1111 OUTPUT 804 .sub test_exception_div_n_nc_by_zero 805 push_eh handler 806 set $N1, 10 807 div $N1, 0 808 handler: 809 .exception_is( 'Divide by zero' ) 810 .end 1112 811 1113 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_n_n_n by zero" ); 1114 set N0, 01115 set N1, 101116 div N2, N1, N01117 end1118 CODE 1119 /.*Divide by zero.*/ 1120 OUTPUT 812 .sub test_exception_div_n_n_n_by_zero 813 push_eh handler 814 set $N0, 0 815 set $N1, 10 816 div $N2, $N1, $N0 817 handler: 818 .exception_is( 'Divide by zero' ) 819 .end 1121 820 1122 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_n_nc_n by zero" ); 1123 set N0, 01124 div N2, 10, N01125 end1126 CODE 1127 /.*Divide by zero.*/ 1128 OUTPUT 821 .sub test_exception_div_n_nc_n_by_zero 822 push_eh handler 823 set $N0, 0 824 div $N2, 10, $N0 825 handler: 826 .exception_is( 'Divide by zero' ) 827 .end 1129 828 1130 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_n_n_nc by zero" ); 1131 set N1, 101132 div N2, N1,01133 end1134 CODE 1135 /.*Divide by zero.*/ 1136 OUTPUT 829 .sub test_exception_div_n_n_nc_by_zero 830 push_eh handler 831 set $N1, 10 832 div $N2, $N1, 0 833 handler: 834 .exception_is( 'Divide by zero' ) 835 .end 1137 836 1138 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_n_n by zero" ); 1139 set N0, 01140 set N1, 101141 fdiv N1, N01142 end1143 CODE 1144 /.*Divide by zero.*/ 1145 OUTPUT 837 .sub test_exception_fdiv_n_n_by_zero 838 push_eh handler 839 set $N0, 0 840 set $N1, 10 841 fdiv $N1, $N0 842 handler: 843 .exception_is( 'Divide by zero' ) 844 .end 1146 845 1147 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_n_nc by zero" ); 1148 set N1, 101149 fdiv N1,01150 end1151 CODE 1152 /.*Divide by zero.*/ 1153 OUTPUT 846 .sub test_exception_fdiv_n_nc_by_zero 847 push_eh handler 848 set $N1, 10 849 fdiv $N1, 0 850 handler: 851 .exception_is( 'Divide by zero' ) 852 .end 1154 853 1155 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_n_n_n by zero" ); 1156 set N0, 01157 set N1, 101158 fdiv N2, N1, N01159 end1160 CODE 1161 /.*Divide by zero.*/ 1162 OUTPUT 854 .sub test_exception_fdiv_n_n_n_by_zero 855 push_eh handler 856 set $N0, 0 857 set $N1, 10 858 fdiv $N2, $N1, $N0 859 handler: 860 .exception_is( 'Divide by zero' ) 861 .end 1163 862 1164 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_n_nc_n by zero" ); 1165 set N0, 01166 fdiv N2, 10, N01167 end1168 CODE 1169 /.*Divide by zero.*/ 1170 OUTPUT 863 .sub test_exception_fdiv_n_nc_n_by_zero 864 push_eh handler 865 set $N0, 0 866 fdiv $N2, 10, $N0 867 handler: 868 .exception_is( 'Divide by zero' ) 869 .end 1171 870 1172 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_n_n_nc by zero" ); 1173 set N1, 101174 fdiv N2, N1,01175 end1176 CODE 1177 /.*Divide by zero.*/ 1178 OUTPUT 871 .sub test_exception_fdiv_n_n_nc_by_zero 872 push_eh handler 873 set $N1, 10 874 fdiv $N2, $N1, 0 875 handler: 876 .exception_is( 'Divide by zero' ) 877 .end 1179 878 1180 pasm_error_output_like( <<'CODE', <<OUTPUT, "cmod_n_n_n by zero" ); 1181 set N0, 01182 set N1, 101183 cmod N2, N1, N01184 end1185 CODE 1186 /.*Divide by zero.*/ 1187 OUTPUT 879 .sub test_exception_cmod_n_n_n_by_zero 880 push_eh handler 881 set $N0, 0 882 set $N1, 10 883 cmod $N2, $N1, $N0 884 handler: 885 .exception_is( 'Divide by zero' ) 886 .end 1188 887 1189 pasm_error_output_like( <<'CODE', <<OUTPUT, "cmod_n_nc_n by zero" ); 1190 set N0, 01191 cmod N2, 10, N01192 end1193 CODE 1194 /.*Divide by zero.*/ 1195 OUTPUT 888 .sub test_exception_cmod_n_nc_n_by_zero 889 push_eh handler 890 set $N0, 0 891 cmod $N2, 10, $N0 892 handler: 893 .exception_is( 'Divide by zero' ) 894 .end 1196 895 1197 pasm_error_output_like( <<'CODE', <<OUTPUT, "cmod_n_n_nc by zero" ); 1198 set N1, 101199 cmod N2, N1,01200 end1201 CODE 1202 /.*Divide by zero.*/ 1203 OUTPUT 896 .sub test_exception_cmod_n_n_nc_by_zero 897 push_eh handler 898 set $N1, 10 899 cmod $N2, $N1, 0 900 handler: 901 .exception_is( 'Divide by zero' ) 902 .end 1204 903 1205 pasm_output_is( <<'CODE', <<OUTPUT, "mod_n_n_n by zero" ); 1206 set N0, 0 1207 set N1, 10 1208 mod N2, N1, N0 1209 end 1210 CODE 1211 OUTPUT 904 .sub test_mod_n_n_n_by_zero 905 set $N0, 0 906 set $N1, 10 907 mod $N2, $N1, $N0 908 is( $N1, "10", 'mod_n_n_n by zero' ) 909 .end 1212 910 1213 pasm_output_is( <<'CODE', <<OUTPUT, "mod_n_nc_n by zero" ); 1214 set N0, 0 1215 mod N2, 10, N0 1216 end 1217 CODE 1218 OUTPUT 911 .sub test_mod_n_nc_n_by_zero 912 set $N0, 0 913 mod $N2, 10, $N0 914 is( $N1, 0, 'mod_n_nc_n by zero' ) 915 .end 1219 916 1220 pasm_output_is( <<'CODE', <<OUTPUT, "mod_n_n_nc by zero" ); 1221 set N1, 10 1222 mod N2, N1, 0 1223 end 1224 CODE 1225 OUTPUT 917 .sub test_mod_n_n_nc_by_zero 918 set $N1, 10 919 mod $N2, $N1, 0 920 is( $N2, '10', 'mod_n_n_nc by zero' ) 921 .end 1226 922 1227 923 # Local Variables: 1228 # mode: cperl924 # mode: pir 1229 925 # cperl-indent-level: 4 1230 926 # fill-column: 100 1231 927 # End: 1232 # vim: expandtab shiftwidth=4 :928 # vim: expandtab shiftwidth=4 ft=pir: