[pypy-svn] r47932 - in pypy/dist/pypy/lang/smalltalk: . test

oscar at codespeak.net oscar at codespeak.net
Thu Oct 25 15:59:24 CEST 2007


Author: oscar
Date: Thu Oct 25 15:59:23 2007
New Revision: 47932

Modified:
   pypy/dist/pypy/lang/smalltalk/primitives.py
   pypy/dist/pypy/lang/smalltalk/test/test_primitives.py
Log:
(cbolz, oscar) arctan primitive

Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py	Thu Oct 25 15:59:23 2007
@@ -201,6 +201,7 @@
 FLOAT_TRUNCATED = 51
 FLOAT_SQUARE_ROOT = 55
 FLOAT_SIN = 56
+FLOAT_ARCTAN = 57
 
 math_ops = {
     FLOAT_ADD: operator.add,
@@ -242,6 +243,13 @@
     w_res = objtable.wrap_float(math.sin(f))
     return w_res
 
+ at primitive(FLOAT_ARCTAN)
+ at stack(1)
+def func(args, (w_float,)): 
+    f = unwrap_float(w_float)
+    w_res = objtable.wrap_float(math.atan(f))
+    return w_res
+
 # ___________________________________________________________________________
 # Subscript and Stream Primitives
 

Modified: pypy/dist/pypy/lang/smalltalk/test/test_primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_primitives.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_primitives.py	Thu Oct 25 15:59:23 2007
@@ -295,3 +295,8 @@
     assert prim(p.FLOAT_SIN, [0.0]).value == 0.0
     assert float_equals(prim(p.FLOAT_SIN, [math.pi]), 0.0)
     assert float_equals(prim(p.FLOAT_SIN, [math.pi/2]), 1.0)
+
+def test_primitive_arctan():
+    assert prim(p.FLOAT_ARCTAN, [0.0]).value == 0.0
+    assert float_equals(prim(p.FLOAT_ARCTAN, [1]), math.pi/4)
+    assert float_equals(prim(p.FLOAT_ARCTAN, [1e99]), math.pi/2)



More information about the Pypy-commit mailing list