Skip to content

Commit 50c81dc

Browse files
committed
Add tests for error in set
1 parent f177716 commit 50c81dc

7 files changed

+56
-0
lines changed

tests/errors/test_set1.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: set[i32]
5+
a = {1, 2, 3}
6+
a.add('err')

tests/errors/test_set2.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: set[i32]
5+
a = {1, 2, 3}
6+
a.remove('error', 'error2')
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-test_set1-11379c7",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/test_set1.py",
5+
"infile_hash": "8b09bdc33cffccdb66d9d70f13474d148c5f422ee3892d30fe45eb95",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-test_set1-11379c7.stderr",
11+
"stderr_hash": "8b09cefb3289bc45f00ca5a571562e62502aaeab7e92fa8ffeb341e7",
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: Found type mismatch in 'add'(character and integer).
2+
--> tests/errors/test_set1.py:6:5
3+
|
4+
6 | a.add('err')
5+
| ^^^^^^^^^^^^
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-test_set2-d91a6f0",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/test_set2.py",
5+
"infile_hash": "46c06330c2f51316a178c5d487fb5628d19ffb4e8f95e50653a19fcd",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-test_set2-d91a6f0.stderr",
11+
"stderr_hash": "5459ddb5148c630f9374c827aad9c37d25967248002dc0dff5314530",
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: remove() takes exactly one argument
2+
--> tests/errors/test_set2.py:6:5
3+
|
4+
6 | a.remove('error', 'error2')
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/tests.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,11 @@ asr = true
302302
[[test]]
303303
filename = "errors/test_list2.py"
304304
asr = true
305+
306+
[[test]]
307+
filename = "errors/test_set1.py"
308+
asr = true
309+
310+
[[test]]
311+
filename = "errors/test_set2.py"
312+
asr = true

0 commit comments

Comments
 (0)