-
-
Notifications
You must be signed in to change notification settings - Fork 420
Fix for Negated condition violators (retry) #18738
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
Draft
carolahp
wants to merge
17
commits into
pharo-project:Pharo14
Choose a base branch
from
carolahp:fix/violators-in-negated-conditions2
base: Pharo14
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
eb5b909
refactor: use candidates for computing nonViolators in MethodConditions
carolahp a00ca3a
feat: refactor for conditions API and lots of tests
carolahp a3ace41
fix: AndCondition nonViolators and NegationCondition not
carolahp 82637b7
fix: check for AndCondition
carolahp 847f4c4
Merge branch 'fix/violators-in-negated-conditions3' into fix/violator…
carolahp cae7925
Merge branch 'fix/violators-in-negated-conditions2' of github.com:car…
carolahp 647dc65
Merge branch 'Pharo14' into fix/violators-in-negated-conditions2
carolahp f27a4c9
refactor: first steps to unify condition apis from parallel hierarchies
carolahp e177c51
refactor: violation message printing
carolahp a9fd635
continue unifying apis
carolahp ea49e25
merge P14
carolahp 89b7dfd
Merge branch 'Pharo14' into fix/violators-in-negated-conditions2
carolahp e3f36fc
fix: violators for InstVarHasRefs
carolahp 64b6f1f
Merge branch 'Pharo14' into fix/violators-in-negated-conditions2
carolahp 4b6239c
Rename obsolete name from class
carolahp 193e768
Merge branch 'fix/violators-in-negated-conditions2' of github.com:car…
carolahp b56ab07
fix: failing tests from Refactoring-Core
carolahp 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
There are no files selected for viewing
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
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
76 changes: 76 additions & 0 deletions
76
src/Refactoring-Core-Tests/ReMethodsHaveNoSendersConditionTest.class.st
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,76 @@ | ||
| Class { | ||
| #name : 'ReMethodsHaveNoSendersConditionTest', | ||
| #superclass : 'TestCase', | ||
| #instVars : [ | ||
| 'model' | ||
| ], | ||
| #category : 'Refactoring-Core-Tests-Conditions', | ||
| #package : 'Refactoring-Core-Tests', | ||
| #tag : 'Conditions' | ||
| } | ||
|
|
||
| { #category : 'accessing' } | ||
| ReMethodsHaveNoSendersConditionTest >> model [ | ||
|
|
||
| ^ model ifNil: [ model := RBNamespace onEnvironment: | ||
| (RBClassEnvironment classes: {MyClassAlpha . MyClassBeta})] | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| ReMethodsHaveNoSendersConditionTest >> testMethodWithNoSenders [ | ||
| | myClassAlpha cond | | ||
| myClassAlpha := self model classNamed: #MyClassAlpha. | ||
|
|
||
| cond := ReMethodsHaveNoSendersCondition new model: self model; | ||
| classSelectorsMapping: { myClassAlpha -> { #methodWithNoSenders } }. | ||
|
|
||
| " the method is not sent by anyone " | ||
| self assert: cond check. | ||
| self assert: cond violators isEmpty. | ||
| self assert: cond nonViolators asSet equals: { myClassAlpha -> (myClassAlpha methodFor: #methodWithNoSenders) } asSet | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| ReMethodsHaveNoSendersConditionTest >> testMethodWithNoSendersWithMessage [ | ||
| | myClassAlpha cond | | ||
| myClassAlpha := self model classNamed: #MyClassAlpha. | ||
|
|
||
| cond := ReMethodsHaveNoSendersCondition new model: self model; | ||
| classSelectorsMapping: { myClassAlpha -> { #methodWithNoSenders } }. | ||
|
|
||
| " the method does not refer to shared variables " | ||
| self assert: cond errorString isEmpty | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| ReMethodsHaveNoSendersConditionTest >> testMethodWithSend [ | ||
| | myClassBeta cond violatorSelectors | | ||
| myClassBeta := self model classNamed: #myClassBeta. | ||
| cond := ReMethodsHaveNoSendersCondition new model: self model; | ||
| classSelectorsMapping: { | ||
| myClassBeta -> { #methodSentFromAMethodInItsOwnClass } | ||
| }. | ||
|
|
||
| " one of the methods have senders " | ||
| self deny: cond check. | ||
| violatorSelectors := (cond violators collect: [ :assoc | assoc key ]) asArray. | ||
| self assert: violatorSelectors equals: { #methodSentFromAMethodInItsOwnClass }. | ||
| self assert: cond nonViolators isEmpty | ||
| ] | ||
|
|
||
| { #category : 'tests' } | ||
| ReMethodsHaveNoSendersConditionTest >> testMethodWithSuperSend [ | ||
| | myClassAlpha myClassBeta cond violatorSelectors | | ||
| myClassAlpha := self model classNamed: #MyClassAlpha. | ||
| myClassBeta := self model classNamed: #MyClassBeta. | ||
| cond := ReMethodsHaveNoSendersCondition new model: self model; | ||
| classSelectorsMapping: { | ||
| myClassAlpha -> { #methodWithSuperSend } | ||
| }. | ||
|
|
||
| " the method is sent from MyClassBeta >> #methodWithSuperSend " | ||
| self deny: cond check. | ||
| violatorSelectors := (cond violators collect: [ :assoc | assoc key ]) asArray. | ||
| self assert: violatorSelectors equals: { #methodWithSuperSend }. | ||
| self assert: cond nonViolators isEmpty | ||
| ] |
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
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
Oops, something went wrong.
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.
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.
Should we rename iv to candidates 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.
Or, should this be removed since accessor is used everywhere?
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.
Yes! I am removing it since we are using the accessor everywhere