Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync libasr with LFortran #2628

Merged
merged 7 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ extsrc/
tmp/
tmpdebug/
gentests/
inst/

## Ninja
build.ninja
Expand Down
2 changes: 2 additions & 0 deletions build0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ python src/libasr/asdl_cpp.py grammar/Python.asdl src/lpython/python_ast.h
python src/libasr/asdl_cpp.py src/libasr/ASR.asdl src/libasr/asr.h
# Generate a wasm_visitor.h from src/libasr/wasm_instructions.txt (C++)
python src/libasr/wasm_instructions_visitor.py
# Generate the intrinsic_function_registry_util.h (C++)
python src/libasr/intrinsic_func_registry_util_gen.py

# Generate the tokenizer and parser
(cd src/lpython/parser && re2c -W -b tokenizer.re -o tokenizer.cpp)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/symbolics_11.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_extraction_of_elements():
print(ele1, ele2, ele3, ele4)
print(l1[0], l1[1], l1[2], l1[3])

test_extraction_of_elements()
test_extraction_of_elements()
13 changes: 0 additions & 13 deletions integration_tests/test_c_interop_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ def _lfortran_dsin(x: f64) -> f64:
def _lfortran_ssin(x: f32) -> f32:
pass

@ccall
def _lfortran_bgt32(i: i32, j: i32) -> i32:
pass

@ccall
def _lfortran_bgt64(i: i64, j: i64) -> i32:
pass

#@ccall
#def _lfortran_random_number(n: i64, v: f64[:]):
# pass
Expand All @@ -28,9 +20,4 @@ def test_c_callbacks():
assert abs(_lfortran_ssin(f32(pi)) - f32(0.0)) < f32(1e-6)
assert abs(_lfortran_ssin(f32(pi/2.0)) - f32(1.0)) < f32(1e-6)

assert _lfortran_bgt32(3, 4) == 0
assert _lfortran_bgt32(4, 3) == 1
assert _lfortran_bgt64(i64(3), i64(4)) == 0
assert _lfortran_bgt64(i64(4), i64(3)) == 1

test_c_callbacks()
30 changes: 15 additions & 15 deletions integration_tests/test_list_reserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ def test_list_reserve():
i: i32

reserve(l1, 100)
for i in range(50):
l1.append(i)
assert len(l1) == i + 1
# for i in range(50):
# l1.append(i)
# assert len(l1) == i + 1

reserve(l1, 150)
# reserve(l1, 150)

for i in range(50):
l1.pop(0)
assert len(l1) == 49 - i
# for i in range(50):
# l1.pop(0)
# assert len(l1) == 49 - i

reserve(l2, 100)
for i in range(50):
l2.append([(f64(i * i), str(i), (i, f64(i + 1))), (f64(i), str(i), (i, f64(i)))])
assert len(l2) == i + 1
# reserve(l2, 100)
# for i in range(50):
# l2.append([(f64(i * i), str(i), (i, f64(i + 1))), (f64(i), str(i), (i, f64(i)))])
# assert len(l2) == i + 1

reserve(l2, 150)
# reserve(l2, 150)

for i in range(50):
l2.pop(0)
assert len(l2) == 49 - i
# for i in range(50):
# l2.pop(0)
# assert len(l2) == 49 - i

test_list_reserve()
6 changes: 3 additions & 3 deletions integration_tests/test_list_reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def test_list_reverse():
l3.reverse()
assert l3 == l4
j += 0.1

l5 = ["abcd", "efgh", "ijkl"]
for s in l5:
l6.reverse()
l6.insert(0, s)
l7.append(s)
l6.reverse()
assert l6 == l7

l8 = [[1, 2], [3, 4, 5], [6, 7, 8, 9], [10]]
l8.reverse()
assert l8 == [[10], [6, 7, 8, 9], [3, 4, 5], [1, 2]]
Expand All @@ -54,4 +54,4 @@ def test_list_reverse():
assert l9 == [(5, 6.0, "ghi"), (3, 4.0, "def"), (1, 2.0, "abc")]


test_list_reverse()
test_list_reverse()
10 changes: 8 additions & 2 deletions integration_tests/test_str_attributes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
def capitalize():
s: str
s = "tom and jerry"
print(s.capitalize())
assert s.capitalize() == "Tom and jerry"
s = "12wddd"
print(s)
assert s.capitalize() == s
s = " tom and jerry"
print(s.capitalize())
assert s.capitalize() == s
assert "empty string" .capitalize() == "Empty string"
assert "".capitalize() == ""
Expand Down Expand Up @@ -76,14 +79,17 @@ def count():
sub: str
s = "ABC ABCDAB ABCDABCDABDE"
sub = "ABC"
print(s.count(sub), s.count("ABC"))
assert s.count(sub) == 4
assert s.count("ABC") == 4

sub = "AB"
print(s.count(sub), s.count("AB"))
assert s.count(sub) == 6
assert s.count("AB") == 6

sub = "ABC"
print("ABC ABCDAB ABCDABCDABDE".count(sub), "ABC ABCDAB ABCDABCDABDE".count("ABC"))
assert "ABC ABCDAB ABCDABCDABDE".count(sub) == 4
assert "ABC ABCDAB ABCDABCDABDE".count("ABC") == 4

Expand Down Expand Up @@ -342,7 +348,7 @@ def is_title():
res4: bool = d.istitle()
res5: bool = e.istitle()
assert res == True
assert res2 == False
assert res2 == False
assert res3 == False
assert res4 == True
assert res5 == False
Expand Down
2 changes: 1 addition & 1 deletion run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def single_test(test, verbose, no_llvm, skip_run_with_dbg, skip_cpptranslate, update_reference,
no_color, specific_backends=None, excluded_backends=None):
verify_hash, no_color, specific_backends=None, excluded_backends=None):
filename = test["filename"]
def is_included(backend):
return test.get(backend, False) \
Expand Down
Loading
Loading