Skip to content

Commit 36df81e

Browse files
Add tests and update the refs.
1 parent a9b4dd8 commit 36df81e

8 files changed

+47
-0
lines changed

tests/errors/test_import/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .test_import_1 import test
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from ltypes import Const, i32
2+
3+
def test(x: i32) -> i32:
4+
return x ** 2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from ltypes import Const, i32
2+
3+
X: Const[i32] = 1.23

tests/errors/test_import_01.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from ltypes import Const, f64
2+
from test_import import test
3+
4+
X: Const[f64] = test(5.0)

tests/errors/test_import_02.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from test_import.test_import_2 import X
2+
3+
print(X)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-test_import_01-b859c43",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/test_import_01.py",
5+
"infile_hash": "dcde95aa235a4257a7ee1b22b0d3fa4d9ba54209066e0a4688fd7722",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-test_import_01-b859c43.stderr",
11+
"stderr_hash": "ef59d49c8273cdd97e830cac94b3cc620fb24b07ce00c3394081c9c5",
12+
"returncode": 2
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
semantic error: Type mismatch in procedure call; the types must be compatible
2+
--> tests/errors/test_import_01.py:4:22
3+
|
4+
4 | X: Const[f64] = test(5.0)
5+
| ^^^ type mismatch (passed argument type is f64 but required type is i32)
6+
7+
--> tests/errors/test_import/test_import_1.py:3:13
8+
|
9+
3 | def test(x: i32) -> i32:
10+
| ^^^ type mismatch (passed argument type is f64 but required type is i32)

tests/tests.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,15 @@ asr = true
885885
filename = "errors/test_for2.py"
886886
asr = true
887887

888+
[[test]]
889+
filename = "errors/test_import_01.py"
890+
asr = true
891+
892+
# TODO: Uncomment this, when #1306 is merged
893+
# [[test]]
894+
# filename = "errors/test_import_02.py"
895+
# asr = true
896+
888897
# tests/tokens/errors
889898

890899
[[test]]

0 commit comments

Comments
 (0)