OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax |
| 6 "use strict"; |
| 7 |
| 8 function test(expected, f) { |
| 9 assertEquals(expected, f()); |
| 10 assertEquals(expected, f()); |
| 11 %OptimizeFunctionOnNextCall(f); |
| 12 assertEquals(expected, f()); |
| 13 assertEquals(expected, f()); |
| 14 } |
| 15 |
| 16 function testThrows(f) { |
| 17 assertThrows(f); |
| 18 assertThrows(f); |
| 19 %OptimizeFunctionOnNextCall(f); |
| 20 assertThrows(f); |
| 21 assertThrows(f); |
| 22 } |
| 23 |
| 24 function f1() { return undefined; } |
| 25 test(void 0, f1); |
| 26 |
| 27 function f2() { return void 0; } |
| 28 test(void 0, f2); |
| 29 |
| 30 function f3() { return void 0 == void 0; } |
| 31 test(true, f3); |
| 32 |
| 33 function f4() { return void 0 == undefined; } |
| 34 test(true, f4); |
| 35 |
| 36 function f5() { return undefined == void 0; } |
| 37 test(true, f5); |
| 38 |
| 39 function f6() { return "" + undefined; } |
| 40 test("undefined", f6); |
| 41 |
| 42 function f7() { return void 0 === void 0; } |
| 43 test(true, f7); |
| 44 |
| 45 function f8() { return void 0 === undefined; } |
| 46 test(true, f8); |
| 47 |
| 48 function f9() { return undefined === void 0; } |
| 49 test(true, f9); |
| 50 |
| 51 function g1() { return this; } |
| 52 test(void 0, g1); |
| 53 |
| 54 function g2() { return void 0; } |
| 55 test(void 0, g2); |
| 56 |
| 57 function g3() { return void 0 == void 0; } |
| 58 test(true, g3); |
| 59 |
| 60 function g4() { return void 0 == this; } |
| 61 test(true, g4); |
| 62 |
| 63 function g5() { return this == void 0; } |
| 64 test(true, g5); |
| 65 |
| 66 function g6() { return "" + this; } |
| 67 test("undefined", g6); |
| 68 |
| 69 function g7() { return void 0 === void 0; } |
| 70 test(true, g7); |
| 71 |
| 72 function g8() { return void 0 === this; } |
| 73 test(true, g8); |
| 74 |
| 75 function g9() { return this === void 0; } |
| 76 test(true, g9); |
| 77 |
| 78 testThrows(function() { undefined = 111; }); |
| 79 |
| 80 function h1() { return undefined; } |
| 81 test(void 0, h1); |
| 82 |
| 83 function h2() { return void 0; } |
| 84 test(void 0, h2); |
| 85 |
| 86 function h3() { return void 0 == void 0; } |
| 87 test(true, h3); |
| 88 |
| 89 function h4() { return void 0 == undefined; } |
| 90 test(true, h4); |
| 91 |
| 92 function h5() { return undefined == void 0; } |
| 93 test(true, h5); |
| 94 |
| 95 function h6() { return "" + undefined; } |
| 96 test("undefined", h6); |
| 97 |
| 98 function h7() { return void 0 === void 0; } |
| 99 test(true, h7); |
| 100 |
| 101 function h8() { return void 0 === undefined; } |
| 102 test(true, h8); |
| 103 |
| 104 function h9() { return undefined === void 0; } |
| 105 test(true, h9); |
| 106 |
| 107 // ------------- |
| 108 |
| 109 function k1() { return this; } |
| 110 test(void 0, k1); |
| 111 |
| 112 function k2() { return void 0; } |
| 113 test(void 0, k2); |
| 114 |
| 115 function k3() { return this === undefined; } |
| 116 test(true, k3); |
| 117 |
| 118 function k4() { return void 0 === this; } |
| 119 test(true, k4); |
| 120 |
| 121 function k5() { return this === void 0; } |
| 122 test(true, k5); |
| 123 |
| 124 function k6() { return "" + this; } |
| 125 test("undefined", k6); |
| 126 |
| 127 function k7() { return void 0 === void 0; } |
| 128 test(true, k7); |
| 129 |
| 130 function k8() { return void 0 === this; } |
| 131 test(true, k8); |
| 132 |
| 133 function k9() { return this === void 0; } |
| 134 test(true, k9); |
| 135 |
| 136 // ------------- |
| 137 |
| 138 function m1() { return this.undefined; } |
| 139 testThrows(m1); |
| 140 |
| 141 function m2() { return void 0; } |
| 142 test(void 0, m2); |
| 143 |
| 144 function m3() { return this === undefined; } |
| 145 test(true, m3); |
| 146 |
| 147 function m4() { return void 0 === this.undefined; } |
| 148 testThrows(m4); |
| 149 |
| 150 function m5() { return this.undefined == void 0; } |
| 151 testThrows(m5); |
| 152 |
| 153 function m6() { return "" + this.undefined; } |
| 154 testThrows(m6); |
| 155 |
| 156 function m7() { return void 0 === void 0; } |
| 157 test(true, m7); |
| 158 |
| 159 function m8() { return void 0 === this.undefined; } |
| 160 testThrows(m8); |
| 161 |
| 162 function m9() { return this.undefined === void 0; } |
| 163 testThrows(m9); |
OLD | NEW |