Author: Stephan <[email protected]>
Branch: 
Changeset: r77:584e323a446d
Date: 2011-05-18 17:50 +0200
http://bitbucket.org/pypy/lang-js/changeset/584e323a446d/

Log:    I guess the type of W_Null should be 'null'. At least it fixes
        endless recursion when trying to compare 'string' to null.

diff --git a/js/jsobj.py b/js/jsobj.py
--- a/js/jsobj.py
+++ b/js/jsobj.py
@@ -109,7 +109,7 @@
         return "null"
 
     def type(self):
-        return 'object'
+        return 'null'
 
 w_Undefined = W_Undefined()
 w_Null = W_Null()
diff --git a/js/test/test_interp.py b/js/test/test_interp.py
--- a/js/test/test_interp.py
+++ b/js/test/test_interp.py
@@ -843,3 +843,14 @@
     }
     i;
     """, 2
+
+def test_compare_string_null():
+    assertv, """
+    var x;
+    if('a' == null){
+        x = true;
+    } else {
+        x = false;
+    }
+    x;
+    """, False
diff --git a/js/test/test_jsobj.py b/js/test/test_jsobj.py
--- a/js/test/test_jsobj.py
+++ b/js/test/test_jsobj.py
@@ -1,8 +1,5 @@
 import pytest
-from js.jsobj import W_IntNumber, W_FloatNumber, W_Object,\
-     w_Undefined, W_NewBuiltin, W_String, create_object, W_List,\
-     W_PrimitiveObject, ActivationObject, W_Array, W_Boolean,\
-     w_Null, W_BaseNumber, isnull_or_undefined
+from js.jsobj import W_IntNumber, W_FloatNumber, W_Null
 from js import interpreter
 
 def test_intnumber():
@@ -18,3 +15,6 @@
     ctx = jsint.w_Global
     assert n.ToInt32(ctx) == -0x80000000
     assert n.ToUInt32(ctx) == 0x80000000
+
+def test_type_null():
+    assert W_Null().type() == 'null'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to