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