Skip to content

Commit 723e639

Browse files
committed
TEST: Add test for pass struct by ref
1 parent 80968be commit 723e639

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ RUN(NAME structs_27 LABELS cpython llvm c)
591591
RUN(NAME structs_28 LABELS cpython llvm c)
592592
RUN(NAME structs_29 LABELS cpython llvm)
593593
RUN(NAME structs_30 LABELS cpython llvm c)
594+
RUN(NAME structs_31 LABELS cpython llvm c)
594595

595596
RUN(NAME symbolics_01 LABELS cpython_sym c_sym)
596597
RUN(NAME symbolics_02 LABELS cpython_sym c_sym)

integration_tests/structs_31.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from lpython import packed, dataclass, i32, InOut
2+
3+
@packed
4+
@dataclass
5+
class inner_struct:
6+
a: i32
7+
8+
@packed
9+
@dataclass
10+
class outer_struct:
11+
b: inner_struct = inner_struct(0)
12+
13+
def update_my_inner_struct(my_inner_struct: InOut[inner_struct]) -> None:
14+
my_inner_struct.a = 99999
15+
16+
def main() -> None:
17+
my_outer_struct: outer_struct = outer_struct()
18+
19+
update_my_inner_struct(my_outer_struct.b)
20+
assert my_outer_struct.b.a == 99999
21+
22+
main()

0 commit comments

Comments
 (0)