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