diff --git a/src/MuTalk-Model/MTAbstractMutantOperator.class.st b/src/MuTalk-Model/MTAbstractMutantOperator.class.st new file mode 100644 index 00000000..929259fe --- /dev/null +++ b/src/MuTalk-Model/MTAbstractMutantOperator.class.st @@ -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 +] diff --git a/src/MuTalk-Model/MTAnalysis.class.st b/src/MuTalk-Model/MTAnalysis.class.st index 472d1e68..347156e0 100644 --- a/src/MuTalk-Model/MTAnalysis.class.st +++ b/src/MuTalk-Model/MTAnalysis.class.st @@ -483,7 +483,7 @@ MTAnalysis >> defaultMutantSelectionStrategy [ { #category : 'accessing - defaults' } MTAnalysis >> defaultOperators [ - ^ MTMutantOperator contents + ^ MTAbstractMutantOperator contents ] { #category : 'accessing - defaults' } diff --git a/src/MuTalk-Model/MTAssignmentNullifierOperator.class.st b/src/MuTalk-Model/MTAssignmentNullifierOperator.class.st index 2ac4aa27..4ecceec2 100644 --- a/src/MuTalk-Model/MTAssignmentNullifierOperator.class.st +++ b/src/MuTalk-Model/MTAssignmentNullifierOperator.class.st @@ -1,11 +1,17 @@ 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 [ @@ -13,17 +19,10 @@ MTAssignmentNullifierOperator >> description [ ] { #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 ] diff --git a/src/MuTalk-Model/MTBlockBasedMutantOperator.class.st b/src/MuTalk-Model/MTBlockBasedMutantOperator.class.st deleted file mode 100644 index b3bd076a..00000000 --- a/src/MuTalk-Model/MTBlockBasedMutantOperator.class.st +++ /dev/null @@ -1,61 +0,0 @@ -Class { - #name : 'MTBlockBasedMutantOperator', - #superclass : 'MTMutantOperator', - #category : 'MuTalk-Model-Operators', - #package : 'MuTalk-Model', - #tag : 'Operators' -} - -{ #category : 'testing' } -MTBlockBasedMutantOperator class >> isAbstract [ - - ^ self == MTBlockBasedMutantOperator -] - -{ #category : 'testing' } -MTBlockBasedMutantOperator class >> isOriginalOperator [ - ^ false -] - -{ #category : 'testing' } -MTBlockBasedMutantOperator >> isAPosibleMutatedNode: aRBMethodNode [ - - | nodeThatMatches | - nodeThatMatches := aRBMethodNode allChildren detect: self newExpression ifNone: [nil]. - ^ nodeThatMatches notNil and: [ - self is: nodeThatMatches equalTo: aRBMethodNode ] -] - -{ #category : 'testing' } -MTBlockBasedMutantOperator >> isAPosibleNodeToMutate: aRBMethodNode [ - - | nodeThatMatches | - nodeThatMatches := aRBMethodNode allChildren - detect: self expressionToReplace - ifNone: [ nil ]. - - ^ nodeThatMatches notNil and: [ - self is: aRBMethodNode equalTo: nodeThatMatches ] -] - -{ #category : 'private' } -MTBlockBasedMutantOperator >> modifiedSourceFor: aCompiledMethod with: aParseTree number: aNumber [ - - | parser allNodes | - parser := aParseTree copy. - allNodes := parser allChildren select: self expressionToReplace. - allNodes size >= aNumber ifTrue: [ - | oldNode newNode | - oldNode := allNodes at: aNumber. - newNode := self newExpression value: oldNode. - oldNode replaceWith: newNode ]. - ^ parser formattedCode -] - -{ #category : 'private' } -MTBlockBasedMutantOperator >> timesToApplyIn: aCompiledMethod with: aParseTree [ - - "Evaluates how many times can the operator be applyied" - - ^ (aParseTree allChildren select: self expressionToReplace) size -] diff --git a/src/MuTalk-Model/MTEmptyMethodOperator.class.st b/src/MuTalk-Model/MTEmptyMethodOperator.class.st index 695482f6..a3fbe767 100644 --- a/src/MuTalk-Model/MTEmptyMethodOperator.class.st +++ b/src/MuTalk-Model/MTEmptyMethodOperator.class.st @@ -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: #( ) ] diff --git a/src/MuTalk-Model/MTLiteralBooleanNegateOperator.class.st b/src/MuTalk-Model/MTLiteralBooleanNegateOperator.class.st index 1f35275f..ddc923f9 100644 --- a/src/MuTalk-Model/MTLiteralBooleanNegateOperator.class.st +++ b/src/MuTalk-Model/MTLiteralBooleanNegateOperator.class.st @@ -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 ] diff --git a/src/MuTalk-Model/MTLiteralIntegersDecreaseOperator.class.st b/src/MuTalk-Model/MTLiteralIntegersDecreaseOperator.class.st index 424ae637..2e569e38 100644 --- a/src/MuTalk-Model/MTLiteralIntegersDecreaseOperator.class.st +++ b/src/MuTalk-Model/MTLiteralIntegersDecreaseOperator.class.st @@ -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 ] diff --git a/src/MuTalk-Model/MTLiteralIntegersIncreaseOperator.class.st b/src/MuTalk-Model/MTLiteralIntegersIncreaseOperator.class.st index 73eab8ca..3468e6f4 100644 --- a/src/MuTalk-Model/MTLiteralIntegersIncreaseOperator.class.st +++ b/src/MuTalk-Model/MTLiteralIntegersIncreaseOperator.class.st @@ -1,25 +1,26 @@ Class { #name : 'MTLiteralIntegersIncreaseOperator', - #superclass : 'MTBlockBasedMutantOperator', + #superclass : 'MTPredicateBasedMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' } -{ #category : 'printing' } -MTLiteralIntegersIncreaseOperator >> description [ +{ #category : 'applying' } +MTLiteralIntegersIncreaseOperator >> appliesToNode: aNode [ - ^ 'Increase a literal integer' + ^ aNode isLiteralNode & aNode isLiteralArray not and: [ + aNode value isInteger ] ] -{ #category : 'applying' } -MTLiteralIntegersIncreaseOperator >> expressionToReplace [ +{ #category : 'printing' } +MTLiteralIntegersIncreaseOperator >> description [ - ^ [ :aNode | aNode isLiteralNode & aNode isLiteralArray not and: [ aNode value isInteger ] ] + ^ 'Increase a literal integer' ] { #category : 'applying' } -MTLiteralIntegersIncreaseOperator >> newExpression [ +MTLiteralIntegersIncreaseOperator >> newNodeFrom: anOldNode [ - ^ [ :anOldNode | RBLiteralValueNode value: anOldNode value + 1 ] + ^ RBLiteralValueNode value: anOldNode value + 1 ] diff --git a/src/MuTalk-Model/MTLiteralIntegersToZeroOperator.class.st b/src/MuTalk-Model/MTLiteralIntegersToZeroOperator.class.st index 89217a63..11642a0e 100644 --- a/src/MuTalk-Model/MTLiteralIntegersToZeroOperator.class.st +++ b/src/MuTalk-Model/MTLiteralIntegersToZeroOperator.class.st @@ -1,27 +1,26 @@ Class { #name : 'MTLiteralIntegersToZeroOperator', - #superclass : 'MTBlockBasedMutantOperator', + #superclass : 'MTPredicateBasedMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' } -{ #category : 'printing' } -MTLiteralIntegersToZeroOperator >> description [ +{ #category : 'applying' } +MTLiteralIntegersToZeroOperator >> appliesToNode: aNode [ - ^ 'Convert a literal integer to zero' + ^ aNode isLiteralNode & aNode isLiteralArray not and: [ + aNode value isInteger and: [ aNode value isZero not ] ] ] -{ #category : 'applying' } -MTLiteralIntegersToZeroOperator >> expressionToReplace [ +{ #category : 'printing' } +MTLiteralIntegersToZeroOperator >> description [ - ^ [ :aNode | - aNode isLiteralNode & aNode isLiteralArray not and: [ - aNode value isInteger and: [aNode value isZero not] ] ] + ^ 'Convert a literal integer to zero' ] { #category : 'applying' } -MTLiteralIntegersToZeroOperator >> newExpression [ +MTLiteralIntegersToZeroOperator >> newNodeFrom: anOldNode [ - ^ [ :anOldNode | RBLiteralValueNode value: 0 ] + ^ RBLiteralValueNode value: 0 ] diff --git a/src/MuTalk-Model/MTLiteralStringChangeOperator.class.st b/src/MuTalk-Model/MTLiteralStringChangeOperator.class.st index 15a420df..cb5ecf95 100644 --- a/src/MuTalk-Model/MTLiteralStringChangeOperator.class.st +++ b/src/MuTalk-Model/MTLiteralStringChangeOperator.class.st @@ -1,29 +1,28 @@ Class { #name : 'MTLiteralStringChangeOperator', - #superclass : 'MTBlockBasedMutantOperator', + #superclass : 'MTPredicateBasedMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' } -{ #category : 'printing' } -MTLiteralStringChangeOperator >> description [ +{ #category : 'applying' } +MTLiteralStringChangeOperator >> appliesToNode: aNode [ - ^ 'Convert a literal string to a predefined string' + ^ aNode isLiteralNode & aNode isLiteralArray not and: [ + aNode value isString and: [ aNode value ~= self stringReplaced ] ] ] -{ #category : 'applying' } -MTLiteralStringChangeOperator >> expressionToReplace [ +{ #category : 'printing' } +MTLiteralStringChangeOperator >> description [ - ^ [ :aNode | - aNode isLiteralNode & aNode isLiteralArray not and: [ - aNode value isString and: [ aNode value ~= self stringReplaced ] ] ] + ^ 'Convert a literal string to a predefined string' ] { #category : 'applying' } -MTLiteralStringChangeOperator >> newExpression [ +MTLiteralStringChangeOperator >> newNodeFrom: anOldNode [ - ^ [ :anOldNode | RBLiteralValueNode value: self stringReplaced ] + ^ RBLiteralValueNode value: self stringReplaced ] { #category : 'applying' } diff --git a/src/MuTalk-Model/MTLiteralStringToEmptyOperator.class.st b/src/MuTalk-Model/MTLiteralStringToEmptyOperator.class.st index 60135e0e..07eb6b73 100644 --- a/src/MuTalk-Model/MTLiteralStringToEmptyOperator.class.st +++ b/src/MuTalk-Model/MTLiteralStringToEmptyOperator.class.st @@ -1,27 +1,26 @@ Class { #name : 'MTLiteralStringToEmptyOperator', - #superclass : 'MTBlockBasedMutantOperator', + #superclass : 'MTPredicateBasedMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' } -{ #category : 'printing' } -MTLiteralStringToEmptyOperator >> description [ +{ #category : 'applying' } +MTLiteralStringToEmptyOperator >> appliesToNode: aNode [ - ^ 'Convert a literal string to empty string' + ^ aNode isLiteralNode & aNode isLiteralArray not and: [ + aNode value isString and: [ aNode value isNotEmpty ] ] ] -{ #category : 'applying' } -MTLiteralStringToEmptyOperator >> expressionToReplace [ +{ #category : 'printing' } +MTLiteralStringToEmptyOperator >> description [ - ^ [ :aNode | - aNode isLiteralNode & aNode isLiteralArray not and: [ - aNode value isString and: [aNode value isNotEmpty ] ] ] + ^ 'Convert a literal string to empty string' ] { #category : 'applying' } -MTLiteralStringToEmptyOperator >> newExpression [ +MTLiteralStringToEmptyOperator >> newNodeFrom: anOldNode [ - ^ [ :anOldNode | RBLiteralValueNode value: '' ] + ^ RBLiteralValueNode value: '' ] diff --git a/src/MuTalk-Model/MTMessageSendArgumentsNullifierOperator.class.st b/src/MuTalk-Model/MTMessageSendArgumentsNullifierOperator.class.st index f014f877..049574cf 100644 --- a/src/MuTalk-Model/MTMessageSendArgumentsNullifierOperator.class.st +++ b/src/MuTalk-Model/MTMessageSendArgumentsNullifierOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTMessageSendArgumentsNullifierOperator', - #superclass : 'MTBlockBasedMutantOperator', + #superclass : 'MTPredicateBasedMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' @@ -12,6 +12,12 @@ MTMessageSendArgumentsNullifierOperator class >> isAbstract [ ^ self == MTMessageSendArgumentsNullifierOperator ] +{ #category : 'applying' } +MTMessageSendArgumentsNullifierOperator >> appliesToNode: aNode [ + + ^ aNode isMessage and: [ aNode arguments size >= self whichArgument ] +] + { #category : 'printing' } MTMessageSendArgumentsNullifierOperator >> description [ @@ -19,21 +25,13 @@ MTMessageSendArgumentsNullifierOperator >> description [ ] { #category : 'applying' } -MTMessageSendArgumentsNullifierOperator >> expressionToReplace [ +MTMessageSendArgumentsNullifierOperator >> newNodeFrom: anOldNode [ - ^ [ :aNode | - aNode isMessage and: [ aNode arguments size >= self whichArgument ] ] -] - -{ #category : 'applying' } -MTMessageSendArgumentsNullifierOperator >> newExpression [ - - | whichToReplace nodeCopy | - ^ [ :anOldNode | - nodeCopy := anOldNode copy. - whichToReplace := nodeCopy arguments at: self whichArgument. - whichToReplace replaceWith: (RBLiteralValueNode value: nil). - nodeCopy] + | nodeCopy whichToReplace | + nodeCopy := anOldNode copy. + whichToReplace := nodeCopy arguments at: self whichArgument. + whichToReplace replaceWith: (RBLiteralValueNode value: nil). + ^ nodeCopy ] { #category : 'applying' } diff --git a/src/MuTalk-Model/MTMessageSendToYourselfOperator.class.st b/src/MuTalk-Model/MTMessageSendToYourselfOperator.class.st index 7fa467de..eaaeefa7 100644 --- a/src/MuTalk-Model/MTMessageSendToYourselfOperator.class.st +++ b/src/MuTalk-Model/MTMessageSendToYourselfOperator.class.st @@ -1,30 +1,27 @@ Class { #name : 'MTMessageSendToYourselfOperator', - #superclass : 'MTBlockBasedMutantOperator', + #superclass : 'MTPredicateBasedMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' } -{ #category : 'printing' } -MTMessageSendToYourselfOperator >> description [ +{ #category : 'applying' } +MTMessageSendToYourselfOperator >> appliesToNode: aNode [ - ^ 'Chnage a message send with #yourself' + ^ aNode isMessage and: [ aNode selector ~= #yourself ] ] -{ #category : 'applying' } -MTMessageSendToYourselfOperator >> expressionToReplace [ +{ #category : 'printing' } +MTMessageSendToYourselfOperator >> description [ - ^ [ :aNode | - aNode isMessage and: [ aNode selector ~= #yourself ] ] + ^ 'Change a message send with #yourself' ] { #category : 'applying' } -MTMessageSendToYourselfOperator >> newExpression [ +MTMessageSendToYourselfOperator >> newNodeFrom: anOldNode [ | nodeCopy | - ^ [ :anOldNode | - nodeCopy := anOldNode copy. - RBMessageNode receiver: nodeCopy receiver selector: #yourself - ] + nodeCopy := anOldNode copy. + ^ RBMessageNode receiver: nodeCopy receiver selector: #yourself ] diff --git a/src/MuTalk-Model/MTMethodMutation.class.st b/src/MuTalk-Model/MTMethodMutation.class.st index 8a3e9075..fe22b7da 100644 --- a/src/MuTalk-Model/MTMethodMutation.class.st +++ b/src/MuTalk-Model/MTMethodMutation.class.st @@ -7,7 +7,8 @@ Class { 'operator', 'originalClass', 'testCaseReferences', - 'originalProtocol' + 'originalProtocol', + 'data' ], #category : 'MuTalk-Model', #package : 'MuTalk-Model' @@ -15,12 +16,25 @@ Class { { #category : 'instance creation' } MTMethodMutation class >> for: aMethod using: anOperatorApplied nodeNumber: aNodeNumber ofClass: aClass [ + ^ self new - initializeFor: aMethod - using: anOperatorApplied - nodeNumber: aNodeNumber - ofClass: aClass; - yourself + initializeFor: aMethod + using: anOperatorApplied + nodeNumber: aNodeNumber + ofClass: aClass; + yourself +] + +{ #category : 'instance creation' } +MTMethodMutation class >> for: aMethod using: anOperatorApplied nodeNumber: aNodeNumber ofClass: aClass withData: anObject [ + + ^ self new + initializeFor: aMethod + using: anOperatorApplied + nodeNumber: aNodeNumber + ofClass: aClass + withData: anObject; + yourself ] { #category : 'comparing' } @@ -36,6 +50,18 @@ MTMethodMutation >> = anObject [ ^ true ] +{ #category : 'accessing' } +MTMethodMutation >> data [ + + ^ data +] + +{ #category : 'accessing' } +MTMethodMutation >> data: anObject [ + + data := anObject +] + { #category : 'comparing' } MTMethodMutation >> hash [ @@ -45,11 +71,24 @@ MTMethodMutation >> hash [ { #category : 'initialize-release' } MTMethodMutation >> initializeFor: aMethod using: anOperatorApplied nodeNumber: aNodeNumber ofClass: aClass [ + + self + initializeFor: aMethod + using: anOperatorApplied + nodeNumber: aNodeNumber + ofClass: aClass + withData: anOperatorApplied newExpression +] + +{ #category : 'initialize-release' } +MTMethodMutation >> initializeFor: aMethod using: anOperatorApplied nodeNumber: aNodeNumber ofClass: aClass withData: anObject [ + originalMethod := aMethod. originalProtocol := aMethod protocol. operator := anOperatorApplied. nodeNumber := aNodeNumber. - originalClass := aClass + originalClass := aClass. + data := anObject ] { #category : 'installing' } @@ -64,7 +103,10 @@ MTMethodMutation >> install [ { #category : 'accessing' } MTMethodMutation >> modifiedSource [ - ^ operator modifiedSourceFor: originalMethod number: nodeNumber + ^ operator + modifiedSourceFor: originalMethod + number: nodeNumber + newExpression: data ] { #category : 'accessing' } diff --git a/src/MuTalk-Model/MTMutantOperator.class.st b/src/MuTalk-Model/MTMutantOperator.class.st deleted file mode 100644 index 1ece4018..00000000 --- a/src/MuTalk-Model/MTMutantOperator.class.st +++ /dev/null @@ -1,203 +0,0 @@ -Class { - #name : 'MTMutantOperator', - #superclass : 'Object', - #category : 'MuTalk-Model-Operators', - #package : 'MuTalk-Model', - #tag : 'Operators' -} - -{ #category : 'accessing' } -MTMutantOperator class >> allConcreteSubclasses [ - - ^ self allSubclasses reject: [ :ea | - ea isAbstract | ea isOriginalOperator not ] -] - -{ #category : 'accessing' } -MTMutantOperator 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' } -MTMutantOperator 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' } -MTMutantOperator class >> isAbstract [ - - ^ self == MTMutantOperator -] - -{ #category : 'testing' } -MTMutantOperator class >> isOriginalOperator [ - ^ true -] - -{ #category : 'as yet unclassified' } -MTMutantOperator class >> recursionsDetectionStatement [ - - ^ RBParser parseExpression: - ('MuTalkInfiniteRecursionError onCount: {1}' format: { self recursionsDetectionThreshold } ) -] - -{ #category : 'as yet unclassified' } -MTMutantOperator class >> recursionsDetectionThreshold [ - - "We need a big enough number" - - ^ 1024 -] - -{ #category : 'applying' } -MTMutantOperator >> applyTo: anOldNode [ - - | rewriter | - rewriter := RBParseTreeRewriter new. - rewriter - replace: self expressionToReplace - withValueFrom: [ :oNode | | aNewNode | - aNewNode := RBParser parseRewriteExpression: self newExpression. - aNewNode copyInContext: rewriter context ]. - rewriter executeTree: anOldNode copy. - ^ rewriter tree -] - -{ #category : 'printing' } -MTMutantOperator >> description [ - self subclassResponsibility -] - -{ #category : 'applying' } -MTMutantOperator >> expressionToReplace [ - self subclassResponsibility -] - -{ #category : 'private' } -MTMutantOperator >> is: originalRBMethodNode equalTo: nodeThatMatches [ - ^ nodeThatMatches formattedCode = originalRBMethodNode formattedCode -] - -{ #category : 'private' } -MTMutantOperator >> isAPosibleMutatedNode: aRBMethodNode [ - |nodeThatMatches | - - nodeThatMatches := (RBParseTreeSearcher treeMatching: self newExpression - in: aRBMethodNode). - - ^ nodeThatMatches notNil and: [self is: nodeThatMatches equalTo: aRBMethodNode] -] - -{ #category : 'private' } -MTMutantOperator >> isAPosibleNodeToMutate: aRBMethodNode [ - | nodeThatMatches | - nodeThatMatches := RBParseTreeSearcher treeMatching: self expressionToReplace - in: aRBMethodNode. - - ^ nodeThatMatches notNil and: [ self is: aRBMethodNode equalTo: nodeThatMatches ] -] - -{ #category : 'testing' } -MTMutantOperator >> isNodeOfMutation: posibleMutatedRBMethodNode comparingWith: originalRBMethodNode [ - ^ (self isAPosibleNodeToMutate: originalRBMethodNode) - and: [ self isAPosibleMutatedNode: posibleMutatedRBMethodNode ] -] - -{ #category : 'private' } -MTMutantOperator >> modifiedSourceFor: aCompiledMethod number: aNumber [ - "this method must be removed, it is only added because some tests send this message - Gabo" - ^self modifiedSourceFor: aCompiledMethod with: aCompiledMethod parseTree number: aNumber -] - -{ #category : 'private' } -MTMutantOperator >> modifiedSourceFor: aCompiledMethod with: aParseTree number: aNumber [ - - | rewriter parser number nNode | - rewriter := RBParseTreeRewriter new. - number := aNumber. - parser := aParseTree copy. - rewriter - replace: self expressionToReplace - withValueFrom: [ :oNode | - | oldNode newNode | - nNode := RBParser parseRewriteExpression: self newExpression. - nNode := nNode copyInContext: rewriter context. - oldNode := oNode. - newNode := nNode. - newNode ] - when: [ :node | - number := number - 1. - number = 0 ]. - rewriter executeTree: parser. - parser := rewriter tree. - ^ parser formattedCode -] - -{ #category : 'private' } -MTMutantOperator >> mutationFor: aCompiledMethod with: aParseTree number: aNumberOfSelector [ - - ^ MTMethodMutation - for: aCompiledMethod - using: self - nodeNumber: aNumberOfSelector - ofClass: aCompiledMethod methodClass -] - -{ #category : 'mutant generation' } -MTMutantOperator >> mutationsFor: aCompiledMethod [ - - (aCompiledMethod ignoredMutationOperators includes: self class) ifTrue: [ ^ Array new ]. - - ^self mutationsFor: aCompiledMethod with: aCompiledMethod parseTree. - -] - -{ #category : 'mutant generation' } -MTMutantOperator >> mutationsFor: aCompiledMethod with: aParseTree [ - | numberOfMutations | - numberOfMutations := ((aCompiledMethod hasPragmaNamed: #ignoreForMutations) or: [ aCompiledMethod hasPragmaNamed: #ignoreForCoverage ]) - ifTrue: [ ^ Array new ] - ifFalse: [ self timesToApplyIn: aCompiledMethod with: aParseTree ]. - ^ (1 to: numberOfMutations) - collect: [:aNumberOfSelector | self - mutationFor: aCompiledMethod - with: aParseTree - number: aNumberOfSelector] -] - -{ #category : 'applying' } -MTMutantOperator >> newExpression [ - self subclassResponsibility -] - -{ #category : 'suggestions' } -MTMutantOperator >> suggestionFor: aMutation using: aMutantKillingSuggestionGenerator [ - ^'No Suggestion' -] - -{ #category : 'applying' } -MTMutantOperator >> timesToApplyIn: aCompiledMethod [ - ^self timesToApplyIn: aCompiledMethod with: aCompiledMethod parseTree. - -] - -{ #category : 'applying' } -MTMutantOperator >> timesToApplyIn: aCompiledMethod with: aParseTree [ - "Evaluates how many times can the operator be applyied" - |searcher timesToApply| - searcher := RBParseTreeSearcher new. - timesToApply := 0. - searcher matches:self expressionToReplace do:[:node :answer | timesToApply := timesToApply + 1]. - searcher executeTree: aParseTree copy. - ^timesToApply. - -] diff --git a/src/MuTalk-Model/MTParseRewriterMutantOperator.class.st b/src/MuTalk-Model/MTParseRewriterMutantOperator.class.st new file mode 100644 index 00000000..857dfa07 --- /dev/null +++ b/src/MuTalk-Model/MTParseRewriterMutantOperator.class.st @@ -0,0 +1,84 @@ +Class { + #name : 'MTParseRewriterMutantOperator', + #superclass : 'MTAbstractMutantOperator', + #category : 'MuTalk-Model-Operators', + #package : 'MuTalk-Model', + #tag : 'Operators' +} + +{ #category : 'testing' } +MTParseRewriterMutantOperator class >> isAbstract [ + + ^ self == MTParseRewriterMutantOperator +] + +{ #category : 'applying' } +MTParseRewriterMutantOperator >> applyTo: anOldNode [ + + | rewriter | + rewriter := RBParseTreeRewriter new. + rewriter + replace: self expressionToReplace + withValueFrom: [ :oNode | | aNewNode | + aNewNode := RBParser parseRewriteExpression: self newExpression. + aNewNode copyInContext: rewriter context ]. + rewriter executeTree: anOldNode copy. + ^ rewriter tree +] + +{ #category : 'applying' } +MTParseRewriterMutantOperator >> expressionToReplace [ + self subclassResponsibility +] + +{ #category : 'private' } +MTParseRewriterMutantOperator >> modifiedSourceFor: aCompiledMethod with: aParseTree number: aNumber newExpression: anExpression [ + + | rewriter parser number nNode | + rewriter := RBParseTreeRewriter new. + number := aNumber. + parser := aParseTree copy. + rewriter + replace: self expressionToReplace + withValueFrom: [ :oNode | + | oldNode newNode | + nNode := RBParser parseRewriteExpression: anExpression. + nNode := nNode copyInContext: rewriter context. + oldNode := oNode. + newNode := nNode. + newNode ] + when: [ :node | + number := number - 1. + number = 0 ]. + rewriter executeTree: parser. + parser := rewriter tree. + ^ parser formattedCode +] + +{ #category : 'private' } +MTParseRewriterMutantOperator >> mutationsFor: aCompiledMethod with: aParseTree number: nodeIndex storeIn: accumulator [ + + accumulator add: (MTMethodMutation + for: aCompiledMethod + using: self + nodeNumber: nodeIndex + ofClass: aCompiledMethod methodClass). + ^ accumulator +] + +{ #category : 'applying' } +MTParseRewriterMutantOperator >> newExpression [ + self subclassResponsibility +] + +{ #category : 'applying' } +MTParseRewriterMutantOperator >> timesToApplyIn: aCompiledMethod with: aParseTree [ + "Evaluates how many times can the operator be applyied" + |searcher timesToApply| + searcher := RBParseTreeSearcher new. + timesToApply := 0. + searcher matches:self expressionToReplace do:[:node :answer | timesToApply := timesToApply + 1]. + searcher executeTree: aParseTree copy. + ^timesToApply. + +] diff --git a/src/MuTalk-Model/MTPredicateBasedMutantOperator.class.st b/src/MuTalk-Model/MTPredicateBasedMutantOperator.class.st new file mode 100644 index 00000000..26a413c8 --- /dev/null +++ b/src/MuTalk-Model/MTPredicateBasedMutantOperator.class.st @@ -0,0 +1,81 @@ +Class { + #name : 'MTPredicateBasedMutantOperator', + #superclass : 'MTAbstractMutantOperator', + #category : 'MuTalk-Model-Operators', + #package : 'MuTalk-Model', + #tag : 'Operators' +} + +{ #category : 'testing' } +MTPredicateBasedMutantOperator class >> isAbstract [ + + ^ self == MTPredicateBasedMutantOperator +] + +{ #category : 'testing' } +MTPredicateBasedMutantOperator class >> isOriginalOperator [ + ^ false +] + +{ #category : 'private' } +MTPredicateBasedMutantOperator >> affectedNodeFor: aParseTree at: nodeIndex [ + + | allNodes | + allNodes := self affectedNodesFor: aParseTree. + ^ allNodes at: nodeIndex +] + +{ #category : 'private' } +MTPredicateBasedMutantOperator >> affectedNodesFor: aParseTree [ + + ^ aParseTree allChildren select: [ :aNode | + self appliesToNode: aNode ] +] + +{ #category : 'instance creation' } +MTPredicateBasedMutantOperator >> appliesToNode: aNode [ + + self subclassResponsibility +] + +{ #category : 'private' } +MTPredicateBasedMutantOperator >> modifiedSourceFor: aCompiledMethod with: aParseTree number: aNumber newExpression: aNode [ + + | parseTreeCopy allNodes | + parseTreeCopy := aParseTree copy. + allNodes := self affectedNodesFor: parseTreeCopy. + allNodes size >= aNumber ifTrue: [ + | oldNode | + oldNode := allNodes at: aNumber. + oldNode replaceWith: aNode ]. + ^ parseTreeCopy formattedCode +] + +{ #category : 'private' } +MTPredicateBasedMutantOperator >> mutationsFor: aCompiledMethod with: aParseTree number: nodeIndex storeIn: accumulator [ + + | affectedNode newNode | + affectedNode := self affectedNodeFor: aParseTree at: nodeIndex. + newNode := self newNodeFrom: affectedNode. + + accumulator add: (MTMethodMutation + for: aCompiledMethod + using: self + nodeNumber: nodeIndex + ofClass: aCompiledMethod methodClass + withData: newNode). + ^ accumulator +] + +{ #category : 'instance creation' } +MTPredicateBasedMutantOperator >> newNodeFrom: anOldNode [ + + self subclassResponsibility +] + +{ #category : 'private' } +MTPredicateBasedMutantOperator >> timesToApplyIn: aCompiledMethod with: aParseTree [ + "Evaluates how many times can the operator be applyied" + + ^ (self affectedNodesFor: aParseTree) size +] diff --git a/src/MuTalk-Model/MTRemoveAtIfAbsentOperator.class.st b/src/MuTalk-Model/MTRemoveAtIfAbsentOperator.class.st index 8355e3fc..c4f08c8d 100644 --- a/src/MuTalk-Model/MTRemoveAtIfAbsentOperator.class.st +++ b/src/MuTalk-Model/MTRemoveAtIfAbsentOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTRemoveAtIfAbsentOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTRemoveCaretOperator.class.st b/src/MuTalk-Model/MTRemoveCaretOperator.class.st index 3674ab20..e4c79224 100644 --- a/src/MuTalk-Model/MTRemoveCaretOperator.class.st +++ b/src/MuTalk-Model/MTRemoveCaretOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTRemoveCaretOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTRemoveExceptionHandlerOperator.class.st b/src/MuTalk-Model/MTRemoveExceptionHandlerOperator.class.st index 9a74c222..2605e619 100644 --- a/src/MuTalk-Model/MTRemoveExceptionHandlerOperator.class.st +++ b/src/MuTalk-Model/MTRemoveExceptionHandlerOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTRemoveExceptionHandlerOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTRemoveInjectIntoOperator.class.st b/src/MuTalk-Model/MTRemoveInjectIntoOperator.class.st index fba9898f..7c6fdc47 100644 --- a/src/MuTalk-Model/MTRemoveInjectIntoOperator.class.st +++ b/src/MuTalk-Model/MTRemoveInjectIntoOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTRemoveInjectIntoOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTRemoveNotOperator.class.st b/src/MuTalk-Model/MTRemoveNotOperator.class.st index 5831c901..886515f2 100644 --- a/src/MuTalk-Model/MTRemoveNotOperator.class.st +++ b/src/MuTalk-Model/MTRemoveNotOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTRemoveNotOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceAndArgumentWithTrueOperator.class.st b/src/MuTalk-Model/MTReplaceAndArgumentWithTrueOperator.class.st index e2b701ef..559a2e82 100644 --- a/src/MuTalk-Model/MTReplaceAndArgumentWithTrueOperator.class.st +++ b/src/MuTalk-Model/MTReplaceAndArgumentWithTrueOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceAndArgumentWithTrueOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceAndWithFalseOperator.class.st b/src/MuTalk-Model/MTReplaceAndWithFalseOperator.class.st index cc045c7b..2c611f21 100644 --- a/src/MuTalk-Model/MTReplaceAndWithFalseOperator.class.st +++ b/src/MuTalk-Model/MTReplaceAndWithFalseOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceAndWithFalseOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperator.class.st b/src/MuTalk-Model/MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperator.class.st index 770f7fa2..2e54fecf 100644 --- a/src/MuTalk-Model/MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperator.class.st +++ b/src/MuTalk-Model/MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperator.class.st b/src/MuTalk-Model/MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperator.class.st index 345ecf65..4068e720 100644 --- a/src/MuTalk-Model/MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperator.class.st +++ b/src/MuTalk-Model/MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperator.class.st b/src/MuTalk-Model/MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperator.class.st index 0d09e61b..ca346cc4 100644 --- a/src/MuTalk-Model/MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperator.class.st +++ b/src/MuTalk-Model/MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceDoBlockWithEmptyBlockOperator.class.st b/src/MuTalk-Model/MTReplaceDoBlockWithEmptyBlockOperator.class.st index a0d8daa8..a40a6185 100644 --- a/src/MuTalk-Model/MTReplaceDoBlockWithEmptyBlockOperator.class.st +++ b/src/MuTalk-Model/MTReplaceDoBlockWithEmptyBlockOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceDoBlockWithEmptyBlockOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceIdentityWithNegationOfIdentity.class.st b/src/MuTalk-Model/MTReplaceIdentityWithNegationOfIdentity.class.st index 06eb68d0..60198e6b 100644 --- a/src/MuTalk-Model/MTReplaceIdentityWithNegationOfIdentity.class.st +++ b/src/MuTalk-Model/MTReplaceIdentityWithNegationOfIdentity.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIdentityWithNegationOfIdentity', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceLessOrEqualWithTrueOperator.class.st b/src/MuTalk-Model/MTReplaceLessOrEqualWithTrueOperator.class.st index 59eff3e5..cc5e7e93 100644 --- a/src/MuTalk-Model/MTReplaceLessOrEqualWithTrueOperator.class.st +++ b/src/MuTalk-Model/MTReplaceLessOrEqualWithTrueOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceLessOrEqualWithTrueOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceOrArgumentWithFalseOperator.class.st b/src/MuTalk-Model/MTReplaceOrArgumentWithFalseOperator.class.st index c8d3aef0..4891f9fc 100644 --- a/src/MuTalk-Model/MTReplaceOrArgumentWithFalseOperator.class.st +++ b/src/MuTalk-Model/MTReplaceOrArgumentWithFalseOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceOrArgumentWithFalseOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceOrWithTrueOperator.class.st b/src/MuTalk-Model/MTReplaceOrWithTrueOperator.class.st index b2c7b701..1a053a90 100644 --- a/src/MuTalk-Model/MTReplaceOrWithTrueOperator.class.st +++ b/src/MuTalk-Model/MTReplaceOrWithTrueOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceOrWithTrueOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceReceiverOperator.class.st b/src/MuTalk-Model/MTReplaceReceiverOperator.class.st index d4ad8d9a..53f19630 100644 --- a/src/MuTalk-Model/MTReplaceReceiverOperator.class.st +++ b/src/MuTalk-Model/MTReplaceReceiverOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceReceiverOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceRejectBlockWithAlwaysFalseBlockOperator.class.st b/src/MuTalk-Model/MTReplaceRejectBlockWithAlwaysFalseBlockOperator.class.st index 46706434..84e9cf9c 100644 --- a/src/MuTalk-Model/MTReplaceRejectBlockWithAlwaysFalseBlockOperator.class.st +++ b/src/MuTalk-Model/MTReplaceRejectBlockWithAlwaysFalseBlockOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceRejectBlockWithAlwaysFalseBlockOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceRejectBlockWithAlwaysTrueBlockOperator.class.st b/src/MuTalk-Model/MTReplaceRejectBlockWithAlwaysTrueBlockOperator.class.st index b1182110..9bdf7e88 100644 --- a/src/MuTalk-Model/MTReplaceRejectBlockWithAlwaysTrueBlockOperator.class.st +++ b/src/MuTalk-Model/MTReplaceRejectBlockWithAlwaysTrueBlockOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceRejectBlockWithAlwaysTrueBlockOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceSelectBlockWithAlwaysFalseBlockOperator.class.st b/src/MuTalk-Model/MTReplaceSelectBlockWithAlwaysFalseBlockOperator.class.st index 6ce8fb15..ed2441f4 100644 --- a/src/MuTalk-Model/MTReplaceSelectBlockWithAlwaysFalseBlockOperator.class.st +++ b/src/MuTalk-Model/MTReplaceSelectBlockWithAlwaysFalseBlockOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceSelectBlockWithAlwaysFalseBlockOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceSelectBlockWithAlwaysTrueBlockOperator.class.st b/src/MuTalk-Model/MTReplaceSelectBlockWithAlwaysTrueBlockOperator.class.st index 8bc623b6..1408a2b2 100644 --- a/src/MuTalk-Model/MTReplaceSelectBlockWithAlwaysTrueBlockOperator.class.st +++ b/src/MuTalk-Model/MTReplaceSelectBlockWithAlwaysTrueBlockOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceSelectBlockWithAlwaysTrueBlockOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTReplaceSortBlockWithAlwaysTrueBlockOperator.class.st b/src/MuTalk-Model/MTReplaceSortBlockWithAlwaysTrueBlockOperator.class.st index 4a2c065e..545d36eb 100644 --- a/src/MuTalk-Model/MTReplaceSortBlockWithAlwaysTrueBlockOperator.class.st +++ b/src/MuTalk-Model/MTReplaceSortBlockWithAlwaysTrueBlockOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceSortBlockWithAlwaysTrueBlockOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTSelectorReplacementMutantOperator.class.st b/src/MuTalk-Model/MTSelectorReplacementMutantOperator.class.st index 624d2a9a..c55df736 100644 --- a/src/MuTalk-Model/MTSelectorReplacementMutantOperator.class.st +++ b/src/MuTalk-Model/MTSelectorReplacementMutantOperator.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTSelectorReplacementMutantOperator', - #superclass : 'MTMutantOperator', + #superclass : 'MTParseRewriterMutantOperator', #category : 'MuTalk-Model-Operators', #package : 'MuTalk-Model', #tag : 'Operators' diff --git a/src/MuTalk-Model/MTSubclassReplacementOperator.class.st b/src/MuTalk-Model/MTSubclassReplacementOperator.class.st new file mode 100644 index 00000000..2cfdc224 --- /dev/null +++ b/src/MuTalk-Model/MTSubclassReplacementOperator.class.st @@ -0,0 +1,58 @@ +Class { + #name : 'MTSubclassReplacementOperator', + #superclass : 'MTPredicateBasedMutantOperator', + #category : 'MuTalk-Model-Operators', + #package : 'MuTalk-Model', + #tag : 'Operators' +} + +{ #category : 'applying' } +MTSubclassReplacementOperator >> appliesToNode: aNode [ + + ^ aNode isVariable and: [ + (self class environment includesKey: aNode name) and: [ + | referencedClass | + referencedClass := self class environment at: aNode name. + referencedClass isClass and: [ + referencedClass subclasses notEmpty ] ] ] +] + +{ #category : 'printing' } +MTSubclassReplacementOperator >> description [ + + ^ 'Replace a class reference by a reference to one of its subclasses' +] + +{ #category : 'private' } +MTSubclassReplacementOperator >> mutationsFor: aCompiledMethod with: aParseTree number: nodeIndex storeIn: accumulator [ + + | subclasses affectedNode | + affectedNode := self affectedNodeFor: aParseTree at: nodeIndex. + "We know that the affectedNode is on a class reference to a class that exists and has subclasses" + subclasses := self subclassesForNode: affectedNode. + accumulator addAll: (subclasses collect: [ :subclass | + | newExpression | + newExpression := RBVariableNode named: subclass name. + MTMethodMutation + for: aCompiledMethod + using: self + nodeNumber: nodeIndex + ofClass: aCompiledMethod methodClass + withData: newExpression ]). + ^ accumulator +] + +{ #category : 'instance creation' } +MTSubclassReplacementOperator >> newNodeFrom: anOldNode [ + + +] + +{ #category : 'applying' } +MTSubclassReplacementOperator >> subclassesForNode: aNode [ + "pre condition: aNode is a class reference node that exists" + + | referencedClass | + referencedClass := self class environment at: aNode name. + ^ referencedClass subclasses +] diff --git a/src/MuTalk-TestResources/MTAuxiliarClassForSubclassReplacementOperator.class.st b/src/MuTalk-TestResources/MTAuxiliarClassForSubclassReplacementOperator.class.st new file mode 100644 index 00000000..70b2c4be --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarClassForSubclassReplacementOperator.class.st @@ -0,0 +1,6 @@ +Class { + #name : 'MTAuxiliarClassForSubclassReplacementOperator', + #superclass : 'Object', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} diff --git a/src/MuTalk-TestResources/MTAuxiliarClassForSubclassReplacementOperatorBis.class.st b/src/MuTalk-TestResources/MTAuxiliarClassForSubclassReplacementOperatorBis.class.st new file mode 100644 index 00000000..32825abc --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarClassForSubclassReplacementOperatorBis.class.st @@ -0,0 +1,6 @@ +Class { + #name : 'MTAuxiliarClassForSubclassReplacementOperatorBis', + #superclass : 'Object', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} diff --git a/src/MuTalk-TestResources/MTAuxiliarClassForSubclassReplacementWithManySubclasses.class.st b/src/MuTalk-TestResources/MTAuxiliarClassForSubclassReplacementWithManySubclasses.class.st new file mode 100644 index 00000000..88b5d7fe --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarClassForSubclassReplacementWithManySubclasses.class.st @@ -0,0 +1,6 @@ +Class { + #name : 'MTAuxiliarClassForSubclassReplacementWithManySubclasses', + #superclass : 'Object', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} diff --git a/src/MuTalk-TestResources/MTAuxiliarSubclass1ForSubclassReplacementWithManySubclasses.class.st b/src/MuTalk-TestResources/MTAuxiliarSubclass1ForSubclassReplacementWithManySubclasses.class.st new file mode 100644 index 00000000..0fa88458 --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarSubclass1ForSubclassReplacementWithManySubclasses.class.st @@ -0,0 +1,6 @@ +Class { + #name : 'MTAuxiliarSubclass1ForSubclassReplacementWithManySubclasses', + #superclass : 'MTAuxiliarClassForSubclassReplacementWithManySubclasses', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} diff --git a/src/MuTalk-TestResources/MTAuxiliarSubclass2ForSubclassReplacementWithManySubclasses.class.st b/src/MuTalk-TestResources/MTAuxiliarSubclass2ForSubclassReplacementWithManySubclasses.class.st new file mode 100644 index 00000000..3fb406f6 --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarSubclass2ForSubclassReplacementWithManySubclasses.class.st @@ -0,0 +1,6 @@ +Class { + #name : 'MTAuxiliarSubclass2ForSubclassReplacementWithManySubclasses', + #superclass : 'MTAuxiliarClassForSubclassReplacementWithManySubclasses', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} diff --git a/src/MuTalk-TestResources/MTAuxiliarSubclass3ForSubclassReplacementWithManySubclasses.class.st b/src/MuTalk-TestResources/MTAuxiliarSubclass3ForSubclassReplacementWithManySubclasses.class.st new file mode 100644 index 00000000..6afcf281 --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarSubclass3ForSubclassReplacementWithManySubclasses.class.st @@ -0,0 +1,6 @@ +Class { + #name : 'MTAuxiliarSubclass3ForSubclassReplacementWithManySubclasses', + #superclass : 'MTAuxiliarClassForSubclassReplacementWithManySubclasses', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} diff --git a/src/MuTalk-TestResources/MTAuxiliarSubclassForSubclassReplacementOperator.class.st b/src/MuTalk-TestResources/MTAuxiliarSubclassForSubclassReplacementOperator.class.st new file mode 100644 index 00000000..47e65564 --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarSubclassForSubclassReplacementOperator.class.st @@ -0,0 +1,6 @@ +Class { + #name : 'MTAuxiliarSubclassForSubclassReplacementOperator', + #superclass : 'MTAuxiliarClassForSubclassReplacementOperator', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} diff --git a/src/MuTalk-TestResources/MTAuxiliarSubclassForSubclassReplacementOperatorBis.class.st b/src/MuTalk-TestResources/MTAuxiliarSubclassForSubclassReplacementOperatorBis.class.st new file mode 100644 index 00000000..55c1b292 --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarSubclassForSubclassReplacementOperatorBis.class.st @@ -0,0 +1,6 @@ +Class { + #name : 'MTAuxiliarSubclassForSubclassReplacementOperatorBis', + #superclass : 'MTAuxiliarClassForSubclassReplacementOperatorBis', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} diff --git a/src/MuTalk-Tests/MTAbstractMutantOperatorTest.class.st b/src/MuTalk-Tests/MTAbstractMutantOperatorTest.class.st new file mode 100644 index 00000000..689b09ae --- /dev/null +++ b/src/MuTalk-Tests/MTAbstractMutantOperatorTest.class.st @@ -0,0 +1,193 @@ +Class { + #name : 'MTAbstractMutantOperatorTest', + #superclass : 'TestCase', + #category : 'MuTalk-Tests', + #package : 'MuTalk-Tests' +} + +{ #category : 'testing' } +MTAbstractMutantOperatorTest class >> isAbstract [ + + ^ self == MTAbstractMutantOperatorTest +] + +{ #category : 'accessing' } +MTAbstractMutantOperatorTest class >> packageNamesUnderTest [ + ^ #('MutationTesting-Model') +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertApplyingMutantToFirstSenderInOneSenderMethod [ + + ^ self subclassResponsibility +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertApplyingMutantToFirstSenderInTwoSendersMethod [ + + ^ self subclassResponsibility +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertApplyingMutantToNonSenderMethod [ + + ^ self subclassResponsibility +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertApplyingMutantToSecondSenderInTwoSendersMethod [ + + ^ self subclassResponsibility +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertNumberMutantsGeneratedForNonSenderMethod [ + + | mutationsGenerated | + mutationsGenerated := self operator mutationsFor: + self class >> #methodWithNoSenders. + ^ mutationsGenerated isEmpty +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertNumberMutantsGeneratedForOneSenderMethod [ + + | mutationsGenerated | + mutationsGenerated := self operator mutationsFor: + self class >> #methodWithOneSender. + ^ mutationsGenerated size = 1 +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertNumberMutantsGeneratedForTwoSendersMethod [ + + | mutationsGenerated | + mutationsGenerated := self operator mutationsFor: + self class >> #methodWithTwoSenders. + ^ mutationsGenerated size = 2 +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertTimesToApplyOperatorInTwoSendersMethod [ + + ^ (self operator timesToApplyIn: self class >> #methodWithTwoSenders) + = 2 +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertTimesToApplyOperatorToNonSenderMethod [ + + ^ (self operator timesToApplyIn: self class >> #methodWithNoSenders) + = 0 +] + +{ #category : 'asserts' } +MTAbstractMutantOperatorTest >> assertTimesToApplyOperatorToOneSenderMethod [ + + ^ (self operator timesToApplyIn: self class >> #methodWithOneSender) + = 1 +] + +{ #category : 'formatting' } +MTAbstractMutantOperatorTest >> compareSource: aSource withSourceInMethod: aCompiledMethod replacingSelector: aSelector [ + "Compare both source replacing the selector of CompiledMethod for aSelector (to make then equal) + and formatting both sources equally." + + | sourceSelector secondString methodSelectorString secondStringModified | + sourceSelector := aSelector asString. + secondString := aCompiledMethod sourceCode asString. + methodSelectorString := aCompiledMethod selector asString. + secondStringModified := secondString + copyReplaceAll: methodSelectorString + with: sourceSelector. + ^ (self formattedStringFor: aSource) + = (self formattedStringFor: secondStringModified) +] + +{ #category : 'formatting' } +MTAbstractMutantOperatorTest >> formattedStringFor: aMethodString [ + + ^ (RBParser parseMethod: aMethodString) formattedCode +] + +{ #category : 'accessing' } +MTAbstractMutantOperatorTest >> methodWithNoSenders [ + + ^ self subclassResponsibility +] + +{ #category : 'accessing' } +MTAbstractMutantOperatorTest >> methodWithOneSender [ + + ^ self subclassResponsibility +] + +{ #category : 'accessing' } +MTAbstractMutantOperatorTest >> methodWithOneSenderModified [ + + ^ self subclassResponsibility +] + +{ #category : 'accessing' } +MTAbstractMutantOperatorTest >> methodWithTwoSenders [ + + ^ self subclassResponsibility +] + +{ #category : 'accessing' } +MTAbstractMutantOperatorTest >> methodWithTwoSendersModifiedFirst [ + + ^ self subclassResponsibility +] + +{ #category : 'accessing' } +MTAbstractMutantOperatorTest >> methodWithTwoSendersModifiedSecond [ + + ^ self subclassResponsibility +] + +{ #category : 'accessing' } +MTAbstractMutantOperatorTest >> operator [ + + ^ self subclassResponsibility +] + +{ #category : 'accessing' } +MTAbstractMutantOperatorTest >> operatorDescription [ + + ^ self operator description +] + +{ #category : 'tests' } +MTAbstractMutantOperatorTest >> testApplyMutantToMethod [ + + self assert: self assertApplyingMutantToNonSenderMethod. + self assert: self assertApplyingMutantToFirstSenderInOneSenderMethod. + self assert: self assertApplyingMutantToFirstSenderInTwoSendersMethod. + self assert: + self assertApplyingMutantToSecondSenderInTwoSendersMethod +] + +{ #category : 'tests' } +MTAbstractMutantOperatorTest >> testNumberMutantsGenerated [ + + self assert: self assertNumberMutantsGeneratedForNonSenderMethod. + self assert: self assertNumberMutantsGeneratedForOneSenderMethod. + self assert: self assertNumberMutantsGeneratedForTwoSendersMethod +] + +{ #category : 'tests' } +MTAbstractMutantOperatorTest >> testPrintingAccessors [ + + self + assert: self operator description + equals: self operatorDescription +] + +{ #category : 'tests' } +MTAbstractMutantOperatorTest >> testTimesToApplyMutantToMethod [ + + self assert: self assertTimesToApplyOperatorToNonSenderMethod. + self assert: self assertTimesToApplyOperatorToOneSenderMethod. + self assert: self assertTimesToApplyOperatorInTwoSendersMethod +] diff --git a/src/MuTalk-Tests/MTAnalysisTest.class.st b/src/MuTalk-Tests/MTAnalysisTest.class.st index 85ecb5df..8acf26f7 100644 --- a/src/MuTalk-Tests/MTAnalysisTest.class.st +++ b/src/MuTalk-Tests/MTAnalysisTest.class.st @@ -66,7 +66,7 @@ MTAnalysisTest >> testDefaultParameters [ analysis := MTAnalysis new. self assert: (analysis operators collect: [ :op | op species ]) - equals: (MTMutantOperator contents collect: [ :op | op species ]). + equals: (MTAbstractMutantOperator contents collect: [ :op | op species ]). self assert: analysis mutantSelectionStrategy species equals: MTAllMutantSelectionStrategy. diff --git a/src/MuTalk-Tests/MTAssignmentNullifierOperatorTest.class.st b/src/MuTalk-Tests/MTAssignmentNullifierOperatorTest.class.st index 9b817586..c7335e85 100644 --- a/src/MuTalk-Tests/MTAssignmentNullifierOperatorTest.class.st +++ b/src/MuTalk-Tests/MTAssignmentNullifierOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTAssignmentNullifierOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTPredicateBasedMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } @@ -49,6 +49,30 @@ MTAssignmentNullifierOperatorTest >> methodWithTwoSendersModifiedSecond [ j := nil ] +{ #category : 'accessing' } +MTAssignmentNullifierOperatorTest >> newNodeOneSender [ + + ^ RBAssignmentNode + variable: (RBVariableNode named: #i) + value: (RBLiteralValueNode value: nil) +] + +{ #category : 'accessing' } +MTAssignmentNullifierOperatorTest >> newNodeTwoSendersFirst [ + + ^ RBAssignmentNode + variable: (RBVariableNode named: #i) + value: (RBLiteralValueNode value: nil) +] + +{ #category : 'accessing' } +MTAssignmentNullifierOperatorTest >> newNodeTwoSendersSecond [ + + ^ RBAssignmentNode + variable: (RBVariableNode named: #j) + value: (RBLiteralValueNode value: nil) +] + { #category : 'accessing' } MTAssignmentNullifierOperatorTest >> operator [ diff --git a/src/MuTalk-Tests/MTEmptyMethodOperatorTest.class.st b/src/MuTalk-Tests/MTEmptyMethodOperatorTest.class.st index e2ba6998..70dc19cc 100644 --- a/src/MuTalk-Tests/MTEmptyMethodOperatorTest.class.st +++ b/src/MuTalk-Tests/MTEmptyMethodOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTEmptyMethodOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTPredicateBasedMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } @@ -18,6 +18,12 @@ MTEmptyMethodOperatorTest >> methodWithOneSenderModified [ ] +{ #category : 'accessing' } +MTEmptyMethodOperatorTest >> newNodeOneSender [ + + ^ RBSequenceNode statements: #( ) +] + { #category : 'accessing' } MTEmptyMethodOperatorTest >> operator [ diff --git a/src/MuTalk-Tests/MTLiteralBooleanNegateOperatorTest.class.st b/src/MuTalk-Tests/MTLiteralBooleanNegateOperatorTest.class.st index 75e92724..4babb97c 100644 --- a/src/MuTalk-Tests/MTLiteralBooleanNegateOperatorTest.class.st +++ b/src/MuTalk-Tests/MTLiteralBooleanNegateOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTLiteralBooleanNegateOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTPredicateBasedMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } @@ -41,6 +41,24 @@ MTLiteralBooleanNegateOperatorTest >> methodWithTwoSendersModifiedSecond [ ^ true & true ] +{ #category : 'accessing' } +MTLiteralBooleanNegateOperatorTest >> newNodeOneSender [ + + ^ RBLiteralValueNode value: false +] + +{ #category : 'accessing' } +MTLiteralBooleanNegateOperatorTest >> newNodeTwoSendersFirst [ + + ^ RBLiteralValueNode value: false +] + +{ #category : 'accessing' } +MTLiteralBooleanNegateOperatorTest >> newNodeTwoSendersSecond [ + + ^ RBLiteralValueNode value: true +] + { #category : 'accessing' } MTLiteralBooleanNegateOperatorTest >> operator [ diff --git a/src/MuTalk-Tests/MTLiteralIntegersIncreaseOperatorTest.class.st b/src/MuTalk-Tests/MTLiteralIntegersIncreaseOperatorTest.class.st index 34019154..66f1bb62 100644 --- a/src/MuTalk-Tests/MTLiteralIntegersIncreaseOperatorTest.class.st +++ b/src/MuTalk-Tests/MTLiteralIntegersIncreaseOperatorTest.class.st @@ -3,7 +3,7 @@ A LiteralIntegersIncreaseOperatorTest is a test class for testing the behavior o " Class { #name : 'MTLiteralIntegersIncreaseOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTPredicateBasedMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } @@ -44,6 +44,24 @@ MTLiteralIntegersIncreaseOperatorTest >> methodWithTwoSendersModifiedSecond [ ^ 1 >= 3 ] +{ #category : 'accessing' } +MTLiteralIntegersIncreaseOperatorTest >> newNodeOneSender [ + + ^ RBLiteralValueNode value: 2 +] + +{ #category : 'accessing' } +MTLiteralIntegersIncreaseOperatorTest >> newNodeTwoSendersFirst [ + + ^ RBLiteralValueNode value: 2 +] + +{ #category : 'accessing' } +MTLiteralIntegersIncreaseOperatorTest >> newNodeTwoSendersSecond [ + + ^ RBLiteralValueNode value: 3 +] + { #category : 'accessing' } MTLiteralIntegersIncreaseOperatorTest >> operator [ diff --git a/src/MuTalk-Tests/MTMessageSendArguments1stNullifierOperatorTest.class.st b/src/MuTalk-Tests/MTMessageSendArguments1stNullifierOperatorTest.class.st index b34b3276..0d913222 100644 --- a/src/MuTalk-Tests/MTMessageSendArguments1stNullifierOperatorTest.class.st +++ b/src/MuTalk-Tests/MTMessageSendArguments1stNullifierOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTMessageSendArguments1stNullifierOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTPredicateBasedMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } @@ -22,7 +22,6 @@ MTMessageSendArguments1stNullifierOperatorTest >> methodWithOneSender [ { #category : 'accessing' } MTMessageSendArguments1stNullifierOperatorTest >> methodWithOneSenderModified [ - | o | o := OrderedCollection new. o at: nil put: 2 @@ -31,11 +30,10 @@ MTMessageSendArguments1stNullifierOperatorTest >> methodWithOneSenderModified [ { #category : 'accessing' } MTMessageSendArguments1stNullifierOperatorTest >> methodWithTwoSenders [ - | o | o := OrderedCollection new. o at: 1 put: 2. - o at: 1 . + o at: 1 ] { #category : 'accessing' } @@ -56,6 +54,37 @@ MTMessageSendArguments1stNullifierOperatorTest >> methodWithTwoSendersModifiedSe o at: nil ] +{ #category : 'accessing' } +MTMessageSendArguments1stNullifierOperatorTest >> newNodeOneSender [ + + ^ RBMessageNode + receiver: (RBVariableNode named: #o) + selector: #at:put: + arguments: { + (RBLiteralValueNode value: nil). + (RBLiteralValueNode value: 2) } +] + +{ #category : 'accessing' } +MTMessageSendArguments1stNullifierOperatorTest >> newNodeTwoSendersFirst [ + + ^ RBMessageNode + receiver: (RBVariableNode named: #o) + selector: #at:put: + arguments: { + (RBLiteralValueNode value: nil). + (RBLiteralValueNode value: 2) } +] + +{ #category : 'accessing' } +MTMessageSendArguments1stNullifierOperatorTest >> newNodeTwoSendersSecond [ + + ^ RBMessageNode + receiver: (RBVariableNode named: #o) + selector: #at: + arguments: { (RBLiteralValueNode value: nil) } +] + { #category : 'accessing' } MTMessageSendArguments1stNullifierOperatorTest >> operator [ diff --git a/src/MuTalk-Tests/MTMessageSendArguments3rdNullifierOperatorTest.class.st b/src/MuTalk-Tests/MTMessageSendArguments3rdNullifierOperatorTest.class.st index 293d175e..67511a63 100644 --- a/src/MuTalk-Tests/MTMessageSendArguments3rdNullifierOperatorTest.class.st +++ b/src/MuTalk-Tests/MTMessageSendArguments3rdNullifierOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTMessageSendArguments3rdNullifierOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTPredicateBasedMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } @@ -17,7 +17,7 @@ MTMessageSendArguments3rdNullifierOperatorTest >> methodWithOneSender [ | o | o := OrderedCollection new. o at: 1 put: 2. - o collect: [:s | s] from: 0 to: 2. + o collect: [ :s | s ] from: 0 to: 2. o at: 1 put: 2 ] @@ -64,6 +64,50 @@ MTMessageSendArguments3rdNullifierOperatorTest >> methodWithTwoSendersModifiedSe o at: 1 put: 2 ] +{ #category : 'accessing' } +MTMessageSendArguments3rdNullifierOperatorTest >> newNodeOneSender [ + + ^ RBMessageNode + receiver: (RBVariableNode named: #o) + selector: #collect:from:to: + arguments: { + (RBBlockNode + arguments: { (RBVariableNode named: #s) } + body: (RBSequenceNode statements: { (RBVariableNode named: #s) })). + (RBLiteralValueNode value: 0). + (RBLiteralValueNode value: nil) } +] + +{ #category : 'accessing' } +MTMessageSendArguments3rdNullifierOperatorTest >> newNodeTwoSendersFirst [ + + ^ RBMessageNode + receiver: (RBVariableNode named: #o) + selector: #collect:from:to: + arguments: { + (RBBlockNode + arguments: { (RBVariableNode named: #s) } + body: + (RBSequenceNode statements: { (RBVariableNode named: #s) })). + (RBLiteralValueNode value: 0). + (RBLiteralValueNode value: nil) } +] + +{ #category : 'accessing' } +MTMessageSendArguments3rdNullifierOperatorTest >> newNodeTwoSendersSecond [ + + ^ RBMessageNode + receiver: (RBVariableNode named: #o) + selector: #collect:from:to: + arguments: { + (RBBlockNode + arguments: { (RBVariableNode named: #s) } + body: + (RBSequenceNode statements: { (RBVariableNode named: #s) })). + (RBLiteralValueNode value: 0). + (RBLiteralValueNode value: nil) } +] + { #category : 'accessing' } MTMessageSendArguments3rdNullifierOperatorTest >> operator [ diff --git a/src/MuTalk-Tests/MTMessageSendToYourselfOperatorTest.class.st b/src/MuTalk-Tests/MTMessageSendToYourselfOperatorTest.class.st index 6daf4027..270abda0 100644 --- a/src/MuTalk-Tests/MTMessageSendToYourselfOperatorTest.class.st +++ b/src/MuTalk-Tests/MTMessageSendToYourselfOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTMessageSendToYourselfOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTPredicateBasedMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } @@ -26,8 +26,9 @@ MTMessageSendToYourselfOperatorTest >> methodWithOneSenderModified [ { #category : 'accessing' } MTMessageSendToYourselfOperatorTest >> methodWithTwoSenders [ - | dict | -dict:= Dictionary new. dict at: 1 put: 2 + | dict | + dict := Dictionary new. + dict at: 1 put: 2 ] { #category : 'accessing' } @@ -46,6 +47,30 @@ MTMessageSendToYourselfOperatorTest >> methodWithTwoSendersModifiedSecond [ dict yourself ] +{ #category : 'accessing' } +MTMessageSendToYourselfOperatorTest >> newNodeOneSender [ + + ^ RBSequenceNode statements: { (RBMessageNode + receiver: (RBVariableNode named: #self) + selector: #yourself) } +] + +{ #category : 'accessing' } +MTMessageSendToYourselfOperatorTest >> newNodeTwoSendersFirst [ + + ^ RBSequenceNode statements: { (RBMessageNode + receiver: (RBVariableNode named: #Dictionary) + selector: #yourself) } +] + +{ #category : 'accessing' } +MTMessageSendToYourselfOperatorTest >> newNodeTwoSendersSecond [ + + ^ RBSequenceNode statements: { (RBMessageNode + receiver: (RBVariableNode named: #dict) + selector: #yourself) } +] + { #category : 'accessing' } MTMessageSendToYourselfOperatorTest >> operator [ diff --git a/src/MuTalk-Tests/MTMethodMutationTest.class.st b/src/MuTalk-Tests/MTMethodMutationTest.class.st index a35d508f..8c1b214d 100644 --- a/src/MuTalk-Tests/MTMethodMutationTest.class.st +++ b/src/MuTalk-Tests/MTMethodMutationTest.class.st @@ -69,14 +69,13 @@ MTMethodMutationTest >> testMutatedNodeBugFix [ MTMethodMutationTest >> testMutationInfiniteLoop [ | compiledMethod operator modifiedSource methodMutation res | - "This test will execute another test that will time out. So this test will need a higher time limit" self timeLimit: self defaultTimeLimit * 2. - + compiledMethod := MTFakeInfiniteLoopForTest >> #iterativeFactorial:. operator := MTReplaceLessOrEqualWithTrueOperator new. - + modifiedSource := operator modifiedSourceFor: compiledMethod number: 1. @@ -99,14 +98,13 @@ MTMethodMutationTest >> testMutationInfiniteLoop [ MTMethodMutationTest >> testMutationInfiniteRecursion [ | compiledMethod operator modifiedSource methodMutation res | - "This test will execute another test that will time out. So this test will need a higher time limit" self timeLimit: self defaultTimeLimit * 2. - + compiledMethod := MTFakeInfiniteLoopForTest >> #recursiveFactorial:. operator := MTReplaceIfTrueReceiverWithFalseOperator new. - + modifiedSource := operator modifiedSourceFor: compiledMethod number: 1. diff --git a/src/MuTalk-Tests/MTMutantOperatorTest.class.st b/src/MuTalk-Tests/MTMutantOperatorTest.class.st deleted file mode 100644 index 2611470a..00000000 --- a/src/MuTalk-Tests/MTMutantOperatorTest.class.st +++ /dev/null @@ -1,191 +0,0 @@ -Class { - #name : 'MTMutantOperatorTest', - #superclass : 'TestCase', - #category : 'MuTalk-Tests', - #package : 'MuTalk-Tests' -} - -{ #category : 'testing' } -MTMutantOperatorTest class >> isAbstract [ - - ^ self == MTMutantOperatorTest -] - -{ #category : 'accessing' } -MTMutantOperatorTest class >> packageNamesUnderTest [ - ^ #('MutationTesting-Model') -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertApplyingMutantToFirstSenderInOneSenderMethod [ - ^ self compareSource: - (self operator - modifiedSourceFor: self class >> #methodWithOneSender - number: 1) - withSourceInMethod: self class >> #methodWithOneSenderModified - replacingSelector: #methodWithOneSender -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertApplyingMutantToFirstSenderInTwoSendersMethod [ - ^self - compareSource: - (self operator - modifiedSourceFor: self class >> #methodWithTwoSenders - number: 1) - withSourceInMethod: self class >> #methodWithTwoSendersModifiedFirst - replacingSelector: #methodWithTwoSenders -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertApplyingMutantToNonSenderMethod [ - ^self - compareSource: - (self operator - modifiedSourceFor: self class >> #methodWithNoSenders - number: 1) - withSourceInMethod: self class >> #methodWithNoSenders - replacingSelector: #methodWithNoSenders -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertApplyingMutantToSecondSenderInTwoSendersMethod [ - ^self - compareSource: - (self operator - modifiedSourceFor: self class >> #methodWithTwoSenders - number: 2) - withSourceInMethod: self class >> #methodWithTwoSendersModifiedSecond - replacingSelector: #methodWithTwoSenders -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertNumberMutantsGeneratedForNonSenderMethod [ - |mutationsGenerated| - mutationsGenerated := self operator mutationsFor: self class >> #methodWithNoSenders. - ^mutationsGenerated size = 0. -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertNumberMutantsGeneratedForOneSenderMethod [ - |mutationsGenerated| - mutationsGenerated := self operator mutationsFor: self class >> #methodWithOneSender. - ^mutationsGenerated size = 1. -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertNumberMutantsGeneratedForTwoSendersMethod [ - |mutationsGenerated| - mutationsGenerated := self operator mutationsFor: self class >> #methodWithTwoSenders. - ^mutationsGenerated size = 2. -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertTimesToApplyOperatorInTwoSendersMethod [ - ^ (self operator timesToApplyIn: self class >> #methodWithTwoSenders) = 2 -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertTimesToApplyOperatorToNonSenderMethod [ - ^ (self operator timesToApplyIn: self class >> #methodWithNoSenders) = 0 -] - -{ #category : 'asserts' } -MTMutantOperatorTest >> assertTimesToApplyOperatorToOneSenderMethod [ - ^ (self operator timesToApplyIn: self class >> #methodWithOneSender) = 1 -] - -{ #category : 'formatting' } -MTMutantOperatorTest >> compareSource: aSource withSourceInMethod: aCompiledMethod replacingSelector: aSelector [ - "Compare both source replacing the selector of CompiledMethod for aSelector (to make then equal) - and formatting both sources equally." - - | sourceSelector secondString methodSelectorString secondStringModified | - sourceSelector := aSelector asString. - secondString := aCompiledMethod sourceCode asString. - methodSelectorString := aCompiledMethod selector asString. - secondStringModified := secondString - copyReplaceAll: methodSelectorString - with: sourceSelector. - ^ (self formattedStringFor: aSource) - = (self formattedStringFor: secondStringModified) -] - -{ #category : 'formatting' } -MTMutantOperatorTest >> formattedStringFor: aMethodString [ - ^ (RBParser parseMethod: aMethodString) formattedCode -] - -{ #category : 'accessing' } -MTMutantOperatorTest >> methodWithNoSenders [ - self subclassResponsibility -] - -{ #category : 'accessing' } -MTMutantOperatorTest >> methodWithOneSender [ - self subclassResponsibility -] - -{ #category : 'accessing' } -MTMutantOperatorTest >> methodWithOneSenderModified [ - - self subclassResponsibility -] - -{ #category : 'accessing' } -MTMutantOperatorTest >> methodWithTwoSenders [ - self subclassResponsibility -] - -{ #category : 'accessing' } -MTMutantOperatorTest >> methodWithTwoSendersModifiedFirst [ - - self subclassResponsibility -] - -{ #category : 'accessing' } -MTMutantOperatorTest >> methodWithTwoSendersModifiedSecond [ - - self subclassResponsibility -] - -{ #category : 'accessing' } -MTMutantOperatorTest >> operator [ - self subclassResponsibility -] - -{ #category : 'accessing' } -MTMutantOperatorTest >> operatorDescription [ - - ^ self operator description -] - -{ #category : 'tests' } -MTMutantOperatorTest >> testApplyMutantToMethod [ - self assert: self assertApplyingMutantToNonSenderMethod. - self assert: self assertApplyingMutantToFirstSenderInOneSenderMethod. - self assert: self assertApplyingMutantToFirstSenderInTwoSendersMethod. - self assert: self assertApplyingMutantToSecondSenderInTwoSendersMethod -] - -{ #category : 'tests' } -MTMutantOperatorTest >> testNumberMutantsGenerated [ - self assert: self assertNumberMutantsGeneratedForNonSenderMethod. - self assert: self assertNumberMutantsGeneratedForOneSenderMethod. - self assert: self assertNumberMutantsGeneratedForTwoSendersMethod -] - -{ #category : 'tests' } -MTMutantOperatorTest >> testPrintingAccessors [ - - self - assert: self operator description - equals: self operatorDescription -] - -{ #category : 'tests' } -MTMutantOperatorTest >> testTimesToApplyMutantToMethod [ - self assert: self assertTimesToApplyOperatorToNonSenderMethod. - self assert: self assertTimesToApplyOperatorToOneSenderMethod. - self assert: self assertTimesToApplyOperatorInTwoSendersMethod -] diff --git a/src/MuTalk-Tests/MTParseRewriterMutantOperatorTest.class.st b/src/MuTalk-Tests/MTParseRewriterMutantOperatorTest.class.st new file mode 100644 index 00000000..f976a9a6 --- /dev/null +++ b/src/MuTalk-Tests/MTParseRewriterMutantOperatorTest.class.st @@ -0,0 +1,100 @@ +Class { + #name : 'MTParseRewriterMutantOperatorTest', + #superclass : 'MTAbstractMutantOperatorTest', + #category : 'MuTalk-Tests', + #package : 'MuTalk-Tests' +} + +{ #category : 'testing' } +MTParseRewriterMutantOperatorTest class >> isAbstract [ + + ^ self == MTParseRewriterMutantOperatorTest +] + +{ #category : 'asserts' } +MTParseRewriterMutantOperatorTest >> assertApplyingMutantToFirstSenderInOneSenderMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: self class >> #methodWithOneSender + number: 1) + withSourceInMethod: self class >> #methodWithOneSenderModified + replacingSelector: #methodWithOneSender +] + +{ #category : 'asserts' } +MTParseRewriterMutantOperatorTest >> assertApplyingMutantToFirstSenderInTwoSendersMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: self class >> #methodWithTwoSenders + number: 1) + withSourceInMethod: + self class >> #methodWithTwoSendersModifiedFirst + replacingSelector: #methodWithTwoSenders +] + +{ #category : 'asserts' } +MTParseRewriterMutantOperatorTest >> assertApplyingMutantToNonSenderMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: self class >> #methodWithNoSenders + number: 1) + withSourceInMethod: self class >> #methodWithNoSenders + replacingSelector: #methodWithNoSenders +] + +{ #category : 'asserts' } +MTParseRewriterMutantOperatorTest >> assertApplyingMutantToSecondSenderInTwoSendersMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: self class >> #methodWithTwoSenders + number: 2) + withSourceInMethod: + self class >> #methodWithTwoSendersModifiedSecond + replacingSelector: #methodWithTwoSenders +] + +{ #category : 'accessing' } +MTParseRewriterMutantOperatorTest >> methodWithNoSenders [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTParseRewriterMutantOperatorTest >> methodWithOneSender [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTParseRewriterMutantOperatorTest >> methodWithOneSenderModified [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTParseRewriterMutantOperatorTest >> methodWithTwoSenders [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTParseRewriterMutantOperatorTest >> methodWithTwoSendersModifiedFirst [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTParseRewriterMutantOperatorTest >> methodWithTwoSendersModifiedSecond [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTParseRewriterMutantOperatorTest >> operator [ + + self subclassResponsibility +] diff --git a/src/MuTalk-Tests/MTPredicateBasedMutantOperatorTest.class.st b/src/MuTalk-Tests/MTPredicateBasedMutantOperatorTest.class.st new file mode 100644 index 00000000..3506e83b --- /dev/null +++ b/src/MuTalk-Tests/MTPredicateBasedMutantOperatorTest.class.st @@ -0,0 +1,122 @@ +Class { + #name : 'MTPredicateBasedMutantOperatorTest', + #superclass : 'MTAbstractMutantOperatorTest', + #category : 'MuTalk-Tests', + #package : 'MuTalk-Tests' +} + +{ #category : 'testing' } +MTPredicateBasedMutantOperatorTest class >> isAbstract [ + + ^ self == MTPredicateBasedMutantOperatorTest +] + +{ #category : 'asserts' } +MTPredicateBasedMutantOperatorTest >> assertApplyingMutantToFirstSenderInOneSenderMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: self class >> #methodWithOneSender + number: 1 + newExpression: self newNodeOneSender) + withSourceInMethod: self class >> #methodWithOneSenderModified + replacingSelector: #methodWithOneSender +] + +{ #category : 'asserts' } +MTPredicateBasedMutantOperatorTest >> assertApplyingMutantToFirstSenderInTwoSendersMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: self class >> #methodWithTwoSenders + number: 1 + newExpression: self newNodeTwoSendersFirst) + withSourceInMethod: + self class >> #methodWithTwoSendersModifiedFirst + replacingSelector: #methodWithTwoSenders +] + +{ #category : 'asserts' } +MTPredicateBasedMutantOperatorTest >> assertApplyingMutantToNonSenderMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: self class >> #methodWithNoSenders + number: 1 + newExpression: self newNodeOneSender) + withSourceInMethod: self class >> #methodWithNoSenders + replacingSelector: #methodWithNoSenders +] + +{ #category : 'asserts' } +MTPredicateBasedMutantOperatorTest >> assertApplyingMutantToSecondSenderInTwoSendersMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: self class >> #methodWithTwoSenders + number: 2 + newExpression: self newNodeTwoSendersSecond) + withSourceInMethod: + self class >> #methodWithTwoSendersModifiedSecond + replacingSelector: #methodWithTwoSenders +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> methodWithNoSenders [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> methodWithOneSender [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> methodWithOneSenderModified [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> methodWithTwoSenders [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> methodWithTwoSendersModifiedFirst [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> methodWithTwoSendersModifiedSecond [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> newNodeOneSender [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> newNodeTwoSendersFirst [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> newNodeTwoSendersSecond [ + + self subclassResponsibility +] + +{ #category : 'accessing' } +MTPredicateBasedMutantOperatorTest >> operator [ + + self subclassResponsibility +] diff --git a/src/MuTalk-Tests/MTRemoveAtIfAbsentMutantOperatorTest.class.st b/src/MuTalk-Tests/MTRemoveAtIfAbsentMutantOperatorTest.class.st index 632e8679..1d0ff847 100644 --- a/src/MuTalk-Tests/MTRemoveAtIfAbsentMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTRemoveAtIfAbsentMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTRemoveAtIfAbsentMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTRemoveCaretMutantOperatorTest.class.st b/src/MuTalk-Tests/MTRemoveCaretMutantOperatorTest.class.st index 9855741c..2ed5308e 100644 --- a/src/MuTalk-Tests/MTRemoveCaretMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTRemoveCaretMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTRemoveCaretMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTRemoveExceptionHandlerOperatorTest.class.st b/src/MuTalk-Tests/MTRemoveExceptionHandlerOperatorTest.class.st index 620ae54f..11ca1910 100644 --- a/src/MuTalk-Tests/MTRemoveExceptionHandlerOperatorTest.class.st +++ b/src/MuTalk-Tests/MTRemoveExceptionHandlerOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTRemoveExceptionHandlerOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceAndArgumentWithTrueOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceAndArgumentWithTrueOperatorTest.class.st index 5339b177..831a6bf6 100644 --- a/src/MuTalk-Tests/MTReplaceAndArgumentWithTrueOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceAndArgumentWithTrueOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceAndArgumentWithTrueOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceAndReceiverWithTrueOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceAndReceiverWithTrueOperatorTest.class.st index 8f075ec5..2e0e44b4 100644 --- a/src/MuTalk-Tests/MTReplaceAndReceiverWithTrueOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceAndReceiverWithTrueOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceAndReceiverWithTrueOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceAndWithEqvMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceAndWithEqvMutantOperatorTest.class.st index 2cac0e0e..adc7f3f5 100644 --- a/src/MuTalk-Tests/MTReplaceAndWithEqvMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceAndWithEqvMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceAndWithEqvMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceAndWithFalseMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceAndWithFalseMutantOperatorTest.class.st index ff3645c6..f06afa86 100644 --- a/src/MuTalk-Tests/MTReplaceAndWithFalseMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceAndWithFalseMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceAndWithFalseMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceAndWithNandMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceAndWithNandMutantOperatorTest.class.st index e7b5a8d5..58ddfc58 100644 --- a/src/MuTalk-Tests/MTReplaceAndWithNandMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceAndWithNandMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceAndWithNandMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceAndWithOrMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceAndWithOrMutantOperatorTest.class.st index d989386d..c2799be2 100644 --- a/src/MuTalk-Tests/MTReplaceAndWithOrMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceAndWithOrMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceAndWithOrMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperatorTest.class.st index d4e4d674..1d68b72f 100644 --- a/src/MuTalk-Tests/MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceDetectIfNoneFirstBlockWithAlwaysFalseBlockOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperatorTest.class.st index a2b3c652..2fd3b92b 100644 --- a/src/MuTalk-Tests/MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceDetectIfNoneFirstBlockWithAlwaysTrueBlockOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperatorTest.class.st index c39ffc7a..8f18c612 100644 --- a/src/MuTalk-Tests/MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceDetectIfNoneSecondBlockWithEmptyBlockOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceDoBlockWithEmptyBlockOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceDoBlockWithEmptyBlockOperatorTest.class.st index fc39de28..1c4c92aa 100644 --- a/src/MuTalk-Tests/MTReplaceDoBlockWithEmptyBlockOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceDoBlockWithEmptyBlockOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceDoBlockWithEmptyBlockOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceGreaterOrEqualWithEqualMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceGreaterOrEqualWithEqualMutantOperatorTest.class.st index 7f2d7f40..b1fe355c 100644 --- a/src/MuTalk-Tests/MTReplaceGreaterOrEqualWithEqualMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceGreaterOrEqualWithEqualMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceGreaterOrEqualWithEqualMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceGreaterOrEqualWithGreaterMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceGreaterOrEqualWithGreaterMutantOperatorTest.class.st index 50ef222a..c3a3fbd7 100644 --- a/src/MuTalk-Tests/MTReplaceGreaterOrEqualWithGreaterMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceGreaterOrEqualWithGreaterMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceGreaterOrEqualWithGreaterMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceIfFalseReceiverWithFalseOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceIfFalseReceiverWithFalseOperatorTest.class.st index d92b7092..377f920d 100644 --- a/src/MuTalk-Tests/MTReplaceIfFalseReceiverWithFalseOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceIfFalseReceiverWithFalseOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIfFalseReceiverWithFalseOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceIfFalseReceiverWithTrueOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceIfFalseReceiverWithTrueOperatorTest.class.st index cb243200..e772eeb9 100644 --- a/src/MuTalk-Tests/MTReplaceIfFalseReceiverWithTrueOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceIfFalseReceiverWithTrueOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIfFalseReceiverWithTrueOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceIfFalseWithIfTrueMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceIfFalseWithIfTrueMutantOperatorTest.class.st index cb6b9c9f..ca27c8c3 100644 --- a/src/MuTalk-Tests/MTReplaceIfFalseWithIfTrueMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceIfFalseWithIfTrueMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIfFalseWithIfTrueMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceIfTrueIfFalseReceiverWithFalseOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceIfTrueIfFalseReceiverWithFalseOperatorTest.class.st index 9259f4ae..b37a85d2 100644 --- a/src/MuTalk-Tests/MTReplaceIfTrueIfFalseReceiverWithFalseOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceIfTrueIfFalseReceiverWithFalseOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIfTrueIfFalseReceiverWithFalseOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceIfTrueIfFalseReceiverWithTrueOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceIfTrueIfFalseReceiverWithTrueOperatorTest.class.st index 07fbc0ff..feecfd08 100644 --- a/src/MuTalk-Tests/MTReplaceIfTrueIfFalseReceiverWithTrueOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceIfTrueIfFalseReceiverWithTrueOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIfTrueIfFalseReceiverWithTrueOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceIfTrueReceiverWithFalseOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceIfTrueReceiverWithFalseOperatorTest.class.st index e11c8443..a9b518f5 100644 --- a/src/MuTalk-Tests/MTReplaceIfTrueReceiverWithFalseOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceIfTrueReceiverWithFalseOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIfTrueReceiverWithFalseOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceIfTrueReceiverWithTrueOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceIfTrueReceiverWithTrueOperatorTest.class.st index 1231388a..6f8638c6 100644 --- a/src/MuTalk-Tests/MTReplaceIfTrueReceiverWithTrueOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceIfTrueReceiverWithTrueOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIfTrueReceiverWithTrueOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceIfTrueWithIfFalseMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceIfTrueWithIfFalseMutantOperatorTest.class.st index 9a53e74e..0767144e 100644 --- a/src/MuTalk-Tests/MTReplaceIfTrueWithIfFalseMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceIfTrueWithIfFalseMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIfTrueWithIfFalseMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceIsEmptyWithNotEmptyMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceIsEmptyWithNotEmptyMutantOperatorTest.class.st index c7a8257f..d9131b5e 100644 --- a/src/MuTalk-Tests/MTReplaceIsEmptyWithNotEmptyMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceIsEmptyWithNotEmptyMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceIsEmptyWithNotEmptyMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceLessOrEqualWithEqualMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceLessOrEqualWithEqualMutantOperatorTest.class.st index ee95a834..8956e066 100644 --- a/src/MuTalk-Tests/MTReplaceLessOrEqualWithEqualMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceLessOrEqualWithEqualMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceLessOrEqualWithEqualMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceLessOrEqualWithLessMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceLessOrEqualWithLessMutantOperatorTest.class.st index a9eb0eb5..c3dcb8ba 100644 --- a/src/MuTalk-Tests/MTReplaceLessOrEqualWithLessMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceLessOrEqualWithLessMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceLessOrEqualWithLessMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceMinusWithPlusMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceMinusWithPlusMutantOperatorTest.class.st index faec8ec5..a55fb959 100644 --- a/src/MuTalk-Tests/MTReplaceMinusWithPlusMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceMinusWithPlusMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceMinusWithPlusMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceOrArgumentWithFalseOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceOrArgumentWithFalseOperatorTest.class.st index 7c282ebd..70257123 100644 --- a/src/MuTalk-Tests/MTReplaceOrArgumentWithFalseOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceOrArgumentWithFalseOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceOrArgumentWithFalseOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceOrReceiverWithFalseOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceOrReceiverWithFalseOperatorTest.class.st index 12a23a8a..78b081ee 100644 --- a/src/MuTalk-Tests/MTReplaceOrReceiverWithFalseOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceOrReceiverWithFalseOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceOrReceiverWithFalseOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceOrWithAndMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceOrWithAndMutantOperatorTest.class.st index ea6121c0..e041f7e9 100644 --- a/src/MuTalk-Tests/MTReplaceOrWithAndMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceOrWithAndMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceOrWithAndMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceOrWithTrueOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceOrWithTrueOperatorTest.class.st index ad88a275..a1a58b1b 100644 --- a/src/MuTalk-Tests/MTReplaceOrWithTrueOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceOrWithTrueOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceOrWithTrueOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceOrWithXorMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceOrWithXorMutantOperatorTest.class.st index 8f72b74c..8e4c75ce 100644 --- a/src/MuTalk-Tests/MTReplaceOrWithXorMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceOrWithXorMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceOrWithXorMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplacePlusWithMinusMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplacePlusWithMinusMutantOperatorTest.class.st index 5c1ae6f7..cebdc9df 100644 --- a/src/MuTalk-Tests/MTReplacePlusWithMinusMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplacePlusWithMinusMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplacePlusWithMinusMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceRejectWithSelectMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceRejectWithSelectMutantOperatorTest.class.st index d87ccb20..7d740b09 100644 --- a/src/MuTalk-Tests/MTReplaceRejectWithSelectMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceRejectWithSelectMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceRejectWithSelectMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceSelectWithRejectMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceSelectWithRejectMutantOperatorTest.class.st index b5dbec27..e67cc4d7 100644 --- a/src/MuTalk-Tests/MTReplaceSelectWithRejectMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceSelectWithRejectMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceSelectWithRejectMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceWhileFalseReceiverWithFalseOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceWhileFalseReceiverWithFalseOperatorTest.class.st index 872745fa..c2b201a8 100644 --- a/src/MuTalk-Tests/MTReplaceWhileFalseReceiverWithFalseOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceWhileFalseReceiverWithFalseOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceWhileFalseReceiverWithFalseOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceWhileFalseReceiverWithTrueOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceWhileFalseReceiverWithTrueOperatorTest.class.st index b571ba7e..ad540308 100644 --- a/src/MuTalk-Tests/MTReplaceWhileFalseReceiverWithTrueOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceWhileFalseReceiverWithTrueOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceWhileFalseReceiverWithTrueOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceWhileFalseWithWhileTrueMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceWhileFalseWithWhileTrueMutantOperatorTest.class.st index c52ec0fc..247acd2b 100644 --- a/src/MuTalk-Tests/MTReplaceWhileFalseWithWhileTrueMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceWhileFalseWithWhileTrueMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceWhileFalseWithWhileTrueMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceWhileTrueReceiverWithFalseOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceWhileTrueReceiverWithFalseOperatorTest.class.st index 73372ab1..eff4a4b7 100644 --- a/src/MuTalk-Tests/MTReplaceWhileTrueReceiverWithFalseOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceWhileTrueReceiverWithFalseOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceWhileTrueReceiverWithFalseOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceWhileTrueReceiverWithTrueOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceWhileTrueReceiverWithTrueOperatorTest.class.st index 4f7d7e62..97118138 100644 --- a/src/MuTalk-Tests/MTReplaceWhileTrueReceiverWithTrueOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceWhileTrueReceiverWithTrueOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceWhileTrueReceiverWithTrueOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTReplaceWhileTrueWithWhileFalseMutantOperatorTest.class.st b/src/MuTalk-Tests/MTReplaceWhileTrueWithWhileFalseMutantOperatorTest.class.st index 8e82e18f..9ae9ea41 100644 --- a/src/MuTalk-Tests/MTReplaceWhileTrueWithWhileFalseMutantOperatorTest.class.st +++ b/src/MuTalk-Tests/MTReplaceWhileTrueWithWhileFalseMutantOperatorTest.class.st @@ -1,6 +1,6 @@ Class { #name : 'MTReplaceWhileTrueWithWhileFalseMutantOperatorTest', - #superclass : 'MTMutantOperatorTest', + #superclass : 'MTParseRewriterMutantOperatorTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } diff --git a/src/MuTalk-Tests/MTResource.class.st b/src/MuTalk-Tests/MTResource.class.st index 692c838c..54ec42bf 100644 --- a/src/MuTalk-Tests/MTResource.class.st +++ b/src/MuTalk-Tests/MTResource.class.st @@ -70,13 +70,15 @@ MTResource >> methodForBuildingMutant [ { #category : 'building-private' } MTResource >> mutation [ "Build Mock Object that simulates a Mutant" - | method | + + | method operator | method := self class >> #methodForBuildingMutant. + operator := MTReplacePlusWithMinusMutantOperator new. ^ MTMethodMutation - for: method - using: MTReplacePlusWithMinusMutantOperator new - nodeNumber: 1 - ofClass: self class + for: method + using: operator + nodeNumber: 1 + ofClass: self class ] { #category : 'running' } diff --git a/src/MuTalk-Tests/MTSubclassReplacementOperatorTest.class.st b/src/MuTalk-Tests/MTSubclassReplacementOperatorTest.class.st new file mode 100644 index 00000000..d87ca70d --- /dev/null +++ b/src/MuTalk-Tests/MTSubclassReplacementOperatorTest.class.st @@ -0,0 +1,179 @@ +Class { + #name : 'MTSubclassReplacementOperatorTest', + #superclass : 'MTPredicateBasedMutantOperatorTest', + #category : 'MuTalk-Tests', + #package : 'MuTalk-Tests' +} + +{ #category : 'asserts' } +MTSubclassReplacementOperatorTest >> assertApplyingMutantWithFirstSubclassInClassWithManySubclassesMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: + self class >> #methodUsingClassWithManySubclasses + number: 1 + newExpression: self newNodeFirstSubclass) + withSourceInMethod: + self class >> #methodUsingClassWithManySubclassesModifiedFirst + replacingSelector: #methodUsingClassWithManySubclasses +] + +{ #category : 'asserts' } +MTSubclassReplacementOperatorTest >> assertApplyingMutantWithSecondSubclassInClassWithManySubclassesMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: + self class >> #methodUsingClassWithManySubclasses + number: 1 + newExpression: self newNodeSecondSubclass) + withSourceInMethod: + self class >> #methodUsingClassWithManySubclassesModifiedSecond + replacingSelector: #methodUsingClassWithManySubclasses +] + +{ #category : 'asserts' } +MTSubclassReplacementOperatorTest >> assertApplyingMutantWithThirdSubclassInClassWithManySubclassesMethod [ + + ^ self + compareSource: (self operator + modifiedSourceFor: + self class >> #methodUsingClassWithManySubclasses + number: 1 + newExpression: self newNodeThirdSubclass) + withSourceInMethod: + self class >> #methodUsingClassWithManySubclassesModifiedThird + replacingSelector: #methodUsingClassWithManySubclasses +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodUsingClassWithManySubclasses [ + + | object | + object := MTAuxiliarClassForSubclassReplacementWithManySubclasses new +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodUsingClassWithManySubclassesModifiedFirst [ + + | object | + object := MTAuxiliarSubclass1ForSubclassReplacementWithManySubclasses new +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodUsingClassWithManySubclassesModifiedSecond [ + + | object | + object := MTAuxiliarSubclass2ForSubclassReplacementWithManySubclasses new +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodUsingClassWithManySubclassesModifiedThird [ + + | object | + object := MTAuxiliarSubclass3ForSubclassReplacementWithManySubclasses new +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodWithNoSenders [ + + ^ 1 + 2 +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodWithOneSender [ + + | object | + object := MTAuxiliarClassForSubclassReplacementOperator new +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodWithOneSenderModified [ + + | object | + object := MTAuxiliarSubclassForSubclassReplacementOperator new +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodWithTwoSenders [ + + | object | + object := MTAuxiliarClassForSubclassReplacementOperator new. + object := MTAuxiliarClassForSubclassReplacementOperatorBis new +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodWithTwoSendersModifiedFirst [ + + | object | + object := MTAuxiliarSubclassForSubclassReplacementOperator new. + object := MTAuxiliarClassForSubclassReplacementOperatorBis new +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> methodWithTwoSendersModifiedSecond [ + + | object | + object := MTAuxiliarClassForSubclassReplacementOperator new. + object := MTAuxiliarSubclassForSubclassReplacementOperatorBis new +] + +{ #category : 'asserts' } +MTSubclassReplacementOperatorTest >> newNodeFirstSubclass [ + + ^ RBVariableNode named: + MTAuxiliarSubclass1ForSubclassReplacementWithManySubclasses name +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> newNodeOneSender [ + + ^ RBVariableNode named: + MTAuxiliarSubclassForSubclassReplacementOperator name +] + +{ #category : 'asserts' } +MTSubclassReplacementOperatorTest >> newNodeSecondSubclass [ + + ^ RBVariableNode named: + MTAuxiliarSubclass2ForSubclassReplacementWithManySubclasses name +] + +{ #category : 'asserts' } +MTSubclassReplacementOperatorTest >> newNodeThirdSubclass [ + + ^ RBVariableNode named: + MTAuxiliarSubclass3ForSubclassReplacementWithManySubclasses name +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> newNodeTwoSendersFirst [ + + ^ RBVariableNode named: + MTAuxiliarSubclassForSubclassReplacementOperator name +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> newNodeTwoSendersSecond [ + + ^ RBVariableNode named: + MTAuxiliarSubclassForSubclassReplacementOperatorBis name +] + +{ #category : 'accessing' } +MTSubclassReplacementOperatorTest >> operator [ + + ^ MTSubclassReplacementOperator new +] + +{ #category : 'tests' } +MTSubclassReplacementOperatorTest >> testSubclassReplacementWithManySubclasses [ + + self assert: self + assertApplyingMutantWithFirstSubclassInClassWithManySubclassesMethod. + self assert: self + assertApplyingMutantWithSecondSubclassInClassWithManySubclassesMethod. + self assert: self + assertApplyingMutantWithThirdSubclassInClassWithManySubclassesMethod +] diff --git a/src/MuTalk-Utilities-Tests/MTMutantOperatorAnalysisTest.class.st b/src/MuTalk-Utilities-Tests/MTMutantOperatorAnalysisTest.class.st index 97ed1063..1113d537 100644 --- a/src/MuTalk-Utilities-Tests/MTMutantOperatorAnalysisTest.class.st +++ b/src/MuTalk-Utilities-Tests/MTMutantOperatorAnalysisTest.class.st @@ -22,7 +22,7 @@ MTMutantOperatorAnalysisTest >> testGetAllOperators [ | actual expected | actual := operatorAnalysis operatorsProducingAtLeast: 0. - expected := (MTMutantOperator contentsAll collect: #species) asSet. + expected := (MTAbstractMutantOperator contentsAll collect: #species) asSet. self assert: actual equals: expected ] @@ -45,7 +45,7 @@ MTMutantOperatorAnalysisTest >> testOperatorsProducingUnder [ | actual expected | actual := operatorAnalysis operatorsProducingAtMost: 2. - expected := (MTMutantOperator contentsAll collect: #species) asSet + expected := (MTAbstractMutantOperator contentsAll collect: #species) asSet reject: [ :operator | { MTLiteralIntegersIncreaseOperator. diff --git a/src/MuTalk-Utilities/MTMutantOperatorAnalysis.class.st b/src/MuTalk-Utilities/MTMutantOperatorAnalysis.class.st index 1acb1ed8..d558bb07 100644 --- a/src/MuTalk-Utilities/MTMutantOperatorAnalysis.class.st +++ b/src/MuTalk-Utilities/MTMutantOperatorAnalysis.class.st @@ -45,7 +45,7 @@ MTMutantOperatorAnalysis >> operatorDictionaryFromAnalysis [ analysis := MTAnalysis new classesToMutate: classes; testClasses: { }; - operators: MTMutantOperator contentsAll. + operators: MTAbstractMutantOperator contentsAll. analysis generateMutations. @@ -75,7 +75,7 @@ MTMutantOperatorAnalysis >> operatorsSelectedWith: aBlock [ MTMutantOperatorAnalysis >> operatorsWithoutMutantsFor: aDictionary [ | operatorsWithoutMutants | - operatorsWithoutMutants := (MTMutantOperator contentsAll collect: + operatorsWithoutMutants := (MTAbstractMutantOperator contentsAll collect: #species) reject: [ :ope | aDictionary keys includes: ope ]. diff --git a/src/MuTalk-Utilities/MTNonMutatedMethodsAnalysis.class.st b/src/MuTalk-Utilities/MTNonMutatedMethodsAnalysis.class.st index 9243c414..5a003599 100644 --- a/src/MuTalk-Utilities/MTNonMutatedMethodsAnalysis.class.st +++ b/src/MuTalk-Utilities/MTNonMutatedMethodsAnalysis.class.st @@ -30,7 +30,7 @@ MTNonMutatedMethodsAnalysis >> mutatedMethods [ analysis := MTAnalysis new classesToMutate: classes; testClasses: { }; - operators: MTMutantOperator contentsAll. + operators: MTAbstractMutantOperator contentsAll. mutatedMethods := Set withAll: (analysis generateMutations collect: