summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Math/min
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Math/min')
-rw-r--r--js/src/tests/test262/built-ins/Math/min/15.8.2.12-1.js11
-rw-r--r--js/src/tests/test262/built-ins/Math/min/Math.min_each-element-coerced.js23
-rw-r--r--js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A1.js11
-rw-r--r--js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A2.js69
-rw-r--r--js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A4.js13
-rw-r--r--js/src/tests/test262/built-ins/Math/min/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Math/min/length.js28
-rw-r--r--js/src/tests/test262/built-ins/Math/min/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Math/min/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Math/min/prop-desc.js19
-rw-r--r--js/src/tests/test262/built-ins/Math/min/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/Math/min/zeros.js22
12 files changed, 279 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Math/min/15.8.2.12-1.js b/js/src/tests/test262/built-ins/Math/min/15.8.2.12-1.js
new file mode 100644
index 0000000000..7f7c789cd7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/15.8.2.12-1.js
@@ -0,0 +1,11 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es5id: 15.8.2.12-1
+description: Math.min({}) is NaN
+---*/
+
+assert.sameValue(Math.min({}), NaN);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/min/Math.min_each-element-coerced.js b/js/src/tests/test262/built-ins/Math/min/Math.min_each-element-coerced.js
new file mode 100644
index 0000000000..2183e1847b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/Math.min_each-element-coerced.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2020 Vladislav Lazurenko. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-math.min
+description: Call ToNumber on each element of params
+info: |
+ 2. For each element arg of args, do
+ Let n be ? ToNumber(arg).
+ Append n to coerced.
+---*/
+
+let valueOf_calls = 0;
+
+const n = {
+ valueOf: function() {
+ valueOf_calls++;
+ }
+};
+Math.min(NaN, n);
+assert.sameValue(valueOf_calls, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A1.js b/js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A1.js
new file mode 100644
index 0000000000..6f8b422680
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A1.js
@@ -0,0 +1,11 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: If no arguments are given, Math.min() is +Infinity
+es5id: 15.8.2.12_A1
+description: Checking if Math.min() equals to +Infinity
+---*/
+assert.sameValue(Math.min(), +Infinity, 'Math.min() must return +Infinity');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A2.js b/js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A2.js
new file mode 100644
index 0000000000..8fa7d672ae
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A2.js
@@ -0,0 +1,69 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: If any value is NaN, the result of Math.min is NaN
+es5id: 15.8.2.12_A2
+description: >
+ The script tests Math.min giving 1, 2 and 3 arguments to the
+ function where at least one of the arguments is NaN
+---*/
+
+// CHECK#1
+assert.sameValue(Math.min(NaN), NaN, "NaN");
+
+// CHECK#2
+var vals = new Array();
+vals[0] = -Infinity;
+vals[1] = -0.000000000000001;
+vals[2] = -0;
+vals[3] = +0
+vals[4] = 0.000000000000001;
+vals[5] = +Infinity;
+vals[6] = NaN;
+var valnum = 7;
+
+var args = new Array();
+for (var i = 0; i <= 1; i++)
+{
+ args[i] = NaN;
+ for (var j = 0; j < valnum; j++)
+ {
+ args[1 - i] = vals[j];
+ assert.sameValue(
+ Math.min(args[0], args[1]),
+ NaN,
+ "min(" + args[0] + ", " + args[1] + ")"
+ );
+ }
+}
+
+// CHECK #3
+var k = 1;
+var l = 2;
+for (var i = 0; i <= 2; i++)
+{
+ args[i] = NaN;
+ if (i === 1)
+ {
+ k = 0;
+ } else if (i === 2)
+ {
+ l = 1;
+ }
+ for (var j = 0; j < valnum; j++)
+ {
+ for (var jj = 0; jj < valnum; jj++)
+ {
+ args[k] = vals[j];
+ args[l] = vals[jj];
+ assert.sameValue(
+ Math.min(args[0], args[1], args[2]),
+ NaN,
+ "min(" + args[0] + ", " + args[1] + ", " + args[2] + ")"
+ );
+ }
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A4.js b/js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A4.js
new file mode 100644
index 0000000000..6af0a31714
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/S15.8.2.12_A4.js
@@ -0,0 +1,13 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: The length property of the Math.min method is 2
+es5id: 15.8.2.12_A4
+description: Checking if Math.min.length property is defined and equals to 2
+---*/
+assert.sameValue(typeof Math.min, "function", 'The value of `typeof Math.min` is expected to be "function"');
+assert.notSameValue(typeof Math.min.length, "undefined", 'The value of typeof Math.min.length is not "undefined"');
+assert.sameValue(Math.min.length, 2, 'The value of Math.min.length is expected to be 2');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/min/browser.js b/js/src/tests/test262/built-ins/Math/min/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/browser.js
diff --git a/js/src/tests/test262/built-ins/Math/min/length.js b/js/src/tests/test262/built-ins/Math/min/length.js
new file mode 100644
index 0000000000..65706dd110
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/length.js
@@ -0,0 +1,28 @@
+// 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.min
+description: >
+ "length" property of Math.min
+info: |
+ Math.min ( value1, value2, ...values )
+
+ 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.min.length, 2);
+
+verifyNotEnumerable(Math.min, "length");
+verifyNotWritable(Math.min, "length");
+verifyConfigurable(Math.min, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/min/name.js b/js/src/tests/test262/built-ins/Math/min/name.js
new file mode 100644
index 0000000000..2fc9c3d206
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/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.25
+description: >
+ Math.min.name is "min".
+info: |
+ Math.min ( value1, value2 , …values )
+
+ 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.min.name, "min");
+
+verifyNotEnumerable(Math.min, "name");
+verifyNotWritable(Math.min, "name");
+verifyConfigurable(Math.min, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/min/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/min/not-a-constructor.js
new file mode 100644
index 0000000000..24fca032af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/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.min 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.min), false, 'isConstructor(Math.min) must return false');
+
+assert.throws(TypeError, () => {
+ new Math.min();
+}, '`new Math.min()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/min/prop-desc.js b/js/src/tests/test262/built-ins/Math/min/prop-desc.js
new file mode 100644
index 0000000000..01e8c74075
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/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.min
+description: >
+ "min" 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, "min");
+verifyWritable(Math, "min");
+verifyConfigurable(Math, "min");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/min/shell.js b/js/src/tests/test262/built-ins/Math/min/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/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;
+}
diff --git a/js/src/tests/test262/built-ins/Math/min/zeros.js b/js/src/tests/test262/built-ins/Math/min/zeros.js
new file mode 100644
index 0000000000..1f3700b993
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/min/zeros.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-math.min
+description: >
+ +0 is considered to be larger than -0
+info: |
+ Math.min ( value1, value2 , …values )
+
+ The comparison of values to determine the smallest value is done using the
+ Abstract Relational Comparison algorithm except that +0 is considered to be
+ larger than -0.
+---*/
+
+assert.sameValue(Math.min(0, 0), 0, "(0, 0)");
+assert.sameValue(Math.min(-0, -0), -0, "(-0, -0)");
+assert.sameValue(Math.min(0, -0), -0, "(0, -0)");
+assert.sameValue(Math.min(-0, 0), -0, "(-0, 0)");
+assert.sameValue(Math.min(0, 0, -0), -0, "(0, 0, -0)");
+
+reportCompare(0, 0);