-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Make SyntaxTest
easier to extend with custom expectations
#14505
Conversation
80511e8
to
f4146ee
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.
Just a small nit or more of a question, but not really a problem.
|
||
protected: | ||
virtual void setupCompiler(); | ||
void parseAndAnalyze() override; | ||
virtual void filterObtainedErrors(); | ||
|
||
bool m_optimiseYul = true; | ||
bool m_parserErrorRecovery = false; | ||
bool m_optimiseYul{}; |
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.
I see that m_optimiseYul
defaults to true
in the constructor, so seems harmless, but still shouldn't we keep it initialized with the same value here too?
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.
It does not really default to true
. It defaults to m_reader.boolSetting("optimize-yul", true)
, which could end up being either. true
is just as misleading here as false
.
I think that using default initialization here is the least bad option. It does not show the value so it does not draw attention away from the initialization in the constructor. The actual value here is irrelevant, we only really care that it's initialized to some deterministic value.
Needs rebase |
f4146ee
to
5fa0993
Compare
Rebased. |
5fa0993
to
bf0d51d
Compare
bf0d51d
to
7768f26
Compare
- Also reorder Error::Type to match initial values for some consistency
- These get re-initialized in constructor anyway. The only purpose if initializing here is our convention to always initialize primitive types at declaration time. We don't want to have to repeat the defaults though.
…ns in addition to expected errors
7768f26
to
e847596
Compare
Prerequisite for #14433.
I originally planned to derive my new Natspec test case from
TestCase
withAnalysisFramework
as a mixin. This allowed me to go 90% of the way, but then it turned out that some useful behaviors of our syntax tests are not a reusable part of the base test case, but available only inSyntaxTest
:Some of them are in
CommonSyntaxTest
, but that in turn does not useAnalysisFramework
and I'd have to reimplement some of the functionality thatSyntaxTest
already has.This PR modifies
CommonSyntaxTest
andSyntaxTest
to make it easier to use them as a base for test cases that want to include errors and warnings in their expectations, but also have extra output when analysis succeeds. The Natspec test case will use this mechanism to expect either errors (if Natspec is invalid) or JSON content.