]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/logical-not-masquerades.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / logical-not-masquerades.js
CommitLineData
ed1e77d3
A
1function foo(value) {
2 return !!value;
3}
4
5noInline(foo);
6
7var tests = [
8 [0, false],
9 [1, true],
10 [0/0, false],
11 [0/-1, false],
12 [0.0, false],
13 ["", false],
14 ["f", true],
15 ["hello", true],
16 [{}, true],
17 [[], true],
18 [null, false],
19 [void 0, false],
20 [false, false],
21 [true, true],
22 [makeMasquerader(), false]
23];
24
25for (var i = 0; i < 10000; ++i) {
26 for (var j = 0; j < tests.length; ++j) {
27 var input = tests[j][0];
28 var expected = tests[j][1];
29 var result = foo(input);
30 if (result !== expected)
31 throw "Error: bad result for " + input + ": " + result;
32 }
33}