Skip to content

Commit

Permalink
TEST: Add for diff dim, type mismatch cases using empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Aug 28, 2023
1 parent f011dbe commit 604dce1
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/errors/arrays_03.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from lpython import i16
from numpy import empty, int16

# checks dim mismatch for local array variable
def main0():
x: i16[4] = empty([5], dtype=int16)

main0()
8 changes: 8 additions & 0 deletions tests/errors/arrays_04.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from lpython import i16
from numpy import empty, int32

# checks type mismatch for local array variable
def main0():
x: i16[5] = empty([5], dtype=int32)

main0()
8 changes: 8 additions & 0 deletions tests/errors/arrays_05.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from lpython import i16
from numpy import empty, int16

# checks multi-dim mismatch for local array variable
def main0():
x: i16[5, 4] = empty([5, 3], dtype=int16)

main0()
8 changes: 8 additions & 0 deletions tests/errors/arrays_06.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from lpython import i16
from numpy import empty, int32

# checks type mismatch for multi-dim local array variable
def main0():
x: i16[5, 4] = empty([5, 4], dtype=int32)

main0()
8 changes: 8 additions & 0 deletions tests/errors/arrays_07.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from lpython import f32
from numpy import empty, complex64

# checks type mismatch for types apart from integers
def main0():
x: f32[5, 4] = empty([5, 4], dtype=complex64)

main0()
11 changes: 11 additions & 0 deletions tests/errors/arrays_08.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from lpython import i32, i64, Const
from numpy import empty, int64

# checks multi-dim mismatch when constant variables are used as dimensions
def main0():
p: Const[i32] = 100
q: Const[i32] = 120
r: Const[i32] = 200
x: i64[p, q, r] = empty([q, p, r], dtype=int64)

main0()
11 changes: 11 additions & 0 deletions tests/errors/arrays_09.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from lpython import i32, i64
from numpy import empty, int64

# checks using runtime variables as value for multi-dims
def main0():
p: i32 = 100
q: i32 = 120
r: i32 = 200
x: i64[p, q, r] = empty([q, p, r], dtype=int64)

main0()
11 changes: 11 additions & 0 deletions tests/errors/arrays_10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from lpython import i32, i64
from numpy import empty, int64

# checks using runtime variables as value for multi-dims of emtpy()
def main0():
p: i32 = 100
q: i32 = 120
r: i32 = 200
x: i64[100, 120, 200] = empty([q, p, r], dtype=int64)

main0()
5 changes: 5 additions & 0 deletions tests/errors/arrays_11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from lpython import i16
from numpy import empty, int16

# Checks dim mismatch for global array variables
x: i16[4] = empty([5], dtype=int16)
5 changes: 5 additions & 0 deletions tests/errors/arrays_12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from lpython import i16
from numpy import empty, int32

# Checks type mismatch for global array variables
x: i16[5] = empty([5], dtype=int32)
9 changes: 9 additions & 0 deletions tests/errors/arrays_13.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from lpython import i16
from numpy import empty, int16

# checks dim mismatch for local array variable
# when dim is specified as a constant integer
def main0():
x: i16[4] = empty(5, dtype=int16)

main0()
9 changes: 9 additions & 0 deletions tests/errors/arrays_14.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from lpython import i16
from numpy import empty, int16

# checks dim mismatch for local array variable
# when dim is specified as a tuple
def main0():
x: i16[4] = empty((5), dtype=int16)

main0()
48 changes: 48 additions & 0 deletions tests/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,54 @@ asr = true
filename = "errors/arrays_02.py"
asr = true

[[test]]
filename = "errors/arrays_03.py"
asr = true

[[test]]
filename = "errors/arrays_04.py"
asr = true

[[test]]
filename = "errors/arrays_05.py"
asr = true

[[test]]
filename = "errors/arrays_06.py"
asr = true

[[test]]
filename = "errors/arrays_07.py"
asr = true

[[test]]
filename = "errors/arrays_08.py"
asr = true

[[test]]
filename = "errors/arrays_09.py"
asr = true

[[test]]
filename = "errors/arrays_10.py"
asr = true

[[test]]
filename = "errors/arrays_11.py"
asr = true

[[test]]
filename = "errors/arrays_12.py"
asr = true

[[test]]
filename = "errors/arrays_13.py"
asr = true

[[test]]
filename = "errors/arrays_14.py"
asr = true

[[test]]
filename = "errors/structs_02.py"
asr = true
Expand Down

0 comments on commit 604dce1

Please sign in to comment.