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