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

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

From:
fperrad
Date:
December 6, 2008 02:06
Subject:
[svn:parrot] r33547 - in trunk/languages/lua: src/lib t
Message ID:
20081206100611.8AC3CCB9AF@x12.develooper.com
Author: fperrad
Date: Sat Dec  6 02:06:06 2008
New Revision: 33547

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

Log:
[Lua] mathx
- more tests

Modified: trunk/languages/lua/src/lib/mathx.pir
==============================================================================
--- trunk/languages/lua/src/lib/mathx.pir	(original)
+++ trunk/languages/lua/src/lib/mathx.pir	Sat Dec  6 02:06:06 2008
@@ -264,18 +264,16 @@
     $P0 = argv[0]
     i = 1
     lua_checknumber(i, $P0)
-    m = clone $P0
+    m = $P0
   L1:
     if i >= argc goto L2
     $P0 = argv[i]
     inc i
     lua_checknumber(i, $P0)
-    y = clone $P0
-    m = m.'fmax'(y)
+    m = m.'fmax'($P0)
     goto L1
   L2:
-    $P0 = clone m
-    .return ($P0)
+    .return (m)
 .end
 
 
@@ -292,18 +290,16 @@
     $P0 = argv[0]
     i = 1
     lua_checknumber(i, $P0)
-    m = clone $P0
+    m = $P0
   L1:
     if i >= argc goto L2
     $P0 = argv[i]
     inc i
     lua_checknumber(i, $P0)
-    y = clone $P0
-    m = m.'fmin'(y)
+    m = m.'fmin'($P0)
     goto L1
   L2:
-    $P0 = clone m
-    .return ($P0)
+    .return (m)
 .end
 
 

Modified: trunk/languages/lua/t/mathx.t
==============================================================================
--- trunk/languages/lua/t/mathx.t	(original)
+++ trunk/languages/lua/t/mathx.t	Sat Dec  6 02:06:06 2008
@@ -22,7 +22,7 @@
 use FindBin;
 use lib "$FindBin::Bin";
 
-use Parrot::Test tests => 23;
+use Parrot::Test tests => 37;
 use Parrot::Config;
 use Test::More;
 use Parrot::Test::Lua;
@@ -85,6 +85,13 @@
 /^1\.259/
 OUTPUT
 
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function copysign' );
+require 'mathx'
+print(math.copysign(3.14, -2))
+CODE
+/^-3\.14/
+OUTPUT
+
 language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function erf' );
 require 'mathx'
 print(math.erf(2))
@@ -113,6 +120,42 @@
 /^6\.389/
 OUTPUT
 
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function fdim' );
+require 'mathx'
+print(math.fdim(7, 3))
+CODE
+/^4$/
+OUTPUT
+
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function fma' );
+require 'mathx'
+print(math.fma(2, 3, 4))
+CODE
+/^10$/
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function fmax' );
+require 'mathx'
+print(math.fmax(1))
+print(math.fmax(1, 2))
+print(math.fmax(1, 2, 3, -4))
+CODE
+1
+2
+3
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function fmin' );
+require 'mathx'
+print(math.fmin(1))
+print(math.fmin(1, 2))
+print(math.fmin(1, 2, 3, -4))
+CODE
+1
+1
+-4
+OUTPUT
+
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function fpclassify' );
 require 'mathx'
 print(math.fpclassify(1))
@@ -197,6 +240,71 @@
 /^5$/
 OUTPUT
 
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function nearbyint' );
+require 'mathx'
+print(math.nearbyint(3.14))
+CODE
+/^3$/
+OUTPUT
+
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function nextafter' );
+require 'mathx'
+print(math.nextafter(3.14, 5))
+CODE
+/^3\.14$/
+OUTPUT
+
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function nexttoward' );
+require 'mathx'
+print(math.nexttoward(3.14, 5))
+CODE
+/^3\.14$/
+OUTPUT
+
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function remainder' );
+require 'mathx'
+print(math.remainder(4, 3))
+CODE
+/^1$/
+OUTPUT
+
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function rint' );
+require 'mathx'
+print(math.rint(3.14))
+CODE
+/^3$/
+OUTPUT
+
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function round' );
+require 'mathx'
+print(math.round(3.14))
+CODE
+/^3$/
+OUTPUT
+
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function scalbn' );
+require 'mathx'
+print(math.scalbn(2, 3))
+CODE
+/^16$/
+OUTPUT
+
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function signbit' );
+require 'mathx'
+print(math.signbit(3.14))
+print(math.signbit(-3.14))
+CODE
+0
+1
+OUTPUT
+
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function trunc' );
+require 'mathx'
+print(math.trunc(3.14))
+CODE
+/^3$/
+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