From ffd4eb88a67fe6ba5284434e9de2d6167e0b38d7 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Mon, 6 May 2024 12:04:10 +0530 Subject: [PATCH 1/6] Support `tuple` and `set` --- src/libasr/pass/intrinsic_functions.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libasr/pass/intrinsic_functions.h b/src/libasr/pass/intrinsic_functions.h index 959f136e1f..16fc29c52e 100644 --- a/src/libasr/pass/intrinsic_functions.h +++ b/src/libasr/pass/intrinsic_functions.h @@ -540,6 +540,10 @@ namespace ObjectType { object_type += "list"; break; } case ASR::ttypeType::Dict : { object_type += "dict"; break; + } case ASR::ttypeType::Set : { + object_type += "set"; break; + } case ASR::ttypeType::Tuple : { + object_type += "tuple"; break; } default: { LCOMPILERS_ASSERT_MSG(false, "Unsupported type"); break; From 8a5020a91bc03c5df291c69984a3f08fe559afb3 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Mon, 6 May 2024 12:04:27 +0530 Subject: [PATCH 2/6] Tests: Add tests --- integration_tests/test_builtin_type.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/integration_tests/test_builtin_type.py b/integration_tests/test_builtin_type.py index 5fc81eadfa..bdea2bd8e9 100644 --- a/integration_tests/test_builtin_type.py +++ b/integration_tests/test_builtin_type.py @@ -6,6 +6,8 @@ def test_builtin_type(): s: str = "Hello, LPython!" l: list[i32] = [1, 2, 3, 4, 5] d: dict[str, i32] = {"a": 1, "b": 2, "c": 3} + t: tuple[str, i32] = ("a", 1) + st: set[i32] = {1, 2, 3, 4} res: str = "" res = str(type(i)) @@ -23,5 +25,12 @@ def test_builtin_type(): res = str(type(d)) print(res) assert res == "" + res = str(type(t)) + print(res) + assert res == "" + res = str(type(st)) + print(res) + assert res == "" + test_builtin_type() From 218e4c356d0241ae516f7b11ee0fc1c79b3ed1b9 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Mon, 6 May 2024 20:18:34 +0530 Subject: [PATCH 3/6] Tests: Remove C backend --- integration_tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 517b40dd9a..4dc7cfb30d 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -831,7 +831,7 @@ RUN(NAME callback_04 IMPORT_PATH .. LABELS cpython) # Intrinsic Functions RUN(NAME intrinsics_01 LABELS cpython llvm llvm_jit NOFAST) # any RUN(NAME intrinsics_02 LABELS cpython llvm llvm_jit c) # floordiv -RUN(NAME test_builtin_type LABELS cpython llvm llvm_jit c) # type +RUN(NAME test_builtin_type LABELS cpython llvm llvm_jit) # type # lpython decorator RUN(NAME lpython_decorator_01 LABELS cpython) From 6cb24c0de6f171816c691d7aaacc3cfc52502de1 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Mon, 6 May 2024 21:37:01 +0530 Subject: [PATCH 4/6] Tests: Add separate tests for `set` --- integration_tests/CMakeLists.txt | 3 ++- integration_tests/test_builtin_type_set.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 integration_tests/test_builtin_type_set.py diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 4dc7cfb30d..cb5287543c 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -831,7 +831,8 @@ RUN(NAME callback_04 IMPORT_PATH .. LABELS cpython) # Intrinsic Functions RUN(NAME intrinsics_01 LABELS cpython llvm llvm_jit NOFAST) # any RUN(NAME intrinsics_02 LABELS cpython llvm llvm_jit c) # floordiv -RUN(NAME test_builtin_type LABELS cpython llvm llvm_jit) # type +RUN(NAME test_builtin_type LABELS cpython llvm llvm_jit c) # type +RUN(NAME test_builtin_type_set LABELS cpython llvm llvm_jit) # type (specifically for `set`) # lpython decorator RUN(NAME lpython_decorator_01 LABELS cpython) diff --git a/integration_tests/test_builtin_type_set.py b/integration_tests/test_builtin_type_set.py new file mode 100644 index 0000000000..ad0046c419 --- /dev/null +++ b/integration_tests/test_builtin_type_set.py @@ -0,0 +1,11 @@ +from lpython import i32 + +def test_builtin_type_set(): + st: set[i32] = {1, 2, 3, 4} + + res = str(type(st)) + print(res) + assert res == "" + + +test_builtin_type_set() From e55e1e5dc4ad82ac2f6e9dcb6e74ae5af2bd05ad Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Tue, 7 May 2024 09:03:43 +0530 Subject: [PATCH 5/6] Tests: Update test --- integration_tests/test_builtin_type_set.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/test_builtin_type_set.py b/integration_tests/test_builtin_type_set.py index ad0046c419..d0265b1c1a 100644 --- a/integration_tests/test_builtin_type_set.py +++ b/integration_tests/test_builtin_type_set.py @@ -3,7 +3,7 @@ def test_builtin_type_set(): st: set[i32] = {1, 2, 3, 4} - res = str(type(st)) + res: str = str(type(st)) print(res) assert res == "" From 057719f29b9d7c9b9ca2b9ab59596a0bf796b417 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Tue, 7 May 2024 11:27:58 +0530 Subject: [PATCH 6/6] Tests: Remove redundant `set` test --- integration_tests/test_builtin_type.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/integration_tests/test_builtin_type.py b/integration_tests/test_builtin_type.py index bdea2bd8e9..188313444f 100644 --- a/integration_tests/test_builtin_type.py +++ b/integration_tests/test_builtin_type.py @@ -7,7 +7,6 @@ def test_builtin_type(): l: list[i32] = [1, 2, 3, 4, 5] d: dict[str, i32] = {"a": 1, "b": 2, "c": 3} t: tuple[str, i32] = ("a", 1) - st: set[i32] = {1, 2, 3, 4} res: str = "" res = str(type(i)) @@ -28,9 +27,6 @@ def test_builtin_type(): res = str(type(t)) print(res) assert res == "" - res = str(type(st)) - print(res) - assert res == "" test_builtin_type()