Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 259046d

Browse files
committed
Merge branch 'set_separate_chaining' of https://github.com/kabra1110/lpython into set_separate_chaining
2 parents d23e928 + 35d4afa commit 259046d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+681
-382
lines changed

integration_tests/CMakeLists.txt

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ message("LPYTHON_RTLIB_DIR: ${LPYTHON_RTLIB_DIR}")
7676
message("LPYTHON_RTLIB_LIBRARY: ${LPYTHON_RTLIB_LIBRARY}")
7777

7878

79-
macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS RUN_COPY_TO_BIN)
79+
macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_NOMOD RUN_EXTRA_ARGS RUN_COPY_TO_BIN)
8080
set(fail ${${RUN_FAIL}})
8181
set(name ${${RUN_NAME}})
8282
set(file_name ${${RUN_FILE_NAME}})
8383
set(labels ${${RUN_LABELS}})
8484
set(extra_files ${${RUN_EXTRAFILES}})
85+
set(no_mod ${${RUN_NOMOD}})
8586
set(extra_args ${${RUN_EXTRA_ARGS}})
8687
set(copy_to_bin ${${RUN_COPY_TO_BIN}})
8788

@@ -213,8 +214,13 @@ macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXT
213214
endif()
214215

215216
add_test(${name} python ${CMAKE_CURRENT_SOURCE_DIR}/${file_name}.py)
216-
set_tests_properties(${name} PROPERTIES
217-
ENVIRONMENT "PYTHONPATH=${CMAKE_SOURCE_DIR}/../src/runtime/lpython:${CMAKE_SOURCE_DIR}/..;LPYTHON_PY_MOD_NAME=${PY_MOD};LPYTHON_PY_MOD_PATH=${CMAKE_CURRENT_BINARY_DIR}")
217+
if (no_mod)
218+
set_tests_properties(${name} PROPERTIES
219+
ENVIRONMENT "PYTHONPATH=${CMAKE_SOURCE_DIR}/../src/runtime/lpython:${CMAKE_SOURCE_DIR}/..")
220+
else()
221+
set_tests_properties(${name} PROPERTIES
222+
ENVIRONMENT "PYTHONPATH=${CMAKE_SOURCE_DIR}/../src/runtime/lpython:${CMAKE_SOURCE_DIR}/..;LPYTHON_PY_MOD_NAME=${PY_MOD};LPYTHON_PY_MOD_PATH=${CMAKE_CURRENT_BINARY_DIR}")
223+
endif()
218224
if (labels)
219225
set_tests_properties(${name} PROPERTIES LABELS "${labels}")
220226
endif()
@@ -305,7 +311,7 @@ macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXT
305311
endmacro(RUN_UTIL)
306312

307313
macro(RUN)
308-
set(options FAIL NOFAST ENABLE_CPYTHON LINK_NUMPY)
314+
set(options FAIL NOFAST NOMOD ENABLE_CPYTHON LINK_NUMPY)
309315
set(oneValueArgs NAME IMPORT_PATH COPY_TO_BIN)
310316
set(multiValueArgs LABELS EXTRAFILES)
311317
cmake_parse_arguments(RUN "${options}" "${oneValueArgs}"
@@ -329,14 +335,14 @@ macro(RUN)
329335
endif()
330336

331337
if (NOT FAST)
332-
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS RUN_COPY_TO_BIN)
338+
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_NOMOD RUN_EXTRA_ARGS RUN_COPY_TO_BIN)
333339
endif()
334340

335341
if ((FAST) AND (NOT RUN_NOFAST))
336342
set(RUN_EXTRA_ARGS ${RUN_EXTRA_ARGS} --fast)
337343
set(RUN_NAME "${RUN_NAME}_FAST")
338344
list(REMOVE_ITEM RUN_LABELS cpython cpython_sym) # remove cpython, cpython_sym, from --fast test
339-
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS RUN_COPY_TO_BIN)
345+
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_NOMOD RUN_EXTRA_ARGS RUN_COPY_TO_BIN)
340346
endif()
341347
endmacro(RUN)
342348

