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.
This commit is contained in:
Leonardo Balter 2016-01-15 15:51:54 -05:00
parent 8f8b663ce7
commit 1a64295a0b
2 changed files with 30 additions and 22 deletions

View File

@ -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);
});

View File

@ -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);
});