[pypy-svn] r53319 - in pypy/branch/js-refactoring/pypy/lang/js: . test/ecma

fijal at codespeak.net fijal at codespeak.net
Fri Apr 4 06:54:31 CEST 2008


Author: fijal
Date: Fri Apr  4 06:54:29 2008
New Revision: 53319

Modified:
   pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
   pypy/branch/js-refactoring/pypy/lang/js/jscode.py
   pypy/branch/js-refactoring/pypy/lang/js/jsobj.py
   pypy/branch/js-refactoring/pypy/lang/js/test/ecma/shell.js
Log:
* Minor fixes for getting tests right
* Print test name


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:54:29 2008
@@ -63,9 +63,11 @@
 
 class W_NumberObject(W_NativeObject):
     def Call(self, ctx, args=[], this=None):
+        import pdb
+        pdb.set_trace()
         if len(args) >= 1 and not isnull_or_undefined(args[0]):
             return W_FloatNumber(args[0].ToNumber())
-        elif isnull_or_undefined(args[0]):
+        elif len(args) >= 1 and args[0] is w_Undefined:
             return W_FloatNumber(NAN)
         else:
             return W_FloatNumber(0.0)

Modified: pypy/branch/js-refactoring/pypy/lang/js/jscode.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/jscode.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/jscode.py	Fri Apr  4 06:54:29 2008
@@ -15,8 +15,11 @@
 
 def run_bytecode(opcodes, ctx, stack, check_stack=True, retlast=False):
     if retlast:
-        assert opcodes[-1] == 'POP'
-        opcodes.pop()
+        if opcodes[-1] == 'POP':
+            opcodes.pop()
+            popped = True
+        else:
+            popped = False
     i = 0
     to_pop = 0
     try:
@@ -41,8 +44,12 @@
             ctx.pop_object()
 
     if retlast:
-        assert len(stack) == 1
-        return stack[0]
+        if popped:
+            assert len(stack) == 1
+            return stack[0]
+        else:
+            assert not stack
+            return w_Undefined
     if check_stack:
         assert not stack
 

Modified: pypy/branch/js-refactoring/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/jsobj.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/jsobj.py	Fri Apr  4 06:54:29 2008
@@ -46,10 +46,10 @@
         return self
 
     def ToNumber(self):
-        return NaN
+        return 0.0
     
     def ToInt32(self):
-        return 0
+        return int(self.ToNumber())
     
     def ToUInt32(self):
         return r_uint(0)
@@ -393,6 +393,14 @@
     def GetPropertyName(self):
         return self.ToString()
 
+    def ToNumber(self):
+        if not self.strval:
+            return 0.0
+        try:
+            return float(self.strval)
+        except ValueError:
+            return NaN
+
 class W_BaseNumber(W_Primitive):
     """ Base class for numbers, both known to be floats
     and those known to be integers

Modified: pypy/branch/js-refactoring/pypy/lang/js/test/ecma/shell.js
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/test/ecma/shell.js	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/test/ecma/shell.js	Fri Apr  4 06:54:29 2008
@@ -77,6 +77,7 @@
   this.actual      = a;
   this.passed      = true;
   this.reason      = "";
+  print (n, d, e, a);
   this.bugnumber   = BUGNUMBER;
 
   this.passed = getTestCaseResult( this.expect, this.actual );



More information about the Pypy-commit mailing list