diff --git a/src/Famix-Diff-Core-Tests/AbstractFamixDiffTest.class.st b/src/Famix-Diff-Core-Tests/AbstractFamixDiffTest.class.st index a3e7d1d..d7b93e7 100644 --- a/src/Famix-Diff-Core-Tests/AbstractFamixDiffTest.class.st +++ b/src/Famix-Diff-Core-Tests/AbstractFamixDiffTest.class.st @@ -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 @@ -22,13 +19,3 @@ AbstractFamixDiffTest >> importModelNamed: name fromPackages: packages [ importer basicRun. ^ model ] - -{ #category : #accessing } -AbstractFamixDiffTest >> model [ - ^ model -] - -{ #category : #accessing } -AbstractFamixDiffTest >> model: anObject [ - model := anObject -] diff --git a/src/Famix-Diff-Core-Tests/FamixDiffTest.class.st b/src/Famix-Diff-Core-Tests/FamixDiffTest.class.st index 331b708..2dd6ace 100644 --- a/src/Famix-Diff-Core-Tests/FamixDiffTest.class.st +++ b/src/Famix-Diff-Core-Tests/FamixDiffTest.class.st @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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" diff --git a/src/Famix-Diff-Core-Tests/TMooseSmalltalkModelImporterForTests.trait.st b/src/Famix-Diff-Core-Tests/TMooseSmalltalkModelImporterForTests.trait.st index e5bfb89..38efd5b 100644 --- a/src/Famix-Diff-Core-Tests/TMooseSmalltalkModelImporterForTests.trait.st +++ b/src/Famix-Diff-Core-Tests/TMooseSmalltalkModelImporterForTests.trait.st @@ -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.