-
Notifications
You must be signed in to change notification settings - Fork 35
Added enum types and verification #168
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c70cc5a
Added enum type support with tests
cheestree e77a33b
Added EnumRefinementMessage test
cheestree a359d1f
Applied fixes and suggestions for enums
cheestree a6a4055
Fixed grammar
cheestree 0ab2098
Revert "Fixed grammar"
cheestree 44758c7
Reapply "Fixed grammar"
cheestree b610928
Separated translation into phases
cheestree cdf192e
Refactored variable translation
cheestree d7dea40
Added enum tests
cheestree e3e49d2
Added enum tests, adjusted grammar
cheestree aafde53
Moved RefinementMessage test
cheestree 7a7e074
Changed Enumerate to Enum
cheestree 96905c1
Renamed fields and getters/setters
cheestree 8a4e507
Updated variable translation with suggestions
cheestree 2e46e5c
Merge branch 'liquid-java:main' into main
cheestree 2754337
Updated tests to fit with main changes
cheestree 2c23a2e
Extracted enum logic to its own method
cheestree c85ed97
Apply suggestions from code review
cheestree 2ad2747
Renamed usage
cheestree File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added enum tests, adjusted grammar
Added some more enum tests for different situations (like as parameters or fields with enum refinements). Merged CorrectEnumResetMode into CorrectEnumUsage (redundant having a separate one that only tests resetting to null) Refactored enumCreate as suggested. Refactored grammar to follow Enumerate class.
- Loading branch information
commit e3e49d28b5a454822b319c47ff8addd89019d206
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
liquidjava-example/src/main/java/testSuite/CorrectEnumField.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package testSuite; | ||
|
|
||
| import liquidjava.specification.Refinement; | ||
|
|
||
| @SuppressWarnings("unused") | ||
| class CorrectEnumField { | ||
| enum Color { | ||
| Red, Green, Blue | ||
| } | ||
|
|
||
| @Refinement("color != Color.Blue") | ||
| Color color; | ||
|
|
||
| void setColor(@Refinement("c != Color.Blue") Color c) { | ||
| color = c; | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| CorrectEnumField cef = new CorrectEnumField(); | ||
| cef.setColor(Color.Red); // correct | ||
| cef.setColor(Color.Green); // correct | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
liquidjava-example/src/main/java/testSuite/CorrectEnumParam.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package testSuite; | ||
|
|
||
| import liquidjava.specification.Refinement; | ||
|
|
||
| @SuppressWarnings("unused") | ||
| class CorrectEnumParam { | ||
| enum Status { | ||
| Active, Inactive, Pending | ||
| } | ||
|
|
||
| Status process(@Refinement("status == Status.Inactive") Status status) { | ||
| return Status.Active; | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| CorrectEnumParam cep = new CorrectEnumParam(); | ||
| cep.process(Status.Inactive); // correct | ||
| } | ||
| } |
44 changes: 0 additions & 44 deletions
44
liquidjava-example/src/main/java/testSuite/CorrectEnumResetMode.java
This file was deleted.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
liquidjava-example/src/main/java/testSuite/ErrorEnumNegation.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Refinement Error | ||
| package testSuite; | ||
|
|
||
| import liquidjava.specification.Refinement; | ||
|
|
||
| @SuppressWarnings("unused") | ||
| class ErrorEnumNegation { | ||
| enum Status { | ||
| Active, Inactive, Pending | ||
| } | ||
|
|
||
| void process(@Refinement("status != Status.Inactive") Status status) {} | ||
|
|
||
| public static void main(String[] args) { | ||
| ErrorEnumNegation e = new ErrorEnumNegation(); | ||
| e.process(Status.Active); // correct | ||
| e.process(Status.Inactive); // error | ||
| } | ||
| } |
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.