-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from DurieuxPol/feat/newOps
Subclass replacement operator
- Loading branch information
Showing
107 changed files
with
1,426 additions
and
670 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
Class { | ||
#name : 'MTAbstractMutantOperator', | ||
#superclass : 'Object', | ||
#category : 'MuTalk-Model-Operators', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Operators' | ||
} | ||
|
||
{ #category : 'accessing' } | ||
MTAbstractMutantOperator class >> allConcreteSubclasses [ | ||
|
||
^ self allSubclasses reject: [ :ea | | ||
ea isAbstract | ea isOriginalOperator not ] | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTAbstractMutantOperator class >> contents [ | ||
"This returns only the traditional operators " | ||
|
||
^ ((self allConcreteSubclasses reject: #isDeprecated) collect: [ | ||
:class | class new ]) asSortedCollection: [ :elem1 :elem2 | | ||
elem1 description <= elem2 description ] | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTAbstractMutantOperator class >> contentsAll [ | ||
"This returns all operators (block based and traditional) " | ||
|
||
^ ((self allSubclasses reject: [ :ea | | ||
ea isAbstract or: [ ea isDeprecated ] ]) collect: [ :class | | ||
class new ]) asSortedCollection: [ :elem1 :elem2 | | ||
elem1 description <= elem2 description ] | ||
] | ||
|
||
{ #category : 'testing' } | ||
MTAbstractMutantOperator class >> isAbstract [ | ||
|
||
^ self == MTAbstractMutantOperator | ||
] | ||
|
||
{ #category : 'testing' } | ||
MTAbstractMutantOperator class >> isOriginalOperator [ | ||
|
||
^ true | ||
] | ||
|
||
{ #category : 'as yet unclassified' } | ||
MTAbstractMutantOperator class >> recursionsDetectionStatement [ | ||
|
||
^ RBParser parseExpression: | ||
('MuTalkInfiniteRecursionError onCount: {1}' format: { self recursionsDetectionThreshold } ) | ||
] | ||
|
||
{ #category : 'as yet unclassified' } | ||
MTAbstractMutantOperator class >> recursionsDetectionThreshold [ | ||
|
||
"We need a big enough number" | ||
|
||
^ 1024 | ||
] | ||
|
||
{ #category : 'printing' } | ||
MTAbstractMutantOperator >> description [ | ||
self subclassResponsibility | ||
] | ||
|
||
{ #category : 'private' } | ||
MTAbstractMutantOperator >> is: originalRBMethodNode equalTo: nodeThatMatches [ | ||
^ nodeThatMatches formattedCode = originalRBMethodNode formattedCode | ||
] | ||
|
||
{ #category : 'private' } | ||
MTAbstractMutantOperator >> modifiedSourceFor: aCompiledMethod number: aNumber [ | ||
|
||
^ self | ||
modifiedSourceFor: aCompiledMethod | ||
with: aCompiledMethod parseTree | ||
number: aNumber | ||
newExpression: self newExpression | ||
] | ||
|
||
{ #category : 'private' } | ||
MTAbstractMutantOperator >> modifiedSourceFor: aCompiledMethod number: aNumber newExpression: anExpression [ | ||
|
||
^ self | ||
modifiedSourceFor: aCompiledMethod | ||
with: aCompiledMethod parseTree | ||
number: aNumber | ||
newExpression: anExpression | ||
] | ||
|
||
{ #category : 'private' } | ||
MTAbstractMutantOperator >> modifiedSourceFor: aCompiledMethod with: aParseTree number: aNumber newExpression: anExpression [ | ||
|
||
self subclassResponsibility | ||
] | ||
|
||
{ #category : 'mutant generation' } | ||
MTAbstractMutantOperator >> mutationsFor: aCompiledMethod [ | ||
|
||
(aCompiledMethod ignoredMutationOperators includes: self class) ifTrue: [ ^ Array new ]. | ||
|
||
^self mutationsFor: aCompiledMethod with: aCompiledMethod parseTree. | ||
|
||
] | ||
|
||
{ #category : 'mutant generation' } | ||
MTAbstractMutantOperator >> mutationsFor: aCompiledMethod with: aParseTree [ | ||
|
||
| numberOfAffectedNodes | | ||
((aCompiledMethod hasPragmaNamed: #ignoreForMutations) or: [ | ||
aCompiledMethod hasPragmaNamed: #ignoreForCoverage ]) ifTrue: [ | ||
^ #( ) ]. | ||
|
||
numberOfAffectedNodes := self | ||
timesToApplyIn: aCompiledMethod | ||
with: aParseTree. | ||
^ (1 to: numberOfAffectedNodes) | ||
inject: OrderedCollection new | ||
into: [ :accumulator :nodeIndex | | ||
self | ||
mutationsFor: aCompiledMethod | ||
with: aParseTree | ||
number: nodeIndex | ||
storeIn: accumulator ] | ||
] | ||
|
||
{ #category : 'private' } | ||
MTAbstractMutantOperator >> mutationsFor: aCompiledMethod with: aParseTree number: nodeIndex storeIn: accumulator [ | ||
|
||
self subclassResponsibility | ||
] | ||
|
||
{ #category : 'suggestions' } | ||
MTAbstractMutantOperator >> suggestionFor: aMutation using: aMutantKillingSuggestionGenerator [ | ||
^'No Suggestion' | ||
] | ||
|
||
{ #category : 'applying' } | ||
MTAbstractMutantOperator >> timesToApplyIn: aCompiledMethod [ | ||
^self timesToApplyIn: aCompiledMethod with: aCompiledMethod parseTree. | ||
|
||
] | ||
|
||
{ #category : 'applying' } | ||
MTAbstractMutantOperator >> timesToApplyIn: aCompiledMethod with: aParseTree [ | ||
|
||
self subclassResponsibility | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
Class { | ||
#name : 'MTAssignmentNullifierOperator', | ||
#superclass : 'MTBlockBasedMutantOperator', | ||
#superclass : 'MTPredicateBasedMutantOperator', | ||
#category : 'MuTalk-Model-Operators', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Operators' | ||
} | ||
|
||
{ #category : 'applying' } | ||
MTAssignmentNullifierOperator >> appliesToNode: aNode [ | ||
|
||
^ aNode isAssignment & aNode value isNotNil | ||
] | ||
|
||
{ #category : 'printing' } | ||
MTAssignmentNullifierOperator >> description [ | ||
|
||
^ 'Nullify the value assigned' | ||
] | ||
|
||
{ #category : 'applying' } | ||
MTAssignmentNullifierOperator >> expressionToReplace [ | ||
|
||
^ [ :aNode | aNode isAssignment & aNode value isNotNil ] | ||
] | ||
|
||
{ #category : 'applying' } | ||
MTAssignmentNullifierOperator >> newExpression [ | ||
MTAssignmentNullifierOperator >> newNodeFrom: anOldNode [ | ||
|
||
^ [ :anOldNode | | ||
| nodeCopy | | ||
nodeCopy := anOldNode copy. | ||
nodeCopy value: (RBLiteralValueNode value: nil). | ||
nodeCopy ] | ||
| nodeCopy | | ||
nodeCopy := anOldNode copy. | ||
nodeCopy value: (RBLiteralValueNode value: nil). | ||
^ nodeCopy | ||
] |
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 |
---|---|---|
@@ -1,26 +1,25 @@ | ||
Class { | ||
#name : 'MTEmptyMethodOperator', | ||
#superclass : 'MTBlockBasedMutantOperator', | ||
#superclass : 'MTPredicateBasedMutantOperator', | ||
#category : 'MuTalk-Model-Operators', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Operators' | ||
} | ||
|
||
{ #category : 'printing' } | ||
MTEmptyMethodOperator >> description [ | ||
{ #category : 'applying' } | ||
MTEmptyMethodOperator >> appliesToNode: aNode [ | ||
|
||
^ 'Removing all lines in a method' | ||
^ aNode isSequence and: [ aNode parent isMethod ] | ||
] | ||
|
||
{ #category : 'applying' } | ||
MTEmptyMethodOperator >> expressionToReplace [ | ||
{ #category : 'printing' } | ||
MTEmptyMethodOperator >> description [ | ||
|
||
^ [ :aNode | | ||
aNode isSequence and: [ aNode parent isMethod] ] | ||
^ 'Removing all lines in a method' | ||
] | ||
|
||
{ #category : 'applying' } | ||
MTEmptyMethodOperator >> newExpression [ | ||
MTEmptyMethodOperator >> newNodeFrom: anOldNode [ | ||
|
||
^ [ :anOldNode | RBSequenceNode statements: #() ] | ||
^ RBSequenceNode statements: #( ) | ||
] |
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 |
---|---|---|
@@ -1,27 +1,26 @@ | ||
Class { | ||
#name : 'MTLiteralBooleanNegateOperator', | ||
#superclass : 'MTBlockBasedMutantOperator', | ||
#superclass : 'MTPredicateBasedMutantOperator', | ||
#category : 'MuTalk-Model-Operators', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Operators' | ||
} | ||
|
||
{ #category : 'printing' } | ||
MTLiteralBooleanNegateOperator >> description [ | ||
{ #category : 'applying' } | ||
MTLiteralBooleanNegateOperator >> appliesToNode: aNode [ | ||
|
||
^ 'Negate a literal boolean' | ||
^ aNode isLiteralNode & aNode isLiteralArray not and: [ | ||
{ true. false } includes: aNode value ] | ||
] | ||
|
||
{ #category : 'applying' } | ||
MTLiteralBooleanNegateOperator >> expressionToReplace [ | ||
{ #category : 'printing' } | ||
MTLiteralBooleanNegateOperator >> description [ | ||
|
||
^ [ :aNode | | ||
aNode isLiteralNode & aNode isLiteralArray not and: [ | ||
{ true. false } includes: aNode value ] ] | ||
^ 'Negate a literal boolean' | ||
] | ||
|
||
{ #category : 'applying' } | ||
MTLiteralBooleanNegateOperator >> newExpression [ | ||
MTLiteralBooleanNegateOperator >> newNodeFrom: anOldNode [ | ||
|
||
^ [ :anOldNode | RBLiteralValueNode value: anOldNode value not ] | ||
^ RBLiteralValueNode value: anOldNode value not | ||
] |
19 changes: 10 additions & 9 deletions
19
src/MuTalk-Model/MTLiteralIntegersDecreaseOperator.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 |
---|---|---|
@@ -1,25 +1,26 @@ | ||
Class { | ||
#name : 'MTLiteralIntegersDecreaseOperator', | ||
#superclass : 'MTBlockBasedMutantOperator', | ||
#superclass : 'MTPredicateBasedMutantOperator', | ||
#category : 'MuTalk-Model-Operators', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Operators' | ||
} | ||
|
||
{ #category : 'printing' } | ||
MTLiteralIntegersDecreaseOperator >> description [ | ||
{ #category : 'applying' } | ||
MTLiteralIntegersDecreaseOperator >> appliesToNode: aNode [ | ||
|
||
^ 'Decrease a literal integer' | ||
^ aNode isLiteralNode & aNode isLiteralArray not and: [ | ||
aNode value isInteger ] | ||
] | ||
|
||
{ #category : 'applying' } | ||
MTLiteralIntegersDecreaseOperator >> expressionToReplace [ | ||
{ #category : 'printing' } | ||
MTLiteralIntegersDecreaseOperator >> description [ | ||
|
||
^ [ :aNode | aNode isLiteralNode & aNode isLiteralArray not and: [ aNode value isInteger ] ] | ||
^ 'Decrease a literal integer' | ||
] | ||
|
||
{ #category : 'applying' } | ||
MTLiteralIntegersDecreaseOperator >> newExpression [ | ||
MTLiteralIntegersDecreaseOperator >> newNodeFrom: anOldNode [ | ||
|
||
^ [ :anOldNode | RBLiteralValueNode value: anOldNode value - 1 ] | ||
^ RBLiteralValueNode value: anOldNode value - 1 | ||
] |
Oops, something went wrong.