Skip to content

Commit fe45849

Browse files
committed
TEST: Add integration_tests for named args
1 parent bc7c483 commit fe45849

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ RUN(NAME structs_20 LABELS cpython llvm c
478478
EXTRAFILES structs_20b.c)
479479
RUN(NAME structs_21 LABELS cpython llvm c)
480480
RUN(NAME structs_22 LABELS cpython llvm c)
481+
RUN(NAME structs_23 LABELS cpython llvm c)
482+
RUN(NAME structs_24 LABELS cpython llvm c)
481483
RUN(NAME sizeof_01 LABELS llvm c
482484
EXTRAFILES sizeof_01b.c)
483485
RUN(NAME sizeof_02 LABELS cpython llvm c)

integration_tests/structs_23.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from lpython import dataclass, i32, u64, f64
2+
3+
@dataclass
4+
class A:
5+
a: i32
6+
b: i32
7+
8+
@dataclass
9+
class B:
10+
a: u64
11+
b: f64
12+
13+
def main0():
14+
s: A = A(b=-24, a=6)
15+
print(s.a)
16+
print(s.b)
17+
18+
assert s.a == 6
19+
assert s.b == -24
20+
21+
def main1():
22+
s: B = B(u64(22), b=3.14)
23+
print(s.a)
24+
print(s.b)
25+
26+
assert s.a == u64(22)
27+
assert abs(s.b - 3.14) <= 1e-12
28+
29+
main0()
30+
main1()

integration_tests/structs_24.py

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

0 commit comments

Comments
 (0)