Skip to content

Commit 4e1e032

Browse files
Add tests and update the refs.
1 parent 3345065 commit 4e1e032

10 files changed

+70
-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)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-test_import_02-55b47fa",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/test_import_02.py",
5+
"infile_hash": "a3326a7bd9f6acc935235e1c0ff9cf4c26eda5f4052af774a148856c",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-test_import_02-55b47fa.stderr",
11+
"stderr_hash": "76231bde5dcf6b0c50fd898363a83aefd5dc79928d75da0feb346fba",
12+
"returncode": 2
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: The module 'test_import/test_import_2' cannot be loaded
2+
--> tests/errors/test_import_02.py:1:1
3+
|
4+
1 | from test_import.test_import_2 import X
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ imported here
6+
7+
semantic error: Type mismatch in annotation-assignment, the types must be compatible
8+
--> tests/errors/test_import/test_import_2.py:3:1
9+
|
10+
3 | X: Const[i32] = 1.23
11+
| ^ ^^^^ type mismatch ('i32' and 'f64')

tests/tests.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,14 @@ 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+
[[test]]
893+
filename = "errors/test_import_02.py"
894+
asr = true
895+
888896
# tests/tokens/errors
889897

890898
[[test]]

0 commit comments

Comments
 (0)