-
-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make RBAbstractClass match the MOP answering both false by default in…
… #isAbstract. Migrate RBMakeClassAbstractTransformation. Add data for testing: #RBClassWithoutSelfClassReferenceTest and #RBWithSelfClassReferenceTest Update RBMakeClassAbstractParametrizedTest Add #RBMakeClassAbstractDriver with tests Update #SycCMakeAbstractCommand
- Loading branch information
Hernán Morales Durand
committed
Mar 25, 2024
1 parent
fe871bc
commit 3d5d31f
Showing
10 changed files
with
267 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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
7 changes: 7 additions & 0 deletions
7
src/Refactoring-DataForTesting/RBClassWithoutSelfClassReferenceTest.class.st
This file contains 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,7 @@ | ||
Class { | ||
#name : 'RBClassWithoutSelfClassReferenceTest', | ||
#superclass : 'TestCase', | ||
#category : 'Refactoring-DataForTesting-ForTestRelatedOperation', | ||
#package : 'Refactoring-DataForTesting', | ||
#tag : 'ForTestRelatedOperation' | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Refactoring-DataForTesting/RBWithSelfClassReferenceTest.class.st
This file contains 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 @@ | ||
Class { | ||
#name : 'RBWithSelfClassReferenceTest', | ||
#superclass : 'TestCase', | ||
#category : 'Refactoring-DataForTesting-ForTestRelatedOperation', | ||
#package : 'Refactoring-DataForTesting', | ||
#tag : 'ForTestRelatedOperation' | ||
} | ||
|
||
{ #category : 'testing' } | ||
RBWithSelfClassReferenceTest class >> isAbstract [ | ||
|
||
^ self == RBWithSelfClassReferenceTest | ||
] | ||
|
||
{ #category : 'accessing' } | ||
RBWithSelfClassReferenceTest >> method [ | ||
|
||
^ RBWithSelfClassReferenceTest | ||
] |
This file contains 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 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
90 changes: 90 additions & 0 deletions
90
src/Refactoring-UI-Tests/ReMakeClassAbstractDriverTest.class.st
This file contains 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,90 @@ | ||
Class { | ||
#name : 'ReMakeClassAbstractDriverTest', | ||
#superclass : 'ReDriverTest', | ||
#category : 'Refactoring-UI-Tests-Driver', | ||
#package : 'Refactoring-UI-Tests', | ||
#tag : 'Driver' | ||
} | ||
|
||
{ #category : 'tests' } | ||
ReMakeClassAbstractDriverTest >> classWithReferenceToAbstract [ | ||
|
||
^ RBWithSelfClassReferenceTest. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ReMakeClassAbstractDriverTest >> classWithoutReferenceToAbstract [ | ||
|
||
^ Smalltalk globals at: #[82 66 67 108 97 115 115 87 105 116 104 111 117 116 83 101 108 102 67 108 97 115 115 82 101 102 101 114 101 110 99 101 84 101 115 116] asString asSymbol | ||
] | ||
|
||
{ #category : 'initialization' } | ||
ReMakeClassAbstractDriverTest >> setUpDriver: driver [ | ||
|
||
| dialog | | ||
super setUpDriver: driver. | ||
dialog := MockObject new. | ||
dialog | ||
on: #openModal | ||
respond: true. | ||
driver requestDialog: dialog. | ||
] | ||
|
||
{ #category : 'running' } | ||
ReMakeClassAbstractDriverTest >> tearDown [ | ||
|
||
self classWithoutReferenceToAbstract class removeSelector: #isAbstract. | ||
super tearDown. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ReMakeClassAbstractDriverTest >> testMakeClassAbstractWhenClassIsReferenced [ | ||
"Test making a class abstract when it is referenced" | ||
| driver environment rbClass | | ||
|
||
environment := RBClassEnvironment class: self classWithReferenceToAbstract. | ||
driver := RBMakeClassAbstractDriver new | ||
scopes: { environment } class: self classWithReferenceToAbstract; | ||
yourself. | ||
|
||
rbClass := driver model classFor: self classWithReferenceToAbstract. | ||
|
||
self | ||
deny: rbClass isAbstract | ||
description: 'It tests that the RB class is not abstract because it contains its class reference'. | ||
|
||
self setUpDriver: driver. | ||
driver runRefactoring. | ||
|
||
self | ||
deny: rbClass isAbstract | ||
description: 'It tests that the RB class is still abstract after applying the refactoring'. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ReMakeClassAbstractDriverTest >> testMakeClassAbstractWhenClassNotUsed [ | ||
"Test making a class abstract when it is not used anywhere in the system" | ||
| driver environment rbClass | | ||
|
||
environment := RBClassEnvironment class: self classWithoutReferenceToAbstract. | ||
driver := RBMakeClassAbstractDriver new | ||
scopes: { environment } class: self classWithoutReferenceToAbstract; | ||
yourself. | ||
|
||
rbClass := driver model classFor: self classWithoutReferenceToAbstract. | ||
|
||
self | ||
deny: rbClass isAbstract | ||
description: 'It tests that the RB class is not abstract by default'. | ||
|
||
self | ||
deny: (self classWithoutReferenceToAbstract canUnderstand: #isAbstract) | ||
description: 'It test that we successfully applied the refactoring which adds #isAbstract to the target class'. | ||
|
||
self setUpDriver: driver. | ||
driver runRefactoring. | ||
|
||
"It test that we successfully applied the refactoring which adds #isAbstract to the target class" | ||
self assert: driver changes changes anyOne selector equals: #isAbstract. | ||
|
||
] |
This file contains 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 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,46 @@ | ||
Class { | ||
#name : 'RBMakeClassAbstractDriver', | ||
#superclass : 'RBInteractionDriver', | ||
#instVars : [ | ||
'class' | ||
], | ||
#category : 'Refactoring-UI-Drivers', | ||
#package : 'Refactoring-UI', | ||
#tag : 'Drivers' | ||
} | ||
|
||
{ #category : 'execution' } | ||
RBMakeClassAbstractDriver >> changes [ | ||
"Remember should not call generateChanges" | ||
|
||
refactoring privateTransform. | ||
^ refactoring changes | ||
] | ||
|
||
{ #category : 'resources' } | ||
RBMakeClassAbstractDriver >> configureRefactoring [ | ||
"Configure the transformation" | ||
|
||
refactoring := RBMakeClassAbstractTransformation new | ||
model: model; | ||
classNamed: class name; | ||
yourself. | ||
] | ||
|
||
{ #category : 'execution' } | ||
RBMakeClassAbstractDriver >> runRefactoring [ | ||
"Run the transformation" | ||
|
||
self configureRefactoring. | ||
refactoring failedApplicabilityPreconditions | ||
ifNotEmpty: [ ^ self inform: 'Preconditions not met' ]. | ||
self applyChanges. | ||
] | ||
|
||
{ #category : 'accessing' } | ||
RBMakeClassAbstractDriver >> scopes: refactoringScopes class: aClass [ | ||
|
||
scopes := refactoringScopes. | ||
model := self refactoringScopeOn: scopes first. | ||
class := aClass | ||
] |
Oops, something went wrong.