saambarati1@gmail.com | 06e3913 | 2015-07-31 21:05:19 +0000 | [diff] [blame] | 1 | function assert(b) { |
| 2 | if (!b) |
| 3 | throw new Error("Assertion failure"); |
| 4 | } |
| 5 | noInline(assert); |
| 6 | |
| 7 | function truth() { return true; } |
| 8 | noInline(truth); |
| 9 | |
| 10 | const NUM_LOOPS = 1000; |
| 11 | |
| 12 | ;(function() { |
| 13 | function foo() { |
| 14 | let first; |
| 15 | let second; |
| 16 | class A {}; |
| 17 | first = A; |
| 18 | if (truth()) { |
| 19 | class A {}; |
| 20 | second = A; |
| 21 | } |
| 22 | assert(first !== second); |
| 23 | } |
| 24 | function baz() { |
| 25 | class A { static hello() { return 10; } }; |
| 26 | assert(A.hello() === 10); |
| 27 | if (truth()) { |
| 28 | class A { static hello() { return 20; } }; |
| 29 | assert(A.hello() === 20); |
| 30 | } |
| 31 | assert(A.hello() === 10); |
| 32 | } |
| 33 | function bar() { |
| 34 | class A { static hello() { return 10; } }; |
| 35 | let capA = function() { return A; } |
| 36 | assert(A.hello() === 10); |
| 37 | if (truth()) { |
| 38 | class A { static hello() { return 20; } }; |
| 39 | let capA = function() { return A; } |
| 40 | assert(A.hello() === 20); |
| 41 | } |
| 42 | assert(A.hello() === 10); |
| 43 | } |
| 44 | for (let i = 0; i < NUM_LOOPS; i++) { |
| 45 | foo(); |
| 46 | bar(); |
| 47 | baz(); |
| 48 | } |
| 49 | })(); |