Enforce proper identifiers in tests#8026
Draft
greg-at-moderne wants to merge 4 commits into
Draft
Conversation
f5e15ae to
c98bdea
Compare
The service() overrides in G, K, JS and S resolved known services inside a try that also held the JavaSourceFile.super.service(...) delegation for unknown services. Their catch (Exception) then re-wrapped the UnsupportedOperationException thrown for unsupported services in a RuntimeException. Callers that probe for an optional service (e.g. the test framework's identifier-name validation) catch UnsupportedOperationException and so could not recognize the wrapped form. Move the super.service(...) delegation outside the try so the UnsupportedOperationException propagates unwrapped, matching the bare behavior of the other language SourceFile implementations.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's changed?
Amending the test harness to add a new check. This is for enforcing that the identifiers contain only these characters which are allowed for given language.
What's your motivation?
The typical situation this check catches is when the parsing stuffs too much into a single
J.Identifier. The round-trip idempotency printing test doesn't necessarily catch that.I caught several cases like this recently in Scala. But the idea is more universal, thus the generic solution.