1#!./parrot 2# Copyright (C) 2006-2008, Parrot Foundation. 3 4=head1 NAME 5 6t/op/cmp-nonbranch.t - Non-branching conditionals 7 8=head1 SYNOPSIS 9 10 % prove t/op/cmp-nonbranch.t 11 12=head1 DESCRIPTION 13 14Tests all non-branching conditional operators. 15 16=cut 17 18 19.const int TESTS = 96 20 21.macro EXP() 22 exp_nok: 23 exp = 0 24 local_return jmpstack 25 exp_ok: 26 exp = 1 27 local_return jmpstack 28.endm 29 30.macro TEST() 31 is( res, exp, desc ) 32 local_return jmpstack 33.endm 34 35.macro SET_DESC(op) 36 .local string desc 37 desc = .op 38.endm 39 40.macro RESET_DESC(op) 41 desc = .op 42.endm 43 44.macro CONCAT_RES() 45 $S98 = $I1 46 res = concat res, $S98 47.endm 48 49 50.sub 'main' :main 51 .include 'test_more.pir' 52 53 'plan'(TESTS) 54 55 'issame'() 56 'isntsame'() 57 'istrue'() 58 'isfalse'() 59 'isnull_pmc'() 60 'isnull_string'() 61 'isgt'() 62 'isge'() 63 'isle'() 64 'islt'() 65 'iseq'() 66 'isne'() 67 'cmp'() 68 'cmp_string_null'() 69 'trac#11'() 70.end 71 72 73.sub 'issame' 74 .local int exp, res 75 .local pmc jmpstack 76 jmpstack = new 'ResizableIntegerArray' 77 .SET_DESC('issame') 78 79 init: 80 $P0 = new 'Integer' 81 $P1 = new 'String' 82 local_branch jmpstack, exp_nok 83 local_branch jmpstack, test_it # not ok 84 $P0 = new 'String' 85 local_branch jmpstack, test_it # not ok 86 local_branch jmpstack, exp_ok 87 $P1 = $P0 88 local_branch jmpstack, test_it # ok 89 $P0 = new 'Null' 90 $P1 = new 'Null' 91 local_branch jmpstack, test_it # ok -- Null is a singleton 92 .return() 93 94 .EXP() 95 test_it: 96 res = issame $P0, $P1 97 .TEST() 98.end 99 100 101.sub 'isntsame' 102 .local int exp, res 103 .local pmc jmpstack 104 jmpstack = new 'ResizableIntegerArray' 105 .SET_DESC('isntsame') 106 107 init: 108 $P0 = new 'Integer' 109 $P1 = new 'String' 110 local_branch jmpstack, exp_ok 111 local_branch jmpstack, test_it # ok 112 $P0 = new 'String' 113 local_branch jmpstack, test_it # ok 114 $P1 = $P0 115 local_branch jmpstack, exp_nok 116 local_branch jmpstack, test_it # not ok 117 $P0 = new 'Null' 118 $P1 = new 'Null' 119 local_branch jmpstack, test_it # not ok -- Null is a singleton 120 .return() 121 122 .EXP() 123 test_it: 124 res = isntsame $P0, $P1 125 .TEST() 126.end 127 128 129.sub 'istrue' 130 .local int exp, res 131 .local pmc jmpstack 132 jmpstack = new 'ResizableIntegerArray' 133 .SET_DESC('istrue') 134 135 init: 136 $P0 = new 'Integer' 137 $P0 = 0 138 local_branch jmpstack, exp_nok 139 local_branch jmpstack, test_it # not ok 140 $P0 = 1 141 local_branch jmpstack, exp_ok 142 local_branch jmpstack, test_it # ok 143 .return() 144 145 .EXP() 146 test_it: 147 res = istrue $P0 148 .TEST() 149.end 150 151 152.sub 'isfalse' 153 .local int exp, res 154 .local pmc jmpstack 155 jmpstack = new 'ResizableIntegerArray' 156 .SET_DESC('isfalse') 157 158 init: 159 $P0 = new 'Integer' 160 $P0 = 0 161 local_branch jmpstack, exp_ok 162 local_branch jmpstack, test_it # ok 163 $P0 = 1 164 local_branch jmpstack, exp_nok 165 local_branch jmpstack, test_it # not ok 166 .return() 167 168 .EXP() 169 test_it: 170 res = isfalse $P0 171 .TEST() 172.end 173 174 175.sub 'isnull_pmc' 176 .local int exp, res 177 .local pmc jmpstack 178 jmpstack = new 'ResizableIntegerArray' 179 .SET_DESC('isnull pmc') 180 181 init: 182 $S0 = 'FUBAR' 183 local_branch jmpstack, exp_ok 184 local_branch jmpstack, test_it 185 $S0 = 'Null' # this is a valid pmc type -- you can't trick parrot :) 186 local_branch jmpstack, exp_nok 187 local_branch jmpstack, test_it 188 $S0 = 'Integer' 189 local_branch jmpstack, test_it 190 .return() 191 192 .EXP() 193 test_it: 194 res = 0 195 push_eh fubar 196 $P0 = new $S0 197 pop_eh 198 goto test 199 200 fubar: 201 res = isnull $P0 202 test: 203 .TEST() 204.end 205 206 207.sub 'isnull_string' 208 .local int res 209 null $S0 210 res = isnull $S0 211 is(res, 1, 'isnull string null') 212 $S0 = 'something' 213 res = isnull $S0 214 is(res, 0, 'isnull string non null') 215 res = isnull 'H' 216 is(res, 0, 'isnull string constant') 217.end 218 219.sub 'isgt' 220 .local string exp, res 221 222 exp = '001' 223 224 .SET_DESC('isgt_i_i_i') 225 set $I1, 111 226 set $I2, 222 227 set $I3, 333 228 isgt $I1, $I2, $I3 229 .CONCAT_RES() 230 set $I2, $I3 231 isgt $I1, $I2, $I3 232 .CONCAT_RES() 233 inc $I2 234 isgt $I1, $I2, $I3 235 .CONCAT_RES() 236 is( res, exp, desc) 237 238 res = '' 239 .RESET_DESC('isgt_i_ic_i') 240 set $I1, 111 241 set $I3, 333 242 isgt $I1, 222, $I3 243 .CONCAT_RES() 244 isgt $I1, 333, $I3 245 .CONCAT_RES() 246 isgt $I1, 334, $I3 247 .CONCAT_RES() 248 is( res, exp, desc) 249 250 res = '' 251 .RESET_DESC('isgt_i_i_ic') 252 set $I1, 111 253 set $I2, 222 254 isgt $I1, $I2, 223 255 .CONCAT_RES() 256 isgt $I1, $I2, 222 257 .CONCAT_RES() 258 isgt $I1, $I2, 221 259 .CONCAT_RES() 260 is( res, exp, desc) 261 262 res = '' 263 .RESET_DESC('isgt_i_ic_ic') 264 set $I1, 111 265 isgt $I1, 222, 223 266 .CONCAT_RES() 267 isgt $I1, 222, 222 268 .CONCAT_RES() 269 isgt $I1, 222, 221 270 .CONCAT_RES() 271 is( res, exp, desc) 272 273 res = '' 274 .RESET_DESC('isgt_i_n_n') 275 set $I1, 111 276 set $N2, 2.22 277 set $N3, 3.33 278 isgt $I1, $N2, $N3 279 .CONCAT_RES() 280 set $N2, $N3 281 isgt $I1, $N2, $N3 282 .CONCAT_RES() 283 inc $N2 284 isgt $I1, $N2, $N3 285 .CONCAT_RES() 286 is( res, exp, desc) 287 288 res = '' 289 .RESET_DESC('isgt_i_nc_n') 290 set $I1, 111 291 set $N3, 3.33 292 isgt $I1, 2.22, $N3 293 .CONCAT_RES() 294 isgt $I1, 3.33, $N3 295 .CONCAT_RES() 296 isgt $I1, 3.34, $N3 297 .CONCAT_RES() 298 is( res, exp, desc) 299 300 res = '' 301 .RESET_DESC('isgt_i_n_nc') 302 set $I1, 111 303 set $N2, 2.22 304 isgt $I1, $N2, 2.23 305 .CONCAT_RES() 306 isgt $I1, $N2, 2.22 307 .CONCAT_RES() 308 isgt $I1, $N2, 2.21 309 .CONCAT_RES() 310 is( res, exp, desc) 311 312 res = '' 313 .RESET_DESC('isgt_i_nc_nc') 314 set $I1, 111 315 isgt $I1, 2.22, 2.23 316 .CONCAT_RES() 317 isgt $I1, 2.22, 2.22 318 .CONCAT_RES() 319 isgt $I1, 2.22, 2.21 320 .CONCAT_RES() 321 is( res, exp, desc) 322 323 res = '' 324 .RESET_DESC('isgt_i_s_s') 325 set $I1, 111 326 set $S2, "Aaa" 327 set $S3, "Bbb" 328 isgt $I1, $S2, $S3 329 .CONCAT_RES() 330 set $S2, $S3 331 isgt $I1, $S2, $S3 332 .CONCAT_RES() 333 set $S2, "Ccc" 334 isgt $I1, $S2, $S3 335 .CONCAT_RES() 336 is( res, exp, desc) 337 338 res = '' 339 .RESET_DESC('isgt_i_sc_s') 340 set $I1, 111 341 set $S3, "Bbb" 342 isgt $I1, "Aaa", $S3 343 .CONCAT_RES() 344 isgt $I1, "Bbb", $S3 345 .CONCAT_RES() 346 isgt $I1, "Ccc", $S3 347 .CONCAT_RES() 348 is( res, exp, desc) 349 350 res = '' 351 .RESET_DESC('isgt_i_s_sc') 352 set $I1, 111 353 set $S2, "Bbb" 354 isgt $I1, $S2, "Ccc" 355 .CONCAT_RES() 356 isgt $I1, $S2, "Bbb" 357 .CONCAT_RES() 358 isgt $I1, $S2, "Aaa" 359 .CONCAT_RES() 360 is( res, exp, desc) 361 362 res = '' 363 .RESET_DESC('isgt_i_sc_sc') 364 set $I1, 111 365 isgt $I1, "Bbb", "Ccc" 366 .CONCAT_RES() 367 isgt $I1, "Bbb", "Bbb" 368 .CONCAT_RES() 369 isgt $I1, "Bbb", "Aaa" 370 .CONCAT_RES() 371 is( res, exp, desc) 372.end 373 374 375.sub 'isge' 376 .local string exp, res 377 378 exp = '011' 379 380 .SET_DESC('isge_i_i_i') 381 set $I1, 111 382 set $I2, 222 383 set $I3, 333 384 isge $I1, $I2, $I3 385 .CONCAT_RES() 386 set $I2, $I3 387 isge $I1, $I2, $I3 388 .CONCAT_RES() 389 inc $I2 390 isge $I1, $I2, $I3 391 .CONCAT_RES() 392 is( res, exp, desc) 393 394 res = '' 395 .RESET_DESC('isge_i_ic_i') 396 set $I1, 111 397 set $I3, 333 398 isge $I1, 222, $I3 399 .CONCAT_RES() 400 isge $I1, 333, $I3 401 .CONCAT_RES() 402 isge $I1, 334, $I3 403 .CONCAT_RES() 404 is( res, exp, desc) 405 406 res = '' 407 .RESET_DESC('isge_i_i_ic') 408 set $I1, 111 409 set $I2, 222 410 isge $I1, $I2, 223 411 .CONCAT_RES() 412 isge $I1, $I2, 222 413 .CONCAT_RES() 414 isge $I1, $I2, 221 415 .CONCAT_RES() 416 is( res, exp, desc) 417 418 res = '' 419 .RESET_DESC('isge_i_ic_ic') 420 set $I1, 111 421 isge $I1, 222, 223 422 .CONCAT_RES() 423 isge $I1, 222, 222 424 .CONCAT_RES() 425 isge $I1, 222, 221 426 .CONCAT_RES() 427 is( res, exp, desc) 428 429 res = '' 430 .RESET_DESC('isge_i_n_n') 431 set $I1, 111 432 set $N2, 2.22 433 set $N3, 3.33 434 isge $I1, $N2, $N3 435 .CONCAT_RES() 436 set $N2, $N3 437 isge $I1, $N2, $N3 438 .CONCAT_RES() 439 inc $N2 440 isge $I1, $N2, $N3 441 .CONCAT_RES() 442 is( res, exp, desc) 443 444 res = '' 445 .RESET_DESC('isge_i_nc_n') 446 set $I1, 111 447 set $N3, 3.33 448 isge $I1, 2.22, $N3 449 .CONCAT_RES() 450 isge $I1, 3.33, $N3 451 .CONCAT_RES() 452 isge $I1, 3.34, $N3 453 .CONCAT_RES() 454 is( res, exp, desc) 455 456 res = '' 457 .RESET_DESC('isge_i_n_nc') 458 set $I1, 111 459 set $N2, 2.22 460 isge $I1, $N2, 2.23 461 .CONCAT_RES() 462 isge $I1, $N2, 2.22 463 .CONCAT_RES() 464 isge $I1, $N2, 2.21 465 .CONCAT_RES() 466 is( res, exp, desc) 467 468 res = '' 469 .RESET_DESC('isge_i_nc_nc') 470 set $I1, 111 471 isge $I1, 2.22, 2.23 472 .CONCAT_RES() 473 isge $I1, 2.22, 2.22 474 .CONCAT_RES() 475 isge $I1, 2.22, 2.21 476 .CONCAT_RES() 477 is( res, exp, desc) 478 479 res = '' 480 .RESET_DESC('isge_i_s_s') 481 set $I1, 111 482 set $S2, "Aaa" 483 set $S3, "Bbb" 484 isge $I1, $S2, $S3 485 .CONCAT_RES() 486 set $S2, $S3 487 isge $I1, $S2, $S3 488 .CONCAT_RES() 489 set $S2, "Ccc" 490 isge $I1, $S2, $S3 491 .CONCAT_RES() 492 is( res, exp, desc) 493 494 res = '' 495 .RESET_DESC('isge_i_sc_s') 496 set $I1, 111 497 set $S3, "Bbb" 498 isge $I1, "Aaa", $S3 499 .CONCAT_RES() 500 isge $I1, "Bbb", $S3 501 .CONCAT_RES() 502 isge $I1, "Ccc", $S3 503 .CONCAT_RES() 504 is( res, exp, desc) 505 506 res = '' 507 .RESET_DESC('isge_i_s_sc') 508 set $I1, 111 509 set $S2, "Bbb" 510 isge $I1, $S2, "Ccc" 511 .CONCAT_RES() 512 isge $I1, $S2, "Bbb" 513 .CONCAT_RES() 514 isge $I1, $S2, "Aaa" 515 .CONCAT_RES() 516 is( res, exp, desc) 517 518 res = '' 519 .RESET_DESC('isge_i_sc_sc') 520 set $I1, 111 521 isge $I1, "Bbb", "Ccc" 522 .CONCAT_RES() 523 isge $I1, "Bbb", "Bbb" 524 .CONCAT_RES() 525 isge $I1, "Bbb", "Aaa" 526 .CONCAT_RES() 527 is( res, exp, desc) 528.end 529 530 531.sub 'isle' 532 .local string exp, res 533 534 exp = '110' 535 536 .SET_DESC('isle_i_i_i') 537 set $I1, 111 538 set $I2, 222 539 set $I3, 333 540 isle $I1, $I2, $I3 541 .CONCAT_RES() 542 set $I2, $I3 543 isle $I1, $I2, $I3 544 .CONCAT_RES() 545 inc $I2 546 isle $I1, $I2, $I3 547 .CONCAT_RES() 548 is( res, exp, desc) 549 550 res = '' 551 .RESET_DESC('isle_i_ic_i') 552 set $I1, 111 553 set $I3, 333 554 isle $I1, 222, $I3 555 .CONCAT_RES() 556 isle $I1, 333, $I3 557 .CONCAT_RES() 558 isle $I1, 334, $I3 559 .CONCAT_RES() 560 is( res, exp, desc) 561 562 res = '' 563 .RESET_DESC('isle_i_i_ic') 564 set $I1, 111 565 set $I2, 222 566 isle $I1, $I2, 223 567 .CONCAT_RES() 568 isle $I1, $I2, 222 569 .CONCAT_RES() 570 isle $I1, $I2, 221 571 .CONCAT_RES() 572 is( res, exp, desc) 573 574 res = '' 575 .RESET_DESC('isle_i_ic_ic') 576 set $I1, 111 577 isle $I1, 222, 223 578 .CONCAT_RES() 579 isle $I1, 222, 222 580 .CONCAT_RES() 581 isle $I1, 222, 221 582 .CONCAT_RES() 583 is( res, exp, desc) 584 585 res = '' 586 .RESET_DESC('isle_i_n_n') 587 set $I1, 111 588 set $N2, 2.22 589 set $N3, 3.33 590 isle $I1, $N2, $N3 591 .CONCAT_RES() 592 set $N2, $N3 593 isle $I1, $N2, $N3 594 .CONCAT_RES() 595 inc $N2 596 isle $I1, $N2, $N3 597 .CONCAT_RES() 598 is( res, exp, desc) 599 600 res = '' 601 .RESET_DESC('isle_i_nc_n') 602 set $I1, 111 603 set $N3, 3.33 604 isle $I1, 2.22, $N3 605 .CONCAT_RES() 606 isle $I1, 3.33, $N3 607 .CONCAT_RES() 608 isle $I1, 3.34, $N3 609 .CONCAT_RES() 610 is( res, exp, desc) 611 612 res = '' 613 .RESET_DESC('isle_i_n_nc') 614 set $I1, 111 615 set $N2, 2.22 616 isle $I1, $N2, 2.23 617 .CONCAT_RES() 618 isle $I1, $N2, 2.22 619 .CONCAT_RES() 620 isle $I1, $N2, 2.21 621 .CONCAT_RES() 622 is( res, exp, desc) 623 624 res = '' 625 .RESET_DESC('isle_i_nc_nc') 626 set $I1, 111 627 isle $I1, 2.22, 2.23 628 .CONCAT_RES() 629 isle $I1, 2.22, 2.22 630 .CONCAT_RES() 631 isle $I1, 2.22, 2.21 632 .CONCAT_RES() 633 is( res, exp, desc) 634 635 res = '' 636 .RESET_DESC('isle_i_s_s') 637 set $I1, 111 638 set $S2, "Aaa" 639 set $S3, "Bbb" 640 isle $I1, $S2, $S3 641 .CONCAT_RES() 642 set $S2, $S3 643 isle $I1, $S2, $S3 644 .CONCAT_RES() 645 set $S2, "Ccc" 646 isle $I1, $S2, $S3 647 .CONCAT_RES() 648 is( res, exp, desc) 649 650 res = '' 651 .RESET_DESC('isle_i_sc_s') 652 set $I1, 111 653 set $S3, "Bbb" 654 isle $I1, "Aaa", $S3 655 .CONCAT_RES() 656 isle $I1, "Bbb", $S3 657 .CONCAT_RES() 658 isle $I1, "Ccc", $S3 659 .CONCAT_RES() 660 is( res, exp, desc) 661 662 res = '' 663 .RESET_DESC('isle_i_s_sc') 664 set $I1, 111 665 set $S2, "Bbb" 666 isle $I1, $S2, "Ccc" 667 .CONCAT_RES() 668 isle $I1, $S2, "Bbb" 669 .CONCAT_RES() 670 isle $I1, $S2, "Aaa" 671 .CONCAT_RES() 672 is( res, exp, desc) 673 674 res = '' 675 .RESET_DESC('isle_i_sc_sc') 676 set $I1, 111 677 isle $I1, "Bbb", "Ccc" 678 .CONCAT_RES() 679 isle $I1, "Bbb", "Bbb" 680 .CONCAT_RES() 681 isle $I1, "Bbb", "Aaa" 682 .CONCAT_RES() 683 is( res, exp, desc) 684.end 685 686 687.sub 'islt' 688 .local string exp, res 689 690 exp = '100' 691 692 .SET_DESC('islt_i_i_i') 693 set $I1, 111 694 set $I2, 222 695 set $I3, 333 696 islt $I1, $I2, $I3 697 .CONCAT_RES() 698 set $I2, $I3 699 islt $I1, $I2, $I3 700 .CONCAT_RES() 701 inc $I2 702 islt $I1, $I2, $I3 703 .CONCAT_RES() 704 is( res, exp, desc) 705 706 res = '' 707 .RESET_DESC('islt_i_ic_i') 708 set $I1, 111 709 set $I3, 333 710 islt $I1, 222, $I3 711 .CONCAT_RES() 712 islt $I1, 333, $I3 713 .CONCAT_RES() 714 islt $I1, 334, $I3 715 .CONCAT_RES() 716 is( res, exp, desc) 717 718 res = '' 719 .RESET_DESC('islt_i_i_ic') 720 set $I1, 111 721 set $I2, 222 722 islt $I1, $I2, 223 723 .CONCAT_RES() 724 islt $I1, $I2, 222 725 .CONCAT_RES() 726 islt $I1, $I2, 221 727 .CONCAT_RES() 728 is( res, exp, desc) 729 730 res = '' 731 .RESET_DESC('islt_i_ic_ic') 732 set $I1, 111 733 islt $I1, 222, 223 734 .CONCAT_RES() 735 islt $I1, 222, 222 736 .CONCAT_RES() 737 islt $I1, 222, 221 738 .CONCAT_RES() 739 is( res, exp, desc) 740 741 res = '' 742 .RESET_DESC('islt_i_n_n') 743 set $I1, 111 744 set $N2, 2.22 745 set $N3, 3.33 746 islt $I1, $N2, $N3 747 .CONCAT_RES() 748 set $N2, $N3 749 islt $I1, $N2, $N3 750 .CONCAT_RES() 751 inc $N2 752 islt $I1, $N2, $N3 753 .CONCAT_RES() 754 is( res, exp, desc) 755 756 res = '' 757 .RESET_DESC('islt_i_nc_n') 758 set $I1, 111 759 set $N3, 3.33 760 islt $I1, 2.22, $N3 761 .CONCAT_RES() 762 islt $I1, 3.33, $N3 763 .CONCAT_RES() 764 islt $I1, 3.34, $N3 765 .CONCAT_RES() 766 is( res, exp, desc) 767 768 res = '' 769 .RESET_DESC('islt_i_n_nc') 770 set $I1, 111 771 set $N2, 2.22 772 islt $I1, $N2, 2.23 773 .CONCAT_RES() 774 islt $I1, $N2, 2.22 775 .CONCAT_RES() 776 islt $I1, $N2, 2.21 777 .CONCAT_RES() 778 is( res, exp, desc) 779 780 res = '' 781 .RESET_DESC('islt_i_nc_nc') 782 set $I1, 111 783 islt $I1, 2.22, 2.23 784 .CONCAT_RES() 785 islt $I1, 2.22, 2.22 786 .CONCAT_RES() 787 islt $I1, 2.22, 2.21 788 .CONCAT_RES() 789 is( res, exp, desc) 790 791 res = '' 792 .RESET_DESC('islt_i_s_s') 793 set $I1, 111 794 set $S2, "Aaa" 795 set $S3, "Bbb" 796 islt $I1, $S2, $S3 797 .CONCAT_RES() 798 set $S2, $S3 799 islt $I1, $S2, $S3 800 .CONCAT_RES() 801 set $S2, "Ccc" 802 islt $I1, $S2, $S3 803 .CONCAT_RES() 804 is( res, exp, desc) 805 806 res = '' 807 .RESET_DESC('islt_i_sc_s') 808 set $I1, 111 809 set $S3, "Bbb" 810 islt $I1, "Aaa", $S3 811 .CONCAT_RES() 812 islt $I1, "Bbb", $S3 813 .CONCAT_RES() 814 islt $I1, "Ccc", $S3 815 .CONCAT_RES() 816 is( res, exp, desc) 817 818 res = '' 819 .RESET_DESC('islt_i_s_sc') 820 set $I1, 111 821 set $S2, "Bbb" 822 islt $I1, $S2, "Ccc" 823 .CONCAT_RES() 824 islt $I1, $S2, "Bbb" 825 .CONCAT_RES() 826 islt $I1, $S2, "Aaa" 827 .CONCAT_RES() 828 is( res, exp, desc) 829 830 res = '' 831 .RESET_DESC('islt_i_sc_sc') 832 set $I1, 111 833 islt $I1, "Bbb", "Ccc" 834 .CONCAT_RES() 835 islt $I1, "Bbb", "Bbb" 836 .CONCAT_RES() 837 islt $I1, "Bbb", "Aaa" 838 .CONCAT_RES() 839 is( res, exp, desc) 840.end 841 842 843.sub 'iseq' 844 .local string exp, res 845 846 exp = '010' 847 848 .SET_DESC('iseq_i_i_i') 849 set $I1, 111 850 set $I2, 222 851 set $I3, 333 852 iseq $I1, $I2, $I3 853 .CONCAT_RES() 854 set $I2, $I3 855 iseq $I1, $I2, $I3 856 .CONCAT_RES() 857 inc $I2 858 iseq $I1, $I2, $I3 859 .CONCAT_RES() 860 is( res, exp, desc) 861 862 res = '' 863 .RESET_DESC('iseq_i_ic_i') 864 set $I1, 111 865 set $I3, 333 866 iseq $I1, 222, $I3 867 .CONCAT_RES() 868 iseq $I1, 333, $I3 869 .CONCAT_RES() 870 iseq $I1, 334, $I3 871 .CONCAT_RES() 872 is( res, exp, desc) 873 874 res = '' 875 .RESET_DESC('iseq_i_i_ic') 876 set $I1, 111 877 set $I2, 222 878 iseq $I1, $I2, 223 879 .CONCAT_RES() 880 iseq $I1, $I2, 222 881 .CONCAT_RES() 882 iseq $I1, $I2, 221 883 .CONCAT_RES() 884 is( res, exp, desc) 885 886 res = '' 887 .RESET_DESC('iseq_i_ic_ic') 888 set $I1, 111 889 iseq $I1, 222, 223 890 .CONCAT_RES() 891 iseq $I1, 222, 222 892 .CONCAT_RES() 893 iseq $I1, 222, 221 894 .CONCAT_RES() 895 is( res, exp, desc) 896 897 res = '' 898 .RESET_DESC('iseq_i_n_n') 899 set $I1, 111 900 set $N2, 2.22 901 set $N3, 3.33 902 iseq $I1, $N2, $N3 903 .CONCAT_RES() 904 set $N2, $N3 905 iseq $I1, $N2, $N3 906 .CONCAT_RES() 907 inc $N2 908 iseq $I1, $N2, $N3 909 .CONCAT_RES() 910 is( res, exp, desc) 911 912 res = '' 913 .RESET_DESC('iseq_i_nc_n') 914 set $I1, 111 915 set $N3, 3.33 916 iseq $I1, 2.22, $N3 917 .CONCAT_RES() 918 iseq $I1, 3.33, $N3 919 .CONCAT_RES() 920 iseq $I1, 3.34, $N3 921 .CONCAT_RES() 922 is( res, exp, desc) 923 924 res = '' 925 .RESET_DESC('iseq_i_n_nc') 926 set $I1, 111 927 set $N2, 2.22 928 iseq $I1, $N2, 2.23 929 .CONCAT_RES() 930 iseq $I1, $N2, 2.22 931 .CONCAT_RES() 932 iseq $I1, $N2, 2.21 933 .CONCAT_RES() 934 is( res, exp, desc) 935 936 res = '' 937 .RESET_DESC('iseq_i_nc_nc') 938 set $I1, 111 939 iseq $I1, 2.22, 2.23 940 .CONCAT_RES() 941 iseq $I1, 2.22, 2.22 942 .CONCAT_RES() 943 iseq $I1, 2.22, 2.21 944 .CONCAT_RES() 945 is( res, exp, desc) 946 947 res = '' 948 .RESET_DESC('iseq_i_s_s') 949 set $I1, 111 950 set $S2, "Aaa" 951 set $S3, "Bbb" 952 iseq $I1, $S2, $S3 953 .CONCAT_RES() 954 set $S2, $S3 955 iseq $I1, $S2, $S3 956 .CONCAT_RES() 957 set $S2, "Ccc" 958 iseq $I1, $S2, $S3 959 .CONCAT_RES() 960 is( res, exp, desc) 961 962 res = '' 963 .RESET_DESC('iseq_i_sc_s') 964 set $I1, 111 965 set $S3, "Bbb" 966 iseq $I1, "Aaa", $S3 967 .CONCAT_RES() 968 iseq $I1, "Bbb", $S3 969 .CONCAT_RES() 970 iseq $I1, "Ccc", $S3 971 .CONCAT_RES() 972 is( res, exp, desc) 973 974 res = '' 975 .RESET_DESC('iseq_i_s_sc') 976 set $I1, 111 977 set $S2, "Bbb" 978 iseq $I1, $S2, "Ccc" 979 .CONCAT_RES() 980 iseq $I1, $S2, "Bbb" 981 .CONCAT_RES() 982 iseq $I1, $S2, "Aaa" 983 .CONCAT_RES() 984 is( res, exp, desc) 985 986 res = '' 987 .RESET_DESC('iseq_i_sc_sc') 988 set $I1, 111 989 iseq $I1, "Bbb", "Ccc" 990 .CONCAT_RES() 991 iseq $I1, "Bbb", "Bbb" 992 .CONCAT_RES() 993 iseq $I1, "Bbb", "Aaa" 994 .CONCAT_RES() 995 is( res, exp, desc) 996.end 997 998 999.sub 'isne' 1000 .local string exp, res 1001 1002 exp = '101' 1003 1004 .SET_DESC('isne_i_i_i') 1005 set $I1, 111 1006 set $I2, 222 1007 set $I3, 333 1008 isne $I1, $I2, $I3 1009 .CONCAT_RES() 1010 set $I2, $I3 1011 isne $I1, $I2, $I3 1012 .CONCAT_RES() 1013 inc $I2 1014 isne $I1, $I2, $I3 1015 .CONCAT_RES() 1016 is( res, exp, desc) 1017 1018 res = '' 1019 .RESET_DESC('isne_i_ic_i') 1020 set $I1, 111 1021 set $I3, 333 1022 isne $I1, 222, $I3 1023 .CONCAT_RES() 1024 isne $I1, 333, $I3 1025 .CONCAT_RES() 1026 isne $I1, 334, $I3 1027 .CONCAT_RES() 1028 is( res, exp, desc) 1029 1030 res = '' 1031 .RESET_DESC('isne_i_i_ic') 1032 set $I1, 111 1033 set $I2, 222 1034 isne $I1, $I2, 223 1035 .CONCAT_RES() 1036 isne $I1, $I2, 222 1037 .CONCAT_RES() 1038 isne $I1, $I2, 221 1039 .CONCAT_RES() 1040 is( res, exp, desc) 1041 1042 res = '' 1043 .RESET_DESC('isne_i_ic_ic') 1044 set $I1, 111 1045 isne $I1, 222, 223 1046 .CONCAT_RES() 1047 isne $I1, 222, 222 1048 .CONCAT_RES() 1049 isne $I1, 222, 221 1050 .CONCAT_RES() 1051 is( res, exp, desc) 1052 1053 res = '' 1054 .RESET_DESC('isne_i_n_n') 1055 set $I1, 111 1056 set $N2, 2.22 1057 set $N3, 3.33 1058 isne $I1, $N2, $N3 1059 .CONCAT_RES() 1060 set $N2, $N3 1061 isne $I1, $N2, $N3 1062 .CONCAT_RES() 1063 inc $N2 1064 isne $I1, $N2, $N3 1065 .CONCAT_RES() 1066 is( res, exp, desc) 1067 1068 res = '' 1069 .RESET_DESC('isne_i_nc_n') 1070 set $I1, 111 1071 set $N3, 3.33 1072 isne $I1, 2.22, $N3 1073 .CONCAT_RES() 1074 isne $I1, 3.33, $N3 1075 .CONCAT_RES() 1076 isne $I1, 3.34, $N3 1077 .CONCAT_RES() 1078 is( res, exp, desc) 1079 1080 res = '' 1081 .RESET_DESC('isne_i_n_nc') 1082 set $I1, 111 1083 set $N2, 2.22 1084 isne $I1, $N2, 2.23 1085 .CONCAT_RES() 1086 isne $I1, $N2, 2.22 1087 .CONCAT_RES() 1088 isne $I1, $N2, 2.21 1089 .CONCAT_RES() 1090 is( res, exp, desc) 1091 1092 res = '' 1093 .RESET_DESC('isne_i_nc_nc') 1094 set $I1, 111 1095 isne $I1, 2.22, 2.23 1096 .CONCAT_RES() 1097 isne $I1, 2.22, 2.22 1098 .CONCAT_RES() 1099 isne $I1, 2.22, 2.21 1100 .CONCAT_RES() 1101 is( res, exp, desc) 1102 1103 res = '' 1104 .RESET_DESC('isne_i_s_s') 1105 set $I1, 111 1106 set $S2, "Aaa" 1107 set $S3, "Bbb" 1108 isne $I1, $S2, $S3 1109 .CONCAT_RES() 1110 set $S2, $S3 1111 isne $I1, $S2, $S3 1112 .CONCAT_RES() 1113 set $S2, "Ccc" 1114 isne $I1, $S2, $S3 1115 .CONCAT_RES() 1116 is( res, exp, desc) 1117 1118 res = '' 1119 .RESET_DESC('isne_i_sc_s') 1120 set $I1, 111 1121 set $S3, "Bbb" 1122 isne $I1, "Aaa", $S3 1123 .CONCAT_RES() 1124 isne $I1, "Bbb", $S3 1125 .CONCAT_RES() 1126 isne $I1, "Ccc", $S3 1127 .CONCAT_RES() 1128 is( res, exp, desc) 1129 1130 res = '' 1131 .RESET_DESC('isne_i_s_sc') 1132 set $I1, 111 1133 set $S2, "Bbb" 1134 isne $I1, $S2, "Ccc" 1135 .CONCAT_RES() 1136 isne $I1, $S2, "Bbb" 1137 .CONCAT_RES() 1138 isne $I1, $S2, "Aaa" 1139 .CONCAT_RES() 1140 is( res, exp, desc) 1141 1142 res = '' 1143 .RESET_DESC('isne_i_sc_sc') 1144 set $I1, 111 1145 isne $I1, "Bbb", "Ccc" 1146 .CONCAT_RES() 1147 isne $I1, "Bbb", "Bbb" 1148 .CONCAT_RES() 1149 isne $I1, "Bbb", "Aaa" 1150 .CONCAT_RES() 1151 is( res, exp, desc) 1152.end 1153 1154 1155.sub 'cmp' 1156 .local string exp, res 1157 .SET_DESC('cmp') 1158 1159 init: 1160 set $I0, 10 1161 cmp $I1, $I0, 9 1162 set $N0, -2.4 1163 cmp $I2, -2.4, $N0 1164 set $S0, "Bruhaha" 1165 cmp $I3, $S0, "Crumbum" 1166 new $P0, 'Integer' 1167 new $P1, 'Integer' 1168 set $P0, 452 1169 set $P1, -15 1170 cmp $I4, $P0, $P1 1171 1172 1173 exp = <<'EXP' 11741 11750 1176-1 11771 11781 11790 1180-1 1181EXP 1182 1183 test_it: 1184 $S99 = $I1 1185 res = concat res, $S99 1186 res = concat res, "\n" 1187 $S99 = $I2 1188 res = concat res, $S99 1189 res = concat res, "\n" 1190 $S99 = $I3 1191 res = concat res, $S99 1192 res = concat res, "\n" 1193 $S99 = $I4 1194 res = concat res, $S99 1195 res = concat res, "\n" 1196 1197 set $I5, 9 1198 set $I6, 10 1199 set $I7, 11 1200 cmp $I1, $I0, $I5 1201 cmp $I2, $I0, $I6 1202 cmp $I3, $I0, $I7 1203 $S99 = $I1 1204 res = concat res, $S99 1205 res = concat res, "\n" 1206 $S99 = $I2 1207 res = concat res, $S99 1208 res = concat res, "\n" 1209 $S99 = $I3 1210 res = concat res, $S99 1211 res = concat res, "\n" 1212 1213 is(exp, res, desc) 1214.end 1215 1216 1217.sub 'cmp_string_null' 1218 .local string s1, s2 1219 .local int r 1220 null s1 1221 s2 = 'hello' 1222 1223 r = cmp s1, s2 1224 is(r, -1, 'cmp snull, snotnull') 1225 1226 r = cmp s2, s1 1227 is(r, 1, 'cmp snotnull, snull') 1228 1229 null s2 1230 r = cmp s2, s1 1231 is(r, 0, 'cmp snull, snull') 1232.end 1233 1234 1235.sub 'trac#11' 1236 $P0 = new 'String' 1237 assign $P0, 'foo' 1238 1239 null $P1 1240 $I0 = issame $P0, $P1 1241 is($I0, 0, 'issame String,Null') 1242 1243 $P1 = split ' ', 'parrot speaks your language' 1244 $I0 = issame $P0, $P1 1245 is($I0, 0, 'issame String,ResizableStringArray') 1246.end 1247 1248 1249# Local Variables: 1250# mode: pir 1251# fill-column: 100 1252# End: 1253# vim: expandtab shiftwidth=4 ft=pir: 1254