Skip to content

Commit b794a6e

Browse files
committed
TEST: Add struct passing syntax test in cpython
1 parent 3c01300 commit b794a6e

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

integration_tests/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ RUN(NAME structs_01 LABELS cpython llvm c)
455455
RUN(NAME structs_02 LABELS cpython llvm c)
456456
RUN(NAME structs_03 LABELS llvm c)
457457
RUN(NAME structs_04 LABELS cpython llvm c)
458-
RUN(NAME structs_05 LABELS llvm c)
458+
RUN(NAME structs_05 LABELS cpython llvm c)
459459
RUN(NAME structs_06 LABELS cpython llvm c)
460460
RUN(NAME structs_07 LABELS llvm c
461461
EXTRAFILES structs_07b.c)
@@ -480,6 +480,7 @@ RUN(NAME structs_21 LABELS cpython llvm c)
480480
RUN(NAME structs_22 LABELS cpython llvm c)
481481
RUN(NAME structs_23 LABELS cpython llvm c)
482482
RUN(NAME structs_24 LABELS cpython llvm c)
483+
RUN(NAME structs_25 LABELS cpython llvm c)
483484
RUN(NAME sizeof_01 LABELS llvm c
484485
EXTRAFILES sizeof_01b.c)
485486
RUN(NAME sizeof_02 LABELS cpython llvm c)

integration_tests/structs_05.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def update_2(s: A[:]):
5050
s[1].c = i8(3)
5151

5252
def g():
53-
# TODO: Enable cpython in integration_tests.
5453
y: A[2] = empty([2], dtype=A)
5554
y[0] = A(1.1, 1, i64(1), f32(1.1), i16(1), i8(1), True)
5655
y[1] = A(2.2, 2, i64(2), f32(2.2), i16(2), i8(2), True)

integration_tests/structs_25.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from lpython import i32, dataclass
2+
from numpy import empty
3+
4+
@dataclass
5+
class Foo:
6+
x: i32
7+
y: i32
8+
9+
def init(foos: Foo[:]) -> None:
10+
foos[0] = Foo(5, 21)
11+
12+
def main0() -> None:
13+
foos: Foo[1] = empty(1, dtype=Foo)
14+
init(foos)
15+
print("foos[0].x =", foos[0].x)
16+
17+
assert foos[0].x == 5
18+
assert foos[0].y == 21
19+
20+
main0()

0 commit comments

Comments
 (0)