diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Math/imul')
7 files changed, 187 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Math/imul/browser.js b/js/src/tests/test262/built-ins/Math/imul/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/imul/browser.js diff --git a/js/src/tests/test262/built-ins/Math/imul/length.js b/js/src/tests/test262/built-ins/Math/imul/length.js new file mode 100644 index 0000000000..e457fa6151 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/imul/length.js @@ -0,0 +1,30 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +es6id: 20.2.2.19 +description: length property of Math.imul +info: | + Math.imul ( x, y ) + + 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.imul.length, 2); + +verifyNotEnumerable(Math.imul, "length"); +verifyNotWritable(Math.imul, "length"); +verifyConfigurable(Math.imul, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/imul/name.js b/js/src/tests/test262/built-ins/Math/imul/name.js new file mode 100644 index 0000000000..46ed5dde63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/imul/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.19 +description: > + Math.imul.name is "imul". +info: | + Math.imul ( x, y ) + + 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.imul.name, "imul"); + +verifyNotEnumerable(Math.imul, "name"); +verifyNotWritable(Math.imul, "name"); +verifyConfigurable(Math.imul, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/imul/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/imul/not-a-constructor.js new file mode 100644 index 0000000000..000f83ab72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/imul/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.imul 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.imul), false, 'isConstructor(Math.imul) must return false'); + +assert.throws(TypeError, () => { + new Math.imul(); +}, '`new Math.imul()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/imul/prop-desc.js b/js/src/tests/test262/built-ins/Math/imul/prop-desc.js new file mode 100644 index 0000000000..695a24401d --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/imul/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.imul +includes: [propertyHelper.js] +es6id: 20.2.2.19 +---*/ + +verifyNotEnumerable(Math, "imul"); +verifyWritable(Math, "imul"); +verifyConfigurable(Math, "imul"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/imul/results.js b/js/src/tests/test262/built-ins/Math/imul/results.js new file mode 100644 index 0000000000..f67171191a --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/imul/results.js @@ -0,0 +1,60 @@ +// 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.imul +description: > + Return results +info: | + Math.imul ( x, y ) + + 1. Let a be ToUint32(x). + 2. Let b be ToUint32(y). + 3. Let product be (a × b) modulo 232. + 4. If product ≥ 231, return product - 232; otherwise return product. +---*/ + +assert.sameValue(Math.imul(2, 4), 8, "(2, 4)"); +assert.sameValue(Math.imul(-1, 8), -8, "(-1, 8)"); +assert.sameValue(Math.imul(-2, -2), 4, "(-2, -2)"); +assert.sameValue(Math.imul(0xffffffff, 5), -5, "(0xffffffff, 5)"); +assert.sameValue(Math.imul(0xfffffffe, 5), -10, "(0xfffffffe, 5)"); + +assert.sameValue(Math.imul(-0, 7), 0); +assert.sameValue(Math.imul(7, -0), 0); + +assert.sameValue(Math.imul(0.1, 7), 0); +assert.sameValue(Math.imul(7, 0.1), 0); +assert.sameValue(Math.imul(0.9, 7), 0); +assert.sameValue(Math.imul(7, 0.9), 0); +assert.sameValue(Math.imul(1.1, 7), 7); +assert.sameValue(Math.imul(7, 1.1), 7); +assert.sameValue(Math.imul(1.9, 7), 7); +assert.sameValue(Math.imul(7, 1.9), 7); + +assert.sameValue(Math.imul(1073741824, 7), -1073741824); +assert.sameValue(Math.imul(7, 1073741824), -1073741824); +assert.sameValue(Math.imul(1073741824, 1073741824), 0); + +assert.sameValue(Math.imul(-1073741824, 7), 1073741824); +assert.sameValue(Math.imul(7, -1073741824), 1073741824); +assert.sameValue(Math.imul(-1073741824, -1073741824), 0); + +assert.sameValue(Math.imul(2147483648, 7), -2147483648); +assert.sameValue(Math.imul(7, 2147483648), -2147483648); +assert.sameValue(Math.imul(2147483648, 2147483648), 0); + +assert.sameValue(Math.imul(-2147483648, 7), -2147483648); +assert.sameValue(Math.imul(7, -2147483648), -2147483648); +assert.sameValue(Math.imul(-2147483648, -2147483648), 0); + +assert.sameValue(Math.imul(2147483647, 7), 2147483641); +assert.sameValue(Math.imul(7, 2147483647), 2147483641); +assert.sameValue(Math.imul(2147483647, 2147483647), 1); + +assert.sameValue(Math.imul(65536, 65536), 0); +assert.sameValue(Math.imul(65535, 65536), -65536); +assert.sameValue(Math.imul(65536, 65535), -65536); +assert.sameValue(Math.imul(65535, 65535), -131071); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/imul/shell.js b/js/src/tests/test262/built-ins/Math/imul/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/imul/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; +} |