mirror of https://github.com/tc39/test262.git
Add tests for %TypedArray%.prototype.copyWithin() with target/start/end=Infinity (#849)
ToInteger can result in the values +Infinity and -Infinity.
This commit is contained in:
parent
f21ac5609b
commit
be0964c8ff
|
@ -37,6 +37,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
'[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
)
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -2, -10),
|
||||
|
@ -45,6 +53,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
'[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, -2, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
)
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -9, -10),
|
||||
|
@ -53,6 +69,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
'[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, -9, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
)
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10),
|
||||
|
@ -61,6 +85,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
'[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-3, -2, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
)
|
||||
'[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9),
|
||||
|
@ -68,4 +100,12 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
),
|
||||
'[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-7, -8, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
)
|
||||
'[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -35,6 +35,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
'[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, -Infinity),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(2, -10),
|
||||
|
@ -43,6 +51,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
'[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(2, -Infinity),
|
||||
[1, 2, 1, 2, 3]
|
||||
),
|
||||
'[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(10, -10),
|
||||
|
@ -51,6 +67,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
'[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(10, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-9, -10),
|
||||
|
@ -58,4 +82,12 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
),
|
||||
'[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-9, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -35,6 +35,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
'[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 0),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2),
|
||||
|
@ -42,4 +50,12 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 2),
|
||||
[3, 4, 5, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -28,6 +28,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
'[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, Infinity),
|
||||
[2, 3, 4, 5, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 6),
|
||||
|
@ -35,4 +43,12 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(1, 3, Infinity),
|
||||
[1, 4, 5, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -27,6 +27,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
)
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, 0),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(0, 6),
|
||||
|
@ -34,6 +42,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
)
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 6),
|
||||
|
@ -47,4 +63,12 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
[0, 1, 2, 3, 4, 5]
|
||||
)
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue