Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ RUN(NAME callback_04 IMPORT_PATH .. LABELS cpython)
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_set LABELS cpython llvm llvm_jit) # type (specifically for `set`)

# lpython decorator
RUN(NAME lpython_decorator_01 LABELS cpython)
Expand Down
5 changes: 5 additions & 0 deletions integration_tests/test_builtin_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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)
res: str = ""

res = str(type(i))
Expand All @@ -23,5 +24,9 @@ def test_builtin_type():
res = str(type(d))
print(res)
assert res == "<class 'dict'>"
res = str(type(t))
print(res)
assert res == "<class 'tuple'>"


test_builtin_type()
11 changes: 11 additions & 0 deletions integration_tests/test_builtin_type_set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from lpython import i32

def test_builtin_type_set():
st: set[i32] = {1, 2, 3, 4}

res: str = str(type(st))
print(res)
assert res == "<class 'set'>"


test_builtin_type_set()
4 changes: 4 additions & 0 deletions src/libasr/pass/intrinsic_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,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;
Expand Down