[pypy-svn] r42016 - in pypy/dist/pypy/lang/js: . test

santagada at codespeak.net santagada at codespeak.net
Fri Apr 13 03:03:43 CEST 2007


Author: santagada
Date: Fri Apr 13 03:03:43 2007
New Revision: 42016

Modified:
   pypy/dist/pypy/lang/js/jsobj.py
   pypy/dist/pypy/lang/js/operations.py
   pypy/dist/pypy/lang/js/test/test_interp.py
Log:
added the creation of a default prototype object


Modified: pypy/dist/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/dist/pypy/lang/js/jsobj.py	(original)
+++ pypy/dist/pypy/lang/js/jsobj.py	Fri Apr 13 03:03:43 2007
@@ -492,7 +492,6 @@
     else:
         ctx.this = this
     ctx.property = Property('', w_Undefined, dd=True)
-    print ctx
     return ctx
     
 def eval_context(calling_context):
@@ -530,5 +529,5 @@
         return self.property_name
 
     def __str__(self):
-        return "< " + str(self.base) + " -> " + str(self.property_name) + " >"
+        return "<" + str(self.base) + " -> " + str(self.property_name) + ">"
     

Modified: pypy/dist/pypy/lang/js/operations.py
==============================================================================
--- pypy/dist/pypy/lang/js/operations.py	(original)
+++ pypy/dist/pypy/lang/js/operations.py	Fri Apr 13 03:03:43 2007
@@ -283,6 +283,7 @@
 
     def eval(self, ctx):
        w_obj = W_Object(ctx=ctx, callfunc = self)
+       w_obj.Put('prototype', W_Object(ctx=ctx))
        return w_obj
 
 class Identifier(Expression):
@@ -654,8 +655,6 @@
 class BinaryNumberOp(BinaryOp):
     def eval(self, ctx):
         nleft = self.left.eval(ctx).GetValue().ToPrimitive(ctx, 'Number')
-        print "context now is:"
-        print ctx
         nright = self.right.eval(ctx).GetValue().ToPrimitive(ctx, 'Number')
         result = self.mathop(ctx, nleft, nright)
         return result

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	Fri Apr 13 03:03:43 2007
@@ -510,21 +510,19 @@
         """, ['0', '1'])
 
     def test_recursive_call(self):
-        #py.test.skip()
         self.assert_prints("""
-        function f(x) { if (x == 0) { return 1; } else { return f(x-1)*x; }}
-        print(f(1))
-        """, ['1',])
+        function fact(x) { if (x == 0) { return 1; } else { return fact(x-1)*x; }}
+        print(fact(3))
+        """, ['6',])
     
     def test_function_prototype(self):
-        py.test.skip()
         self.assert_prints("""
         function foo() {}; foo.prototype.bar = function() {}
-        """, ['',])
+        """, [])
 
 
     def test_function_this(self):
         py.test.skip()
         self.assert_prints("""
-        function foo() {this.bar = function() {}}; var f = new foo(); f.bar();
+        function foo() {print("debug");this.bar = function() {}}; var f = new foo(); f.bar();
         """, ['',])



More information about the Pypy-commit mailing list