]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/string-ident-to-not-string-var-equality.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / string-ident-to-not-string-var-equality.js
1 function foo(a, b) {
2 return a === b;
3 }
4
5 function bar(a, b) {
6 return b === a;
7 }
8
9 function test(a, b, expected) {
10 var fooActual = foo(a, b);
11 var barActual = bar(a, b);
12
13 if (fooActual != expected)
14 throw new Error("Bad result: " + fooActual);
15 if (barActual != expected)
16 throw new Error("Bad result: " + barActual);
17 }
18
19 for (var i = 0; i < 10000; ++i) {
20 test("foo", "foo", true);
21 test("foo", "bar", false);
22 test("fuz", 42, false);
23 test("buz", {}, false);
24 test("bla", null, false);
25 }
26
27 var fooString = "";
28 fooString += "f";
29 for (var i = 0; i < 2; ++i)
30 fooString += "o";
31
32 test(fooString, "foo", true);