# New Ticket Created by  Simon Glover 
# Please include the string:  [perl #15680]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=15680 >



 The patches below add tests for:

  * jsr

  * bor_i_i, bxor_i_i and band_i_i

  * not_i_i, or_i_i_i, and_i_i_i

  * eq_n_n

  * clone_s_s, set_i_s

  * inc_p, dec_p and unless_p

 and improves the test coverage for:

  * ne_i_i, eq_i_i

  * set_s_n


 Simon


--- t/op/basic.t.old    Mon Jul 22 19:18:19 2002
+++ t/op/basic.t        Mon Jul 22 19:21:11 2002
@@ -1,6 +1,6 @@
 #! perl -w

-use Parrot::Test tests => 14;
+use Parrot::Test tests => 15;

 # It would be very embarrassing if these didn't work...
 output_is(<<'CODE', '', "noop, end");
@@ -106,4 +106,17 @@ output_is(<<'CODE', 32, "Predeclared opc
      end
 CODE

+output_is(<<'CODE', <<'OUTPUT', "jsr");
+     set_addr I1, FOO
+     jsr I1
+     print "and back again\n"
+     end
+
+FOO: print "There "
+     ret
+
+CODE
+There and back again
+OUTPUT
+
 1; # HONK

--- t/op/bitwise.t.old  Mon Jul 22 20:59:52 2002
+++ t/op/bitwise.t      Mon Jul 22 21:10:23 2002
@@ -1,6 +1,6 @@
 #perl -w

-use Parrot::Test tests => 15;
+use Parrot::Test tests => 18;

 output_is(<<'CODE', <<'OUTPUT', "shr_i_i (>>)");
        set I0, 0b001100
@@ -142,7 +142,7 @@ CODE
 40
 OUTPUT

-output_is(<<'CODE', <<'OUTPUT', "bxor_i_i (~)");
+output_is(<<'CODE', <<'OUTPUT', "bxor_i_i (^)");
        set     I0, 0b001100
        set     I1, 0b100110
        bxor    I2, I0, I1
@@ -160,7 +160,7 @@ CODE
 12
 OUTPUT

-output_is(<<'CODE', <<'OUTPUT', "bxor_i_ic (~)");
+output_is(<<'CODE', <<'OUTPUT', "bxor_i_ic (^)");
        set I0, 0b001100
        bxor I2, I0, 0b100110
        print I2
@@ -177,6 +177,36 @@ CODE
 42
 OUTPUT

+output_is(<<'CODE', <<'OUTPUT', "bxor_i|ic (^)");
+       set I0, 0b001100
+        set I2, 0b000011
+       bxor I2, I0
+       print I2
+       print "\n"
+
+        set I2, 0b001100
+       bxor  I2, I0
+       print I2
+       print "\n"
+
+        set I2, 0b101010
+        bxor I2, I2
+       print I2
+       print "\n"
+
+        set I2, 0b010101
+        bxor I2, 0b000011
+       print I2
+       print "\n"
+
+       end
+CODE
+15
+0
+0
+22
+OUTPUT
+
 output_is(<<'CODE', <<'OUTPUT', "band_i_i (&)");
        set     I0, 0b001100
        set     I1, 0b010110
@@ -212,6 +242,36 @@ CODE
 4
 OUTPUT

+output_is(<<'CODE', <<'OUTPUT', "band_i|ic (&)");
+       set I0, 0b001100
+        set I2, 0b000011
+       band I2, I0
+       print I2
+       print "\n"
+
+        set I2, 0b001100
+       band  I2, I0
+       print I2
+       print "\n"
+
+        set I2, 0b101010
+        band I2, I2
+       print I2
+       print "\n"
+
+        set I2, 0b010101
+        band I2, 0b000011
+       print I2
+       print "\n"
+
+       end
+CODE
+0
+12
+42
+1
+OUTPUT
+
 output_is(<<'CODE', <<'OUTPUT', "bor_i_i (|)");
        set I0, 0b001100
        set I1, 0b010110
@@ -247,6 +307,36 @@ CODE
 30
 OUTPUT

+output_is(<<'CODE', <<'OUTPUT', "bor_i|ic (|)");
+       set I0, 0b001100
+        set I2, 0b000011
+       bor I2, I0
+       print I2
+       print "\n"
+
+        set I2, 0b001100
+       bor  I2, I0
+       print I2
+       print "\n"
+
+        set I2, 0b101010
+        bor I2, I2
+       print I2
+       print "\n"
+
+        set I2, 0b010101
+        bor I2, 0b000011
+       print I2
+       print "\n"
+
+       end
+CODE
+15
+12
+42
+23
+OUTPUT
+
 # use C<and> to only check low order bits, this should be platform nice
 output_is(<<'CODE', <<'OUTPUT', "bnot_i (~)");
        set     I0, 0b001100

--- t/op/integer.t.old  Mon Jul 22 19:40:51 2002
+++ t/op/integer.t      Mon Jul 22 20:13:51 2002
@@ -1,6 +1,6 @@
 #! perl -w

-use Parrot::Test tests => 35;
+use Parrot::Test tests => 39;

 output_is(<<CODE, <<OUTPUT, "set_i_ic");
        # XXX: Need a test for writing outside the set of available
@@ -439,6 +439,8 @@ output_is(<<CODE, <<OUTPUT, "eq i, i|ic
        print   "done 2\\n"
        bsr     BR3
        print   "done 3\\n"
+        bsr     BR4
+        print   "Shouldn't get here \\n"

        end

@@ -454,11 +456,16 @@ BR3:      eq      I0, I1
        print   "not equal, equal int regs "
        ret

+BR4:    eq      12, 13
+        print   "done 4\\n"
+        end
+
 CODE
 the word
 done 1
 done 2
 done 3
+done 4
 OUTPUT

 output_is(<<CODE, <<OUTPUT, "ne_i_ic");
@@ -525,6 +532,8 @@ output_is(<<CODE, <<OUTPUT, "ne ic, i (p
        print   "done 2\\n"
        bsr     BR3
        print   "done 3\\n"
+        bsr     BR4
+        print   "Shouldn't get here\\n"

        end

@@ -539,11 +548,17 @@ BR2:      ne      10, 12
 BR3:   ne      I0, I1
        print   "10 is 12, even when in I reg "
        ret
+
+BR4:    ne      12, 12
+        print   "done 4\\n"
+        end
+
 CODE
 start
 done 1
 done 2
 done 3
+done 4
 OUTPUT

 output_is(<<CODE, <<OUTPUT, "lt_i_ic");
@@ -822,6 +837,141 @@ ok 2
 ok 3
 OUTPUT

+output_is(<<'CODE', <<OUTPUT, "not_i_i");
+        set I0, 1
+        not I1, I0
+        print I1
+        print "\n"
+
+        not I2, I1
+        print I2
+        print "\n"
+
+        set I3, 12345
+        not I4, I3
+        print I4
+        print "\n"
+
+        set I5, -1
+        not I6, I5
+        print I6
+        print "\n"
+
+        not I7, 0
+        print I7
+        print "\n"
+        not I7, 1
+        print I7
+        print "\n"
+
+        end
+CODE
+0
+1
+0
+0
+1
+0
+OUTPUT
+
+output_is(<<'CODE', <<OUTPUT, "and");
+        set I0, 0
+        set I1, 10
+
+        set I2, 1
+        and I2, I1, I0
+        print I2
+        print "\n"
+
+        set I2, 1
+        and I2, I0, I1
+        print I2
+        print "\n"
+
+        set I2, 1
+        and I2, I0, I0
+        print I2
+        print "\n"
+
+        set I2, 1
+        and I2, I2, I1
+        print I2
+        print "\n"
+
+        end
+CODE
+0
+0
+0
+10
+OUTPUT
+
+output_is(<<'CODE', <<OUTPUT, "or");
+        set I0, 0
+        set I1, 10
+
+        set I2, 42
+        or I2, I1, I0
+        print I2
+        print "\n"
+
+        set I2, 42
+        or I2, I0, I1
+        print I2
+        print "\n"
+
+        or I2, I0, I0
+        print I2
+        print "\n"
+
+        or I2, I2, I1
+        print I2
+        print "\n"
+
+        end
+CODE
+10
+10
+0
+10
+OUTPUT
+
+output_is(<<'CODE', <<OUTPUT, "xor");
+        set I0, 0
+        set I1, 2
+
+        set I2, 42
+        xor I2, I1, I0
+        print I2
+        print "\n"
+
+        set I2, 42
+        xor I2, I0, I1
+        print I2
+        print "\n"
+
+        xor I2, I0, I0
+        print I2
+        print "\n"
+
+        xor I2, I1, I1
+        print I2
+        print "\n"
+
+        set I2, 1
+        xor I2, I2, I2
+        print I2
+        print "\n"
+
+        end
+CODE
+2
+2
+0
+0
+0
+OUTPUT
+
 output_is(<<CODE, <<OUTPUT, "inc_i");
        set     I0, 0

--- t/op/number.t.old   Mon Jul 22 20:38:06 2002
+++ t/op/number.t       Mon Jul 22 20:44:20 2002
@@ -1,6 +1,6 @@
 #! perl -w

-use Parrot::Test tests => 32;
+use Parrot::Test tests => 33;
 use Test::More;

 output_is(<<CODE, <<OUTPUT, "set_n_nc");
@@ -386,6 +386,59 @@ ok 1
 ok 2
 OUTPUT

+output_is(<<'CODE', <<OUTPUT, "eq_n");
+        set     N0, 1.234567
+        set     N1, 1.234567
+        set     N2, 0.3
+
+        bsr     BR1
+        print   "ok 1\n"
+        bsr     BR2
+        print   "ok 2\n"
+        bsr     BR3
+        print   "ok 3\n"
+        bsr     BR4
+        print   "ok 4\n"
+        bsr     BR5
+        print   "ok 5\n"
+        bsr     BR6
+        print   "Shouldn't get here\n"
+        end
+
+BR1:    eq N0, N1
+        print "not ok 1\n"
+        ret
+
+BR2:    eq N0, N0
+        print "not ok 2\n"
+        ret
+
+BR3:    eq 1.234567, N0
+        print "not ok 3\n"
+        ret
+
+BR4:    eq N0, 1.234567
+        print "not ok 4\n"
+        ret
+
+BR5:    eq 1.234567, 1.234567
+        print "not ok 5\n"
+        ret
+
+BR6:    eq N0, N2
+        print "ok 6\n"
+        end
+
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+ok 6
+OUTPUT
+
+
 output_is(<<CODE, <<OUTPUT, "ne_n_ic");
        set     N0, -22.222222
        set     N1, -22.222222

--- t/op/string.t.old   Mon Jul 22 20:15:12 2002
+++ t/op/string.t       Mon Jul 22 20:36:15 2002
@@ -1,6 +1,6 @@
 #! perl -w

-use Parrot::Test tests => 85;
+use Parrot::Test tests => 87;
 use Test::More;

 output_is( <<'CODE', <<OUTPUT, "set_s_s|sc" );
@@ -14,6 +14,26 @@ JAPH
 JAPH
 OUTPUT

+output_is( <<'CODE', <<OUTPUT, "clone" );
+        set     S0, "Foo\n"
+       clone   S1, S0
+        print   S0
+       print   S1
+
+       clone   S1, "Bar\n"
+       print   S1
+        chopn   S1, 1   # Check that the contents of S1 are no longer constant
+       print   S1
+        print   "\n"
+
+       end
+CODE
+Foo
+Foo
+Bar
+Bar
+OUTPUT
+
 output_is( <<'CODE', '4', "length_i_s" );
        set     I4, 0
        set     S4, "JAPH"
@@ -1218,16 +1238,58 @@ CODE
 -1
 OUTPUT

-output_is(<<'CODE',<<OUTPUT,"string to num");
+output_is(<<'CODE',<<OUTPUT,"num to string");
     set N0, 80.43
     set S0, N0
     print S0
     print "\n"
+
+    set N0, -1.111111
+    set S0, N0
+    print S0
+    print "\n"
     end
 CODE
 80.430000
+-1.111111
 OUTPUT

+output_is(<<'CODE', <<OUTPUT, "string to int");
+       set     S0, "123"
+       set     I0, S0
+       print   I0
+       print   "\n"
+
+       set     S0, " 1"
+       set     I0, S0
+       print   I0
+       print   "\n"
+
+       set     S0, "-1"
+       set     I0, S0
+       print   I0
+       print   "\n"
+
+        set     S0, "Not a number"
+       set     I0, S0
+       print   I0
+       print   "\n"
+
+       set     S0, ""
+       set     I0, S0
+       print   I0
+       print   "\n"
+
+       end
+CODE
+123
+1
+-1
+0
+0
+OUTPUT
+
+
 # Set all string registers to values given by &$_[0](reg num)
 sub set_str_regs {
   my $code = shift;

--- t/pmc/pmc.t.old     Mon Jul 22 20:46:19 2002
+++ t/pmc/pmc.t Sat Jul 27 14:17:01 2002
@@ -1,6 +1,6 @@
 #! perl -w

-use Parrot::Test tests => 60;
+use Parrot::Test tests => 65;
 use Test::More;

 my $fp_equality_macro = <<'ENDOFMACRO';
@@ -934,6 +934,26 @@ ok 1
 ok 2
 OUTPUT

+output_is(<<CODE, <<OUTPUT, "unless (P) - Int");
+       new     P0, .PerlInt
+
+       set     P0, 0
+       unless  P0, OK1
+       print   "not "
+OK1:   print   "ok 1\\n"
+
+       set     P0, 1
+       unless  P0, BAD2
+       branch OK2
+BAD2:  print   "not "
+OK2:   print   "ok 2\\n"
+
+       end
+CODE
+ok 1
+ok 2
+OUTPUT
+
 output_is(<<CODE, <<OUTPUT, "if (P) - Num");
        new     P0, .PerlInt

@@ -954,6 +974,26 @@ ok 1
 ok 2
 OUTPUT

+output_is(<<CODE, <<OUTPUT, "unless (P) - Num");
+       new     P0, .PerlInt
+
+       set     P0, 0.0
+       unless  P0, OK1
+       print   "not "
+OK1:   print   "ok 1\\n"
+
+       set     P0, 1.1
+       unless  P0, BAD2
+       branch OK2
+BAD2:  print   "not "
+OK2:   print   "ok 2\\n"
+
+       end
+CODE
+ok 1
+ok 2
+OUTPUT
+
 output_is(<<CODE, <<OUTPUT, "if (P) - String");
        new     P0, .PerlString

@@ -1017,6 +1057,26 @@ ok 8
 ok 9
 OUTPUT

+output_is(<<CODE, <<OUTPUT, "unless (P) - String");
+       new     P0, .PerlString
+
+        set     P0, "0"
+        unless  P0, OK1
+        print   "not"
+OK1:   print   "ok 1\\n"
+
+       set     P0, "1"
+       unless  P0, BAD2
+        branch  OK2
+BAD2:  print   "not "
+OK2:   print   "ok 2\\n"
+
+       end
+CODE
+ok 1
+ok 2
+OUTPUT
+
 output_is(<<"CODE", <<'OUTPUT', "undef-logical");
        new P0, .PerlUndef
        new P1, .PerlUndef
@@ -1337,4 +1397,42 @@ ok 1
 ok 2
 OUTPUT

+output_is(<<'CODE', <<OUTPUT, "inc, PerlInt");
+    new P3, .PerlInt
+    set P3, 0
+    inc P3
+    print P3
+    print "\n"
+
+LP: inc P3
+    set I3, P3
+    lt I3, 1000, LP
+    print P3
+    print "\n"
+
+    end
+CODE
+1
+1000
+OUTPUT
+
+output_is(<<'CODE', <<OUTPUT, "dec, PerlInt");
+    new P3, .PerlInt
+    set P3, 0
+    dec P3
+    print P3
+    print "\n"
+
+LP: dec P3
+    set I3, P3
+    gt I3, -2000, LP
+    print P3
+    print "\n"
+
+    end
+CODE
+-1
+-2000
+OUTPUT
+
 1;



Reply via email to