Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 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 | |
| 7 | function test(expected, f) { |
| 8 | assertEquals(expected, f()); |
| 9 | assertEquals(expected, f()); |
| 10 | %OptimizeFunctionOnNextCall(f); |
| 11 | assertEquals(expected, f()); |
| 12 | assertEquals(expected, f()); |
| 13 | } |
| 14 | |
| 15 | function f1() { return Infinity; } |
| 16 | test((1/0), f1); |
| 17 | |
| 18 | function f2() { return (1/0); } |
| 19 | test((1/0), f2); |
| 20 | |
| 21 | function f3() { return (1/0) == (1/0); } |
| 22 | test(true, f3); |
| 23 | |
| 24 | function f4() { return (1/0) == Infinity; } |
| 25 | test(true, f4); |
| 26 | |
| 27 | function f5() { return Infinity == (1/0); } |
| 28 | test(true, f5); |
| 29 | |
| 30 | function f6() { return "" + Infinity; } |
| 31 | test("Infinity", f6); |
| 32 | |
| 33 | function f7() { return (1/0) === (1/0); } |
| 34 | test(true, f7); |
| 35 | |
| 36 | function f8() { return (1/0) === Infinity; } |
| 37 | test(true, f8); |
| 38 | |
| 39 | function f9() { return Infinity === (1/0); } |
| 40 | test(true, f9); |
| 41 | |
| 42 | delete Infinity; |
| 43 | |
| 44 | function g1() { return Infinity; } |
| 45 | test((1/0), g1); |
| 46 | |
| 47 | function g2() { return (1/0); } |
| 48 | test((1/0), g2); |
| 49 | |
| 50 | function g3() { return (1/0) == (1/0); } |
| 51 | test(true, g3); |
| 52 | |
| 53 | function g4() { return (1/0) == Infinity; } |
| 54 | test(true, g4); |
| 55 | |
| 56 | function g5() { return Infinity == (1/0); } |
| 57 | test(true, g5); |
| 58 | |
| 59 | function g6() { return "" + Infinity; } |
| 60 | test("Infinity", g6); |
| 61 | |
| 62 | function g7() { return (1/0) === (1/0); } |
| 63 | test(true, g7); |
| 64 | |
| 65 | function g8() { return (1/0) === Infinity; } |
| 66 | test(true, g8); |
| 67 | |
| 68 | function g9() { return Infinity === (1/0); } |
| 69 | test(true, g9); |
| 70 | |
| 71 | Infinity = 111; |
| 72 | |
| 73 | function h1() { return Infinity; } |
| 74 | test((1/0), h1); |
| 75 | |
| 76 | function h2() { return (1/0); } |
| 77 | test((1/0), h2); |
| 78 | |
| 79 | function h3() { return (1/0) == (1/0); } |
| 80 | test(true, h3); |
| 81 | |
| 82 | function h4() { return (1/0) == Infinity; } |
| 83 | test(true, h4); |
| 84 | |
| 85 | function h5() { return Infinity == (1/0); } |
| 86 | test(true, h5); |
| 87 | |
| 88 | function h6() { return "" + Infinity; } |
| 89 | test("Infinity", h6); |
| 90 | |
| 91 | function h7() { return (1/0) === (1/0); } |
| 92 | test(true, h7); |
| 93 | |
| 94 | function h8() { return (1/0) === Infinity; } |
| 95 | test(true, h8); |
| 96 | |
| 97 | function h9() { return Infinity === (1/0); } |
| 98 | test(true, h9); |
| 99 | |
| 100 | // ------------- |
| 101 | |
| 102 | function k1() { return this.Infinity; } |
| 103 | test((1/0), k1); |
| 104 | |
| 105 | function k2() { return (1/0); } |
| 106 | test((1/0), k2); |
| 107 | |
| 108 | function k3() { return (1/0) == (1/0); } |
| 109 | test(true, k3); |
| 110 | |
| 111 | function k4() { return (1/0) == this.Infinity; } |
| 112 | test(true, k4); |
| 113 | |
| 114 | function k5() { return this.Infinity == (1/0); } |
| 115 | test(true, k5); |
| 116 | |
| 117 | function k6() { return "" + this.Infinity; } |
| 118 | test("Infinity", k6); |
| 119 | |
| 120 | function k7() { return (1/0) === (1/0); } |
| 121 | test(true, k7); |
| 122 | |
| 123 | function k8() { return (1/0) === this.Infinity; } |
| 124 | test(true, k8); |
| 125 | |
| 126 | function k9() { return this.Infinity === (1/0); } |
| 127 | test(true, k9); |