mirror of https://github.com/tc39/test262.git
Add tests for Number.isFinite
This commit is contained in:
parent
454b8f10b8
commit
46d8c3d6b8
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2016 The V8 Project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es6id: 20.1.2.2
|
||||
esid: sec-number.isfinite
|
||||
description: >
|
||||
Return false if argument is not Number
|
||||
info: |
|
||||
Number.isFinite ( number )
|
||||
|
||||
1. If Type(number) is not Number, return false.
|
||||
[...]
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Number.isFinite("1"), false, "string");
|
||||
assert.sameValue(Number.isFinite([1]), false, "[1]");
|
||||
assert.sameValue(Number.isFinite(new Number(42)), false, "Number object");
|
||||
assert.sameValue(Number.isFinite(false), false, "false");
|
||||
assert.sameValue(Number.isFinite(true), false, "true");
|
||||
assert.sameValue(Number.isFinite(undefined), false, "undefined");
|
||||
assert.sameValue(Number.isFinite(null), false, "null");
|
||||
assert.sameValue(Number.isFinite(Symbol("1")), false, "symbol");
|
||||
assert.sameValue(Number.isFinite(), false, "no arg");
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2016 The V8 Project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es6id: 20.1.2.2
|
||||
esid: sec-number.isfinite
|
||||
description: >
|
||||
Return true for valid finite numbers
|
||||
info: |
|
||||
Number.isFinite ( number )
|
||||
|
||||
1. If Type(number) is not Number, return false.
|
||||
2. If number is NaN, +∞, or -∞, return false.
|
||||
3. Otherwise, return true.
|
||||
---*/
|
||||
|
||||
assert.sameValue(Number.isFinite(-10), true, "-10");
|
||||
assert.sameValue(Number.isFinite(-0), true, "-0");
|
||||
assert.sameValue(Number.isFinite(0), true, "0");
|
||||
assert.sameValue(Number.isFinite(10), true, "10");
|
||||
assert.sameValue(Number.isFinite(1e10), true, "1e10");
|
||||
assert.sameValue(Number.isFinite(10.10), true, "10.10");
|
||||
assert.sameValue(Number.isFinite(9007199254740991), true, "9007199254740991");
|
||||
assert.sameValue(Number.isFinite(-9007199254740991), true, "-9007199254740991");
|
||||
assert.sameValue(Number.isFinite(Number.MAX_VALUE), true, "Number.MAX_VALUE");
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (C) 2016 The V8 Project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es6id: 20.1.2.2
|
||||
esid: sec-number.isfinite
|
||||
description: >
|
||||
Return false if argument is Infinity or -Infinity
|
||||
info: |
|
||||
Number.isFinite ( number )
|
||||
|
||||
[...]
|
||||
2. If number is NaN, +∞, or -∞, return false.
|
||||
[...]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Number.isFinite(Infinity), false, "+Infinity");
|
||||
assert.sameValue(Number.isFinite(-Infinity), false, "-Infinity");
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2016 The V8 Project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es6id: 20.1.2.2
|
||||
esid: sec-number.isfinite
|
||||
description: >
|
||||
Return false if argument is NaN
|
||||
info: |
|
||||
Number.isFinite ( number )
|
||||
|
||||
[...]
|
||||
2. If number is NaN, +∞, or -∞, return false.
|
||||
[...]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Number.isFinite(NaN), false);
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2016 The V8 Project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es6id: 20.1.2.2
|
||||
esid: sec-number.isfinite
|
||||
description: >
|
||||
"isFinite" property of Number
|
||||
info: >
|
||||
17 ECMAScript Standard Built-in Objects:
|
||||
|
||||
Every other data property described in clauses 18 through 26 and in Annex B.2
|
||||
has the attributes { [[Writable]]: true, [[Enumerable]]: false,
|
||||
[[Configurable]]: true } unless otherwise specified.
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
verifyNotEnumerable(Number, "isFinite");
|
||||
verifyWritable(Number, "isFinite");
|
||||
verifyConfigurable(Number, "isFinite");
|
Loading…
Reference in New Issue