-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathtest_set_discard.py
48 lines (40 loc) · 985 Bytes
/
test_set_discard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from lpython import i32
def test_set_discard():
s1: set[i32]
s2: set[tuple[i32, tuple[i32, i32], str]]
s3: set[str]
st1: str
i: i32
j: i32
k: i32
for k in range(2):
s1 = {0}
s2 = {(0, (1, 2), "a")}
for i in range(20):
j = i % 10
s1.add(j)
s2.add((j, (j + 1, j + 2), "a"))
for i in range(10):
s1.discard(i)
s2.discard((i, (i + 1, i + 2), "a"))
assert len(s1) == 10 - 1 - i
assert len(s1) == len(s2)
st1 = "a"
s3 = {st1}
for i in range(20):
s3.add(st1)
if i < 10:
if i > 0:
st1 += "a"
st1 = "a"
for i in range(10):
s3.discard(st1)
assert len(s3) == 10 - 1 - i
if i < 10:
st1 += "a"
for i in range(20):
s1.add(i)
if i % 2 == 0:
s1.discard(i)
assert len(s1) == (i + 1) // 2
test_set_discard()