Skip to content

Commit

Permalink
TEST: Updated reference tests
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 committed Mar 26, 2024
1 parent 0df9c2c commit d3fb1dd
Show file tree
Hide file tree
Showing 518 changed files with 2,858 additions and 2,105 deletions.
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
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
2 changes: 1 addition & 1 deletion tests/reference/asr-array_01_decl-39cf894.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-array_01_decl-39cf894.stdout",
"stdout_hash": "f14010ffcf7d42b89e54c88ebecc7ca51d67b204825e07f4f708875e",
"stdout_hash": "34c5f9983e43e6b5c65f021792e415f0c2e4fe5135c6435eb5322719",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
55 changes: 31 additions & 24 deletions tests/reference/asr-array_01_decl-39cf894.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
)
[]
[(Var 224 xf32)]
[(=
[(Assignment
(ArrayItem
(Var 224 xf32)
[(()
Expand All @@ -180,7 +180,7 @@
)
()
)
(=
(Assignment
(Var 224 _lpython_return_variable)
(ArrayItem
(Var 224 xf32)
Expand Down Expand Up @@ -265,7 +265,7 @@
)
[]
[(Var 225 xf64)]
[(=
[(Assignment
(ArrayItem
(Var 225 xf64)
[(()
Expand All @@ -281,7 +281,7 @@
)
()
)
(=
(Assignment
(Var 225 _lpython_return_variable)
(ArrayItem
(Var 225 xf64)
Expand Down Expand Up @@ -366,7 +366,7 @@
)
[]
[(Var 221 xi16)]
[(=
[(Assignment
(ArrayItem
(Var 221 xi16)
[(()
Expand All @@ -384,7 +384,7 @@
)
()
)
(=
(Assignment
(Var 221 _lpython_return_variable)
(ArrayItem
(Var 221 xi16)
Expand Down Expand Up @@ -469,7 +469,7 @@
)
[]
[(Var 222 xi32)]
[(=
[(Assignment
(ArrayItem
(Var 222 xi32)
[(()
Expand All @@ -482,7 +482,7 @@
(IntegerConstant 32 (Integer 4))
()
)
(=
(Assignment
(Var 222 _lpython_return_variable)
(ArrayItem
(Var 222 xi32)
Expand Down Expand Up @@ -567,7 +567,7 @@
)
[]
[(Var 223 xi64)]
[(=
[(Assignment
(ArrayItem
(Var 223 xi64)
[(()
Expand All @@ -585,7 +585,7 @@
)
()
)
(=
(Assignment
(Var 223 _lpython_return_variable)
(ArrayItem
(Var 223 xi64)
Expand Down Expand Up @@ -779,100 +779,107 @@
accept_f32_array
accept_f64_array]
[]
[(=
[(Assignment
(Var 226 ai16)
(ArrayConstant
(ArrayConstructor
[]
(Array
(Integer 2)
[((IntegerConstant 0 (Integer 4))
(IntegerConstant 3 (Integer 4)))]
FixedSizeArray
)
()
RowMajor
)
()
)
(=
(Assignment
(Var 226 ai32)
(ArrayConstant
(ArrayConstructor
[]
(Array
(Integer 4)
[((IntegerConstant 0 (Integer 4))
(IntegerConstant 3 (Integer 4)))]
FixedSizeArray
)
()
RowMajor
)
()
)
(=
(Assignment
(Var 226 ai64)
(ArrayConstant
(ArrayConstructor
[]
(Array
(Integer 8)
[((IntegerConstant 0 (Integer 4))
(IntegerConstant 10 (Integer 4)))]
FixedSizeArray
)
()
RowMajor
)
()
)
(=
(Assignment
(Var 226 af32)
(ArrayConstant
(ArrayConstructor
[]
(Array
(Real 4)
[((IntegerConstant 0 (Integer 4))
(IntegerConstant 3 (Integer 4)))]
FixedSizeArray
)
()
RowMajor
)
()
)
(=
(Assignment
(Var 226 af64)
(ArrayConstant
(ArrayConstructor
[]
(Array
(Real 8)
[((IntegerConstant 0 (Integer 4))
(IntegerConstant 10 (Integer 4)))]
FixedSizeArray
)
()
RowMajor
)
()
)
(=
(Assignment
(Var 226 ac32)
(ArrayConstant
(ArrayConstructor
[]
(Array
(Complex 4)
[((IntegerConstant 0 (Integer 4))
(IntegerConstant 3 (Integer 4)))]
FixedSizeArray
)
()
RowMajor
)
()
)
(=
(Assignment
(Var 226 ac64)
(ArrayConstant
(ArrayConstructor
[]
(Array
(Complex 8)
[((IntegerConstant 0 (Integer 4))
(IntegerConstant 10 (Integer 4)))]
FixedSizeArray
)
()
RowMajor
)
()
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-array_02_decl-e8f6874.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-array_02_decl-e8f6874.stdout",
"stdout_hash": "5279aef41f63f0cd241fff1b853b3186a3d83a32905264b64b66705c",
"stdout_hash": "16f1a4388b7117f7ce6886ac48749fe533265ee12949b513a9317eba",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
Loading

0 comments on commit d3fb1dd

Please sign in to comment.