diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Math/hypot | |
parent | Initial commit. (diff) | |
download | firefox-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/hypot')
14 files changed, 264 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_Infinity.js b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_Infinity.js new file mode 100644 index 0000000000..b1044692b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_Infinity.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.2.2.18 +author: Ryan Lewis +description: > + Math.hypot should return Infinity if called with any argument that + is Infinity. +---*/ + +assert.sameValue(Math.hypot(3, Infinity), Infinity, 'Math.hypot(3, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_InfinityNaN.js b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_InfinityNaN.js new file mode 100644 index 0000000000..d06561cdd2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_InfinityNaN.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.2.2.18 +author: Ryan Lewis +description: > + Math.hypot should return Infinity if called with any argument that + is Infinity. +---*/ + +assert.sameValue(Math.hypot(NaN, Infinity), Infinity, 'Math.hypot(NaN, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_NaN.js b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_NaN.js new file mode 100644 index 0000000000..36260e96f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_NaN.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.2.2.18 +author: Ryan Lewis +description: > + Math.hypot should return NaN if called with any argument that is + NaN. +---*/ + +assert.sameValue(Math.hypot(NaN, 3), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_NegInfinity.js b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_NegInfinity.js new file mode 100644 index 0000000000..5c4dd8566b --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_NegInfinity.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.2.2.18 +author: Ryan Lewis +description: > + Math.hypot should return Infinity if called with any argument that + is -Infinity. +---*/ + +assert.sameValue(Math.hypot(3, -Infinity), Infinity, 'Math.hypot(3, -Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_NoArgs.js b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_NoArgs.js new file mode 100644 index 0000000000..328fd8de43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_NoArgs.js @@ -0,0 +1,12 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.2.2.18 +author: Ryan Lewis +description: Math.hypot should return 0 if called with no arguments. +---*/ + +assert.sameValue(Math.hypot(), 0, 'Math.hypot()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_Success_2.js b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_Success_2.js new file mode 100644 index 0000000000..15fcca9749 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_Success_2.js @@ -0,0 +1,12 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.2.2.18 +author: Ryan Lewis +description: Math.hypot should return 5 if called with 3 and 4. +---*/ + +assert.sameValue(Math.hypot(3, 4), 5, 'Math.hypot(3,4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_ToNumberErr.js b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_ToNumberErr.js new file mode 100644 index 0000000000..ae2fc40f1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_ToNumberErr.js @@ -0,0 +1,37 @@ +// Copyright (c) 2021 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Math.hypot should coerce all arguments before inspecting them. +esid: sec-math.hypot +info: | + 1. Let _coerced_ be a new empty List. + 2. For each element _arg_ of _args_, do + a. Let _n_ be ? ToNumber(_arg_). + b. Append _n_ to _coerced_. + 3. For each element _number_ of _coerced_, do +---*/ + +var counter = 0; + +assert.throws( + Test262Error, + function() { + Math.hypot( + Infinity, + -Infinity, + NaN, + 0, + -0, + {valueOf: function(){ throw new Test262Error(); }}, + {valueOf: function(){ counter++; }} + ); + }, + 'Math.hypot propagates an abrupt completion from coercing an argument to Number' +); + +assert.sameValue(counter, 0, + 'Math.hypot aborts argument processing at the first abrupt completion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_Zero_2.js b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_Zero_2.js new file mode 100644 index 0000000000..0e121bd021 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/Math.hypot_Zero_2.js @@ -0,0 +1,19 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-math.hypot +es6id: 20.2.2.18 +author: Ryan Lewis +description: Math.hypot should return 0 if all arguments are 0 or -0. +---*/ + +assert.sameValue(Math.hypot(0), 0, 'Math.hypot(0)'); +assert.sameValue(Math.hypot(-0), 0, 'Math.hypot(-0)'); +assert.sameValue(Math.hypot(0, 0), 0, 'Math.hypot(0, 0)'); +assert.sameValue(Math.hypot(0, -0), 0, 'Math.hypot(0, -0)'); +assert.sameValue(Math.hypot(-0, 0), 0, 'Math.hypot(-0, 0)'); +assert.sameValue(Math.hypot(-0, -0), 0, 'Math.hypot(-0, -0)'); +assert.sameValue(Math.hypot(0, -0, -0), 0, 'Math.hypot(0, -0, -0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/browser.js b/js/src/tests/test262/built-ins/Math/hypot/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/browser.js diff --git a/js/src/tests/test262/built-ins/Math/hypot/length.js b/js/src/tests/test262/built-ins/Math/hypot/length.js new file mode 100644 index 0000000000..9800debc1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/length.js @@ -0,0 +1,31 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 20.2.2.18 +author: Ryan Lewis +description: Math.hypot.length should return 2. +info: | + Math.hypot ( value1, value2, ...values ) + + 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.hypot.length, 2); + +verifyNotEnumerable(Math.hypot, "length"); +verifyNotWritable(Math.hypot, "length"); +verifyConfigurable(Math.hypot, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/name.js b/js/src/tests/test262/built-ins/Math/hypot/name.js new file mode 100644 index 0000000000..46d395ca06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/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.18 +description: > + Math.hypot.name is "hypot". +info: | + Math.hypot ( 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.hypot.name, "hypot"); + +verifyNotEnumerable(Math.hypot, "name"); +verifyNotWritable(Math.hypot, "name"); +verifyConfigurable(Math.hypot, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/hypot/not-a-constructor.js new file mode 100644 index 0000000000..21ff4ba634 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/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.hypot 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.hypot), false, 'isConstructor(Math.hypot) must return false'); + +assert.throws(TypeError, () => { + new Math.hypot(); +}, '`new Math.hypot()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/prop-desc.js b/js/src/tests/test262/built-ins/Math/hypot/prop-desc.js new file mode 100644 index 0000000000..3161342511 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/prop-desc.js @@ -0,0 +1,14 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Testing descriptor property of Math.hypot +includes: [propertyHelper.js] +es6id: 20.2.2.18 +---*/ + +verifyNotEnumerable(Math, "hypot"); +verifyWritable(Math, "hypot"); +verifyConfigurable(Math, "hypot"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/shell.js b/js/src/tests/test262/built-ins/Math/hypot/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/hypot/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; +} |