-
Notifications
You must be signed in to change notification settings - Fork 600
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
Add more exhaustive tests for .asTypeOf #4160
Conversation
I'll add that I wrote these tests against the Verilog because:
|
59c2594
to
9c4229d
Compare
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.
SGTM
I glanced through the tests. This is locking in existing behavior so they, by definition, should be fine.
The checking of the exact Verilog output is going to be somewhat brittle as this could change in arbitrary ways in the future. One idea is to avoid the wire
keyword and width specification when it is not necessary.
// 8-bit wire for inferred test puts several spaces between wire and out | ||
(verilog should include).regex("""wire +out = in\[0\];""") |
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.
This type of test is going to be somewhat annoyingly brittle. You could probably skip the wire (probably in all tests, too).
So I originally wrote the tests against an output port which would be better, but since we can no longer have inferred width output ports (at least for the top-level module), that didn't work for the tests with the inferred widths. That being said, I suspect these should be pretty stable as written. I intentionally used widths <= 10 bits so that there would not be any alignment issues due to wire + bitwidth. The tests are also pretty simple--there's not a lot of degrees of freedom for the Verilog to change. The main thing could be if the default setting changes to splitting declaration from assignment, but hopefully that would be exposed via a lowering option to snag the old (i.e. current) behavior. In any case, if the Verilog does change, then I will vehemently agree with tweaking the tests to be more stable 🙂, but I would be comfortable going ahead as is and fixing that if/when necessary. |
This includes changing AsTypeOfSpec to be FunSpec instead of FlatSpec so that the tests can have more structure.
9c4229d
to
b80a9ef
Compare
This includes changing AsTypeOfSpec to be FunSpec instead of FlatSpec so that the tests can have more structure. (cherry picked from commit 2997fa8)
This includes changing AsTypeOfSpec to be FunSpec instead of FlatSpec so that the tests can have more structure. (cherry picked from commit 2997fa8) Co-authored-by: Jack Koenig <[email protected]>
This includes changing AsTypeOfSpec to be FunSpec instead of FlatSpec so that the tests can have more structure.
I'm working on making it possible to preserve literals across
.asTypeOf
casts (which will help with unit testing and is much more convenient for async reset). In doing so, I found the existing tests extremely lacking so I decided to lay out the existing behavior exhaustively. Please do not review this PR based on what you think should happen1, rather, treat this as documenting the existing behavior so that at least changes that should be functionally equivalent will be and we can be intentional in changing the behavior going forward.I marked this as documentation since, at least for development purposes, it is documenting the behavior.
Marked for backporting to 6.x since I want to backport the literal preservation as well.
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.Footnotes
All truncation should become an error when we get rid of implicit truncation and the "implicit extensions" for non-arithmetic types also should be an error, but that is obviously not the purpose of this PR. ↩