summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Math/round
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Math/round
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Math/round')
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A1.js12
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A2.js12
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A3.js12
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A4.js14
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A5.js14
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A6.js44
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A7.js60
-rw-r--r--js/src/tests/test262/built-ins/Math/round/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Math/round/length.js31
-rw-r--r--js/src/tests/test262/built-ins/Math/round/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Math/round/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Math/round/prop-desc.js19
-rw-r--r--js/src/tests/test262/built-ins/Math/round/shell.js24
13 files changed, 301 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A1.js b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A1.js
new file mode 100644
index 0000000000..8bed2740d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A1.js
@@ -0,0 +1,12 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: If x is NaN, Math.round(x) is NaN
+es5id: 15.8.2.15_A1
+description: Checking if Math.round(x) is NaN, where x is NaN
+---*/
+
+assert.sameValue(Math.round(NaN), NaN);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A2.js b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A2.js
new file mode 100644
index 0000000000..5248d4434c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A2.js
@@ -0,0 +1,12 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: If x is +0, Math.round(x) is +0
+es5id: 15.8.2.15_A2
+description: Checking if Math.round(x) equals to +0, where x is +0
+---*/
+
+assert.sameValue(Math.round(0), 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A3.js b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A3.js
new file mode 100644
index 0000000000..7df73fb8fd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A3.js
@@ -0,0 +1,12 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: If x is -0, Math.round(x) is -0
+es5id: 15.8.2.15_A3
+description: Checking if Math.round(x) equals to -0, where x is -0
+---*/
+
+assert.sameValue(Math.round(-0), -0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A4.js b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A4.js
new file mode 100644
index 0000000000..498914393f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A4.js
@@ -0,0 +1,14 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: If x is +Infinity, Math.round(x) is +Infinity
+es5id: 15.8.2.15_A4
+description: Checking if Math.round(x) is +Infinity, where x is +Infinity
+---*/
+
+// CHECK#1
+var x = +Infinity;
+assert.sameValue(Math.round(x), +Infinity, 'Math.round(+Infinity) must return +Infinity');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A5.js b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A5.js
new file mode 100644
index 0000000000..684ae3d86d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A5.js
@@ -0,0 +1,14 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: If x is -Infinity, Math.round(x) is -Infinity
+es5id: 15.8.2.15_A5
+description: Checking if Math.round(x) is -Infinity, where x is -Infinity
+---*/
+
+// CHECK#1
+var x = -Infinity;
+assert.sameValue(Math.round(x), -Infinity, 'Math.round(-Infinity) must return -Infinity');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A6.js b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A6.js
new file mode 100644
index 0000000000..0c41087f28
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A6.js
@@ -0,0 +1,44 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If x is equal to 0 or greater than 0, or if x is less than -0.5,
+ Math.round(x) is equal to Math.floor(x+0.5)
+es5id: 15.8.2.15_A6
+description: >
+ Checking if Math.round(x) is equal to Math.floor(x+0.5), where x
+ equals to 0, greater than 0, or is less than -0.5; this check is
+ performed on 2000 argument x values
+---*/
+
+// CHECK#1
+for (var i = 0; i <= 1000; i++)
+{
+ var x = i / 10.0;
+
+ assert.sameValue(
+ Math.round(x),
+ Math.floor(x + 0.5),
+ 'Math.round(i / 10.0) must return the same value returned by Math.floor(x + 0.5)'
+ );
+}
+
+for (i = -5; i >= -1000; i--)
+{
+ if (i === -5)
+ {
+ x = -0.500000000000001;
+ } else
+ {
+ x = i / 10.0;
+ }
+
+ assert.sameValue(
+ Math.round(x),
+ Math.floor(x + 0.5),
+ 'Math.round(i / 10.0) must return the same value returned by Math.floor(x + 0.5)'
+ );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A7.js b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A7.js
new file mode 100644
index 0000000000..d7a3e6e63f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A7.js
@@ -0,0 +1,60 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ If x is less than or equal to -0 and x is greater than or equal to -0.5,
+ Math.round(x) is equal to -0
+es5id: 15.8.2.15_A7
+description: >
+ `Math.round(x)` differs from `Math.floor(x + 0.5)`:
+
+ 1) for values in [-0.5; -0]
+ 2) for 0.5 - Number.EPSILON / 4
+ 3) for odd integers in [-(2 / Number.EPSILON - 1); -(1 / Number.EPSILON + 1)] or in [1 / Number.EPSILON + 1; 2 / Number.EPSILON - 1]
+---*/
+assert.sameValue(
+ 1 / Math.round(-0.5),
+ 1 / -0,
+ 'The result of evaluating (1 / Math.round(-0.5)) is expected to be 1 / -0'
+);
+
+assert.sameValue(
+ 1 / Math.round(-0.25),
+ 1 / -0,
+ 'The result of evaluating (1 / Math.round(-0.25)) is expected to be 1 / -0'
+);
+
+assert.sameValue(1 / Math.round(-0), 1 / -0, 'The result of evaluating (1 / Math.round(-0)) is expected to be 1 / -0');
+
+var x = 0;
+
+// CHECK#4
+x = 0.5 - Number.EPSILON / 4;
+assert.sameValue(1 / Math.round(x), 1 / 0, 'The result of evaluating (1 / Math.round(x)) is expected to be 1 / 0');
+
+// CHECK#5
+x = -(2 / Number.EPSILON - 1);
+assert.sameValue(Math.round(x), x, 'Math.round(-(2 / Number.EPSILON - 1)) returns x');
+
+// CHECK#6
+x = -(1.5 / Number.EPSILON - 1);
+assert.sameValue(Math.round(x), x, 'Math.round(-(1.5 / Number.EPSILON - 1)) returns x');
+
+// CHECK#7
+x = -(1 / Number.EPSILON + 1);
+assert.sameValue(Math.round(x), x, 'Math.round(-(1 / Number.EPSILON + 1)) returns x');
+
+// CHECK#8
+x = 1 / Number.EPSILON + 1;
+assert.sameValue(Math.round(x), x, 'Math.round(1 / Number.EPSILON + 1) returns x');
+
+// CHECK#9
+x = 1.5 / Number.EPSILON - 1;
+assert.sameValue(Math.round(x), x, 'Math.round(1.5 / Number.EPSILON - 1) returns x');
+
+// CHECK#10
+x = 2 / Number.EPSILON - 1;
+assert.sameValue(Math.round(x), x, 'Math.round(2 / Number.EPSILON - 1) returns x');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/browser.js b/js/src/tests/test262/built-ins/Math/round/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/browser.js
diff --git a/js/src/tests/test262/built-ins/Math/round/length.js b/js/src/tests/test262/built-ins/Math/round/length.js
new file mode 100644
index 0000000000..262c1ddebf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/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.2.2.28
+description: >
+ Math.round.length is 1.
+info: |
+ Math.round ( x )
+
+ 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(Math.round.length, 1);
+
+verifyNotEnumerable(Math.round, "length");
+verifyNotWritable(Math.round, "length");
+verifyConfigurable(Math.round, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/name.js b/js/src/tests/test262/built-ins/Math/round/name.js
new file mode 100644
index 0000000000..d1e21d7be4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/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.2.2.28
+description: >
+ Math.round.name is "round".
+info: |
+ Math.round ( x )
+
+ 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(Math.round.name, "round");
+
+verifyNotEnumerable(Math.round, "name");
+verifyNotWritable(Math.round, "name");
+verifyConfigurable(Math.round, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/round/not-a-constructor.js
new file mode 100644
index 0000000000..45996875c4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/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: >
+ Math.round 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(Math.round), false, 'isConstructor(Math.round) must return false');
+
+assert.throws(TypeError, () => {
+ new Math.round();
+}, '`new Math.round()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/prop-desc.js b/js/src/tests/test262/built-ins/Math/round/prop-desc.js
new file mode 100644
index 0000000000..43072ec8e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/prop-desc.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-math.round
+description: >
+ "round" property of Math
+info: |
+ Section 17: 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(Math, "round");
+verifyWritable(Math, "round");
+verifyConfigurable(Math, "round");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/round/shell.js b/js/src/tests/test262/built-ins/Math/round/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}