Update and add tests for Number.isNaN

This commit is contained in:
Leonardo Balter 2016-06-20 14:42:41 -04:00 committed by Mike Pennisi
parent c246bc7d09
commit 3685e6b7b3
7 changed files with 69 additions and 32 deletions

View File

@ -1,10 +0,0 @@
// Copyright (c) 2014 Ryan Lewis. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 20.1.2.4
author: Ryan Lewis
description: Number.IsNaN should return false if called with a boolean.
---*/
assert.sameValue(Number.isNaN(true), false, 'Number.isNaN(true)');

View File

@ -1,12 +0,0 @@
// Copyright (c) 2014 Ryan Lewis. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 20.1.2.4
author: Ryan Lewis
description: >
Number.IsNaN should return false if called with a non-number
Object.
---*/
assert.sameValue(Number.isNaN(new Object()), false, 'Number.isNaN(new Object())');

View File

@ -1,10 +0,0 @@
// Copyright (c) 2014 Ryan Lewis. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 20.1.2.4
author: Ryan Lewis
description: Number.IsNaN should return false if called with a String.
---*/
assert.sameValue(Number.isNaN('string'), false, 'Number.isNaN("string")');

View File

@ -0,0 +1,25 @@
// Copyright (c) 2014 Ryan Lewis. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 20.1.2.4
esid: sec-number.isnan
description: >
Return false if argument is not Number
info: |
Number.isNaN ( number )
1. If Type(number) is not Number, return false.
[...]
features: [Symbol]
---*/
assert.sameValue(Number.isNaN("NaN"), false, "string");
assert.sameValue(Number.isNaN([NaN]), false, "[NaN]");
assert.sameValue(Number.isNaN(new Number(NaN)), false, "Number object");
assert.sameValue(Number.isNaN(false), false, "false");
assert.sameValue(Number.isNaN(true), false, "true");
assert.sameValue(Number.isNaN(undefined), false, "undefined");
assert.sameValue(Number.isNaN(null), false, "null");
assert.sameValue(Number.isNaN(Symbol("1")), false, "symbol");
assert.sameValue(Number.isNaN(), false, "no arg");

View File

@ -0,0 +1,24 @@
// 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.4
esid: sec-number.isnan
description: >
Return false if argument is not NaN
info: |
Number.isNaN ( number )
1. If Type(number) is not Number, return false.
2. If number is NaN, return true.
3. Otherwise, return false.
---*/
assert.sameValue(Number.isNaN(0), false, "0");
assert.sameValue(Number.isNaN(-0), false, "-0");
assert.sameValue(Number.isNaN(1), false, "1");
assert.sameValue(Number.isNaN(-1), false, "-1");
assert.sameValue(Number.isNaN(1.1), false, "1.1");
assert.sameValue(Number.isNaN(1e10), false, "1e10");
assert.sameValue(Number.isNaN(Infinity), false, "Infinity");
assert.sameValue(Number.isNaN(-Infinity), false, "-Infinity");

View File

@ -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.4
esid: sec-number.isnan
description: >
"isNaN" 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, "isNaN");
verifyWritable(Number, "isNaN");
verifyConfigurable(Number, "isNaN");