Skip to content

Commit 6c6043b

Browse files
committed
TEST: Add test for array.size
1 parent 46d283d commit 6c6043b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ RUN(NAME variable_decl_02 LABELS cpython llvm c)
280280
RUN(NAME variable_decl_03 LABELS cpython llvm c)
281281
RUN(NAME array_expr_01 LABELS cpython llvm c)
282282
RUN(NAME array_expr_02 LABELS cpython llvm c)
283+
RUN(NAME array_size_01 LABELS cpython llvm c)
283284
RUN(NAME array_01 LABELS cpython llvm wasm c)
284285
RUN(NAME array_02 LABELS cpython wasm c)
285286
RUN(NAME bindc_01 LABELS cpython llvm c)

integration_tests/array_size_01.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from lpython import i32, f64, c32, c64
2+
from numpy import empty
3+
4+
def main0():
5+
x: i32[4, 5, 2] = empty([4, 5, 2])
6+
y: f64[24, 100, 2, 5] = empty([24, 100, 2, 5])
7+
print(x.size)
8+
print(y.size)
9+
10+
assert x.size == 40
11+
assert y.size == 24000
12+
13+
def main1():
14+
a: c32[12] = empty([12])
15+
b: c64[15, 15, 10] = empty([15, 15, 10])
16+
print(a.size)
17+
print(b.size)
18+
19+
assert a.size == 12
20+
assert b.size == 2250
21+
22+
main0()
23+
main1()

0 commit comments

Comments
 (0)