[pypy-svn] r35921 - in pypy/dist/pypy/lang/js: . test
santagada at codespeak.net
santagada at codespeak.net
Wed Dec 20 19:06:41 CET 2006
Author: santagada
Date: Wed Dec 20 19:06:32 2006
New Revision: 35921
Modified:
pypy/dist/pypy/lang/js/interpreter.py
pypy/dist/pypy/lang/js/jsobj.py
pypy/dist/pypy/lang/js/test/test_interp.py
Log:
Finished the work on while loops and object literals
just one test is failing
Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py (original)
+++ pypy/dist/pypy/lang/js/interpreter.py Wed Dec 20 19:06:32 2006
@@ -118,7 +118,9 @@
class __extend__(If):
def call(self, ctx=None):
- if self.condition.call(ctx).ToBoolean():
+ temp = self.condition.call(ctx)
+ print "if condition = ", temp
+ if temp.ToBoolean():
return self.thenPart.call(ctx)
else:
return self.elsePart.call(ctx)
@@ -135,6 +137,7 @@
# TODO complete the funcion with strings comparison
s1 = x.ToPrimitive('Number')
s2 = y.ToPrimitive('Number')
+ print "ARC x = %s, y = %s"%(str(s1),str(s2))
if not (isinstance(s1, W_String) and isinstance(s2, W_String)):
s4 = s1.ToNumber()
s5 = s2.ToNumber()
@@ -162,6 +165,7 @@
s2 = self.left.call(ctx).GetValue()
s4 = self.right.call(ctx).GetValue()
s5 = ARC(s2, s4)
+ print "< ARC result = ", s5
if s5 is None:
return W_Boolean(False)
else:
Modified: pypy/dist/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/dist/pypy/lang/js/jsobj.py (original)
+++ pypy/dist/pypy/lang/js/jsobj.py Wed Dec 20 19:06:32 2006
@@ -210,6 +210,9 @@
return 1.0
return 0.0
+ def ToBoolean(self):
+ return self.boolval
+
class W_String(W_Primitive):
def __init__(self, strval):
self.strval = strval
@@ -237,7 +240,9 @@
return str(self.floatval)
def ToBoolean(self):
- return W_Boolean(bool(self.floatval))
+ if self.floatval == 0.0 or self.floatval == NaN:
+ return False
+ return bool(self.floatval)
def ToNumber(self):
return self.floatval
Modified: pypy/dist/pypy/lang/js/test/test_interp.py
==============================================================================
--- pypy/dist/pypy/lang/js/test/test_interp.py (original)
+++ pypy/dist/pypy/lang/js/test/test_interp.py Wed Dec 20 19:06:32 2006
@@ -233,9 +233,16 @@
print(o);
""", ["[object Object]"])
+ def test_function_name(self):
+ py.test.skip("not ready yet")
+ self.assert_prints("""
+ function x() {
+ print("my name is x");
+ }
+ x();
+ """, ["my name is x"])
+
def test_new_with_function(self):
-
-
c= """
x = function() {this.info = 'hello';};
o = new x();
More information about the Pypy-commit
mailing list