summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/isFinite/tonumber-operations.js
blob: 9861e349e7092977e9ad1c1bf00d8f257c3f44c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (C) 2016 The V8 Project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-isfinite-number
description: >
  number argument is converted by ToNumber
info: |
  isFinite (number)

  1. Let num be ? ToNumber(number).
  2. If num is NaN, +∞, or -∞, return false.
  3. Otherwise, return true.
---*/

assert.sameValue(isFinite("0"), true, "'0'");
assert.sameValue(isFinite(""), true, "the empty string");
assert.sameValue(isFinite("Infinity"), false, "'Infinity'");
assert.sameValue(isFinite("this is not a number"), false, "string");
assert.sameValue(isFinite(true), true, "true");
assert.sameValue(isFinite(false), true, "false");
assert.sameValue(isFinite([1]), true, "Object [1]");
assert.sameValue(isFinite([Infinity]), false, "Object [Infinity]");
assert.sameValue(isFinite([NaN]), false, "Object [NaN]");
assert.sameValue(isFinite(null), true, "null");
assert.sameValue(isFinite(undefined), false, "undefined");
assert.sameValue(isFinite(), false, "no arg");

reportCompare(0, 0);