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

Skip to content

Commit 79c69d1

Browse files
committed
Merge branch 'main' into dict_keys_values
2 parents 493c859 + d559090 commit 79c69d1

File tree

504 files changed

+20178
-12391
lines changed

Some content is hidden

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

504 files changed

+20178
-12391
lines changed

.github/workflows/CI.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,14 @@ jobs:
278278
279279
- uses: hendrikmuhs/ccache-action@main
280280
with:
281+
variant: sccache
281282
key: ${{ github.job }}-${{ matrix.os }}
282283

283284
- name: Build Linux
284285
shell: bash -l {0}
285286
run: |
286287
./build0.sh
288+
export CXXFLAGS="-Werror"
287289
cmake . -GNinja \
288290
-DCMAKE_BUILD_TYPE=Debug \
289291
-DWITH_LLVM=yes \
@@ -292,8 +294,55 @@ jobs:
292294
-DWITH_RUNTIME_STACKTRACE=yes \
293295
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
294296
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
295-
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
296-
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
297+
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
298+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
299+
300+
cmake --build . -j16 --target install
301+
302+
- name: Test Linux
303+
shell: bash -l {0}
304+
run: |
305+
ctest
306+
./run_tests.py -s
307+
cd integration_tests
308+
./run_tests.py -b llvm c
309+
./run_tests.py -b llvm c -f
310+
311+
release:
312+
name: Check Release build
313+
runs-on: ubuntu-latest
314+
steps:
315+
- uses: actions/checkout@v3
316+
with:
317+
fetch-depth: 0
318+
319+
- uses: mamba-org/setup-micromamba@v1
320+
with:
321+
environment-file: ci/environment.yml
322+
create-args: >-
323+
python=3.10
324+
bison=3.4
325+
326+
- uses: hendrikmuhs/ccache-action@main
327+
with:
328+
variant: sccache
329+
key: ${{ github.job }}-${{ matrix.os }}
330+
331+
- name: Build Linux
332+
shell: bash -l {0}
333+
run: |
334+
./build0.sh
335+
export CXXFLAGS="-Werror"
336+
cmake . -GNinja \
337+
-DCMAKE_BUILD_TYPE=Release \
338+
-DWITH_LLVM=yes \
339+
-DLFORTRAN_BUILD_ALL=yes \
340+
-DWITH_STACKTRACE=no \
341+
-DWITH_RUNTIME_STACKTRACE=yes \
342+
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
343+
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
344+
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
345+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
297346
298347
cmake --build . -j16 --target install
299348
@@ -304,6 +353,7 @@ jobs:
304353
./run_tests.py -s
305354
cd integration_tests
306355
./run_tests.py -b llvm c
356+
./run_tests.py -b llvm c -f
307357
308358
cpython_interop:
309359
name: Test CPython Interop (@pythoncall)
@@ -347,6 +397,7 @@ jobs:
347397
run: |
348398
cd integration_tests
349399
./run_tests.py -b cpython c_py
400+
./run_tests.py -b cpython c_py -f
350401
351402
sympy:
352403
name: Run SymPy tests
@@ -391,3 +442,4 @@ jobs:
391442
run: |
392443
cd integration_tests
393444
./run_tests.py -b c_sym cpython_sym
445+
./run_tests.py -b c_sym cpython_sym -f

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
./build0.sh
4+
./build1.sh

build0.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@ python src/libasr/wasm_instructions_visitor.py
1919
(cd src/lpython/parser && re2c -W -b tokenizer.re -o tokenizer.cpp)
2020
(cd src/lpython/parser && bison -Wall -d -r all parser.yy)
2121

22+
python -c "file = 'src/lpython/parser/parser.tab.cc'
23+
with open(file, 'r') as f: text = f.read()
24+
with open(file, 'w') as f:
25+
f.write('[[maybe_unused]] int yynerrs'.join(text.split('int yynerrs')))"
26+
2227
grep -n "'" src/lpython/parser/parser.yy && echo "Single quote not allowed" && exit 1
2328
echo "OK"

