Skip to content

Commit eca1a9f

Browse files
Add a test
1 parent e7c9a9c commit eca1a9f

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
from numpy import array
2-
from lpython import i32, f64, lpython, TypeVar
2+
from lpython import i32, i64, f64, lpython, TypeVar
33

44
n = TypeVar("n")
55

66
@lpython
7-
def multiply(n: i32, x: f64[:]) -> f64[n]:
7+
def multiply_01(n: i32, x: f64[:]) -> f64[n]:
88
i: i32
99
for i in range(n):
1010
x[i] *= 5.0
1111
return x
1212

13-
def test():
14-
size: i32 = 5
15-
x: f64[5] = array([11.0, 12.0, 13.0, 14.0, 15.0])
16-
y: f64[5] = multiply(size, x)
13+
@lpython
14+
def multiply_02(n: i32, x: i64[:], y: i64[:]) -> i64[n]:
15+
i: i32
16+
for i in range(n):
17+
x[i] *= y[i]
18+
return x
19+
20+
21+
def test_01():
22+
size = 5
23+
x = array([11.0, 12.0, 13.0, 14.0, 15.0])
24+
y = multiply_01(size, x)
1725
assert y[2] == 65.
1826

19-
test()
27+
x = array([11, 12, 13])
28+
y = array([14, 15, 16])
29+
z = multiply_02(3, x, y)
30+
assert z[1] == 180
31+
32+
test_01()

0 commit comments

Comments
 (0)