forked from pharo-contributions/mutalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor random mutant selection to only shuffle mutants & rename oth…
…er mutant selection strategies to mutant generation strategies
- Loading branch information
Durieux Pol
committed
Apr 5, 2024
1 parent
daecc3e
commit 3f5e340
Showing
22 changed files
with
255 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/MuTalk-Model/MTManualMutatedMethodGenerationStrategy.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Class { | ||
#name : 'MTManualMutatedMethodGenerationStrategy', | ||
#superclass : 'MTMutantGenerationStrategy', | ||
#instVars : [ | ||
'targetMethods' | ||
], | ||
#category : 'MuTalk-Model-Mutant generation strategies', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Mutant generation strategies' | ||
} | ||
|
||
{ #category : 'generating' } | ||
MTManualMutatedMethodGenerationStrategy >> methodsToMutateFrom: aMutationTestingAnalysis [ | ||
|
||
^ targetMethods | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTManualMutatedMethodGenerationStrategy >> targetMethods: anObject [ | ||
|
||
targetMethods := anObject | ||
] |
22 changes: 0 additions & 22 deletions
22
src/MuTalk-Model/MTManualMutatedMethodSelectionStrategy.class.st
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/MuTalk-Model/MTManualMutationGenerationStrategy.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
" | ||
This strategy uses a fixed list of mutations pre-computed by the user | ||
" | ||
Class { | ||
#name : 'MTManualMutationGenerationStrategy', | ||
#superclass : 'MTMutantGenerationStrategy', | ||
#instVars : [ | ||
'mutations' | ||
], | ||
#category : 'MuTalk-Model-Mutant generation strategies', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Mutant generation strategies' | ||
} | ||
|
||
{ #category : 'instance creation' } | ||
MTManualMutationGenerationStrategy class >> with: aCollection [ | ||
|
||
^ self new | ||
mutations: aCollection; | ||
yourself | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTManualMutationGenerationStrategy >> mutations: anInfiniteReadStream [ | ||
mutations := anInfiniteReadStream | ||
] | ||
|
||
{ #category : 'generating' } | ||
MTManualMutationGenerationStrategy >> mutationsFor: aMutationTestingAnalysis loggingIn: aLogger [ | ||
|
||
"Do not compute a list of mutations, just use the explicit one" | ||
^ mutations | ||
] |
33 changes: 0 additions & 33 deletions
33
src/MuTalk-Model/MTManualMutationSelectionStrategy.class.st
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
Class { | ||
#name : 'MTMutantGenerationStrategy', | ||
#superclass : 'Object', | ||
#instVars : [ | ||
'mutantSelectionStrategy' | ||
], | ||
#category : 'MuTalk-Model-Mutant generation strategies', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Mutant generation strategies' | ||
} | ||
|
||
{ #category : 'instance creation' } | ||
MTMutantGenerationStrategy class >> withRandomClassMutantSelection [ | ||
|
||
^ self new | ||
mutantSelectionStrategy: MTRandomClassMutantSelectionStrategy new; | ||
yourself | ||
] | ||
|
||
{ #category : 'instance creation' } | ||
MTMutantGenerationStrategy class >> withRandomMethodMutantSelection [ | ||
|
||
^ self new | ||
mutantSelectionStrategy: MTRandomMethodMutantSelectionStrategy new; | ||
yourself | ||
] | ||
|
||
{ #category : 'instance creation' } | ||
MTMutantGenerationStrategy class >> withRandomMutantSelection [ | ||
|
||
^ self new | ||
mutantSelectionStrategy: MTRandomMutantSelectionStrategy new; | ||
yourself | ||
] | ||
|
||
{ #category : 'instance creation' } | ||
MTMutantGenerationStrategy class >> withRandomOperatorMutantSelection [ | ||
|
||
^ self new | ||
mutantSelectionStrategy: MTRandomOperatorMutantSelectionStrategy new; | ||
yourself | ||
] | ||
|
||
{ #category : 'accessing - defaults' } | ||
MTMutantGenerationStrategy >> defaultMutantSelectionStrategy [ | ||
|
||
^ MTMutantSelectionStrategy new | ||
] | ||
|
||
{ #category : 'initialization' } | ||
MTMutantGenerationStrategy >> initialize [ | ||
|
||
super initialize. | ||
mutantSelectionStrategy := self defaultMutantSelectionStrategy | ||
] | ||
|
||
{ #category : 'generating' } | ||
MTMutantGenerationStrategy >> methodsToMutateFrom:aMutationTestingAnalysis [ | ||
self subclassResponsibility. | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTMutantGenerationStrategy >> mutantSelectionStrategy [ | ||
|
||
^ mutantSelectionStrategy | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTMutantGenerationStrategy >> mutantSelectionStrategy: anObject [ | ||
|
||
mutantSelectionStrategy := anObject | ||
] | ||
|
||
{ #category : 'generating' } | ||
MTMutantGenerationStrategy >> mutationsFor: aMutationTestingAnalysis [ | ||
^ self | ||
mutationsFor: aMutationTestingAnalysis | ||
loggingIn: self nullLogger | ||
] | ||
|
||
{ #category : 'generating' } | ||
MTMutantGenerationStrategy >> mutationsFor: aMutationTestingAnalysis loggingIn: aLogger [ | ||
|
||
| mutations | | ||
mutations := OrderedCollection new. | ||
(self methodsToMutateFrom: aMutationTestingAnalysis) | ||
do: [ :aMethod | | ||
mutations addAll: (self | ||
mutationsFor: aMethod | ||
usingAll: aMutationTestingAnalysis operators | ||
logginIn: aLogger) ] | ||
displayingProgress: 'Building Mutants'. | ||
^ mutantSelectionStrategy shuffleMutants: mutations | ||
] | ||
|
||
{ #category : 'generating' } | ||
MTMutantGenerationStrategy >> mutationsFor: aMethod usingAll: aCollectionOfMutantOperators logginIn: aLogger [ | ||
|
||
| parseTree | | ||
parseTree := aMethod parseTree. | ||
^ aCollectionOfMutantOperators | ||
inject: OrderedCollection new | ||
into: [ :mutations :anOperator | | ||
aLogger logStartBuildingMutantionsFor: aMethod using: anOperator. | ||
(aMethod ignoredMutationOperators includes: anOperator class) | ||
ifFalse: [ | ||
| newMutations | | ||
newMutations := anOperator | ||
mutationsFor: aMethod | ||
with: parseTree. | ||
aLogger logNumberOfGeneratedMutations: newMutations size. | ||
mutations addAll: newMutations ]. | ||
mutations ] | ||
] | ||
|
||
{ #category : 'logging' } | ||
MTMutantGenerationStrategy >> nullLogger [ | ||
|
||
^ MTNullLogger new. | ||
] |
Oops, something went wrong.