@@ -466,7 +472,6 @@ RUN(NAME expr_18 FAIL LABELS cpython llvm c)
466472
RUN(NAME expr_19 LABELS cpython llvm c)
467473
RUN(NAME expr_20 LABELS cpython llvm c)
468474
RUN(NAME expr_21 LABELS cpython llvm c)
469-
RUN(NAME expr_22 LABELS cpython llvm c)
470475

471476
RUN(NAME expr_01u LABELS cpython llvm c NOFAST)
472477
RUN(NAME expr_02u LABELS cpython llvm c NOFAST)
@@ -479,6 +484,7 @@ RUN(NAME loop_03 LABELS cpython llvm c wasm wasm_x64)
479484
RUN(NAME loop_04 LABELS cpython llvm c)
480485
RUN(NAME loop_05 LABELS cpython llvm c)
481486
RUN(NAME loop_06 LABELS cpython llvm c NOFAST)
487+
RUN(NAME loop_07 LABELS cpython llvm c)
482488
RUN(NAME if_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
483489
RUN(NAME if_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
484490
RUN(NAME if_03 FAIL LABELS cpython llvm c NOFAST)
@@ -500,14 +506,18 @@ RUN(NAME test_list_09 LABELS cpython llvm c NOFAST)
500506
RUN(NAME test_list_10 LABELS cpython llvm c NOFAST)
501507
RUN(NAME test_list_11 LABELS cpython llvm c)
502508
RUN(NAME test_list_section LABELS cpython llvm c NOFAST)
509+
RUN(NAME test_list_section2 LABELS cpython llvm c NOFAST)
503510
RUN(NAME test_list_count LABELS cpython llvm)
504511
RUN(NAME test_list_index LABELS cpython llvm)
505512
RUN(NAME test_list_index2 LABELS cpython llvm)
506-
RUN(NAME test_list_repeat LABELS cpython llvm NOFAST)
513+
RUN(NAME test_list_repeat LABELS cpython llvm c NOFAST)
514+
RUN(NAME test_list_repeat2 LABELS cpython llvm c NOFAST)
507515
RUN(NAME test_list_reverse LABELS cpython llvm)
508516
RUN(NAME test_list_pop LABELS cpython llvm NOFAST) # TODO: Remove NOFAST from here.
509517
RUN(NAME test_list_pop2 LABELS cpython llvm NOFAST) # TODO: Remove NOFAST from here.
518+
RUN(NAME test_list_pop3 LABELS cpython llvm)
510519
RUN(NAME test_list_compare LABELS cpython llvm)
520+
RUN(NAME test_list_concat LABELS cpython llvm c NOFAST)
511521
RUN(NAME test_tuple_01 LABELS cpython llvm c)
512522
RUN(NAME test_tuple_02 LABELS cpython llvm c NOFAST)
513523
RUN(NAME test_tuple_03 LABELS cpython llvm c)
@@ -662,7 +672,6 @@ RUN(NAME structs_31 LABELS cpython llvm c)
662672
RUN(NAME structs_32 LABELS cpython llvm c)
663673
RUN(NAME structs_33 LABELS cpython llvm c)
664674
RUN(NAME structs_34 LABELS cpython llvm c)
665-
RUN(NAME structs_35 LABELS cpython llvm c)
666675

667676
RUN(NAME symbolics_01 LABELS cpython_sym c_sym)
668677
RUN(NAME symbolics_02 LABELS cpython_sym c_sym)
@@ -709,7 +718,7 @@ RUN(NAME test_package_01 LABELS cpython llvm NOFAST)
709718
RUN(NAME test_pkg_lpdraw LABELS cpython llvm wasm)
710719
RUN(NAME test_pkg_lnn_01 LABELS cpython llvm NOFAST)
711720
RUN(NAME test_pkg_lnn_02 LABELS cpython llvm NOFAST)
712-
RUN(NAME test_pkg_lpconvexhull LABELS cpython c)
721+
RUN(NAME test_pkg_lpconvexhull LABELS cpython llvm c NOFAST)
713722

714723
RUN(NAME generics_01 LABELS cpython llvm c)
715724
RUN(NAME generics_02 LABELS cpython llvm c)
@@ -760,3 +769,6 @@ RUN(NAME lpython_decorator_01 LABELS cpython)
760769
RUN(NAME lpython_decorator_02 LABELS cpython)
761770

762771
COMPILE(NAME import_order_01 LABELS cpython llvm c) # any
772+
773+
# LPython emulation mode
774+
RUN(NAME lpython_emulation_01 LABELS cpython NOMOD)

integration_tests/expr_22.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

integration_tests/loop_07.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from lpython import i32
2+
3+
def main0():
4+
points: list[tuple[i32, i32]] = [(445, 193), (138, 28), (418, 279)]
5+
point: tuple[i32, i32]
6+
x_sum: i32 = 0
7+
y_sum: i32 = 0
8+
for point in points:
9+
print(point)
10+
x_sum += point[0]
11+
y_sum += point[1]
12+
13+
print(x_sum, y_sum)
14+
assert x_sum == 1001
15+
assert y_sum == 500
16+
17+
main0()

integration_tests/lpython_decorator_02.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from numpy import array
2-
from lpython import i32, i64, f64, lpython, TypeVar
2+
from lpython import i32, i64, f64, lpython, TypeVar, Const
33

44
n = TypeVar("n")
55

@@ -17,6 +17,10 @@ def multiply_02(n: i32, x: i64[:], y: i64[:]) -> i64[n]:
1717
z[i] = x[i] * y[i]
1818
return z
1919

20+
@lpython
21+
def const_arg_sum(x: Const[i32]) -> i32:
22+
return 10 + x
23+
2024

2125
def test_01():
2226
size = 5
@@ -30,5 +34,6 @@ def test_01():
3034
z = multiply_02(size, x, y)
3135
for i in range(size):
3236
assert z[i] == x[i] * y[i]
37+
assert const_arg_sum(size) == size + 10
3338

3439
test_01()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import lpython_emulation_01_mod
2+
import lpython
3+
from lpython import ccall, i64
4+
from types import FunctionType
5+
lpython.CTypes.emulations = {k: v for k, v in \
6+
lpython_emulation_01_mod.__dict__.items() \
7+
if isinstance(v, FunctionType)}
8+
9+
@ccall
10+
def f1(a: i64) -> i64:
11+
pass
12+
13+
@ccall
14+
def f2(a: i64):
15+
pass
16+
17+
def main():
18+
assert f1(2) == 3
19+
f2(4)
20+
21+
main()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from lpython import i64
2+
3+
def f1(a: i64) -> i64:
4+
return a + 1
5+
6+
def f2(a: i64):
7+
assert a == 4

integration_tests/structs_35.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

integration_tests/test_list_concat.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from lpython import i32, f64
2+
3+
def test_list_concat():
4+
t1: list[i32]
5+
t1 = [2] + [3]
6+
print(t1)
7+
assert len(t1) == 2
8+
assert t1[0] == 2
9+
assert t1[1] == 3
10+
11+
t2: list[f64]
12+
t2 = [3.14, -4.5] + [1.233, -0.012, 5555.50]
13+
print(t2)
14+
assert len(t2) == 5
15+
assert abs(t2[0] - 3.14) <= 1e-5
16+
assert abs(t2[-1] - 5555.50) <= 1e-5
17+
18+
test_list_concat()

integration_tests/test_list_pop3.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from lpython import i32
2+
3+
def main0():
4+
a: list[i32] = [3, 4, 5]
5+
i: i32
6+
for i in range(10):
7+
a.append(1)
8+
a.pop()
9+
10+
print(a)
11+
assert a[-1] == 5
12+
assert len(a) == 3
13+
14+
main0()

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()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from lpython import i32
2+
3+
4+
def test_list_section():
5+
x: list[i32]
6+
x = [5, -6, 7, -1, 2, 10, -8, 15]
7+
8+
n: i32 = len(x[1:4])
9+
print(n)
10+
assert n == 3
11+
12+
test_list_section()

0 commit comments

Comments
 (0)