Author: bernhard
Date: Sun Nov  4 09:39:41 2007
New Revision: 22704

Modified:
   trunk/languages/scheme/t/arith/basic.t
   trunk/languages/scheme/t/logic/basic.t

Log:
[Scheme]
Add test with complex numbers.
Add tests for number type hierarchy.
42 failures.


Modified: trunk/languages/scheme/t/arith/basic.t
==============================================================================
--- trunk/languages/scheme/t/arith/basic.t      (original)
+++ trunk/languages/scheme/t/arith/basic.t      Sun Nov  4 09:39:41 2007
@@ -8,7 +8,7 @@
 use FindBin;
 use lib "$FindBin::Bin/../../lib";
 
-use Test::More     tests => 22;
+use Test::More     tests => 23;
 
 use Parrot::Test;
 
@@ -120,6 +120,15 @@
 (write (abs -7))
 CODE
 
+###
+### complex arithmetics
+###
+
+language_output_is( 'Scheme', <<'CODE', '3+3i', 'adding two complex numbers' );
+(write (+ 1+1i 2+2i))
+CODE
+
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4

Modified: trunk/languages/scheme/t/logic/basic.t
==============================================================================
--- trunk/languages/scheme/t/logic/basic.t      (original)
+++ trunk/languages/scheme/t/logic/basic.t      Sun Nov  4 09:39:41 2007
@@ -8,7 +8,7 @@
 use FindBin;
 use lib "$FindBin::Bin/../../lib";
 
-use Test::More tests => 371;
+use Test::More tests => 416;
 
 use Parrot::Test;
 
@@ -105,6 +105,45 @@
     }
 }
 
+# numeric tower
+# Testing numeric types.
+# Tests for types that are higher than $lowest_type are true.
+# Tests for the $lowest_type are true.
+# Tests for types that are lower than $lowest_type are false.
+{
+    my @numeric_types = qw(number complex real rational integer );  # high to 
low
+    my %object = (
+        number      => [ 
+                       ],
+        complex     => [ q{0+3i},
+                         q{3+4i},
+                         q{3+4i},
+                       ],
+        real        => [ 
+                       ],
+        rational    => [ 
+                       ],
+        integer     => [ -1,
+                         -0,
+                          0,
+                         +0,
+                         +1,
+                          1
+                       ]
+    );   
+  
+    foreach my $lowest_type ( @numeric_types ) {
+        my $expected = '#t';
+        foreach my $predicate ( @numeric_types ) {
+            foreach my $object ( @{ $object{$lowest_type} } ) {
+                my $code = qq{ (write ($predicate? $object)) };
+                language_output_is( 'Scheme', $code, $expected, 
"expected_type: $code" );
+            }
+            if ( $predicate eq $lowest_type ) { $expected = '#f'; }
+        }
+    }
+}
+
 ###
 ### and
 ###

Reply via email to