Skip to content

Commit 043b05e

Browse files
committed
TEST: Add for dataclass init val for lpython emulation
1 parent 2a85e87 commit 043b05e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,3 +780,4 @@ COMPILE(NAME import_order_01 LABELS cpython llvm c) # any
780780

781781
# LPython emulation mode
782782
RUN(NAME lpython_emulation_01 LABELS cpython NOMOD)
783+
RUN(NAME lpython_emulation_02 LABELS cpython)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from lpython import i32, dataclass
2+
from numpy import array
3+
4+
@dataclass
5+
class X:
6+
a: i32 = 123
7+
b: bool = True
8+
c: i32[:] = array([1, 2, 3])
9+
d: i32[:] = array([4, 5, 6])
10+
11+
def main0():
12+
x: X = X()
13+
print(x)
14+
assert x.a == 123
15+
assert x.b == True
16+
assert x.c.sum() == 6
17+
assert x.d.sum() == 15
18+
19+
main0()

0 commit comments

Comments
 (0)