[pypy-commit] lang-js default: 15.8.2.1
stepahn
noreply at buildbot.pypy.org
Fri Dec 28 11:33:45 CET 2012
Author: Stephan <stephan at stzal.com>
Branch:
Changeset: r205:6016a8ebb2e5
Date: 2012-05-22 16:50 +0200
http://bitbucket.org/pypy/lang-js/changeset/6016a8ebb2e5/
Log: 15.8.2.1
diff --git a/js/builtins_math.py b/js/builtins_math.py
--- a/js/builtins_math.py
+++ b/js/builtins_math.py
@@ -11,13 +11,13 @@
w_Math = W_Math()
put_property(global_object, 'Math', w_Math)
- put_native_function(w_Math, 'abs', js_abs)
+ put_native_function(w_Math, 'abs', js_abs, params = ['x'])
put_native_function(w_Math, 'floor', floor)
put_native_function(w_Math, 'round', js_round)
put_native_function(w_Math, 'random', random)
put_native_function(w_Math, 'min', js_min)
put_native_function(w_Math, 'max', js_max)
- put_native_function(w_Math, 'pow', pow)
+ put_native_function(w_Math, 'pow', js_pow)
put_native_function(w_Math, 'sqrt', sqrt)
put_native_function(w_Math, 'log', log)
@@ -62,8 +62,13 @@
# 15.8.2.1
def js_abs(this, args):
- val = args[0]
- return abs(val.ToNumber())
+ arg0 = get_arg(args, 0)
+ x = arg0.ToNumber()
+
+ if isnan(x):
+ return NAN
+
+ return abs(x)
# 15.8.2.15
def js_round(this, args):
@@ -73,7 +78,7 @@
isinstance(i, int) and i % 2 == 1
# 15.8.2.13
-def pow(this, args):
+def js_pow(this, args):
w_x = get_arg(args, 0)
w_y = get_arg(args, 1)
x = w_x.ToNumber()
More information about the pypy-commit
mailing list