Skip to content

Commit 9d9d17c

Browse files
authored
Merge pull request #18082 from tesonep/helping-to-test-refactorings
Improving Refactorins
2 parents 3d8dbe4 + 4dcf6c0 commit 9d9d17c

20 files changed

+320
-49
lines changed

src/Refactoring-Environment/RBBrowserEnvironment.class.st

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ RBBrowserEnvironment >> & anEnvironment [
5757
^RBAndEnvironment onEnvironment: self and: anEnvironment
5858
]
5959

60+
{ #category : 'comparing' }
61+
RBBrowserEnvironment >> = anotherObject [
62+
63+
self == anotherObject ifTrue: [ ^ true ].
64+
65+
"The default browser environment is always equals to other default"
66+
67+
^ self class = anotherObject class
68+
]
69+
6070
{ #category : 'accessing' }
6171
RBBrowserEnvironment >> accessGuard [
6272
^ accessGuard ifNil: [ accessGuard := Mutex new ]
@@ -357,6 +367,12 @@ RBBrowserEnvironment >> handleSystemChange: aSystemAnnouncement [
357367
todoList remove: anyResult]
358368
]
359369

370+
{ #category : 'comparing' }
371+
RBBrowserEnvironment >> hash [
372+
373+
^ self class hash
374+
]
375+
360376
{ #category : 'environments' }
361377
RBBrowserEnvironment >> implementorsMatching: aString [
362378
^RBSelectorEnvironment implementorsMatching: aString in: self

src/Refactoring-Environment/RBBrowserEnvironmentWrapper.class.st

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ RBBrowserEnvironmentWrapper class >> onEnvironment: anEnvironment [
2727
yourself
2828
]
2929

30+
{ #category : 'comparing' }
31+
RBBrowserEnvironmentWrapper >> = anotherEnvironment [
32+
33+
^ self == anotherEnvironment or: [anotherEnvironment class = self class and: [ environment = anotherEnvironment environment ]]
34+
]
35+
3036
{ #category : 'visiting' }
3137
RBBrowserEnvironmentWrapper >> acceptVisitor: aProgramNodeVisitor [
3238

@@ -69,6 +75,12 @@ RBBrowserEnvironmentWrapper >> environment [
6975
^ environment
7076
]
7177

78+
{ #category : 'comparing' }
79+
RBBrowserEnvironmentWrapper >> hash [
80+
81+
^ environment hash
82+
]
83+
7284
{ #category : 'testing' }
7385
RBBrowserEnvironmentWrapper >> includesClass: aClass [
7486
^environment includesClass: aClass

src/Refactoring-Environment/RBClassEnvironment.class.st

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ RBClassEnvironment class >> onEnvironment: anEnvironment classes: aCollection [
4343
classes: aCollection; yourself
4444
]
4545

46+
{ #category : 'comparing' }
47+
RBClassEnvironment >> = anotherEnvironment [
48+
49+
self == anotherEnvironment
50+
ifTrue: [ ^ true ].
51+
52+
anotherEnvironment class = self class ifFalse: [ ^ false ].
53+
54+
^ environment = anotherEnvironment environment and: [ classes = anotherEnvironment classesOnEnvironment and: [ metaClasses = anotherEnvironment metaClasses ] ]
55+
]
56+
4657
{ #category : 'adding' }
4758
RBClassEnvironment >> addClass: aClass [
4859
aClass isMeta
@@ -110,6 +121,12 @@ RBClassEnvironment >> classesDo: aBlock [
110121
ifTrue: [ aBlock value: class classSide ] ]
111122
]
112123

124+
{ #category : 'accessing' }
125+
RBClassEnvironment >> classesOnEnvironment [
126+
127+
^ classes
128+
]
129+
113130
{ #category : 'private' }
114131
RBClassEnvironment >> defaultLabel [
115132
| stream |
@@ -127,6 +144,12 @@ RBClassEnvironment >> definesClass: aClass [
127144
^ self includesClass: aClass
128145
]
129146

147+
{ #category : 'comparing' }
148+
RBClassEnvironment >> hash [
149+
150+
^ super hash bitXor: (classes hash bitXor: metaClasses hash)
151+
]
152+
130153
{ #category : 'testing' }
131154
RBClassEnvironment >> includesClass: aClass [
132155
^(aClass isMeta
@@ -162,6 +185,12 @@ RBClassEnvironment >> metaClassSelectorDictionary [
162185
yourself ]
163186
]
164187

188+
{ #category : 'accessing' }
189+
RBClassEnvironment >> metaClasses [
190+
191+
^ metaClasses
192+
]
193+
165194
{ #category : 'accessing - classes' }
166195
RBClassEnvironment >> orphanClasses [
167196

src/Refactoring-Environment/RBClassHierarchiesEnvironment.class.st

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ RBClassHierarchiesEnvironment class >> onEnvironment: anEnvironment classes: aCo
4343
classes: aCollection; yourself
4444
]
4545

46+
{ #category : 'comparing' }
47+
RBClassHierarchiesEnvironment >> = anotherEnvironment [
48+
49+
self == anotherEnvironment
50+
ifTrue: [ ^ true ].
51+
52+
anotherEnvironment class = self class ifFalse: [ ^ false ].
53+
54+
^ environment = anotherEnvironment environment and: [ classes = anotherEnvironment classesOnEnvironment and: [ metaClasses = anotherEnvironment metaClasses ] ]
55+
]
56+
4657
{ #category : 'adding' }
4758
RBClassHierarchiesEnvironment >> addClass: aClass [
4859
aClass isMeta
@@ -112,6 +123,12 @@ RBClassHierarchiesEnvironment >> classesDo: aBlock [
112123
ifTrue: [ aBlock value: class classSide ] ]
113124
]
114125

126+
{ #category : 'accessing' }
127+
RBClassHierarchiesEnvironment >> classesOnEnvironment [
128+
129+
^ classes
130+
]
131+
115132
{ #category : 'private' }
116133
RBClassHierarchiesEnvironment >> defaultLabel [
117134
| stream |
@@ -129,6 +146,12 @@ RBClassHierarchiesEnvironment >> definesClass: aClass [
129146
^ self includesClass: aClass
130147
]
131148

149+
{ #category : 'comparing' }
150+
RBClassHierarchiesEnvironment >> hash [
151+
152+
^ super hash bitXor: (classes hash bitXor: metaClasses hash)
153+
]
154+
132155
{ #category : 'testing' }
133156
RBClassHierarchiesEnvironment >> includesClass: aClass [
134157
^(aClass isMeta
@@ -164,6 +187,12 @@ RBClassHierarchiesEnvironment >> metaClassSelectorDictionary [
164187
yourself ]
165188
]
166189

190+
{ #category : 'accessing' }
191+
RBClassHierarchiesEnvironment >> metaClasses [
192+
193+
^ metaClasses
194+
]
195+
167196
{ #category : 'copying' }
168197
RBClassHierarchiesEnvironment >> postCopy [
169198
super postCopy.

src/Refactoring-Environment/RBClassHierarchyEnvironment.class.st

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ RBClassHierarchyEnvironment class >> onEnvironment: anEnvironment class: aClass
3434
yourself
3535
]
3636

37+
{ #category : 'comparing' }
38+
RBClassHierarchyEnvironment >> = anotherEnvironment [
39+
40+
self == anotherEnvironment
41+
ifTrue: [ ^ true ].
42+
43+
anotherEnvironment class = self class ifFalse: [ ^ false ].
44+
45+
^ environment = anotherEnvironment environment and: [ class = anotherEnvironment hierarchyClass ]
46+
]
47+
3748
{ #category : 'accessing' }
3849
RBClassHierarchyEnvironment >> basisObjects [
3950
^ { class }
@@ -51,6 +62,18 @@ RBClassHierarchyEnvironment >> definesClass: aClass [
5162
[ aClass inheritsFrom: class ] ]) and: [super definesClass: aClass]
5263
]
5364

65+
{ #category : 'comparing' }
66+
RBClassHierarchyEnvironment >> hash [
67+
68+
^ super hash bitXor: class hash
69+
]
70+
71+
{ #category : 'accessing' }
72+
RBClassHierarchyEnvironment >> hierarchyClass [
73+
74+
^ class
75+
]
76+
5477
{ #category : 'testing' }
5578
RBClassHierarchyEnvironment >> includesClass: aClass [
5679
^ (aClass == class or:

src/Refactoring-Environment/RBCompositeEnvironment.class.st

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ Class {
88
#package : 'Refactoring-Environment'
99
}
1010

11+
{ #category : 'comparing' }
12+
RBCompositeEnvironment >> = anObject [
13+
"Answer whether the receiver and anObject represent the same object."
14+
15+
self == anObject ifTrue: [ ^ true ].
16+
self class = anObject class ifFalse: [ ^ false ].
17+
^ environment = anObject environment and: [otherEnvironment = anObject otherEnvironment]
18+
]
19+
1120
{ #category : 'description' }
1221
RBCompositeEnvironment >> description [
1322

@@ -16,6 +25,13 @@ RBCompositeEnvironment >> description [
1625
, (otherEnvironment descriptionUntil: 15) ]
1726
]
1827

28+
{ #category : 'comparing' }
29+
RBCompositeEnvironment >> hash [
30+
"Answer an integer value that is related to the identity of the receiver."
31+
32+
^ otherEnvironment hash
33+
]
34+
1935
{ #category : 'testing' }
2036
RBCompositeEnvironment >> isCompositeEnvironment [
2137
^ true

src/Refactoring-Environment/RBPackageEnvironment.class.st

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ RBPackageEnvironment class >> packages: aCollection [
6060
packages: aCollection
6161
]
6262

63+
{ #category : 'comparing' }
64+
RBPackageEnvironment >> = anObject [
65+
"Answer whether the receiver and anObject represent the same object."
66+
67+
self == anObject ifTrue: [ ^ true ].
68+
self class = anObject class ifFalse: [ ^ false ].
69+
^ environment = anObject environment and: [
70+
packages = anObject packages ]
71+
]
72+
6373
{ #category : 'adding' }
6474
RBPackageEnvironment >> addPackage: aSymbol [
6575
packages add: aSymbol
@@ -105,6 +115,13 @@ RBPackageEnvironment >> definesClass: aClass [
105115
^ (super definesClass: aClass) and: [ self packages anySatisfy: [ :package | package includesClass: aClass ] ]
106116
]
107117

118+
{ #category : 'comparing' }
119+
RBPackageEnvironment >> hash [
120+
"Answer an integer value that is related to the identity of the receiver."
121+
122+
^ packages hash
123+
]
124+
108125
{ #category : 'testing' }
109126
RBPackageEnvironment >> includesClass: aClass [
110127

src/Refactoring-Environment/RBPragmaEnvironment.class.st

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ RBPragmaEnvironment class >> onEnvironment: anEnvironment keywords: aKeywordColl
3434
yourself
3535
]
3636

37+
{ #category : 'comparing' }
38+
RBPragmaEnvironment >> = anObject [
39+
"Answer whether the receiver and anObject represent the same object."
40+
41+
self == anObject ifTrue: [ ^ true ].
42+
self class = anObject class ifFalse: [ ^ false ].
43+
^ environment = anObject environment and: [
44+
keywords = anObject basisObjects and: [
45+
condition = anObject condition ] ]
46+
]
47+
3748
{ #category : 'adding' }
3849
RBPragmaEnvironment >> addKeyword: aSymbol [
3950
keywords add: aSymbol
@@ -44,6 +55,12 @@ RBPragmaEnvironment >> basisObjects [
4455
^ keywords
4556
]
4657

58+
{ #category : 'accessing' }
59+
RBPragmaEnvironment >> condition [
60+
61+
^ condition
62+
]
63+
4764
{ #category : 'initialization' }
4865
RBPragmaEnvironment >> condition: aBlock [
4966
condition := aBlock
@@ -57,6 +74,13 @@ RBPragmaEnvironment >> defaultLabel [
5774
^ stream contents
5875
]
5976

77+
{ #category : 'comparing' }
78+
RBPragmaEnvironment >> hash [
79+
"Answer an integer value that is related to the identity of the receiver."
80+
81+
^ keywords hash bitXor: condition hash
82+
]
83+
6084
{ #category : 'testing' }
6185
RBPragmaEnvironment >> includesClass: aClass [
6286
^ (environment includesClass: aClass) and: [ aClass selectors anySatisfy: [ :each | self includesSelector: each in: aClass ] ]

src/Refactoring-Environment/RBProtocolEnvironment.class.st

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ RBProtocolEnvironment class >> onEnvironment: anEnvironment class: aClass protoc
3434
class: aClass protocols: aCollection; yourself
3535
]
3636

37+
{ #category : 'comparing' }
38+
RBProtocolEnvironment >> = anObject [
39+
"Answer whether the receiver and anObject represent the same object."
40+
41+
self == anObject ifTrue: [ ^ true ].
42+
self class = anObject class ifFalse: [ ^ false ].
43+
^ environment = anObject environment and: [
44+
class = anObject definedClass and: [
45+
protocols = anObject protocols ] ]
46+
]
47+
3748
{ #category : 'adding' }
3849
RBProtocolEnvironment >> addProtocol: aSymbol [
3950
protocols add: aSymbol
@@ -79,6 +90,13 @@ RBProtocolEnvironment >> description [
7990
^ label ifNil: [self defaultName , ' of ', self class name, self descriptionBasis]
8091
]
8192

93+
{ #category : 'comparing' }
94+
RBProtocolEnvironment >> hash [
95+
"Answer an integer value that is related to the identity of the receiver."
96+
97+
^ class hash bitXor: protocols hash
98+
]
99+
82100
{ #category : 'testing' }
83101
RBProtocolEnvironment >> includesClass: aClass [
84102
^ aClass == class and: [super includesClass: aClass]

0 commit comments

Comments
 (0)