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+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
semantic error: StructConstructor arguments do not match the number of struct members
2+
--> tests/errors/structs_05.py:9:12
3+
|
4+
9 | s: S = S(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_06-6e14537",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/structs_06.py",
5+
"infile_hash": "9f4273c5fb4469837f65003255dcdca067c5c17735d0642757fd069c",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-structs_06-6e14537.stderr",
11+
"stderr_hash": "21e94af3d6a631d4871d9bc2a86200c3c3c3b661964a079105721dde",
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: StructConstructor arguments do not match the number of struct members
2+
--> tests/errors/structs_06.py:9:12
3+
|
4+
9 | s: S = S(2, 3, 4, 5)
5+
| ^^^^^^^^^^^^^
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-structs_07-83694b7",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/structs_07.py",
5+
"infile_hash": "4e4f15d47dc5d9cdadd653567f6d105365b7fe20b194663c10b3802a",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-structs_07-83694b7.stderr",
11+
"stderr_hash": "6b1e1646f11ee384e5dce1ded0d91751f7113eaea7c90da5c1bcf4ff",
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: Not enough arguments to S(), expected 2
2+
--> tests/errors/structs_07.py:9:12
3+
|
4+
9 | s: S = S(y=2)
5+
| ^^^^^^

tests/tests.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,26 @@ asr = true
642642
filename = "errors/structs_02.py"
643643
asr = true
644644

645+
[[test]]
646+
filename = "errors/structs_03.py"
647+
asr = true
648+
649+
[[test]]
650+
filename = "errors/structs_04.py"
651+
asr = true
652+
653+
[[test]]
654+
filename = "errors/structs_05.py"
655+
asr = true
656+
657+
[[test]]
658+
filename = "errors/structs_06.py"
659+
asr = true
660+
661+
[[test]]
662+
filename = "errors/structs_07.py"
663+
asr = true
664+
645665
[[test]]
646666
filename = "errors/const_01.py"
647667
asr = true

0 commit comments

Comments
 (0)