Skip to content

Commit 462a731

Browse files
committed
TEST: Add error tests named struct args
1 parent fe45849 commit 462a731

16 files changed

+164
-0
lines changed

tests/errors/structs_03.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from lpython import i32, dataclass
2+
3+
@dataclass
4+
class S:
5+
x: i32
6+
7+
def main0():
8+
s: S = S(y=2)
9+
10+
main0()

tests/errors/structs_04.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from lpython import i32, dataclass
2+
3+
@dataclass
4+
class S:
5+
x: i32
6+
y: i32
7+
8+
def main0():
9+
s: S = S(24, x=2)
10+
11+
main0()

tests/errors/structs_05.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from lpython import i32, dataclass
2+
3+
@dataclass
4+
class S:
5+
x: i32
6+
y: i32
7+
8+
def main0():
9+
s: S = S(2)
10+
11+
main0()

tests/errors/structs_06.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from lpython import i32, dataclass
2+
3+
@dataclass
4+
class S:
5+
x: i32
6+
y: i32
7+
8+
def main0():
9+
s: S = S(2, 3, 4, 5)
10+
11+
main0()

tests/errors/structs_07.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from lpython import i32, dataclass
2+
3+
@dataclass
4+
class S:
5+
x: i32
6+
y: i32
7+
8+
def main0():
9+
s: S = S(y=2)
10+
11+
main0()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-structs_03-754fb64",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/structs_03.py",
5+
"infile_hash": "19180d0a7a22141e74e61452cc6cc185f1dd1c4f4315446450ce98db",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-structs_03-754fb64.stderr",
11+
"stderr_hash": "c6410f9948863d922cb0a0cd36613c529ad45fdf556d393d36e2df07",
12+
"returncode": 2
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
semantic error: Member 'y' not found in struct
2+
--> tests/errors/structs_03.py:8:14
3+
|
4+
8 | s: S = S(y=2)
5+
| ^^^
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-structs_04-7b864bc",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/structs_04.py",
5+
"infile_hash": "5951c49d2d7f143bbe3d67b982770ceb6d709939eb2d5ed544888f16",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-structs_04-7b864bc.stderr",
11+
"stderr_hash": "e4e04a1a30ae38b6587c4c3ad12a7e83839c63938c025a3884f62ef8",
12+
"returncode": 2
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
semantic error: S() got multiple values for argument 'x'
2+
--> tests/errors/structs_04.py:9:18
3+
|
4+
9 | s: S = S(24, x=2)
5+
| ^^^
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-structs_05-a89315d",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/structs_05.py",
5+
"infile_hash": "3b94e692a074b226736f068daf39c876f113277a73468bd21c01d3cc",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-structs_05-a89315d.stderr",
11+
"stderr_hash": "227decb39171becb34a42cbdd93d96bcdd4d8c9dc5151706a74d7074",
12+
"returncode": 2
13+
}

0 commit comments

Comments
 (0)