number-isfinite-inl.js 1.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax

function test(f) {
  assertTrue(Number.isFinite(0));
  assertTrue(Number.isFinite(Number.MIN_VALUE));
  assertTrue(Number.isFinite(Number.MAX_VALUE));
  assertTrue(Number.isFinite(Number.MIN_SAFE_INTEGER));
  assertTrue(Number.isFinite(Number.MIN_SAFE_INTEGER - 13));
  assertTrue(Number.isFinite(Number.MAX_SAFE_INTEGER));
  assertTrue(Number.isFinite(Number.MAX_SAFE_INTEGER + 23));
  assertTrue(Number.isFinite(0));
  assertTrue(Number.isFinite(-1));
  assertTrue(Number.isFinite(123456));
  assertFalse(Number.isFinite(Number.NaN));
  assertFalse(Number.isFinite(Number.POSITIVE_INFINITY));
  assertFalse(Number.isFinite(Number.NEGATIVE_INFINITY));
  assertFalse(Number.isFinite(1 / 0));
  assertFalse(Number.isFinite(-1 / 0));
}

25
%PrepareFunctionForOptimization(test);
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
test();
test();
%OptimizeFunctionOnNextCall(test);
test();


function test2(f) {
  assertFalse(Number.isFinite({}));
  assertFalse(Number.isFinite("abc"));
  assertTrue(Number.isFinite(0));
  assertTrue(Number.isFinite(Number.MIN_VALUE));
  assertTrue(Number.isFinite(Number.MAX_VALUE));
  assertTrue(Number.isFinite(Number.MIN_SAFE_INTEGER));
  assertTrue(Number.isFinite(Number.MIN_SAFE_INTEGER - 13));
  assertTrue(Number.isFinite(Number.MAX_SAFE_INTEGER));
  assertTrue(Number.isFinite(Number.MAX_SAFE_INTEGER + 23));
  assertTrue(Number.isFinite(0));
  assertTrue(Number.isFinite(-1));
  assertTrue(Number.isFinite(123456));
  assertFalse(Number.isFinite(Number.NaN));
  assertFalse(Number.isFinite(Number.POSITIVE_INFINITY));
  assertFalse(Number.isFinite(Number.NEGATIVE_INFINITY));
  assertFalse(Number.isFinite(1 / 0));
  assertFalse(Number.isFinite(-1 / 0));
}

52
%PrepareFunctionForOptimization(test2);
53 54 55 56
test2();
test2();
%OptimizeFunctionOnNextCall(test2);
test2();