Skip to content

Commit e276f33

Browse files
committed
Add test check_listcopy.test
1 parent eb73b21 commit e276f33

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed

mypyc/test-data/run-lists.test

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,8 @@ print(2, a)
5151
1 [-1, 5]
5252
2 [340282366920938463463374607431768211461, -170141183460469231731687303715884105736]
5353

54-
[case testListCopy]
55-
from typing import List
56-
def test_list_copy() -> None:
57-
l1 = [1, 2, 3, -4, 5]
58-
l2 = l1.copy()
59-
assert l1.copy() == l1
60-
assert l1.copy() == l2
61-
assert l1 == l2
62-
assert l1.copy() == l2.copy()
63-
l1 = l2.copy()
64-
assert l1 == l2
65-
assert l1.copy() == l2
66-
assert l1 == [1, 2, 3, -4, 5]
67-
l2 = [1, 2, -3]
68-
l1 = []
69-
assert l1.copy() == []
70-
assert l2.copy() != l1
71-
assert l2 == l2.copy()
72-
l1 = l2
73-
assert l1.copy().copy() == l2.copy().copy().copy()
74-
assert l1.copy() == l2.copy()
75-
l1 == [1, 2, -3].copy()
76-
assert l1 == l2
77-
l2 = [1, 2, 3].copy()
78-
assert l2 != l1
79-
l1 = [1, 2, 3]
80-
assert l1.copy() == l2.copy()
81-
8254
[case testSieve]
8355
from typing import List
84-
8556
def primes(n: int) -> List[int]:
8657
a = [1] * (n + 1)
8758
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)