]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | function foo(value) { |
2 | return !!value; | |
3 | } | |
4 | ||
5 | noInline(foo); | |
6 | ||
7 | var 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 | ||
25 | for (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 | } |