Commit f788bd9c authored by bakkot's avatar bakkot Committed by Commit bot

Amends the TypedArray constructor to use the path for primitives for all

types of primitives, not just undefined, booleans, numbers, and strings.
(The missing cases were null and Symbol.) This is required by the
specification, and there are test262 tests which we were failing due to
this bug.

BUG=v8:5124

Review-Url: https://codereview.chromium.org/2096873002
Cr-Commit-Position: refs/heads/master@{#37234}
parent cbbcef80
......@@ -262,18 +262,17 @@ function NAMEConstructor(arg1, arg2, arg3) {
if (!IS_UNDEFINED(new.target)) {
if (IS_ARRAYBUFFER(arg1) || IS_SHAREDARRAYBUFFER(arg1)) {
NAMEConstructByArrayBuffer(this, arg1, arg2, arg3);
} else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
NAMEConstructByLength(this, arg1);
} else if (IS_TYPEDARRAY(arg1)) {
NAMEConstructByTypedArray(this, arg1);
} else {
} else if (IS_RECEIVER(arg1)) {
var iteratorFn = arg1[iteratorSymbol];
if (IS_UNDEFINED(iteratorFn) || iteratorFn === ArrayValues) {
NAMEConstructByArrayLike(this, arg1, arg1.length);
} else {
NAMEConstructByIterable(this, arg1, iteratorFn);
}
} else {
NAMEConstructByLength(this, arg1);
}
} else {
throw MakeTypeError(kConstructorNotFunction, "NAME")
......
......@@ -229,6 +229,27 @@ function TestTypedArray(constr, elementSize, typicalElement) {
RangeError);
}
var aFromUndef = new constr();
assertSame(elementSize, aFromUndef.BYTES_PER_ELEMENT);
assertSame(0, aFromUndef.length);
assertSame(0*elementSize, aFromUndef.byteLength);
assertSame(0, aFromUndef.byteOffset);
assertSame(0*elementSize, aFromUndef.buffer.byteLength);
var aFromNull = new constr(null);
assertSame(elementSize, aFromNull.BYTES_PER_ELEMENT);
assertSame(0, aFromNull.length);
assertSame(0*elementSize, aFromNull.byteLength);
assertSame(0, aFromNull.byteOffset);
assertSame(0*elementSize, aFromNull.buffer.byteLength);
var aFromBool = new constr(true);
assertSame(elementSize, aFromBool.BYTES_PER_ELEMENT);
assertSame(1, aFromBool.length);
assertSame(1*elementSize, aFromBool.byteLength);
assertSame(0, aFromBool.byteOffset);
assertSame(1*elementSize, aFromBool.buffer.byteLength);
var aFromString = new constr("30");
assertSame(elementSize, aFromString.BYTES_PER_ELEMENT);
assertSame(30, aFromString.length);
......@@ -236,6 +257,8 @@ function TestTypedArray(constr, elementSize, typicalElement) {
assertSame(0, aFromString.byteOffset);
assertSame(30*elementSize, aFromString.buffer.byteLength);
assertThrows(function() { new constr(Symbol()); }, TypeError);
var jsArray = [];
for (i = 0; i < 30; i++) {
jsArray.push(typicalElement);
......
......@@ -132,12 +132,6 @@
'built-ins/ArrayBuffer/positive-integer-length': [FAIL],
'language/statements/class/subclass/builtin-objects/ArrayBuffer/regular-subclassing': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4727
'built-ins/TypedArrays/length-arg-is-undefined-throws': [FAIL],
'built-ins/TypedArrays/length-arg-is-symbol-throws': [FAIL],
'built-ins/TypedArrays/length-arg-is-float-throws-rangeerror': [FAIL],
'built-ins/TypedArrays/length-arg-is-nan-throws-rangeerror': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4784
'built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws': [FAIL],
'built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws': [FAIL],
......@@ -433,9 +427,6 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=5121
'language/expressions/assignment/destructuring/obj-prop-__proto__dup': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=5124
'built-ins/TypedArrays/length-arg-toindex-length': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4973
'language/literals/numeric/non-octal-decimal-integer-strict': [FAIL],
......@@ -572,6 +563,9 @@
'built-ins/RegExp/prototype/ignoreCase/15.10.7.3-1': [FAIL],
'built-ins/RegExp/prototype/multiline/15.10.7.4-1': [FAIL],
# https://github.com/tc39/test262/issues/694
'built-ins/TypedArrays/length-arg-toindex-length': [FAIL],
############################ SKIPPED TESTS #############################
# These tests take a looong time to run.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment