forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix symbolic pass for handling
IntrinsicElementalFunction
in `print…
…()` (lcompilers#2665) * Fix symbolic pass for handling `IntrinsicElementalFunction` in `print()` * Tests: Add tests and update references * Fix mistakenly commented out lines * Tests: Add testcase and update references * Tests: Update references * Style changes * Remove C backend * Tests: Add asserts and update test reference
- Loading branch information
Showing
6 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from lpython import i32 | ||
|
||
def test_intrinsic_function_mixed_print(): | ||
# list and list methods | ||
my_list: list[i32] = [1, 2, 3, 4, 5] | ||
print("Popped element:", my_list.pop()) | ||
assert my_list == [1, 2, 3, 4] | ||
|
||
print("1 is located at:", my_list.index(1)) | ||
assert my_list.index(1) == 0 | ||
|
||
my_list.append(2) | ||
print("2 is present", my_list.count(2), "times") | ||
assert my_list.count(2) == 2 | ||
|
||
print(my_list.pop(), my_list) | ||
assert my_list == [1, 2, 3, 4] | ||
|
||
# dict and dict methods | ||
my_dict: dict[str, i32] = {"first": 1, "second": 2, "third": 3} | ||
print("Keys:", my_dict.keys()) | ||
print("Value of 'third':", my_dict.pop("third")) | ||
assert len(my_dict.keys()) == 2 | ||
|
||
test_intrinsic_function_mixed_print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/reference/runtime-test_intrinsic_function_mixed_print-a862825.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"basename": "runtime-test_intrinsic_function_mixed_print-a862825", | ||
"cmd": "lpython {infile}", | ||
"infile": "tests/../integration_tests/test_intrinsic_function_mixed_print.py", | ||
"infile_hash": "b0f779598e5d9868d183f1032fb3f87c131fedacf7848aaed6c4d238", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "runtime-test_intrinsic_function_mixed_print-a862825.stdout", | ||
"stdout_hash": "a8d2083be043accf4ebe8c6a3e8a2427d492323b12d0c041ba79f10e", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/reference/runtime-test_intrinsic_function_mixed_print-a862825.stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Popped element: 5 | ||
1 is located at: 0 | ||
2 is present 2 times | ||
2 [1, 2, 3, 4] | ||
Keys: ['second', 'third', 'first'] | ||
Value of 'third': 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters