forked from M-Labs/nac3
1
0
Fork 0

[standalone] Add tests for tuple equality

This commit is contained in:
David Mak 2024-08-21 15:39:48 +08:00
parent b8dab6cf7c
commit c5ae0e7c36
1 changed files with 42 additions and 0 deletions

View File

@ -1,3 +1,7 @@
@extern
def output_bool(b: bool):
...
@extern
def output_int32_list(x: list[int32]):
...
@ -13,6 +17,41 @@ class A:
self.a = a
self.b = b
def test_tuple_eq():
# 0-len
output_bool(() == ())
# 1-len
output_bool((1,) == ())
output_bool(() == (1,))
output_bool((1,) == (1,))
output_bool((1,) == (2,))
# # 2-len
output_bool((1, 2) == ())
output_bool(() == (1, 2))
output_bool((1,) == (1, 2))
output_bool((1, 2) == (1,))
output_bool((2, 2) == (1, 2))
output_bool((1, 2) == (2, 2))
def test_tuple_ne():
# 0-len
output_bool(() != ())
# 1-len
output_bool((1,) != ())
output_bool(() != (1,))
output_bool((1,) != (1,))
output_bool((1,) != (2,))
# 2-len
output_bool((1, 2) != ())
output_bool(() != (1, 2))
output_bool((1,) != (1, 2))
output_bool((1, 2) != (1,))
output_bool((2, 2) != (1, 2))
output_bool((1, 2) != (2, 2))
def run() -> int32:
data = [0, 1, 2, 3]
@ -33,4 +72,7 @@ def run() -> int32:
output_int32(len((1, 2, 3, 4)))
output_int32(len((1, 2, 3, 4, 5)))
test_tuple_eq()
test_tuple_ne()
return 0