| 1 | #!/usr/bin/env perl |
| 2 | |
| 3 | # Perl code used to generate t/op/arithmetics_pmc.t |
| 4 | |
| 5 | # We should generate more tests for all possible combinations |
| 6 | # Map vtable method to op |
| 7 | my %methods = qw{ |
| 8 | add add |
| 9 | subtract sub |
| 10 | multiply mul |
| 11 | divide div |
| 12 | |
| 13 | floor_divide fdiv |
| 14 | modulus mod |
| 15 | pow pow |
| 16 | |
| 17 | bitwise_or bor |
| 18 | bitwise_and band |
| 19 | bitwise_xor bxor |
| 20 | |
| 21 | bitwise_shr shr |
| 22 | bitwise_shl shl |
| 23 | bitwise_lsr lsr |
| 24 | |
| 25 | concatenate concat |
| 26 | |
| 27 | logical_or or |
| 28 | logical_and and |
| 29 | logical_xor xor |
| 30 | }; |
| 31 | |
| 32 | # foreach my $pmc (@pmcs) { |
| 33 | while(my($vtable, $op) = each(%methods)) { |
| 34 | |
| 35 | print <<"END"; |
| 36 | .sub test_$vtable |
| 37 | .param pmc type |
| 38 | |
| 39 | \$P0 = new type |
| 40 | \$P0 = 40 |
| 41 | \$P1 = new type |
| 42 | \$P1 = 2 |
| 43 | \$P2 = new type |
| 44 | \$P2 = 115200 |
| 45 | |
| 46 | \$P99 = \$P2 |
| 47 | |
| 48 | \$S0 = "original dest is untouched in $vtable for " |
| 49 | \$S1 = type |
| 50 | concat \$S0, \$S1 |
| 51 | |
| 52 | # ignore exceptions |
| 53 | push_eh done |
| 54 | $op \$P2, \$P0, \$P1 |
| 55 | |
| 56 | \$I0 = cmp \$P99, 115200 |
| 57 | |
| 58 | is( \$I0, 0, \$S0 ) |
| 59 | goto end |
| 60 | |
| 61 | done: |
| 62 | ok(1, 'ignoring exceptions') |
| 63 | end: |
| 64 | .end |
| 65 | |
| 66 | END |
| 67 | |
| 68 | } |