Skip to content

Commit 604dce1

Browse files
committed
TEST: Add for diff dim, type mismatch cases using empty
1 parent f011dbe commit 604dce1

File tree

13 files changed

+149
-0
lines changed

13 files changed

+149
-0
lines changed

tests/errors/arrays_03.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from lpython import i16
2+
from numpy import empty, int16
3+
4+
# checks dim mismatch for local array variable
5+
def main0():
6+
x: i16[4] = empty([5], dtype=int16)
7+
8+
main0()

tests/errors/arrays_04.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from lpython import i16
2+
from numpy import empty, int32
3+
4+
# checks type mismatch for local array variable
5+
def main0():
6+
x: i16[5] = empty([5], dtype=int32)
7+
8+
main0()

tests/errors/arrays_05.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from lpython import i16
2+
from numpy import empty, int16
3+
4+
# checks multi-dim mismatch for local array variable
5+
def main0():
6+
x: i16[5, 4] = empty([5, 3], dtype=int16)
7+
8+
main0()

tests/errors/arrays_06.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from lpython import i16
2+
from numpy import empty, int32
3+
4+
# checks type mismatch for multi-dim local array variable
5+
def main0():
6+
x: i16[5, 4] = empty([5, 4], dtype=int32)
7+
8+
main0()

tests/errors/arrays_07.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from lpython import f32
2+
from numpy import empty, complex64
3+
4+
# checks type mismatch for types apart from integers
5+
def main0():
6+
x: f32[5, 4] = empty([5, 4], dtype=complex64)
7+
8+
main0()

tests/errors/arrays_08.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from lpython import i32, i64, Const
2+
from numpy import empty, int64
3+
4+
# checks multi-dim mismatch when constant variables are used as dimensions
5+
def main0():
6+
p: Const[i32] = 100
7+
q: Const[i32] = 120
8+
r: Const[i32] = 200
9+
x: i64[p, q, r] = empty([q, p, r], dtype=int64)
10+
11+
main0()

tests/errors/arrays_09.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from lpython import i32, i64
2+
from numpy import empty, int64
3+
4+
# checks using runtime variables as value for multi-dims
5+
def main0():
6+
p: i32 = 100
7+
q: i32 = 120
8+
r: i32 = 200
9+
x: i64[p, q, r] = empty([q, p, r], dtype=int64)
10+
11+
main0()

tests/errors/arrays_10.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from lpython import i32, i64
2+
from numpy import empty, int64
3+
4+
# checks using runtime variables as value for multi-dims of emtpy()
5+
def main0():
6+
p: i32 = 100
7+
q: i32 = 120
8+
r: i32 = 200
9+
x: i64[100, 120, 200] = empty([q, p, r], dtype=int64)
10+
11+
main0()

tests/errors/arrays_11.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from lpython import i16
2+
from numpy import empty, int16
3+
4+
# Checks dim mismatch for global array variables
5+
x: i16[4] = empty([5], dtype=int16)

tests/errors/arrays_12.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from lpython import i16
2+
from numpy import empty, int32
3+
4+
# Checks type mismatch for global array variables
5+
x: i16[5] = empty([5], dtype=int32)

0 commit comments

Comments
 (0)