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

santagada at codespeak.net santagada at codespeak.net
Tue May 22 01:44:19 CEST 2007


Author: santagada
Date: Tue May 22 01:44:18 2007
New Revision: 43548

Modified:
   pypy/dist/pypy/lang/js/jsobj.py
   pypy/dist/pypy/lang/js/jsparser.py
   pypy/dist/pypy/lang/js/test/test_interp.py
   pypy/dist/pypy/lang/js/test/test_parser.py
Log:
fixed some test on test_interp and aplied a nice patch from Amaury Forgeot 
d'Arc <amauryfa at gmail.com> to make js interp tests not fail on windows, and
made it more compliant to the js spec


Modified: pypy/dist/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/dist/pypy/lang/js/jsobj.py	(original)
+++ pypy/dist/pypy/lang/js/jsobj.py	Tue May 22 01:44:18 2007
@@ -389,14 +389,19 @@
         return str(self.floatval)+"W"
         
     def ToString(self):
-        if str(self.floatval) == str(NaN):
+        floatstr = str(self.floatval)
+        if floatstr == str(NaN):
             return 'NaN'
+        if floatstr == str(Infinity):
+            return 'Infinity'
+        if floatstr == str(-Infinity):
+            return '-Infinity'
         try:
             if float(int(self.floatval)) == self.floatval:
                 return str(int(self.floatval))
         except OverflowError, e:
             pass
-        return str(self.floatval)
+        return floatstr
     
     def ToBoolean(self):
         if self.floatval == 0.0 or str(self.floatval) == str(NaN):

Modified: pypy/dist/pypy/lang/js/jsparser.py
==============================================================================
--- pypy/dist/pypy/lang/js/jsparser.py	(original)
+++ pypy/dist/pypy/lang/js/jsparser.py	Tue May 22 01:44:18 2007
@@ -5,7 +5,7 @@
 GFILE = py.magic.autopath().dirpath().join("jsgrammar.txt")
 
 try:
-    t = GFILE.read()
+    t = GFILE.read(mode='U')
     regexs, rules, ToAST = parse_ebnf(t)
 except ParseError,e:
     print e.nice_error_message(filename=str(GFILE),source=t)

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	Tue May 22 01:44:18 2007
@@ -230,11 +230,11 @@
     
 def test_if_then():
     py.test.skip("not ready yet")
-    assert_prints("""
+    assertp("""
     if (1) {
         print(1);
     }
-    """, ["1"])
+    """, "1")
 
 def test_if_then_else():
     py.test.skip("not ready yet")
@@ -435,14 +435,15 @@
     print(Math.floor(3.2));
     print(null);
     print(-z);
-    """, ['10', '2', 'false', '3', 'NaN', 'inf', '-inf', '3', '', '-2'])
+    """, ['10', '2', 'false', '3', 'NaN', 'Infinity', '-Infinity',
+    '3', '', '-2'])
     
 def test_globalproperties():
     assertp( """
     print(NaN);
     print(Infinity);
     print(undefined);
-    """, ['NaN', 'inf', 'undefined'])
+    """, ['NaN', 'Infinity', 'undefined'])
 
 def test_strangefunc():
     py.test.skip("not ready yet")

Modified: pypy/dist/pypy/lang/js/test/test_parser.py
==============================================================================
--- pypy/dist/pypy/lang/js/test/test_parser.py	(original)
+++ pypy/dist/pypy/lang/js/test/test_parser.py	Tue May 22 01:44:18 2007
@@ -12,7 +12,7 @@
 GFILE = py.magic.autopath().dirpath().dirpath().join("jsgrammar.txt")
 
 try:
-    t = GFILE.read()
+    t = GFILE.read(mode='U')
     regexs, rules, ToAST = parse_ebnf(t)
 except ParseError,e:
     print e.nice_error_message(filename=str(GFILE),source=t)



More information about the Pypy-commit mailing list