Skip to content

Commit

Permalink
Tests: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kmr-srbh committed Mar 28, 2024
1 parent c39f350 commit 3a9424e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ RUN(NAME test_dict_nested1 LABELS cpython llvm)
RUN(NAME test_set_len LABELS cpython llvm)
RUN(NAME test_set_add LABELS cpython llvm)
RUN(NAME test_set_remove LABELS cpython llvm)
RUN(NAME test_set_discard LABELS cpython llvm)
RUN(NAME test_global_set LABELS cpython llvm)
RUN(NAME test_for_loop LABELS cpython llvm c)
RUN(NAME modules_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
Expand Down
48 changes: 48 additions & 0 deletions integration_tests/test_set_discard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()

0 comments on commit 3a9424e

Please sign in to comment.