Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list comparison #2025

Merged
merged 6 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test for less than
  • Loading branch information
kabra1110 committed Jun 25, 2023
commit f3f720b20872356b2d94e2476267a163f40dc965
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ RUN(NAME test_list_repeat LABELS cpython llvm NOFAST)
RUN(NAME test_list_reverse LABELS cpython llvm)
RUN(NAME test_list_pop LABELS cpython llvm NOFAST) # TODO: Remove NOFAST from here.
RUN(NAME test_list_pop2 LABELS cpython llvm NOFAST) # TODO: Remove NOFAST from here.
RUN(NAME test_list_compare LABELS cpython llvm)
RUN(NAME test_tuple_01 LABELS cpython llvm c)
RUN(NAME test_tuple_02 LABELS cpython llvm c NOFAST)
RUN(NAME test_tuple_03 LABELS cpython llvm c)
Expand Down
33 changes: 33 additions & 0 deletions integration_tests/test_list_compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from lpython import i32, f64

def test_list_compare():
l1: list[i32] = [1, 2, 3]
l2: list[i32] = [1, 2, 3, 4]
l3: list[tuple[i32, f64, str]] = [(1, 2.0, 'a'), (3, 4.0, 'b')]
l4: list[tuple[i32, f64, str]] = [(1, 3.0, 'a')]
l5: list[list[str]] = [[''], ['']]
l6: list[str] = []
l7: list[str] = []
i: i32

assert l1 < l2
i = l2.pop()
i = l2.pop()
assert l2 < l1
assert not (l1 < l2)

assert l3 < l4
l4[0] = l3[0]
assert l4 < l3

for i in range(0, 10):
if i % 2 == 0:
l6.append('a')
else:
l7.append('a')
l5[0] = l6
l5[1] = l7
if i % 2 == 0:
assert l5[1 - i % 2] < l5[i % 2]

test_list_compare()