ci/test.xsh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ else:
2323
src/bin/lpython --backend=c examples/expr2.py
2424
cd integration_tests
2525
python run_tests.py -j16 -b llvm cpython c wasm
26+
python run_tests.py -j16 -b llvm cpython c wasm -f
2627

2728
if $(uname).strip() == "Linux":
2829
python run_tests.py -j16 -b x86 wasm_x86 wasm_x64
30+
python run_tests.py -j16 -b x86 wasm_x86 wasm_x64 -f

examples/expr2.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
from lpython import i32
2+
13
def main0():
24
x: i32
35
x = (2+3)*5
46
print(x)
57

6-
main0()
7-
8-
# Not implemented yet in LPython:
9-
#if __name__ == "__main__":
10-
# main()
8+
if __name__ == "__main__":
9+
main0()

integration_tests/CMakeLists.txt

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR
1313
endif ()
1414

1515
set(KIND no CACHE STRING "Type of Test")
16-
set(DISABLE_FAST no CACHE BOOL "Disable --fast testing of integration tests")
16+
set(FAST no CACHE BOOL "Run supported tests with --fast")
1717

1818
find_program(LPYTHON NAMES lpython)
1919

@@ -69,7 +69,7 @@ else ()
6969
endif ()
7070
message("Installation prefix: ${CMAKE_INSTALL_PREFIX}")
7171
message("KIND: ${KIND}")
72-
message("DISABLE_FAST: ${DISABLE_FAST}")
72+
message("FAST: ${FAST}")
7373
message("PYTHON_LIBS_REQ: ${PYTHON_LIBS_REQ}")
7474
message("LPYTHON: ${LPYTHON}")
7575
message("LPYTHON_RTLIB_DIR: ${LPYTHON_RTLIB_DIR}")
@@ -287,9 +287,11 @@ macro(RUN)
287287
set(RUN_EXTRA_ARGS ${RUN_EXTRA_ARGS} -I${CMAKE_CURRENT_SOURCE_DIR}/${RUN_IMPORT_PATH})
288288
endif()
289289

290-
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS)
290+
if (NOT FAST)
291+
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS)
292+
endif()
291293

