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

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

From:
fperrad
Date:
December 12, 2008 07:19
Subject:
[svn:parrot] r33832 - in trunk/languages/lua: src/lib t
Message ID:
20081212151911.436D5CB9AF@x12.develooper.com
Author: fperrad
Date: Fri Dec 12 07:19:10 2008
New Revision: 33832

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

Log:
[Lua] complex
- fix __unm

Modified: trunk/languages/lua/src/lib/complex.pir
==============================================================================
--- trunk/languages/lua/src/lib/complex.pir	(original)
+++ trunk/languages/lua/src/lib/complex.pir	Fri Dec 12 07:19:10 2008
@@ -221,8 +221,9 @@
     .param pmc z :optional
     .param pmc extra :slurpy
     $P1 = get(1, z)
-    $P0 = new $P1
-    .tailcall newcomplex($P0)
+    $P0 = neg $P1
+    $P0 = newcomplex($P0)
+    .return ($P0)
 .end
 
 

Modified: trunk/languages/lua/t/complex.t
==============================================================================
--- trunk/languages/lua/t/complex.t	(original)
+++ trunk/languages/lua/t/complex.t	Fri Dec 12 07:19:10 2008
@@ -22,7 +22,7 @@
 use FindBin;
 use lib "$FindBin::Bin";
 
-use Parrot::Test tests => 25;
+use Parrot::Test tests => 26;
 use Parrot::Config;
 use Test::More;
 use Parrot::Test::Lua;
@@ -85,6 +85,14 @@
 /^[^:]+: [^:]+:\d+: bad argument #1 to 'real' \(number expected, got string\)\nstack traceback:\n/
 OUTPUT
 
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'complex __unm' );
+require 'complex'
+z = complex.new(3, 4)
+print(-z)
+CODE
+-3-4i
+OUTPUT
+
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function abs' );
 require 'complex'
 z = complex.new(3, 4)



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