From 1a64295a0bac867d69b0d1718ee0504bf738cbe8 Mon Sep 17 00:00:00 2001 From: Leonardo Balter <leonardo.balter@gmail.com> Date: Fri, 15 Jan 2016 15:51:54 -0500 Subject: [PATCH] Replace TypedArray constructor invalid length test for ES2016 specs Replace a ES2015 test where calling the TypedArray constructor with a floating number triggered a RangeError. Within the ES2016 specs, the same call will trigger a TypeError, as the result for `SameValue(NewTarget, here)` will be checked before. --- .../invoked-as-ctor-with-arguments.js | 30 +++++++++++++++++++ test/built-ins/TypedArray/length-invalid.js | 22 -------------- 2 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 test/built-ins/TypedArray/invoked-as-ctor-with-arguments.js delete mode 100644 test/built-ins/TypedArray/length-invalid.js diff --git a/test/built-ins/TypedArray/invoked-as-ctor-with-arguments.js b/test/built-ins/TypedArray/invoked-as-ctor-with-arguments.js new file mode 100644 index 0000000000..6bc266f56b --- /dev/null +++ b/test/built-ins/TypedArray/invoked-as-ctor-with-arguments.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es7id: pending +description: TypedArray(length) cannot be direclty invoked as a constructor +info: > + 22.2.1.1 %TypedArray%()# + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let here be the active function object. + 3. If SameValue(NewTarget, here) is true, throw a TypeError exception. + ... + + Note: there's a breaking change from ES2015's 22.2.1.2 step 7 where calling + the %TypedArray% constructor with a floating number as the argument throws a + RangeError exception before checking `SameValue(NewTarget, here)`. +includes: [testTypedArray.js] +---*/ + +assert.throws(TypeError, function() { + new TypedArray(1); +}); + +assert.throws(TypeError, function() { + new TypedArray({}); +}); + +assert.throws(TypeError, function() { + new TypedArray(1.1); +}); diff --git a/test/built-ins/TypedArray/length-invalid.js b/test/built-ins/TypedArray/length-invalid.js deleted file mode 100644 index fc51e5465d..0000000000 --- a/test/built-ins/TypedArray/length-invalid.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 22.2.1.2 -description: TypedArray rejects non-integer arguments -info: > - 22.2.1.2 %TypedArray% ( length ) - - ... - 4. Let numberLength be ToNumber(length). - 5. Let elementLength be ToLength(numberLength). - 6. ReturnIfAbrupt(elementLength). - 7. If SameValueZero(numberLength, elementLength) is false, throw a RangeError - exception. - ... -features: [TypedArray] -includes: [testTypedArray.js] ----*/ - -assert.throws(RangeError, function() { - new TypedArray(1.1); -}); -- GitLab