Author: fijal
Date: Fri Apr 4 06:40:50 2008
New Revision: 53318
Modified:
pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py
Log:
Small fix + debugging tools
Modified: pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/interpreter.py (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/interpreter.py Fri Apr 4 06:40:50 2008
@@ -10,6 +10,7 @@
from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib.streamio import open_file_as_stream
from pypy.lang.js.jscode import JsCode
+from pypy.rlib.rarithmetic import NAN, INFINITY
ASTBUILDER = ASTBuilder()
@@ -64,6 +65,8 @@
def Call(self, ctx, args=[], this=None):
if len(args) >= 1 and not isnull_or_undefined(args[0]):
return W_FloatNumber(args[0].ToNumber())
+ elif isnull_or_undefined(args[0]):
+ return W_FloatNumber(NAN)
else:
return W_FloatNumber(0.0)
@@ -553,6 +556,9 @@
"""run the interpreter"""
bytecode = JsCode()
script.emit(bytecode)
+ if not we_are_translated():
+ # debugging
+ self._code = bytecode
if interactive:
return bytecode.run(self.global_context, retlast=True)
else:
Modified: pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py Fri Apr 4 06:40:50 2008
@@ -620,3 +620,6 @@
py.test.skip("I don't understand, but it does not work")
assertv("pypy_repr(3);", 'W_IntNumber')
assertv("pypy_repr(3.0);", 'W_FloatNumber')
+
+def test_number():
+ assertp("print(Number(void 0))", "NaN")