Skip to content

Commit 737a45c

Browse files
committed
Add tests
1 parent 43ba941 commit 737a45c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,11 @@ RUN(NAME enum_07 IMPORT_PATH ..
561561
RUN(NAME union_01 LABELS cpython llvm c)
562562
RUN(NAME union_02 LABELS llvm c)
563563
RUN(NAME union_03 LABELS cpython llvm c)
564+
RUN(NAME union_01 LABELS cpython llvm c)
565+
RUN(NAME union_02 LABELS llvm c)
566+
RUN(NAME union_03 LABELS cpython llvm c)
567+
RUN(NAME union_04 IMPORT_PATH ..
568+
LABELS cpython llvm c)
564569
RUN(NAME test_str_to_int LABELS cpython llvm c)
565570
RUN(NAME test_platform LABELS cpython llvm c)
566571
RUN(NAME test_vars_01 LABELS cpython llvm)

integration_tests/union_04.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from union_01 import u_type
2+
from lpython import f32, f64, i64
3+
4+
# Test taken from union_01.py but checks importing union
5+
6+
def test_union_04():
7+
unionobj: u_type = u_type()
8+
unionobj.integer32 = 1
9+
print(unionobj.integer32)
10+
assert unionobj.integer32 == 1
11+
12+
unionobj.real32 = f32(2.0)
13+
print(unionobj.real32)
14+
assert abs(f64(unionobj.real32) - 2.0) <= 1e-6
15+
16+
unionobj.real64 = 3.5
17+
print(unionobj.real64)
18+
assert abs(unionobj.real64 - 3.5) <= 1e-12
19+
20+
unionobj.integer64 = i64(4)
21+
print(unionobj.integer64)
22+
assert unionobj.integer64 == i64(4)
23+
24+
test_union_04()

0 commit comments

Comments
 (0)