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/clz32 | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.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/clz32')
12 files changed, 263 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Math/clz32/Math.clz32.js b/js/src/tests/test262/built-ins/Math/clz32/Math.clz32.js new file mode 100644 index 0000000000..d73dec8999 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/Math.clz32.js @@ -0,0 +1,13 @@ +// 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.11 +author: Ryan Lewis +description: Math.clz32 should return 32 if passed 0. +---*/ + +assert.sameValue(Math.clz32(0), 32, 'Math.clz32(0)'); +assert.sameValue(Math.clz32(-0), 32, 'Math.clz32(-0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/Math.clz32_1.js b/js/src/tests/test262/built-ins/Math/clz32/Math.clz32_1.js new file mode 100644 index 0000000000..bdae08044f --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/Math.clz32_1.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.11 +author: Ryan Lewis +description: Math.clz32 should return 31 if passed 1. +---*/ + +assert.sameValue(Math.clz32(1), 31, 'Math.clz32(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/Math.clz32_2.js b/js/src/tests/test262/built-ins/Math/clz32/Math.clz32_2.js new file mode 100644 index 0000000000..b5e2fd8804 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/Math.clz32_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.11 +author: Ryan Lewis +description: Math.clz32 should return 0 if passed 2147483648 +---*/ + +assert.sameValue(Math.clz32(2147483648), 0, 'Math.clz32(2147483648)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/browser.js b/js/src/tests/test262/built-ins/Math/clz32/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/browser.js diff --git a/js/src/tests/test262/built-ins/Math/clz32/infinity.js b/js/src/tests/test262/built-ins/Math/clz32/infinity.js new file mode 100644 index 0000000000..87c6b6805e --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/infinity.js @@ -0,0 +1,25 @@ +// 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.clz32 +description: > + Return 32 if x is Infinity or -Infinity +info: | + Math.clz32 ( x ) + + 1. Let n be ToUint32(x). + 2. Let p be the number of leading zero bits in the 32-bit binary representation of n. + 3. Return p. + + 7.1.6 ToUint32 ( argument ) + + [...] + 2. If number is NaN, +0, -0, +∞, or -∞, return +0. + [...] +---*/ + +assert.sameValue(Math.clz32(Infinity), 32, "Infinity"); +assert.sameValue(Math.clz32(-Infinity), 32, "-Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/int32bit.js b/js/src/tests/test262/built-ins/Math/clz32/int32bit.js new file mode 100644 index 0000000000..b1056a6e7f --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/int32bit.js @@ -0,0 +1,49 @@ +// 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.clz32 +description: > + Catches the int32bit value in the ToUint32 operation +info: | + Math.clz32 ( x ) + + 1. Let n be ToUint32(x). + 2. Let p be the number of leading zero bits in the 32-bit binary representation of n. + 3. Return p. + + 7.1.6 ToUint32 ( argument ) + + [...] + 3. Let int be the mathematical value that is the same sign as number and whose + magnitude is floor(abs(number)). + 4. Let int32bit be int modulo 232. + 5. Return int32bit. + [...] +---*/ + +assert.sameValue(Math.clz32(4294967295), 0, "2**32-1"); +assert.sameValue(Math.clz32(4294967296), 32, "2**32"); +assert.sameValue(Math.clz32(4294967297), 31, "2**32+1"); + +assert.sameValue(Math.clz32(65535), 16, "2**16-1"); +assert.sameValue(Math.clz32(65536), 15, "2**16"); +assert.sameValue(Math.clz32(65537), 15, "2**16+1"); + +assert.sameValue(Math.clz32(255), 24, "2**8-1"); +assert.sameValue(Math.clz32(256), 23, "2**8"); +assert.sameValue(Math.clz32(257), 23, "2**8+1"); + +assert.sameValue(Math.clz32(-4294967295), 31, "-(2**32-1)"); +assert.sameValue(Math.clz32(-4294967296), 32, "-(2**32)"); +assert.sameValue(Math.clz32(-4294967297), 0, "-(2**32+1)"); + +assert.sameValue(Math.clz32(-65535), 0, "-(2**16-1)"); +assert.sameValue(Math.clz32(-65536), 0, "-(2**16)"); +assert.sameValue(Math.clz32(-65537), 0, "-(2**16+1)"); + +assert.sameValue(Math.clz32(-255), 0, "-(2**8-1)"); +assert.sameValue(Math.clz32(-256), 0, "-(2**8)"); +assert.sameValue(Math.clz32(-257), 0, "-(2**8+1)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/length.js b/js/src/tests/test262/built-ins/Math/clz32/length.js new file mode 100644 index 0000000000..038975b13d --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/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.11 +description: > + Math.clz32.length is 1. +info: | + Math.clz32 ( 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.clz32.length, 1); + +verifyNotEnumerable(Math.clz32, "length"); +verifyNotWritable(Math.clz32, "length"); +verifyConfigurable(Math.clz32, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/name.js b/js/src/tests/test262/built-ins/Math/clz32/name.js new file mode 100644 index 0000000000..2862f87439 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/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.11 +description: > + Math.clz32.name is "clz32". +info: | + Math.clz32 ( 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.clz32.name, "clz32"); + +verifyNotEnumerable(Math.clz32, "name"); +verifyNotWritable(Math.clz32, "name"); +verifyConfigurable(Math.clz32, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/nan.js b/js/src/tests/test262/built-ins/Math/clz32/nan.js new file mode 100644 index 0000000000..9f1e044138 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/nan.js @@ -0,0 +1,24 @@ +// 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.clz32 +description: > + Return 32 if x is NaN +info: | + Math.clz32 ( x ) + + 1. Let n be ToUint32(x). + 2. Let p be the number of leading zero bits in the 32-bit binary representation of n. + 3. Return p. + + 7.1.6 ToUint32 ( argument ) + + [...] + 2. If number is NaN, +0, -0, +∞, or -∞, return +0. + [...] +---*/ + +assert.sameValue(Math.clz32(NaN), 32); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/clz32/not-a-constructor.js new file mode 100644 index 0000000000..2bff88114f --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/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.clz32 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.clz32), false, 'isConstructor(Math.clz32) must return false'); + +assert.throws(TypeError, () => { + new Math.clz32(); +}, '`new Math.clz32()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/prop-desc.js b/js/src/tests/test262/built-ins/Math/clz32/prop-desc.js new file mode 100644 index 0000000000..96617d887a --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/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.clz32 +description: > + "clz32" 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, "clz32"); +verifyWritable(Math, "clz32"); +verifyConfigurable(Math, "clz32"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/shell.js b/js/src/tests/test262/built-ins/Math/clz32/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/clz32/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; +} |