Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TEST: Add for dataclass field()
  • Loading branch information
ubaidsk committed Aug 16, 2023
commit 9bdb90eb73d99aff6450944f847cc8d59f6d8158
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ RUN(NAME structs_31 LABELS cpython llvm c)
RUN(NAME structs_32 LABELS cpython llvm c)
RUN(NAME structs_33 LABELS cpython llvm c)
RUN(NAME structs_34 LABELS cpython llvm c)
RUN(NAME structs_35 LABELS cpython llvm)

RUN(NAME symbolics_01 LABELS cpython_sym c_sym llvm_sym NOFAST)
RUN(NAME symbolics_02 LABELS cpython_sym c_sym llvm_sym NOFAST)
Expand Down
26 changes: 26 additions & 0 deletions integration_tests/structs_35.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from lpython import dataclass, field, i32
from numpy import array

@dataclass
class X:
a: i32 = 123
b: bool = True
c: list[i32] = field(default_factory=lambda: [1, 2, 3])
d: i32[3] = field(default_factory=lambda: array([4, 5, 6]))
e: i32 = field(default=-5)

def main0():
x: X = X()
print(x)
assert x.a == 123
assert x.b == True
assert x.c[0] == 1
assert x.d[1] == 5
assert x.e == -5
x.c[0] = 3
x.d[0] = 3
print(x)
assert x.c[0] == 3
assert x.d[0] == 3

main0()