-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now, a label declared with `public foo:` will be exported in the `public_labels` property of `Program` objects. Additionally, a test of this feature as well as the existing duplicate label detection feature is added. Change the return type of `assemble` so that it better reflects reality Add docstrings for the public properties of Program objects
- Loading branch information
Showing
2 changed files
with
79 additions
and
2 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,63 @@ | ||
# SPDX-FileCopyrightText: 2024 Jeff Epler for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
""" | ||
Tests out | ||
""" | ||
|
||
from pytest_helpers import assert_assembly_fails | ||
import adafruit_pioasm | ||
|
||
|
||
def test_label() -> None: | ||
source = [ | ||
" jmp label1", | ||
"label1:", | ||
" jmp label2", | ||
"public label2:", | ||
" nop", | ||
] | ||
program = adafruit_pioasm.Program("\n".join(source)) | ||
assert program.public_labels == {"label2": 2} | ||
|
||
# Test each combination of public/privagte label duplication | ||
source = [ | ||
"label1:\n", | ||
"nop\n", | ||
"public label1:\n", | ||
"nop\n", | ||
] | ||
assert_assembly_fails( | ||
"\n".join(source), match="Duplicate label", errtype=SyntaxError | ||
) | ||
|
||
source = [ | ||
"label1:\n", | ||
" nop\n", | ||
"label1:\n", | ||
" nop\n", | ||
] | ||
assert_assembly_fails( | ||
"\n".join(source), match="Duplicate label", errtype=SyntaxError | ||
) | ||
|
||
source = [ | ||
"public label1:\n", | ||
" nop\n", | ||
"label1:\n", | ||
" nop\n", | ||
] | ||
assert_assembly_fails( | ||
"\n".join(source), match="Duplicate label", errtype=SyntaxError | ||
) | ||
|
||
source = [ | ||
"public label1:\n", | ||
" nop\n", | ||
"public label1:\n", | ||
" nop\n", | ||
] | ||
assert_assembly_fails( | ||
"\n".join(source), match="Duplicate label", errtype=SyntaxError | ||
) |