File tree Expand file tree Collapse file tree 3 files changed +74
-1
lines changed
Expand file tree Collapse file tree 3 files changed +74
-1
lines changed Original file line number Diff line number Diff line change @@ -592,6 +592,7 @@ RUN(NAME structs_28 LABELS cpython llvm c)
592592RUN(NAME structs_29 LABELS cpython llvm)
593593RUN(NAME structs_30 LABELS cpython llvm c)
594594RUN(NAME structs_31 LABELS cpython llvm c)
595+ RUN(NAME structs_32 LABELS cpython llvm c)
595596
596597RUN(NAME symbolics_01 LABELS cpython_sym c_sym)
597598RUN(NAME symbolics_02 LABELS cpython_sym c_sym)
Original file line number Diff line number Diff line change 1- from lpython import dataclass , i32
1+ from lpython import dataclass , i32 , u16 , f32
22
33
44@dataclass
@@ -7,6 +7,15 @@ class StringIO:
77 _0cursor : i32 = 10
88 _len : i32 = 1
99
10+ @dataclass
11+ class StringIONew :
12+ _buf : str
13+ _0cursor : i32 = i32 (142 )
14+ _len : i32 = i32 (2439 )
15+ _var1 : u16 = u16 (23 )
16+ _var2 : f32 = f32 (30.24 )
17+
18+ #print("ok")
1019
1120def test_issue_1928 ():
1221 integer_asr : str = '(Integer 4 [])'
@@ -47,4 +56,22 @@ def test_issue_1928():
4756 assert test_dude4 ._0cursor == 31
4857
4958
59+ def test_issue_1981 ():
60+ integer_asr : str = '(Integer 4 [])'
61+ test_dude : StringIONew = StringIONew (integer_asr )
62+ assert test_dude ._buf == integer_asr
63+ assert test_dude ._len == 2439
64+ assert test_dude ._0cursor == 142
65+ assert test_dude ._var1 == u16 (23 )
66+ assert abs (test_dude ._var2 - f32 (30.24 )) < f32 (1e-5 )
67+ test_dude ._len = 13
68+ test_dude ._0cursor = 52
69+ test_dude ._var1 = u16 (34 )
70+ assert test_dude ._buf == integer_asr
71+ assert test_dude ._len == 13
72+ assert test_dude ._0cursor == 52
73+ assert test_dude ._var1 == u16 (34 )
74+
75+
76+ test_issue_1981 ()
5077test_issue_1928 ()
Original file line number Diff line number Diff line change 1+ from lpython import packed , dataclass , i32 , InOut
2+
3+
4+ @packed
5+ @dataclass
6+ class inner_struct :
7+ a : i32
8+
9+
10+ @packed
11+ @dataclass
12+ class outer_struct :
13+ b : inner_struct = inner_struct (0 )
14+
15+
16+ def update_my_inner_struct (my_inner_struct : InOut [inner_struct ]) -> None :
17+ my_inner_struct .a = 99999
18+
19+
20+ def update_my_outer_struct (my_outer_struct : InOut [outer_struct ]) -> None :
21+ my_outer_struct .b .a = 12345
22+
23+
24+ def main () -> None :
25+ my_outer_struct : outer_struct = outer_struct ()
26+ my_inner_struct : inner_struct = my_outer_struct .b
27+
28+ assert my_outer_struct .b .a == 0
29+
30+ my_outer_struct .b .a = 12345
31+ assert my_outer_struct .b .a == 12345
32+
33+ my_outer_struct .b .a = 0
34+ assert my_outer_struct .b .a == 0
35+
36+ update_my_outer_struct (my_outer_struct )
37+ assert my_outer_struct .b .a == 12345
38+
39+ my_inner_struct .a = 1111
40+ assert my_inner_struct .a == 1111
41+
42+ update_my_inner_struct (my_inner_struct )
43+ assert my_inner_struct .a == 99999
44+
45+ main ()
You can’t perform that action at this time.
0 commit comments