-
Notifications
You must be signed in to change notification settings - Fork 171
Fix symbolic pass for printing ListItem
#2620
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
Merged
ubaidsk
merged 7 commits into
lcompilers:main
from
kmr-srbh:fix-list-item-symbolic-pass
Mar 23, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f437160
Fix list item symbolic pass
kmr-srbh c1e097b
Merge branch 'lcompilers:main' into fix-list-item-symbolic-pass
kmr-srbh be94f56
Tests: Add tests and update test references
kmr-srbh 20b4ad6
Tests: Update test references
kmr-srbh c23b1c8
Remove trailing whitespace
kmr-srbh 4baad5e
Simplify statement
kmr-srbh 09c688b
Tests: Update test and test references
kmr-srbh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,44 @@ | ||
from lpython import i32, f64 | ||
|
||
# Test for verifying printing items of different types with a list: | ||
# 1. string and list item | ||
# 2. integer and list item | ||
# 3. float and list item | ||
# 4. tuple and list item | ||
# | ||
# Also test with a list item which is a nested list. | ||
def test_list_item_mixed_print(): | ||
s_list: list[str] = ["Hello", "LPython"] | ||
|
||
print("", s_list[0]) | ||
print("This is", s_list[1]) | ||
|
||
i_list: list[i32] = [1, 2, 3, 4, 5] | ||
|
||
print(i_list[0], i_list[1], i_list[2], "...", i_list[-3], i_list[-2], i_list[-1]) | ||
print("The first element is:", i_list[0]) | ||
|
||
m: i32 = len(i_list) // 2 | ||
print("The middle element is:", i_list[m]) | ||
|
||
f_list: list[f64] = [3.14, 6.28] | ||
|
||
print(f_list[0], "* 2 =", f_list[1]) | ||
print("Total:", f_list[0] + f_list[1]) | ||
|
||
t: tuple[i32, i32, i32] = (1, 2, 3) | ||
print(t, "is a tuple, but", i_list[0], "is a number.") | ||
|
||
i_list2: list[i32] = [1, 2, 3] | ||
print(i_list2[0], i_list2[1], i_list2[2], sep=" is smaller than ") | ||
|
||
i: i32 | ||
for i in range(len(i_list)): | ||
print(i_list[i], end=" # ") | ||
print("\n") | ||
|
||
n_list: list[list[i32]] = [[1, 2], [3, 4], [5, 6]] | ||
for i in range(len(n_list)): | ||
print("List ", i, ":", n_list[i]) | ||
|
||
test_list_item_mixed_print() |
This file contains hidden or 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_list_item_mixed_print-a3fd49f.json
This file contains hidden or 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_list_item_mixed_print-a3fd49f", | ||
"cmd": "lpython {infile}", | ||
"infile": "tests/../integration_tests/test_list_item_mixed_print.py", | ||
"infile_hash": "14ce4950ca0ff6c6f610df787ad8d260148866f4c7062ab0b856ec5a", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "runtime-test_list_item_mixed_print-a3fd49f.stdout", | ||
"stdout_hash": "cffcdb43864ef4e234dec5a10923f9077b7c6d1f4d9c37df1882f375", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/reference/runtime-test_list_item_mixed_print-a3fd49f.stdout
This file contains hidden or 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,14 @@ | ||
Hello | ||
This is LPython | ||
1 2 3 ... 3 4 5 | ||
The first element is: 1 | ||
The middle element is: 3 | ||
3.14000000000000012e+00 * 2 = 6.28000000000000025e+00 | ||
Total: 9.41999999999999993e+00 | ||
(1, 2, 3) is a tuple, but 1 is a number. | ||
1 is smaller than 2 is smaller than 3 | ||
1 # 2 # 3 # 4 # 5 # | ||
|
||
List 0 : [1, 2] | ||
List 1 : [3, 4] | ||
List 2 : [5, 6] |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.