Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f177716

Browse files
committed
Add tests for error in list
1 parent 5a883e5 commit f177716

File tree

7 files changed

+56
-0
lines changed

7 files changed

+56
-0
lines changed

tests/errors/test_list1.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ltypes import i32
2+
3+
def test1():
4+
a: list[i32]
5+
a = [1, 2, 3]
6+
a.remove('error')

tests/errors/test_list2.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ltypes import i32
2+
3+
def test1():
4+
a: list[i32]
5+
a = [1, 2, 3]
6+
a.append(4, 5)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-test_list1-73fd538",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/test_list1.py",
5+
"infile_hash": "86f36c119afcaef5c6f790c88c7c517fa6f766bfcc95d121bc16becd",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-test_list1-73fd538.stderr",
11+
"stderr_hash": "b09a9abfc3c61d6d4fe93b81ebbfd29ab1494db6d1e7b6a3bd4cba25",
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: Type mismatch while removing from a list, found (character and integer).
2+
--> tests/errors/test_list1.py:6:5
3+
|
4+
6 | a.remove('error')
5+
| ^^^^^^^^^^^^^^^^^
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-test_list2-10ffdd7",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/test_list2.py",
5+
"infile_hash": "0fde6372e40865fa25b4ef87b0ac31978ae2df367215004cad31a414",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-test_list2-10ffdd7.stderr",
11+
"stderr_hash": "be192bc4655f28313c415c7180d676e0383f0acb7e4de75a6b3d1a37",
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: append() takes exactly one argument
2+
--> tests/errors/test_list2.py:6:5
3+
|
4+
6 | a.append(4, 5)
5+
| ^^^^^^^^^^^^^^

tests/tests.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,11 @@ asr = true
294294
[[test]]
295295
filename = "errors/test_append_type_mismatch.py"
296296
asr = true
297+
298+
[[test]]
299+
filename = "errors/test_list1.py"
300+
asr = true
301+
302+
[[test]]
303+
filename = "errors/test_list2.py"
304+
asr = true

0 commit comments

Comments
 (0)