Skip to content

Commit

Permalink
More cleaning + work on Pharo 11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed May 27, 2024
1 parent 8ce6ec5 commit 6cb53c8
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 66 deletions.
12 changes: 6 additions & 6 deletions src/Famix-Diff-Core-Tests/FamixDiffAssociationsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ FamixDiffAssociationsTest >> testAssocsAddP2 [
with: (snapshot targetModel entityNamed: 'Smalltalk::A3diff.c3().toto').
snapshot diffComputer changesDico: testChanges.
snapshot diffComputer diffAssociations.
self assert: snapshot diffComputer assocChanges size equals: 8.
self assert: snapshot diffComputer associationChanges size equals: 8.
self
assert: (snapshot diffComputer assocChanges select: [ :c | c isAddition ]) size
assert: (snapshot diffComputer associationChanges select: [ :c | c isAddition ]) size
equals: 4.
self
assert: (snapshot diffComputer assocChanges select: [ :c | c isRemoval ]) size
assert: (snapshot diffComputer associationChanges select: [ :c | c isRemoval ]) size
equals: 4
]

Expand All @@ -56,9 +56,9 @@ FamixDiffAssociationsTest >> testAssocsDelP3 [
with: (snapshot baseModel entityNamed: 'Smalltalk::A4diff.b3()').
snapshot diffComputer changesDico: testChanges.
snapshot diffComputer diffAssociations.
self assert: snapshot diffComputer assocChanges size equals: 4.
self assert: snapshot diffComputer associationChanges size equals: 4.
self
assert: (snapshot diffComputer assocChanges select: [ :c | c isRemoval ]) size
assert: (snapshot diffComputer associationChanges select: [ :c | c isRemoval ]) size
equals: 4
]

