Add test for bug 507180
authorLuke Wagner <lw@mozilla.com>
Wed, 19 Aug 2009 09:36:25 -0700
changeset 31891 cf4c686996375acfb71d736351fb45c89cc4b812
parent 31890 40db1206d791574e2650f19d69b314707969100b
child 31892 5819b38a86861c70b8c97f4631ec00b693ab1b10
push idunknown
push userunknown
push dateunknown
bugs507180
milestone1.9.3a1pre
Add test for bug 507180
js/src/trace-test/tests/basic/bug507180.js
new file mode 100644
--- /dev/null
+++ b/js/src/trace-test/tests/basic/bug507180.js
@@ -0,0 +1,69 @@
+var o = {
+  valueOf : function() {
+    return {
+      toString : function() { return "fail" }
+    }
+  },
+  toString : function() { return "good" }
+};
+
+var p = {
+  valueOf : function() {
+    return {
+      toString : function() { return "0" }
+    }
+  },
+  toString : function() { return "7" }
+};
+
+var q = {
+  toString : function() {
+    return {
+      valueOf : function() { return "0" }
+    }
+  },
+  valueOf : function() { return "7" }
+};
+
+function assert(b, s) {
+    if (b)
+        return;
+    assertEq("imacro produces incorrect result for " + s, "fail");
+}
+
+function run() {
+    for (var i = 0; i < 5; ++i) {
+        // equality / inequality
+        assert(!(o == "fail"), "obj == any");
+        assert(!("fail" == o), "any == obj");
+        assert(!(o != "good"), "obj != any");
+        assert(!("good" != o), "any != obj");
+
+        // binary
+        assert(!((p | 3) != 7), "obj | any");
+        assert(!((3 | p) != 7), "any | obj");
+        assert(!((p | p) != 7), "obj | obj");
+        assert(!((p & 3) != 3), "obj & any");
+        assert(!((3 & p) != 3), "any & obj");
+        assert(!((p & p) != 7), "obj & obj");
+        assert(!((p * 3) != 21), "obj * any");
+        assert(!((3 * p) != 21), "any * obj");
+        assert(!((p * p) != 49), "obj * obj");
+
+        // addition
+        assert(!(o + "" != "good"), "obj + any");
+        assert(!("" + o != "good"), "any + obj");
+        assert(!(o + o != "goodgood"), "any + any");
+
+        // sign
+        assert(!(-p != -7), "-obj");
+        assert(!(+p != 7), "+obj");
+
+        // String
+        assert(!(String(q) != "7"), "String(obj)");
+        assert(!(new String(q) != "7"), "new String(obj)");
+    }
+    return true;
+}
+
+run();