mirror of https://github.com/tc39/test262.git
Add Infinity test cases to Array.prototype.copyWithin (#882)
Fixes #861 Ref #849 Based on the cases from TypedArray.prototype.copyWithin
This commit is contained in:
parent
866d7f8d8e
commit
c062d93012
|
@ -25,6 +25,14 @@ assert(
|
|||
'[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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(
|
||||
[0, 1, 2, 3].copyWithin(0, -2, -10),
|
||||
|
@ -33,6 +41,14 @@ assert(
|
|||
'[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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(
|
||||
[0, 1, 2, 3].copyWithin(0, -9, -10),
|
||||
|
@ -41,6 +57,14 @@ assert(
|
|||
'[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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(
|
||||
[0, 1, 2, 3].copyWithin(-3, -2, -10),
|
||||
|
@ -49,10 +73,26 @@ assert(
|
|||
'[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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(
|
||||
[0, 1, 2, 3].copyWithin(-7, -8, -9),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
|
||||
);
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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]'
|
||||
);
|
||||
|
|
|
@ -22,6 +22,14 @@ assert(
|
|||
'[0, 1, 2, 3].copyWithin(0, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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(
|
||||
[0, 1, 2, 3, 4].copyWithin(2, -10),
|
||||
|
@ -30,6 +38,15 @@ assert(
|
|||
'[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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(
|
||||
[0, 1, 2, 3, 4].copyWithin(10, -10),
|
||||
|
@ -38,6 +55,15 @@ assert(
|
|||
'[0, 1, 2, 3, 4].copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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(
|
||||
[0, 1, 2, 3].copyWithin(-9, -10),
|
||||
|
@ -45,3 +71,11 @@ assert(
|
|||
),
|
||||
'[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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]'
|
||||
);
|
||||
|
|
|
@ -22,6 +22,14 @@ assert(
|
|||
'[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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(
|
||||
[0, 1, 2, 3, 4].copyWithin(-10, 2),
|
||||
|
@ -29,3 +37,11 @@ assert(
|
|||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[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]'
|
||||
);
|
||||
|
|
|
@ -41,10 +41,26 @@ assert(
|
|||
'[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3].copyWithin(0, 1, Infinity),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, Infinity) -> [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6),
|
||||
[0, 3, 4, 5, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
|
||||
);
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(1, 3, Infinity),
|
||||
[0, 3, 4, 5, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [0, 3, 4, 5, 4, 5]'
|
||||
);
|
||||
|
|
|
@ -31,26 +31,120 @@ assert(
|
|||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(6, 0),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
)
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(6, 0) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(7, 0),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(6, 0) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(Infinity, 0),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(Infinity, 0) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(6, 2),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(6, 2) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(7, 2),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(7, 2) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(Infinity, 2),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(Infinity, 2) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(0, 6),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
)
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(0, 6) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(0, 7),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(0, 7) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(0, Infinity),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(0, Infinity) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(2, 6),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(2, 6) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(1, 7),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(1, 7) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(3, Infinity),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(3, Infinity) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(6, 6),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
)
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(6, 6) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(10, 10),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
)
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(10, 10) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(Infinity, Infinity),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) => [0, 1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue