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.

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

mercurial