[svn:parrot] r39332 - branches/no_pmc_reuse/t/op

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Jun 2 10:46:42 UTC 2009


Author: bacek
Date: Tue Jun  2 10:46:41 2009
New Revision: 39332
URL: https://trac.parrot.org/parrot/changeset/39332

Log:
[t] Generate tests for 3-args arithmetic dest handling.

Modified:
   branches/no_pmc_reuse/t/op/arithmetics.t

Modified: branches/no_pmc_reuse/t/op/arithmetics.t
==============================================================================
--- branches/no_pmc_reuse/t/op/arithmetics.t	Tue Jun  2 09:42:20 2009	(r39331)
+++ branches/no_pmc_reuse/t/op/arithmetics.t	Tue Jun  2 10:46:41 2009	(r39332)
@@ -7,7 +7,7 @@
 use lib qw( . lib ../lib ../../lib );
 
 use Test::More;
-use Parrot::Test tests => 24;
+use Parrot::Test tests => 57;
 
 # test for GMP
 use Parrot::Config;
@@ -639,32 +639,68 @@
 -Inf
 OUTPUT
 
+# Map vtable method to op
+my %methods = qw{
+    add             add
+    subtract        sub
+    multiply        mul
+    divide          div
+
+    floor_divide    fdiv
+    modulus         mod
+    pow             pow
+
+    bitwise_or      bor
+    bitwise_and     band
+    bitwise_xor     bxor
+
+    bitwise_shr     shr
+    bitwise_shl     shl
+    bitwise_lsr     lsr
+
+    concatenate     concat
+
+    logical_or      or
+    logical_and     and
+    logical_xor     xor
+};
+
+# XXX Put BigInt and BigNum here 
+my @pmcs = qw{
+    Integer Float
+};
+
+foreach my $pmc (@pmcs) {
+    while(my($vtable, $op) = each(%methods)) {
+
 # We should generate more tests for all possible combinations
-pir_output_is( <<'CODE', <<OUTPUT, "Original dest is untouched in 3-args arithmetic" );
+pir_output_is( <<"CODE", <<OUTPUT, "Original dest is untouched in $pmc.$vtable " );
 .sub 'test' :main
-    $P0 = new 'Integer'
-    $P0 = 40
-    $P1 = new 'Integer'
-    $P1 = 2
-    $P2 = new 'Integer'
-
-    $P99 = $P2
-    $P2 = add $P0, $P1
-    say $P2
-    say $P99
-
-    $P99 = $P2
-    $P2  = concat $P0, $P1
-    say $P2
-    say $P99
+    \$P0 = new '$pmc'
+    \$P0 = 40
+    \$P1 = new '$pmc'
+    \$P1 = 2
+    \$P2 = new '$pmc'
+    \$P2 = 115200
+
+    \$P99 = \$P2
+    # ignore exceptions
+    push_eh done
+    $op \$P2, \$P0, \$P1
+
+    \$I0 = cmp \$P99, 115200
+    unless \$I0 goto done
+    print " not "
+  done:
+    say "ok"
 .end
 CODE
-42
-0
-402
-42
+ok
 OUTPUT
 
+    }
+}
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4


More information about the parrot-commits mailing list