js/src/jit-test/tests/basic/bug507180.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 var o = {
michael@0 2 valueOf : function() {
michael@0 3 return {
michael@0 4 toString : function() { return "fail" }
michael@0 5 }
michael@0 6 },
michael@0 7 toString : function() { return "good" }
michael@0 8 };
michael@0 9
michael@0 10 var p = {
michael@0 11 valueOf : function() {
michael@0 12 return {
michael@0 13 toString : function() { return "0" }
michael@0 14 }
michael@0 15 },
michael@0 16 toString : function() { return "7" }
michael@0 17 };
michael@0 18
michael@0 19 var q = {
michael@0 20 toString : function() {
michael@0 21 return {
michael@0 22 valueOf : function() { return "0" }
michael@0 23 }
michael@0 24 },
michael@0 25 valueOf : function() { return "7" }
michael@0 26 };
michael@0 27
michael@0 28 function assert(b, s) {
michael@0 29 if (b)
michael@0 30 return;
michael@0 31 assertEq("imacro produces incorrect result for " + s, "fail");
michael@0 32 }
michael@0 33
michael@0 34 function run() {
michael@0 35 for (var i = 0; i < 5; ++i) {
michael@0 36 // equality / inequality
michael@0 37 assert(!(o == "fail"), "obj == any");
michael@0 38 assert(!("fail" == o), "any == obj");
michael@0 39 assert(!(o != "good"), "obj != any");
michael@0 40 assert(!("good" != o), "any != obj");
michael@0 41
michael@0 42 // binary
michael@0 43 assert(!((p | 3) != 7), "obj | any");
michael@0 44 assert(!((3 | p) != 7), "any | obj");
michael@0 45 assert(!((p | p) != 7), "obj | obj");
michael@0 46 assert(!((p & 3) != 3), "obj & any");
michael@0 47 assert(!((3 & p) != 3), "any & obj");
michael@0 48 assert(!((p & p) != 7), "obj & obj");
michael@0 49 assert(!((p * 3) != 21), "obj * any");
michael@0 50 assert(!((3 * p) != 21), "any * obj");
michael@0 51 assert(!((p * p) != 49), "obj * obj");
michael@0 52
michael@0 53 // addition
michael@0 54 assert(!(o + "" != "good"), "obj + any");
michael@0 55 assert(!("" + o != "good"), "any + obj");
michael@0 56 assert(!(o + o != "goodgood"), "any + any");
michael@0 57
michael@0 58 // sign
michael@0 59 assert(!(-p != -7), "-obj");
michael@0 60 assert(!(+p != 7), "+obj");
michael@0 61
michael@0 62 // String
michael@0 63 assert(!(String(q) != "7"), "String(obj)");
michael@0 64 assert(!(new String(q) != "7"), "new String(obj)");
michael@0 65 }
michael@0 66 return true;
michael@0 67 }
michael@0 68
michael@0 69 run();

mercurial