Skip to content

Commit 8e149f4

Browse files
committed
Add test check_listcopy.test
1 parent 6d9ae0a commit 8e149f4

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

mypyc/test-data/run-lists.test

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ print(2, a)
5151
1 [-1, 5]
5252
2 [340282366920938463463374607431768211461, -170141183460469231731687303715884105736]
5353

54+
<<<<<<< HEAD
55+
<<<<<<< HEAD
5456
[case testListCopy]
57+
from typing import List
5558
def test_list_copy() -> None:
5659
l1 = [1, 2, 3, -4, 5]
5760
l2 = l1.copy()
@@ -78,9 +81,12 @@ def test_list_copy() -> None:
7881
l1 = [1, 2, 3]
7982
assert l1.copy() == l2.copy()
8083

84+
=======
85+
>>>>>>> e276f33f1 (Add test check_listcopy.test)
86+
=======
87+
>>>>>>> d1f946e3d (Remove test)
8188
[case testSieve]
8289
from typing import List
83-
8490
def primes(n: int) -> List[int]:
8591
a = [1] * (n + 1)
8692
a[0] = 0

test-data/unit/check-listcopy.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[case testListCopy]
2+
[builtins fixtures/list.pyi]
3+
def test_list_copy() -> None:
4+
l1 = [1, 2, 3, -4, 5]
5+
l2 = l1.copy()
6+
assert l1.copy() == l1
7+
assert l1.copy() == l2
8+
assert l1 == l2
9+
assert l1.copy() == l2.copy()
10+
l1 = l2.copy()
11+
assert l1 == l2
12+
assert l1.copy() == l2
13+
assert l1 == [1, 2, 3, -4, 5]
14+
l2 = [1, 2, -3]
15+
l1 = []
16+
assert l1.copy() == []
17+
assert l2.copy() != l1
18+
assert l2 == l2.copy()
19+
l1 = l2
20+
assert l1.copy().copy() == l2.copy().copy().copy()
21+
assert l1.copy() == l2.copy()
22+
l1 == [1, 2, -3].copy()
23+
assert l1 == l2
24+
l2 = [1, 2, 3].copy()
25+
assert l2 != l1
26+
l1 = [1, 2, 3]
27+
assert l1.copy() == l2.copy()
28+
l3 = ["string", 2 , 3]
29+
assert l3 == l3.copy()
30+
l2 = ["string", 2, 3]
31+
assert l2 == l3.copy()

test-data/unit/fixtures/list.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class list(Sequence[T]):
2525
def __setitem__(self, x: int, v: T) -> None: pass
2626
def append(self, x: T) -> None: pass
2727
def extend(self, x: Iterable[T]) -> None: pass
28+
def copy(self) -> list[T] : pass
2829

2930
class tuple(Generic[T]): pass
3031
class function: pass

0 commit comments

Comments
 (0)