summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Number/isSafeInteger
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Number/isSafeInteger
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Number/isSafeInteger')
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/arg-is-not-number.js26
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/infinity.js19
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/length.js31
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/nan.js18
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/not-integer.js22
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/not-safe-integer.js21
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/safe-integers.js25
-rw-r--r--js/src/tests/test262/built-ins/Number/isSafeInteger/shell.js0
12 files changed, 242 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/arg-is-not-number.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/arg-is-not-number.js
new file mode 100644
index 0000000000..d6b7e3f640
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/arg-is-not-number.js
@@ -0,0 +1,26 @@
+// 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-number.issafeinteger
+description: >
+ Return false if argument is not Number
+info: |
+ Number.isSafeInteger ( number )
+
+ 1. If Type(number) is not Number, return false.
+ [...]
+features: [Symbol]
+---*/
+
+assert.sameValue(Number.isSafeInteger("1"), false, "string");
+assert.sameValue(Number.isSafeInteger([1]), false, "[1]");
+assert.sameValue(Number.isSafeInteger(new Number(42)), false, "Number object");
+assert.sameValue(Number.isSafeInteger(false), false, "false");
+assert.sameValue(Number.isSafeInteger(true), false, "true");
+assert.sameValue(Number.isSafeInteger(undefined), false, "undefined");
+assert.sameValue(Number.isSafeInteger(null), false, "null");
+assert.sameValue(Number.isSafeInteger(Symbol("1")), false, "symbol");
+assert.sameValue(Number.isSafeInteger(), false, "no arg");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/browser.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/browser.js
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/infinity.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/infinity.js
new file mode 100644
index 0000000000..53642c9289
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/infinity.js
@@ -0,0 +1,19 @@
+// 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-number.issafeinteger
+description: >
+ Return false if argument is an Infinity value
+info: |
+ Number.isSafeInteger ( number )
+
+ [...]
+ 2. If number is NaN, +∞, or -∞, return false.
+ [...]
+---*/
+
+assert.sameValue(Number.isSafeInteger(Infinity), false, "Infinity");
+assert.sameValue(Number.isSafeInteger(-Infinity), false, "-Infinity");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js
new file mode 100644
index 0000000000..bcc7e6a770
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 20.1.2.5
+description: >
+ Number.isSafeInteger.length is 1.
+info: |
+ Number.isSafeInteger ( number )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Number.isSafeInteger.length, 1);
+
+verifyNotEnumerable(Number.isSafeInteger, "length");
+verifyNotWritable(Number.isSafeInteger, "length");
+verifyConfigurable(Number.isSafeInteger, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js
new file mode 100644
index 0000000000..3844d43e13
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 20.1.2.5
+description: >
+ Number.isSafeInteger.name is "isSafeInteger".
+info: |
+ Number.isSafeInteger ( number )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Number.isSafeInteger.name, "isSafeInteger");
+
+verifyNotEnumerable(Number.isSafeInteger, "name");
+verifyNotWritable(Number.isSafeInteger, "name");
+verifyConfigurable(Number.isSafeInteger, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/nan.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/nan.js
new file mode 100644
index 0000000000..7320e44f77
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/nan.js
@@ -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.
+
+/*---
+esid: sec-number.issafeinteger
+description: >
+ Return false if argument is NaN
+info: |
+ Number.isSafeInteger ( number )
+
+ [...]
+ 2. If number is NaN, +∞, or -∞, return false.
+ [...]
+---*/
+
+assert.sameValue(Number.isSafeInteger(NaN), false);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js
new file mode 100644
index 0000000000..dca11c9cd3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ Number.isSafeInteger does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Number.isSafeInteger), false, 'isConstructor(Number.isSafeInteger) must return false');
+
+assert.throws(TypeError, () => {
+ new Number.isSafeInteger();
+}, '`new Number.isSafeInteger()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/not-integer.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-integer.js
new file mode 100644
index 0000000000..794a6d623c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-integer.js
@@ -0,0 +1,22 @@
+// 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-number.issafeinteger
+description: >
+ Return false if argument is not an integer
+info: |
+ Number.isSafeInteger ( number )
+
+ [...]
+ 3. Let integer be ToInteger(number).
+ 4. If integer is not equal to number, return false.
+ [...]
+---*/
+
+assert.sameValue(Number.isSafeInteger(1.1), false, "1.1");
+assert.sameValue(Number.isSafeInteger(0.000001), false, "0.000001");
+assert.sameValue(Number.isSafeInteger(-0.000001), false, "-0.000001");
+assert.sameValue(Number.isSafeInteger(11e-1), false, "11e-1");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/not-safe-integer.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-safe-integer.js
new file mode 100644
index 0000000000..d3552d0511
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-safe-integer.js
@@ -0,0 +1,21 @@
+// 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-number.issafeinteger
+description: >
+ Return false if argument is not a safe integer
+info: |
+ Number.isSafeInteger ( number )
+
+ [...]
+ 3. Let integer be ToInteger(number).
+ 4. If integer is not equal to number, return false.
+ 5. If abs(integer) ≤ 2**53-1, return true.
+ 6. Otherwise, return false.
+---*/
+
+assert.sameValue(Number.isSafeInteger(9007199254740992), false, "2**53");
+assert.sameValue(Number.isSafeInteger(-9007199254740992), false, "-(2**53)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/prop-desc.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/prop-desc.js
new file mode 100644
index 0000000000..5fdb2ba049
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/prop-desc.js
@@ -0,0 +1,21 @@
+// 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-number.issafeinteger
+description: >
+ "isSafeInteger" 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, "isSafeInteger");
+verifyWritable(Number, "isSafeInteger");
+verifyConfigurable(Number, "isSafeInteger");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/safe-integers.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/safe-integers.js
new file mode 100644
index 0000000000..721a045434
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/safe-integers.js
@@ -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.
+
+/*---
+esid: sec-number.issafeinteger
+description: >
+ Return true if argument is a safe integer
+info: |
+ Number.isSafeInteger ( number )
+
+ [...]
+ 3. Let integer be ToInteger(number).
+ 4. If integer is not equal to number, return false.
+ 5. If abs(integer) ≤ 2**53-1, return true.
+ [...]
+---*/
+
+assert.sameValue(Number.isSafeInteger(1), true, "1");
+assert.sameValue(Number.isSafeInteger(-0), true, "-0");
+assert.sameValue(Number.isSafeInteger(0), true, "0");
+assert.sameValue(Number.isSafeInteger(-1), true, "-1");
+assert.sameValue(Number.isSafeInteger(9007199254740991), true, "9007199254740991");
+assert.sameValue(Number.isSafeInteger(-9007199254740991), true, "-9007199254740991");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/shell.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/shell.js