File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -561,6 +561,11 @@ RUN(NAME enum_07 IMPORT_PATH ..
561
561
RUN (NAME union_01 LABELS cpython llvm c )
562
562
RUN (NAME union_02 LABELS llvm c )
563
563
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 )
564
569
RUN (NAME test_str_to_int LABELS cpython llvm c )
565
570
RUN (NAME test_platform LABELS cpython llvm c )
566
571
RUN (NAME test_vars_01 LABELS cpython llvm )
Original file line number Diff line number Diff line change
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 ()
You can’t perform that action at this time.
0 commit comments