292-
if ((NOT DISABLE_FAST) AND (NOT RUN_NOFAST))
294+
if ((FAST) AND (NOT RUN_NOFAST))
293295
set(RUN_EXTRA_ARGS ${RUN_EXTRA_ARGS} --fast)
294296
set(RUN_NAME "${RUN_NAME}_FAST")
295297
list(REMOVE_ITEM RUN_LABELS cpython cpython_sym) # remove cpython, cpython_sym, from --fast test
@@ -366,12 +368,16 @@ RUN(NAME array_size_02 LABELS cpython llvm c)
366368
RUN(NAME array_01 LABELS cpython llvm wasm c)
367369
RUN(NAME array_02 LABELS cpython wasm c)
368370
RUN(NAME array_03 LABELS cpython llvm c)
371+
RUN(NAME array_04 LABELS cpython llvm c)
369372
RUN(NAME bindc_01 LABELS cpython llvm c)
370373
RUN(NAME bindc_02 LABELS cpython llvm c)
371374
RUN(NAME bindc_04 LABELS llvm c NOFAST)
372375
RUN(NAME bindc_07 LABELS cpython llvm c NOFAST)
373376
RUN(NAME bindc_08 LABELS cpython llvm c)
374377
RUN(NAME bindc_09 LABELS cpython llvm c)
378+
RUN(NAME bindc_09b LABELS cpython llvm c)
379+
RUN(NAME bindc_10 LABELS cpython llvm c NOFAST)
380+
RUN(NAME bindc_11 LABELS cpython) # This is CPython test only
375381
RUN(NAME exit_01 LABELS cpython llvm c NOFAST)
376382
RUN(NAME exit_02 FAIL LABELS cpython llvm c NOFAST)
377383
RUN(NAME exit_03 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
@@ -414,16 +420,22 @@ RUN(NAME expr_13 LABELS llvm c
414420
RUN(NAME expr_14 LABELS cpython llvm c)
415421
RUN(NAME expr_15 LABELS cpython llvm c)
416422
RUN(NAME expr_16 LABELS cpython c)
423+
RUN(NAME expr_17 LABELS cpython llvm c)
424+
RUN(NAME expr_18 FAIL LABELS cpython llvm c)
425+
RUN(NAME expr_19 LABELS cpython llvm c)
426+
RUN(NAME expr_20 LABELS cpython llvm c)
417427

418428
RUN(NAME expr_01u LABELS cpython llvm c NOFAST)
419429
RUN(NAME expr_02u LABELS cpython llvm c NOFAST)
420430
RUN(NAME expr_03u LABELS cpython llvm c NOFAST)
431+
RUN(NAME expr_04u LABELS cpython llvm c)
421432

422433
RUN(NAME loop_01 LABELS cpython llvm c)
423434
RUN(NAME loop_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
424435
RUN(NAME loop_03 LABELS cpython llvm c wasm wasm_x64)
425436
RUN(NAME loop_04 LABELS cpython llvm c)
426437
RUN(NAME loop_05 LABELS cpython llvm c)
438+
RUN(NAME loop_06 LABELS cpython llvm c NOFAST)
427439
RUN(NAME if_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
428440
RUN(NAME if_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
429441
RUN(NAME if_03 FAIL LABELS cpython llvm c NOFAST)
@@ -452,9 +464,11 @@ RUN(NAME test_list_repeat LABELS cpython llvm NOFAST)
452464
RUN(NAME test_list_reverse LABELS cpython llvm)
453465
RUN(NAME test_list_pop LABELS cpython llvm NOFAST) # TODO: Remove NOFAST from here.
454466
RUN(NAME test_list_pop2 LABELS cpython llvm NOFAST) # TODO: Remove NOFAST from here.
467+
RUN(NAME test_list_compare LABELS cpython llvm)
455468
RUN(NAME test_tuple_01 LABELS cpython llvm c)
456469
RUN(NAME test_tuple_02 LABELS cpython llvm c NOFAST)
457470
RUN(NAME test_tuple_03 LABELS cpython llvm c)
471+
RUN(NAME test_tuple_04 LABELS cpython llvm c)
458472
RUN(NAME test_tuple_concat LABELS cpython llvm)
459473
RUN(NAME test_tuple_nested LABELS cpython llvm)
460474
RUN(NAME test_dict_01 LABELS cpython llvm c)
@@ -473,6 +487,9 @@ RUN(NAME test_dict_13 LABELS cpython llvm c)
473487
RUN(NAME test_dict_bool LABELS cpython llvm)
474488
RUN(NAME test_dict_increment LABELS cpython llvm)
475489
RUN(NAME test_dict_keys_values LABELS cpython llvm)
490+
RUN(NAME test_set_len LABELS cpython llvm)
491+
RUN(NAME test_set_add LABELS cpython llvm)
492+
RUN(NAME test_set_remove LABELS cpython llvm)
476493
RUN(NAME test_for_loop LABELS cpython llvm c)
477494
RUN(NAME modules_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
478495
RUN(NAME modules_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
@@ -482,6 +499,7 @@ RUN(NAME test_import_03 LABELS cpython llvm c)
482499
RUN(NAME test_import_04 IMPORT_PATH ..
483500
LABELS cpython llvm c)
484501
RUN(NAME test_import_05 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
502+
RUN(NAME test_import_06 LABELS cpython llvm)
485503
RUN(NAME test_math LABELS cpython llvm NOFAST)
486504
RUN(NAME test_numpy_01 LABELS cpython llvm c)
487505
RUN(NAME test_numpy_02 LABELS cpython llvm c)
@@ -543,17 +561,26 @@ RUN(NAME test_generics_01 LABELS cpython llvm c NOFAST)
543561
RUN(NAME test_cmath LABELS cpython llvm c NOFAST)
544562
RUN(NAME test_complex_01 LABELS cpython llvm c wasm wasm_x64)
545563
RUN(NAME test_complex_02 LABELS cpython llvm c)
564+
RUN(NAME test_ConstantEllipsis LABLES cpython llvm c)
546565
RUN(NAME test_max_min LABELS cpython llvm c)
547566
RUN(NAME test_global LABELS cpython llvm c)
548567
RUN(NAME test_global_decl LABELS cpython llvm c)
549-
RUN(NAME test_integer_bitnot LABELS cpython llvm c wasm)
550-
RUN(NAME test_ifexp LABELS cpython llvm c)
551-
RUN(NAME test_unary_minus LABELS cpython llvm c)
552-
RUN(NAME test_unary_plus LABELS cpython llvm c)
568+
RUN(NAME test_ifexp_01 LABELS cpython llvm c)
569+
RUN(NAME test_ifexp_02 LABELS cpython llvm c)
570+
RUN(NAME test_unary_op_01 LABELS cpython llvm c) # unary minus
571+
RUN(NAME test_unary_op_02 LABELS cpython llvm c) # unary plus
572+
RUN(NAME test_unary_op_03 LABELS cpython llvm c wasm) # unary bitinvert
573+
RUN(NAME test_unary_op_04 LABELS cpython llvm c) # unary bitinvert
574+
RUN(NAME test_unary_op_05 LABELS cpython llvm c) # unsigned unary minus, plus
575+
RUN(NAME test_unary_op_06 LABELS cpython llvm c) # unsigned unary bitnot
576+
RUN(NAME test_unsigned_01 LABELS cpython llvm c) # unsigned bitshift left, right
577+
RUN(NAME test_unsigned_02 LABELS cpython llvm c)
578+
RUN(NAME test_unsigned_03 LABELS cpython llvm c)
553579
RUN(NAME test_bool_binop LABELS cpython llvm c)
554580
RUN(NAME test_issue_518 LABELS cpython llvm c NOFAST)
555581
RUN(NAME structs_01 LABELS cpython llvm c)
556582
RUN(NAME structs_02 LABELS cpython llvm c)
583+
RUN(NAME structs_02b LABELS cpython llvm c NOFAST)
557584
RUN(NAME structs_03 LABELS llvm c)
558585
RUN(NAME structs_04 LABELS cpython llvm c)
559586
RUN(NAME structs_05 LABELS cpython llvm c)
@@ -586,10 +613,19 @@ RUN(NAME structs_26 LABELS cpython llvm c)
586613
RUN(NAME structs_27 LABELS cpython llvm c)
587614
RUN(NAME structs_28 LABELS cpython llvm c)
588615
RUN(NAME structs_29 LABELS cpython llvm)
616+
RUN(NAME structs_30 LABELS cpython llvm c)
617+
RUN(NAME structs_31 LABELS cpython llvm c)
618+
RUN(NAME structs_32 LABELS cpython llvm c)
619+
RUN(NAME structs_33 LABELS cpython llvm c)
620+
RUN(NAME structs_34 LABELS cpython llvm c)
589621

590622
RUN(NAME symbolics_01 LABELS cpython_sym c_sym)
591623
RUN(NAME symbolics_02 LABELS cpython_sym c_sym)
592624
RUN(NAME symbolics_03 LABELS cpython_sym c_sym)
625+
RUN(NAME symbolics_04 LABELS cpython_sym c_sym)
626+
RUN(NAME symbolics_05 LABELS cpython_sym c_sym)
627+
RUN(NAME symbolics_06 LABELS cpython_sym c_sym)
628+
RUN(NAME symbolics_07 LABELS cpython_sym c_sym)
593629

594630
RUN(NAME sizeof_01 LABELS llvm c
595631
EXTRAFILES sizeof_01b.c)
@@ -617,6 +653,8 @@ RUN(NAME vec_01 LABELS cpython llvm c NOFAST)
617653
RUN(NAME test_str_comparison LABELS cpython llvm c)
618654
RUN(NAME test_bit_length LABELS cpython llvm c)
619655
RUN(NAME str_to_list_cast LABELS cpython llvm c)
656+
RUN(NAME cast_01 LABELS cpython llvm c)
657+
RUN(NAME cast_02 LABELS cpython llvm c)
620658
RUN(NAME test_sys_01 LABELS cpython llvm c NOFAST)
621659
RUN(NAME intent_01 LABELS cpython llvm)
622660

@@ -643,6 +681,7 @@ RUN(NAME func_static_01 LABELS cpython llvm c wasm)
643681
RUN(NAME func_static_02 LABELS cpython llvm c wasm)
644682
RUN(NAME func_dep_03 LABELS cpython llvm c)
645683
RUN(NAME func_dep_04 LABELS cpython llvm c)
684+
RUN(NAME func_internal_def_01 LABELS cpython llvm NOFAST)
646685

647686
RUN(NAME float_01 LABELS cpython llvm c wasm wasm_x64)
648687
RUN(NAME recursive_01 LABELS cpython llvm c wasm wasm_x64 wasm_x86)
@@ -659,7 +698,8 @@ RUN(NAME global_syms_04 LABELS cpython llvm c wasm wasm_x64)
659698
RUN(NAME global_syms_05 LABELS cpython llvm c)
660699
RUN(NAME global_syms_06 LABELS cpython llvm c)
661700

662-
RUN(NAME callback_01 LABELS cpython llvm)
701+
RUN(NAME callback_01 LABELS cpython llvm c)
702+
RUN(NAME callback_02 LABELS cpython llvm c)
663703

664704
# Intrinsic Functions
665705
RUN(NAME intrinsics_01 LABELS cpython llvm NOFAST) # any

integration_tests/array_04.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from lpython import i32, Const
2+
from numpy import empty, int32
3+
4+
def main0():
5+
n: Const[i32] = 1
6+
x: i32[n, n] = empty([n, n], dtype=int32)
7+
y: i32[n, n] = empty([n, n], dtype=int32)
8+
9+
x[0, 0] = -10
10+
y[0, 0] = -10
11+
12+
print(x[0, 0], y[0, 0])
13+
assert x == y
14+
15+
y[0, 0] = 10
16+
print(x[0, 0], y[0, 0])
17+
assert x != y
18+
19+
main0()

integration_tests/array_expr_02.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from lpython import i32, f32, TypeVar
22
from numpy import empty, sqrt, float32
33

4-
n: i32
54
n = TypeVar("n")
65

76
def modify(array_a: f32[:], n: i32) -> f32[n]:

integration_tests/bindc_09.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from enum import Enum
22

3-
from lpython import CPtr, c_p_pointer, p_c_pointer, dataclass, empty_c_void_p, pointer, Pointer, i32, ccallable
3+
from lpython import (CPtr, c_p_pointer, p_c_pointer, dataclass, empty_c_void_p,
4+
pointer, Pointer, i32, ccallable, InOut)
45

56
class Value(Enum):
67
TEN: i32 = 10
@@ -17,8 +18,7 @@ class Foo:
1718
class FooC:
1819
value: Value
1920

20-
def bar(foo_ptr: CPtr) -> None:
21-
foo: Pointer[Foo] = c_p_pointer(foo_ptr, Foo)
21+
def bar(foo: InOut[Foo]) -> None:
2222
foo.value = Value.FIVE
2323

2424
def barc(foo_ptr: CPtr) -> None:
@@ -30,8 +30,7 @@ def main() -> None:
3030
fooc: FooC = FooC(Value.TWO)
3131
foo_ptr: CPtr = empty_c_void_p()
3232

33-
p_c_pointer(pointer(foo), foo_ptr)
34-
bar(foo_ptr)
33+
bar(foo)
3534
print(foo.value, foo.value.name)
3635
assert foo.value == Value.FIVE
3736

0 commit comments

Comments
 (0)