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

santagada at codespeak.net santagada at codespeak.net
Sun Jan 14 11:01:20 CET 2007


Author: santagada
Date: Sun Jan 14 11:01:18 2007
New Revision: 36716

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:
semicolon works


Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py	(original)
+++ pypy/dist/pypy/lang/js/interpreter.py	Sun Jan 14 11:01:18 2007
@@ -752,9 +752,11 @@
         node = Script(getlist(t), var_decl, func_decl)
     elif tp == 'SEMICOLON':
         expr = gettreeitem(t, 'expression')
+        print expr
         if isinstance(expr, Symbol):
             node = Semicolon()
-        node = Semicolon(from_tree(expr))
+        else:
+            node = Semicolon(from_tree(expr))
     elif tp == 'STRING':
         node = String(gettreeitem(t, 'value').additional_info)
     elif tp == 'THIS':

Modified: pypy/dist/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/dist/pypy/lang/js/jsobj.py	(original)
+++ pypy/dist/pypy/lang/js/jsobj.py	Sun Jan 14 11:01:18 2007
@@ -275,26 +275,25 @@
                  Value=w_Undefined, callfunc=None):
         W_Object.__init__(self, ctx, Prototype, Class, Value, callfunc)
         self.Put('length', W_Number(0))
+        self.array = []
     
     def Put(self, P, V):
-        if not self.CanPut(P): return
-        if P in self.propdict:
-            self.propdict[P].value = V
-        else:
-            try:
-                x = int(P)
-            except ValueError:
-                x = -1
-            # FIXME: Get this working
-            # if x > self.Get('length'):
-            #     self.propdict['length'].value = W_Number(x)
-            self.propdict[P] = Property(P, V)
+        try:
+            x = int(P)
+            if x > self.Get('length').ToNumber():
+                self.propdict['length'].value = W_Number(x)
+        except ValueError:
+            if not self.CanPut(P): return
+            if P in self.propdict:
+                self.propdict[P].value = V
+            else:
+                self.propdict[P] = Property(P, V)
     
     def str_builtin(self, ctx, args, this):
         return W_String(ToString())
 
     def ToString(self):
-        return ''
+        return ','.join(self.array)
 
 
 class W_Boolean(W_Primitive):

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	Sun Jan 14 11:01:18 2007
@@ -335,6 +335,9 @@
     
     def test_switch(self):
         py.test.skip('not ready yet')
+    
+    def test_semicolon(self):
+        self.assert_prints(';', [])
 
     def test_newwithargs(self):
         self.assert_prints("""



More information about the Pypy-commit mailing list