Expand Down Expand Up @@ -88,5 +88,5 @@ FamixDiffAssociationsTest >> testAssocsMatching [
snapshot diffComputer diffAssociations.

"because the invocations of new (in A3.c3()) does not have candidates, an exception is added"
self assert: snapshot assocChanges isEmpty
self assert: snapshot associationChanges isEmpty
]
3 changes: 1 addition & 2 deletions src/Famix-Diff-Core-Tests/FamixDiffResultTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ FamixDiffResultTest >> testWithoutStubs [

self deny: result identicalTo: withoutStubs. "We want a new collection, not to update the original one."
self assert: (withoutStubs noneSatisfy: [ :change | change entity isStub ]).
self assert: withoutStubs class equals: result class.
self assert: result orchestrator identicalTo: withoutStubs orchestrator
self assert: withoutStubs class equals: result class
]
48 changes: 30 additions & 18 deletions src/Famix-Diff-Core-Tests/FamixDiffTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ FamixDiffTest >> testDiffAssociations [
baseModel: (self createModelWith: #(#'Famix-Diff-TestResource-P3' #'Famix-Diff-TestResource-P2'));
targetModel: (self createModelWith: #(#'Famix-Diff-TestResource-P1' #'Famix-Diff-TestResource-P2')).
self runDiff.
self assert: result assocChanges size equals: 6.
self assert: (result assocChanges select: [ :c | c isAddition ]) size equals: 2.
self assert: (result assocChanges select: [ :c | c isRemoval ]) size equals: 4
self assert: result associationChanges size equals: 6.
self assert: (result associationChanges select: [ :c | c isAddition ]) size equals: 2.
self assert: (result associationChanges select: [ :c | c isRemoval ]) size equals: 4
]

{ #category : #tests }
Expand All @@ -48,16 +48,21 @@ FamixDiffTest >> testDiffEntitiesAddP1 [
snapshot targetModel: (self createModelWith: #(#'Famix-Diff-TestResource-P1')).
self runDiff.
self assert: result entityChanges size equals: 7.
self assert: (result entityChanges select: [ :e | e isAddition ]) size equals: 7 "Smalltalk P1 A2 B2 + stubs: ProtoObject Object Kernel"
self assert: (result entityChanges select: [ :e | e isAddition ]) size equals: (SystemVersion current major < 12
ifTrue: [ 8 ]
ifFalse: [ 7 ]) "Smalltalk P1 A2 B2 + stubs: ProtoObject Object Kernel"
]

{ #category : #tests }
FamixDiffTest >> testDiffEntitiesDelP1 [
snapshot baseModel: (self createModelWith: #(#'Famix-Diff-TestResource-P1')).

snapshot baseModel: (self createModelWith: #( #'Famix-Diff-TestResource-P1' )).
snapshot targetModel: MooseModel new.
self runDiff.
self assert: result entityChanges size equals: 7.
self assert: (result entityChanges select: [ :e | e isRemoval ]) size equals: 7 "Smalltalk P1 A2 B2 + stubs: ProtoObject Object Kernel"
self assert: (result entityChanges select: [ :e | e isRemoval ]) size equals: (SystemVersion current major < 12
ifTrue: [ 8 ]
ifFalse: [ 7 ]) "Smalltalk P1 A2 B2 + stubs: ProtoObject Object Kernel"
]

{ #category : #tests }
Expand All @@ -66,25 +71,32 @@ FamixDiffTest >> testDiffEntitiesMatchP1 [
snapshot baseModel: (self createModelWith: #( #'Famix-Diff-TestResource-P1' )).
snapshot targetModel: (self createModelWith: #( #'Famix-Diff-TestResource-P1' )).
self runDiff.
self assert: result entityChanges size equals: 14 / 2. "because in the old version result were duplicated"
self assert: (result entityChanges select: [ :e | e isMatch ]) asSet size equals: 7
self assert: result entityChanges size equals: (SystemVersion current major < 12
ifTrue: [ 8 ]
ifFalse: [ 7 ]). "because in the old version result were duplicated"
self assert: (result entityChanges select: [ :e | e isMatch ]) asSet size equals: (SystemVersion current major < 12
ifTrue: [ 8 ]
ifFalse: [ 7 ])
]

{ #category : #tests }
FamixDiffTest >> testDiffEntitiesP1P2P3 [
snapshot baseModel: (self createModelWith: #(#'Famix-Diff-TestResource-P2' #'Famix-Diff-TestResource-P3')).
snapshot targetModel: (self createModelWith: #(#'Famix-Diff-TestResource-P1' #'Famix-Diff-TestResource-P2')).

snapshot baseModel: (self createModelWith: #( #'Famix-Diff-TestResource-P2' #'Famix-Diff-TestResource-P3' )).
snapshot targetModel: (self createModelWith: #( #'Famix-Diff-TestResource-P1' #'Famix-Diff-TestResource-P2' )).
self runDiff.
self assert: result entityChanges size equals: 38.
self assert: (result entityChanges select: [ :e | e isAddition ]) size equals: 3. "P2 A2diff B2diff"
self assert: (result entityChanges select: [ :e | e isRemoval ]) size equals: 7. "P4 A4diff A4diff.att1 A4diff.b3() B4diff + annotations"
self assert: result entityChanges size equals: (SystemVersion current major < 12
ifTrue: [ 39 ]
ifFalse: [ 38 ]).
self assert: (result entityChanges select: [ :e | e isAddition ]) size equals: 3. "P2 A2diff B2diff"
self assert: (result entityChanges select: [ :e | e isRemoval ]) size equals: 7. "P4 A4diff A4diff.att1 A4diff.b3() B4diff + annotations"
self assert: (result entityChanges select: [ :e | e isMatch ]) size equals: 12 + 4 + 4 + 5 + 2 + 1.
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStLocalVariable ] ]) size equals: 12.
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStAttribute ] ]) size equals: 4. "A3.att1 A3.att2 B3.att1 B3.att2"
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStMethod ] ]) size equals: 4. "A3.b2 A3.c3 B3.c3"
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStClass ] ]) size equals: 5. "A3 B3 C3 Object ProtoObject"
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStPackage ] ]) size equals: 2. "P3 Kernel"
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStNamespace ] ]) size equals: 1 "Smalltalk"
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStAttribute ] ]) size equals: 4. "A3.att1 A3.att2 B3.att1 B3.att2"
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStMethod ] ]) size equals: 4. "A3.b2 A3.c3 B3.c3"
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStClass ] ]) size equals: 5. "A3 B3 C3 Object ProtoObject"
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStPackage ] ]) size equals: 2. "P3 Kernel"
self assert: (result entityChanges select: [ :e | e isMatch and: [ e baseEntity isKindOf: FamixStNamespace ] ]) size equals: 1 "Smalltalk"
]

