This does not match ES6 spec but is the behavior in both Firefox and WebKit/Blink.
R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/19086003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15655 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
1384094efc
commit
a6419e3e47
@ -154,7 +154,7 @@ function TypedArraySet(obj, offset) {
|
||||
|
||||
var l = obj.length;
|
||||
if (IS_UNDEFINED(l)) {
|
||||
throw MakeTypeError("invalid_argument");
|
||||
return;
|
||||
}
|
||||
if (intOffset + l > this.length) {
|
||||
throw MakeRangeError("typed_array_set_source_too_large");
|
||||
|
@ -606,8 +606,10 @@ a61.set(a62)
|
||||
assertArrayPrefix([1, 12], a61)
|
||||
|
||||
// Invalid source
|
||||
assertThrows(function() { a.set(0) })
|
||||
assertThrows(function() { a.set({}) })
|
||||
a.set(0); // does not throw
|
||||
assertArrayPrefix([1,2,3,4,5,6], a);
|
||||
a.set({}); // does not throw
|
||||
assertArrayPrefix([1,2,3,4,5,6], a);
|
||||
|
||||
|
||||
// Test arraybuffer.slice
|
||||
|
@ -605,8 +605,10 @@ a61.set(a62)
|
||||
assertArrayPrefix([1, 12], a61)
|
||||
|
||||
// Invalid source
|
||||
assertThrows(function() { a.set(0) })
|
||||
assertThrows(function() { a.set({}) })
|
||||
a.set(0); // does not throw
|
||||
assertArrayPrefix([1,2,3,4,5,6], a);
|
||||
a.set({}); // does not throw
|
||||
assertArrayPrefix([1,2,3,4,5,6], a);
|
||||
|
||||
|
||||
// Test arraybuffer.slice
|
||||
|
@ -453,8 +453,15 @@ function TestTypedArraySet() {
|
||||
|
||||
// Invalid source
|
||||
var a = new Uint16Array(50);
|
||||
assertThrows(function() { a.set(0) }, TypeError);
|
||||
assertThrows(function() { a.set({}) }, TypeError);
|
||||
var expected = [];
|
||||
for (i = 0; i < 50; i++) {
|
||||
a[i] = i;
|
||||
expected.push(i);
|
||||
}
|
||||
a.set(0);
|
||||
assertArrayPrefix(expected, a);
|
||||
a.set({});
|
||||
assertArrayPrefix(expected, a);
|
||||
assertThrows(function() { a.set.call({}) }, TypeError);
|
||||
assertThrows(function() { a.set.call([]) }, TypeError);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user