Skip to content

Commit

Permalink
Better fix for P11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed May 27, 2024
1 parent b30e513 commit 83f12ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 46 deletions.
15 changes: 1 addition & 14 deletions src/Famix-Diff-Core-Tests/AbstractFamixDiffTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ Class {
#superclass : #TestCase,
#traits : 'TMooseSmalltalkModelImporterForTests',
#classTraits : 'TMooseSmalltalkModelImporterForTests classTrait',
#instVars : [
'model'
],
#category : #'Famix-Diff-Core-Tests'
}

{ #category : #running }
AbstractFamixDiffTest >> importModelNamed: name fromPackages: packages [
| importer |
| importer model |
model := FamixStModel new.
model name: name.
importer := FamixStPharoImporterTask new
Expand All @@ -22,13 +19,3 @@ AbstractFamixDiffTest >> importModelNamed: name fromPackages: packages [
importer basicRun.
^ model
]

{ #category : #accessing }
AbstractFamixDiffTest >> model [
^ model
]

{ #category : #accessing }
AbstractFamixDiffTest >> model: anObject [
model := anObject
]
49 changes: 18 additions & 31 deletions src/Famix-Diff-Core-Tests/FamixDiffTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ Class {
}

{ #category : #running }
FamixDiffTest >> createModelWith: somePackages [
| importer |
importer := MoosePharoImporterTask new
model: FamixStModel new;
addFromPackagesNamed: somePackages.
importer importingContext mergeClassAndMetaclass.
^importer basicRun
FamixDiffTest >> createModelWith: somePackages [

| importer model |
importer := FamixStPharoImporterTask new
model: FamixStModel new;
addFromPackagesNamed: somePackages.
importer importingContext mergeClassAndMetaclass.
model := importer basicRun.
self flag: #pharo11. "This is a hack because this attribute was removed from P12 and we want tests to work in P11 and P12 for now. So we remove it if we find it."
(model entityNamed: #'Smalltalk::Object.DependentsFields') ifNotNil: [ :entity | model remove: entity ].
^ model
]

{ #category : #tests }
Expand Down Expand Up @@ -48,12 +51,8 @@ FamixDiffTest >> testDiffEntitiesAddP1 [
snapshot baseModel: MooseModel new.
snapshot targetModel: (self createModelWith: #( #'Famix-Diff-TestResource-P1' )).
self runDiff.
self assert: result entityChanges size equals: (SystemVersion current major < 12
ifTrue: [ 8 ]
ifFalse: [ 7 ]).
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"
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"
]

{ #category : #tests }
Expand All @@ -62,12 +61,8 @@ FamixDiffTest >> testDiffEntitiesDelP1 [
snapshot baseModel: (self createModelWith: #( #'Famix-Diff-TestResource-P1' )).
snapshot targetModel: MooseModel new.
self runDiff.
self assert: result entityChanges size equals: (SystemVersion current major < 12
ifTrue: [ 8 ]
ifFalse: [ 7 ]).
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"
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"
]

{ #category : #tests }
Expand All @@ -76,12 +71,8 @@ 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: (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 ])
self assert: result entityChanges size equals: 7. "because in the old version result were duplicated"
self assert: (result entityChanges select: [ :e | e isMatch ]) asSet size equals: 7
]

{ #category : #tests }
Expand All @@ -90,14 +81,10 @@ 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' )).
self runDiff.
self assert: result entityChanges size equals: (SystemVersion current major < 12
ifTrue: [ 39 ]
ifFalse: [ 38 ]).
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 select: [ :e | e isMatch ]) size equals: 12 + 4 + 4 + 5 + 2 + 1 + (SystemVersion current major < 12
ifTrue: [ 1 ]
ifFalse: [ 0 ]).
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TMooseSmalltalkModelImporterForTests >> importModelNamed: name fromPackages: pac
| model |
model := FamixStModel new.
model name: name.
MoosePharoImporterTask new
FamixStPharoImporterTask new
model: model;
addFromPackagesNamed: packages;
basicRun.
Expand Down

0 comments on commit 83f12ef

Please sign in to comment.