From c5ae0e7c36c233ac7840b7ce1f9f15e4f2dd328b Mon Sep 17 00:00:00 2001 From: David Mak Date: Wed, 21 Aug 2024 15:39:48 +0800 Subject: [PATCH] [standalone] Add tests for tuple equality --- nac3standalone/demo/src/tuple.py | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/nac3standalone/demo/src/tuple.py b/nac3standalone/demo/src/tuple.py index 6947171d..988739f7 100644 --- a/nac3standalone/demo/src/tuple.py +++ b/nac3standalone/demo/src/tuple.py @@ -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 \ No newline at end of file