diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/built-ins/Math/max | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Math/max')
12 files changed, 290 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Math/max/15.8.2.11-1.js b/js/src/tests/test262/built-ins/Math/max/15.8.2.11-1.js new file mode 100644 index 0000000000..a504429170 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/15.8.2.11-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.11-1 +description: Math.max({}) is NaN +---*/ + +assert.sameValue(Math.max({}), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/Math.max_each-element-coerced.js b/js/src/tests/test262/built-ins/Math/max/Math.max_each-element-coerced.js new file mode 100644 index 0000000000..98488f710e --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/Math.max_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.max +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.max(NaN, n); +assert.sameValue(valueOf_calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/S15.8.2.11_A1.js b/js/src/tests/test262/built-ins/Math/max/S15.8.2.11_A1.js new file mode 100644 index 0000000000..c8cb142000 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/S15.8.2.11_A1.js @@ -0,0 +1,16 @@ +// 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.max() is -Infinity +es5id: 15.8.2.11_A1 +description: Checking if Math.max() equals to -Infinity +---*/ + +// CHECK#1 +if (Math.max() != -Infinity) +{ + $ERROR("#1: 'Math.max() != -Infinity'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/S15.8.2.11_A2.js b/js/src/tests/test262/built-ins/Math/max/S15.8.2.11_A2.js new file mode 100644 index 0000000000..bf2fe00a0a --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/S15.8.2.11_A2.js @@ -0,0 +1,68 @@ +// 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.max is NaN +es5id: 15.8.2.11_A2 +description: > + The script tests Math.max giving 1, 2 and 3 arguments to the + function where at least one of the arguments is NaN +---*/ + +assert.sameValue(Math.max(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.max(args[0], args[1]), + NaN, + "max(" + 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.max(args[0], args[1], args[2]), + NaN, + "max(" + args[0] + ", " + args[1] + ", " + args[2] + ")" + ); + } + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/S15.8.2.11_A4.js b/js/src/tests/test262/built-ins/Math/max/S15.8.2.11_A4.js new file mode 100644 index 0000000000..8cf2cd669a --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/S15.8.2.11_A4.js @@ -0,0 +1,25 @@ +// 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.max method is 2 +es5id: 15.8.2.11_A4 +description: Checking if Math.max.length property is defined and equals to 2 +---*/ + +// CHECK#1 +if (typeof Math.max !== "function") { + $ERROR('#1: Math.max method is not defined'); +} + +// CHECK#2 +if (typeof Math.max.length === "undefined") { + $ERROR('#2: length property of Math.max method is undefined'); +} + +// CHECK#3 +if (Math.max.length !== 2) { + $ERROR('#3: The length property of the Math.max method is not 2'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/browser.js b/js/src/tests/test262/built-ins/Math/max/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/browser.js diff --git a/js/src/tests/test262/built-ins/Math/max/length.js b/js/src/tests/test262/built-ins/Math/max/length.js new file mode 100644 index 0000000000..a985231596 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/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.max +description: > + "length" property of Math.max +info: | + Math.max ( 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.max.length, 2); + +verifyNotEnumerable(Math.max, "length"); +verifyNotWritable(Math.max, "length"); +verifyConfigurable(Math.max, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/name.js b/js/src/tests/test262/built-ins/Math/max/name.js new file mode 100644 index 0000000000..2078d602bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/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.24 +description: > + Math.max.name is "max". +info: | + Math.max ( 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.max.name, "max"); + +verifyNotEnumerable(Math.max, "name"); +verifyNotWritable(Math.max, "name"); +verifyConfigurable(Math.max, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/max/not-a-constructor.js new file mode 100644 index 0000000000..36e92c627c --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/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.max 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.max), false, 'isConstructor(Math.max) must return false'); + +assert.throws(TypeError, () => { + new Math.max(); +}, '`new Math.max()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/prop-desc.js b/js/src/tests/test262/built-ins/Math/max/prop-desc.js new file mode 100644 index 0000000000..6b8fbac518 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/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.max +description: > + "max" 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, "max"); +verifyWritable(Math, "max"); +verifyConfigurable(Math, "max"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/shell.js b/js/src/tests/test262/built-ins/Math/max/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/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; +} diff --git a/js/src/tests/test262/built-ins/Math/max/zeros.js b/js/src/tests/test262/built-ins/Math/max/zeros.js new file mode 100644 index 0000000000..42892ae481 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/max/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.max +description: > + +0 is considered to be larger than -0 +info: | + Math.max ( value1, value2 , …values ) + + The comparison of values to determine the largest value is done using the + Abstract Relational Comparison algorithm except that +0 is considered to be + larger than -0. +---*/ + +assert.sameValue(Math.max(0, 0), 0, "(0, 0)"); +assert.sameValue(Math.max(-0, -0), -0, "(-0, -0)"); +assert.sameValue(Math.max(0, -0), 0, "(0, -0)"); +assert.sameValue(Math.max(-0, 0), 0, "(-0, 0)"); +assert.sameValue(Math.max(0, 0, -0), 0, "(0, 0, -0)"); + +reportCompare(0, 0); |