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 Infinity; } |
| 25 test((1/0), f1); |
| 26 |
| 27 function f2() { return (1/0); } |
| 28 test((1/0), f2); |
| 29 |
| 30 function f3() { return (1/0) == (1/0); } |
| 31 test(true, f3); |
| 32 |
| 33 function f4() { return (1/0) == Infinity; } |
| 34 test(true, f4); |
| 35 |
| 36 function f5() { return Infinity == (1/0); } |
| 37 test(true, f5); |
| 38 |
| 39 function f6() { return "" + Infinity; } |
| 40 test("Infinity", f6); |
| 41 |
| 42 function f7() { return (1/0) === (1/0); } |
| 43 test(true, f7); |
| 44 |
| 45 function f8() { return (1/0) === Infinity; } |
| 46 test(true, f8); |
| 47 |
| 48 function f9() { return Infinity === (1/0); } |
| 49 test(true, f9); |
| 50 |
| 51 // -- |
| 52 |
| 53 function g1() { return Infinity; } |
| 54 test((1/0), g1); |
| 55 |
| 56 function g2() { return (1/0); } |
| 57 test((1/0), g2); |
| 58 |
| 59 function g3() { return (1/0) == (1/0); } |
| 60 test(true, g3); |
| 61 |
| 62 function g4() { return (1/0) == Infinity; } |
| 63 test(true, g4); |
| 64 |
| 65 function g5() { return Infinity == (1/0); } |
| 66 test(true, g5); |
| 67 |
| 68 function g6() { return "" + Infinity; } |
| 69 test("Infinity", g6); |
| 70 |
| 71 function g7() { return (1/0) === (1/0); } |
| 72 test(true, g7); |
| 73 |
| 74 function g8() { return (1/0) === Infinity; } |
| 75 test(true, g8); |
| 76 |
| 77 function g9() { return Infinity === (1/0); } |
| 78 test(true, g9); |
| 79 |
| 80 testThrows(function() { Infinity = 111; }); |
| 81 |
| 82 function h1() { return Infinity; } |
| 83 test((1/0), h1); |
| 84 |
| 85 function h2() { return (1/0); } |
| 86 test((1/0), h2); |
| 87 |
| 88 function h3() { return (1/0) == (1/0); } |
| 89 test(true, h3); |
| 90 |
| 91 function h4() { return (1/0) == Infinity; } |
| 92 test(true, h4); |
| 93 |
| 94 function h5() { return Infinity == (1/0); } |
| 95 test(true, h5); |
| 96 |
| 97 function h6() { return "" + Infinity; } |
| 98 test("Infinity", h6); |
| 99 |
| 100 function h7() { return (1/0) === (1/0); } |
| 101 test(true, h7); |
| 102 |
| 103 function h8() { return (1/0) === Infinity; } |
| 104 test(true, h8); |
| 105 |
| 106 function h9() { return Infinity === (1/0); } |
| 107 test(true, h9); |
| 108 |
| 109 // ------------- |
| 110 |
| 111 function k1() { return this.Infinity; } |
| 112 testThrows(k1); |
| 113 |
| 114 function k2() { return (1/0); } |
| 115 test((1/0), k2); |
| 116 |
| 117 function k3() { return (1/0) == (1/0); } |
| 118 test(true, k3); |
| 119 |
| 120 function k4() { return (1/0) == this.Infinity; } |
| 121 testThrows(k4); |
| 122 |
| 123 function k5() { return this.Infinity == (1/0); } |
| 124 testThrows(k5); |
| 125 |
| 126 function k6() { return "" + this.Infinity; } |
| 127 testThrows(k6); |
| 128 |
| 129 function k7() { return (1/0) === (1/0); } |
| 130 test(true, k7); |
| 131 |
| 132 function k8() { return (1/0) === this.Infinity; } |
| 133 testThrows(k8); |
| 134 |
| 135 function k9() { return this.Infinity === (1/0); } |
| 136 testThrows(k9); |
OLD | NEW |