Skip to content

Commit d4cafbd

Browse files
committed
TESTS: C: Add and enable for list repeat
1 parent 7dbf153 commit d4cafbd

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

integration_tests/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ RUN(NAME test_list_section2 LABELS cpython llvm c NOFAST)
504504
RUN(NAME test_list_count LABELS cpython llvm)
505505
RUN(NAME test_list_index LABELS cpython llvm)
506506
RUN(NAME test_list_index2 LABELS cpython llvm)
507-
RUN(NAME test_list_repeat LABELS cpython llvm NOFAST)
507+
RUN(NAME test_list_repeat LABELS cpython llvm c NOFAST)
508+
RUN(NAME test_list_repeat2 LABELS cpython llvm c NOFAST)
508509
RUN(NAME test_list_reverse LABELS cpython llvm)
509510
RUN(NAME test_list_pop LABELS cpython llvm NOFAST) # TODO: Remove NOFAST from here.
510511
RUN(NAME test_list_pop2 LABELS cpython llvm NOFAST) # TODO: Remove NOFAST from here.

integration_tests/test_list_repeat.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ def test_list_repeat():
2828
l_str_3 = l_str_1 * i
2929
assert l_str_3 == l_str_2
3030
l_str_2 += l_str_1
31-
31+
3232
for i in range(5):
3333
assert l_int_1 * i + l_int_1 * (i + 1) == l_int_1 * (2 * i + 1)
3434
assert l_tuple_1 * i + l_tuple_1 * (i + 1) == l_tuple_1 * (2 * i + 1)
3535
assert l_str_1 * i + l_str_1 * (i + 1) == l_str_1 * (2 * i + 1)
3636

37-
test_list_repeat()
37+
print(l_int_1)
38+
print(l_tuple_1)
39+
print(l_tuple_1)
40+
41+
test_list_repeat()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from lpython import i32, f32
2+
3+
def add_list(x: list[f32]) -> f32:
4+
sum: f32 = f32(0.0)
5+
i: i32
6+
7+
for i in range(len(x)):
8+
sum = sum + f32(x[i])
9+
return sum
10+
11+
def create_list(n: i32) -> list[f32]:
12+
x: list[f32]
13+
i: i32
14+
15+
x = [f32(0.0)] * n
16+
for i in range(n):
17+
x[i] = f32(i)
18+
return x
19+
20+
def main0():
21+
x: list[f32] = create_list(i32(10))
22+
print(add_list(x))
23+
24+
main0()

0 commit comments

Comments
 (0)