-
Notifications
You must be signed in to change notification settings - Fork 119
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
Restructure tests #15
Conversation
A proposal for testing intermediate code (that might be good to add to a different PR): It may be possible to automatically generate differential tests that catch if some detail of low-level code generation changes from one version of PyTEAL to the next. There could be a test generator which exhaustively runs through the opcodes (and maybe small combinations of them) and outputs the expected values of these compiled opcodes; if these expected values are checked into the git repo, then we can have unit tests that check that we match these values. If we change how code generation works from one version to the next, then these tests will catch that. I think we do something similar in the TEAL assembler here: |
@@ -51,6 +52,7 @@ def test_atomic_swap(): | |||
&& | |||
|| | |||
&&""" | |||
reset_label_count() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why are these required here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are required in general to reset the global label counter in util.py
so that the labels match the expected code string. Although it looks like this example does not actually use labels, so that call can be removed from here if you think it's confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay--that makes sense.
I don't think it's necessary to remove them; rather, it seems somewhat redundant that you'd just place it before every test for the tests to be correct.
To a larger point, it's a little unfortunate that state for these labels is global and not already implicitly reset per invocation of compileTeal
, which is what intuitively makes sense to me. Perhaps there's a way to move this global counter to somewhere local to compileTeal
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Might want to make a small note in the merge that the way byte
is compiled is now slightly different.
Move AST tests from
tests/test_ops.py
into individual testing files in thepyteal
directory. The first commit only moves tests, while the second commit restructures the individual tests and adds checking for generated intermediate code.