summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Math/round
diff options
context:
space:
mode:
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.js17
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A5.js17
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A6.js41
-rw-r--r--js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A7.js76
-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.js19
13 files changed, 315 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..6775bcc042
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A4.js
@@ -0,0 +1,17 @@
+// 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;
+if (Math.round(x) !== +Infinity)
+{
+ $ERROR("#1: 'var x=+Infinity; Math.round(x) !== +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..b606776e8d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A5.js
@@ -0,0 +1,17 @@
+// 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;
+if (Math.round(x) !== -Infinity)
+{
+ $ERROR("#1: 'var x=-Infinity; Math.round(x) !== -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..957919e365
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A6.js
@@ -0,0 +1,41 @@
+// 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;
+ if (Math.round(x) !== Math.floor(x + 0.5))
+ {
+ $ERROR("#1: 'x = " + x + "; Math.round(x) !== Math.floor(x + 0.5)'")
+ }
+}
+
+for (i = -5; i >= -1000; i--)
+{
+ if (i === -5)
+ {
+ x = -0.500000000000001;
+ } else
+ {
+ x = i / 10.0;
+ }
+
+ if (Math.round(x) !== Math.floor(x + 0.5))
+ {
+ $ERROR("#2: 'x = " + x + "; Math.round(x) !== 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..cf84343851
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/S15.8.2.15_A7.js
@@ -0,0 +1,76 @@
+// 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]
+---*/
+
+// CHECK#1
+if (1 / Math.round(-0.5) !== 1 / -0) {
+ $ERROR("#1: '1 / Math.round(-0.5) !== 1 / -0'");
+}
+
+// CHECK#2
+if (1 / Math.round(-0.25) !== 1 / -0) {
+ $ERROR("#2: '1 / Math.round(-0.25) !== 1 / -0'");
+}
+
+// CHECK#3
+if (1 / Math.round(-0) !== 1 / -0) {
+ $ERROR("#3: '1 / Math.round(-0) !== 1 / -0'");
+}
+
+var x = 0;
+
+// CHECK#4
+x = 0.5 - Number.EPSILON / 4;
+if (1 / Math.round(x) !== 1 / 0) {
+ $ERROR("#4: '1 / Math.round(" + x + ") !== 1 / 0'");
+}
+
+// CHECK#5
+x = -(2 / Number.EPSILON - 1);
+if (Math.round(x) !== x) {
+ $ERROR("#5: 'Math.round(" + x + ") !== " + x + "'");
+}
+
+// CHECK#6
+x = -(1.5 / Number.EPSILON - 1);
+if (Math.round(x) !== x) {
+ $ERROR("#6: 'Math.round(" + x + ") !== " + x + "'");
+}
+
+// CHECK#7
+x = -(1 / Number.EPSILON + 1);
+if (Math.round(x) !== x) {
+ $ERROR("#7: 'Math.round(" + x + ") !== " + x + "'");
+}
+
+// CHECK#8
+x = 1 / Number.EPSILON + 1;
+if (Math.round(x) !== x) {
+ $ERROR("#8: 'Math.round(" + x + ") !== " + x + "'");
+}
+
+// CHECK#9
+x = 1.5 / Number.EPSILON - 1;
+if (Math.round(x) !== x) {
+ $ERROR("#9: 'Math.round(" + x + ") !== " + x + "'");
+}
+
+// CHECK#10
+x = 2 / Number.EPSILON - 1;
+if (Math.round(x) !== x) {
+ $ERROR("#10: 'Math.round(" + x + ") !== " + 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..54371b7789
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/round/shell.js
@@ -0,0 +1,19 @@
+// 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]
+---*/
+
+function isConstructor(f) {
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}