develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33564 - in trunk/languages/lua: src/lib t

From:
fperrad
Date:
December 6, 2008 07:36
Subject:
[svn:parrot] r33564 - in trunk/languages/lua: src/lib t
Message ID:
20081206153646.A7B2ECB9AF@x12.develooper.com
Author: fperrad
Date: Sat Dec  6 07:36:45 2008
New Revision: 33564

Modified:
   trunk/languages/lua/src/lib/complex.pir
   trunk/languages/lua/t/complex.t

Log:
[Lua] complex
- more tests

Modified: trunk/languages/lua/src/lib/complex.pir
==============================================================================
--- trunk/languages/lua/src/lib/complex.pir	(original)
+++ trunk/languages/lua/src/lib/complex.pir	Sat Dec  6 07:36:45 2008
@@ -234,9 +234,7 @@
     .param pmc z :optional
     .param pmc extra :slurpy
     $P1 = get(1, z)
-    $N0 = $P1.'abs'()
-    new $P0, 'LuaNumber'
-    set $P0, $N0
+    $P0 = abs $P1
     .return ($P0)
 .end
 
@@ -441,7 +439,6 @@
 =cut
 
 .sub 'pow'
-    .param pmc extra :slurpy
     .param pmc z :optional
     .param pmc w :optional
     .param pmc extra :slurpy

Modified: trunk/languages/lua/t/complex.t
==============================================================================
--- trunk/languages/lua/t/complex.t	(original)
+++ trunk/languages/lua/t/complex.t	Sat Dec  6 07:36:45 2008
@@ -22,7 +22,7 @@
 use FindBin;
 use lib "$FindBin::Bin";
 
-use Parrot::Test tests => 7;
+use Parrot::Test tests => 25;
 use Parrot::Config;
 use Test::More;
 use Parrot::Test::Lua;
@@ -85,6 +85,154 @@
 /^[^:]+: [^:]+:\d+: bad argument #1 to 'real' \(number expected, got string\)\nstack traceback:\n/
 OUTPUT
 
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function abs' );
+require 'complex'
+z = complex.new(3, 4)
+a = z:abs()
+print(a)
+print(type(a))
+CODE
+5
+number
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function acos' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:acos())
+CODE
+0.936812-2.30551i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function acosh' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:acosh())
+CODE
+2.30551+0.936812i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function asin' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:asin())
+CODE
+0.633984+2.30551i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function asinh' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:asinh())
+CODE
+2.29991+0.917617i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function atan' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:atan())
+CODE
+1.44831+0.158997i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function atanh' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:atanh())
+CODE
+0.117501+1.40992i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function conj' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:conj())
+CODE
+3-4i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function cos' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:cos())
+CODE
+-27.0349-3.85115i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function cosh' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:cosh())
+CODE
+-6.58066-7.58155i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function exp' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:exp())
+CODE
+-13.1288-15.2008i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function log' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:log())
+CODE
+1.60944+0.927295i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function pow' );
+require 'complex'
+z = complex.new(3, 4)
+w = complex.new(2, 1)
+print(z:pow(w))
+CODE
+-9.38086-3.1341i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function sin' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:sin())
+CODE
+3.85374-27.0168i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function sinh' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:sinh())
+CODE
+-6.54812-7.61923i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function sqrt' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:sqrt())
+CODE
+2+1i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function tan' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:tan())
+CODE
+-0.000187346+0.999356i
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function tanh' );
+require 'complex'
+z = complex.new(3, 4)
+print(z:tanh())
+CODE
+1.00071+0.00490826i
+OUTPUT
+
 
 # Local Variables:
 #   mode: cperl



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About