{ #category : #'tests-run-entities' }
Expand Down
6 changes: 3 additions & 3 deletions src/Famix-Diff-Core/FXDiff.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ FXDiff class >> runOnBaseModel: aBaseModel targetModel: aTargetModel [
]

{ #category : #accessing }
FXDiff >> assocChanges [
^ self result assocChanges
FXDiff >> associationChanges [
^ self result associationChanges
]

{ #category : #accessing }
Expand Down Expand Up @@ -101,7 +101,7 @@ FXDiff >> initialize [

super initialize.
tolerance := 0.2.
result := FamixDiffResult orchestrator: self.
result := FamixDiffResult new.
diffComputer := FamixDiffResolver new
orchestrator: self;
yourself
Expand Down
16 changes: 8 additions & 8 deletions src/Famix-Diff-Core/FamixDiffResolver.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ FamixDiffResolver class >> generatedPackageProtocol [
FamixDiffResolver >> addAssociations: asociations [

asociations do: [ :association |
self assocChanges add: (FamixAddChange new
self associationChanges add: (FamixAddChange new
entity: association;
yourself) ]
]

{ #category : #accessing }
FamixDiffResolver >> assocChanges [
^ assocChanges
FamixDiffResolver >> assocChanges: aCollection [
^ assocChanges := aCollection
]

{ #category : #accessing }
FamixDiffResolver >> assocChanges: aCollection [
^ assocChanges := aCollection
FamixDiffResolver >> associationChanges [
^ assocChanges
]

{ #category : #accessing }
Expand Down Expand Up @@ -86,7 +86,7 @@ FamixDiffResolver >> checkAssocsMatches: baseAssocs with: targetAssocs [
detect: [ :targetAss | targetAss matches: baseAss resolver: self ]
ifOne: [ :found | targetAssocs remove: found ]
ifNone: [ "not creating FAMIXMatchChange for associations"
self assocChanges add: (FamixRemovalChange new
self associationChanges add: (FamixRemovalChange new
entity: baseAss;
yourself) ] ].
self addAssociations: targetAssocs
Expand All @@ -96,7 +96,7 @@ FamixDiffResolver >> checkAssocsMatches: baseAssocs with: targetAssocs [
FamixDiffResolver >> delAssociations: assocs [
assocs
do: [ :a |
self assocChanges
self associationChanges
add:
(FamixRemovalChange new
entity: a;
Expand All @@ -110,7 +110,7 @@ FamixDiffResolver >> diff [
[self diffEntities.
self diffAssociations.
self result addAll: self changesDico values asSet.
self result addAll: self assocChanges asSet.] ensure:[self removeFamixDiffCaches]
self result addAll: self associationChanges asSet.] ensure:[self removeFamixDiffCaches]
]

{ #category : #'run-associations' }
Expand Down
35 changes: 6 additions & 29 deletions src/Famix-Diff-Core/FamixDiffResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ I contain the results of the diff made on 2 models.
Class {
#name : #FamixDiffResult,
#superclass : #MooseGroup,
#instVars : [
'orchestrator'
],
#category : #'Famix-Diff-Core'
}

{ #category : #accessing }
FamixDiffResult class >> orchestrator: aFXDiff [

^ self new
orchestrator: aFXDiff;
yourself
]

{ #category : #adding }
FamixDiffResult >> addChanges [
^ self entityChanges allWithType: FamixAddChange
]
Expand All @@ -41,14 +30,14 @@ FamixDiffResult >> allImpactingChanges [
]

{ #category : #accessing }
FamixDiffResult >> assocChanges [
FamixDiffResult >> associationChanges [
<navigation: 'All assocChanges'>
^ self select: [ :e | e isForAssociation ]
]

{ #category : #accessing }
FamixDiffResult >> assocRemovalChanges [
^ self assocChanges allWithType: FamixRemovalChange
FamixDiffResult >> associationRemovalChanges [
^ self associationChanges allWithType: FamixRemovalChange
]

{ #category : #accessing }
Expand All @@ -72,7 +61,7 @@ FamixDiffResult >> entityChanges [

{ #category : #accessing }
FamixDiffResult >> kindOfAssocAdditionChanges [
^ self assocChanges select: #isKindOfAddition
^ self associationChanges select: #isKindOfAddition
]

{ #category : #accessing }
Expand All @@ -95,16 +84,6 @@ FamixDiffResult >> numberOfVersions [
^ self entityChanges count: #isVersion
]

{ #category : #accessing }
FamixDiffResult >> orchestrator [
^ orchestrator
]

{ #category : #accessing }
FamixDiffResult >> orchestrator: anObject [
orchestrator := anObject
]

{ #category : #accessing }
FamixDiffResult >> removalChanges [
^ self entityChanges allWithType: FamixRemovalChange
Expand All @@ -116,7 +95,7 @@ FamixDiffResult >> species [
^ self class
]

{ #category : #versions }
{ #category : #accessing }
FamixDiffResult >> versionChanges [
^ self entityChanges allWithType: FamixUnchangedChange
]
Expand All @@ -125,7 +104,5 @@ FamixDiffResult >> versionChanges [
FamixDiffResult >> withoutStubs [
"Returns all the results without the stubs"

^ (self reject: [ :change | change entity isStub ])
orchestrator: orchestrator;
yourself
^ self reject: [ :change | change entity isStub ]
]

0 comments on commit 6cb53c8

Please sign in to comment.