Skip to content

Commit

Permalink
Move naming responsibility from exporter to importer
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Darbord committed Mar 9, 2024
1 parent 825b7ae commit bc22fdc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 2 additions & 24 deletions src/Famix-UnitTest-Exporter/FamixUTAbstractExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Class {
#instVars : [
'valueExporter',
'model',
'statementBlock',
'nameDict'
'statementBlock'
],
#category : #'Famix-UnitTest-Exporter'
}
Expand Down Expand Up @@ -98,12 +97,6 @@ FamixUTAbstractExporter >> exportSuite: aFamixUTSuite [
self subclassResponsibility
]

{ #category : #initialization }
FamixUTAbstractExporter >> initialize [

nameDict := Dictionary new
]

{ #category : #ast }
FamixUTAbstractExporter >> makeActComment [

Expand Down Expand Up @@ -139,7 +132,7 @@ FamixUTAbstractExporter >> makeTestCaseComment [
{ #category : #ast }
FamixUTAbstractExporter >> makeTestMethod: aFamixUTMethod [

^ self model newMethodEntity name: (self nameFor: aFamixUTMethod)
^ self model newMethodEntity name: aFamixUTMethod name
]

{ #category : #accessing }
Expand All @@ -154,21 +147,6 @@ FamixUTAbstractExporter >> model: aFASTModel [
self valueExporter model: (model := aFASTModel)
]

{ #category : #initialization }
FamixUTAbstractExporter >> nameFor: anEntity [
"Answer a unique name for an entity."

| name nameID |
name := anEntity name.
nameID := nameDict
at: name
ifPresent: [ :id | nameDict at: name put: id + 1 ]
ifAbsentPut: [ 1 ].
^ nameID == 1
ifTrue: [ name ]
ifFalse: [ name , nameID asString ]
]

{ #category : #'instance creation' }
FamixUTAbstractExporter >> newValueExporter [

Expand Down
26 changes: 24 additions & 2 deletions src/Famix-UnitTest-Importer/FamixUTImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Class {
#name : #FamixUTImporter,
#superclass : #Object,
#instVars : [
'model'
'model',
'nameDict'
],
#category : #'Famix-UnitTest-Importer'
}
Expand All @@ -23,6 +24,12 @@ FamixUTImporter >> fromOpenTelemetrySpans: spans [
^ model
]

{ #category : #initialization }
FamixUTImporter >> initialize [

nameDict := Dictionary new
]

{ #category : #'instance creation' }
FamixUTImporter >> model [

Expand All @@ -42,7 +49,7 @@ FamixUTImporter >> testMethod: aFamixTMethod arguments: arguments expected: expe
| method |
method := self model newMethod
testedMethod: aFamixTMethod;
name: 'test' , aFamixTMethod name capitalized.
name: (self testMethodNameFor: aFamixTMethod).
expected ifNotNil: [
model newSetUp
method: method;
Expand All @@ -55,3 +62,18 @@ FamixUTImporter >> testMethod: aFamixTMethod arguments: arguments expected: expe
arguments: arguments.
^ method
]

{ #category : #tests }
FamixUTImporter >> testMethodNameFor: aFamixTMethod [
"Give a unique name for a new test method."

| name nameID |
name := 'test' , aFamixTMethod name capitalized.
nameID := nameDict
at: name
ifPresent: [ :id | nameDict at: name put: id + 1 ]
ifAbsentPut: [ 1 ].
^ nameID == 1
ifTrue: [ name ]
ifFalse: [ name , nameID asString ]
]

0 comments on commit bc22fdc

Please sign in to comment.