Skip to content

Commit

Permalink
start refactoring predicates, mutations are not applied
Browse files Browse the repository at this point in the history
  • Loading branch information
Durieux Pol committed Feb 9, 2024
1 parent e20557f commit 4b2e2ea
Show file tree
Hide file tree
Showing 37 changed files with 233 additions and 234 deletions.
51 changes: 22 additions & 29 deletions src/MuTalk-Model/MTAbstractMutantOperator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ MTAbstractMutantOperator >> modifiedSourceFor: aCompiledMethod with: aParseTree
self subclassResponsibility
]

{ #category : 'private' }
MTAbstractMutantOperator >> mutationFor: aCompiledMethod with: aParseTree number: aNumberOfSelector storeIn: aCollection [

aCollection add: (MTMethodMutation
for: aCompiledMethod
using: self
nodeNumber: aNumberOfSelector
ofClass: aCompiledMethod methodClass).
^ aCollection
]

{ #category : 'mutant generation' }
MTAbstractMutantOperator >> mutationsFor: aCompiledMethod [

Expand All @@ -118,29 +107,33 @@ MTAbstractMutantOperator >> mutationsFor: aCompiledMethod [
{ #category : 'mutant generation' }
MTAbstractMutantOperator >> 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)
| numberOfAffectedNodes |
((aCompiledMethod hasPragmaNamed: #ignoreForMutations) or: [
aCompiledMethod hasPragmaNamed: #ignoreForCoverage ]) ifTrue: [
^ #( ) ].

numberOfAffectedNodes := self
timesToApplyIn: aCompiledMethod
with: aParseTree.
^ (1 to: numberOfAffectedNodes)
inject: OrderedCollection new
into: [ :collection :aNumberOfSelector |
into: [ :accumulator :nodeIndex |
self
mutationFor: aCompiledMethod
mutationsFor: aCompiledMethod
with: aParseTree
number: aNumberOfSelector
storeIn: collection ]
number: nodeIndex
storeIn: accumulator ]
]

{ #category : 'applying' }
MTAbstractMutantOperator >> newExpression [
self subclassResponsibility
{ #category : 'private' }
MTAbstractMutantOperator >> mutationsFor: aCompiledMethod with: aParseTree number: aNumberOfSelector storeIn: aCollection [

aCollection add: (MTMethodMutation
for: aCompiledMethod
using: self
nodeNumber: aNumberOfSelector
ofClass: aCompiledMethod methodClass).
^ aCollection
]

{ #category : 'suggestions' }
Expand Down
14 changes: 7 additions & 7 deletions src/MuTalk-Model/MTAssignmentNullifierOperator.class.st
Original file line number Diff line number Diff line change
@@ -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 [

Expand All @@ -21,9 +27,3 @@ MTAssignmentNullifierOperator >> newExpression [
nodeCopy value: (RBLiteralValueNode value: nil).
nodeCopy ]
]

{ #category : 'applying' }
MTAssignmentNullifierOperator >> nodeSelectionPredicate [

^ [ :aNode | aNode isAssignment & aNode value isNotNil ]
]
54 changes: 0 additions & 54 deletions src/MuTalk-Model/MTBlockBasedMutantOperator.class.st

This file was deleted.

15 changes: 7 additions & 8 deletions src/MuTalk-Model/MTEmptyMethodOperator.class.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
Class {
#name : 'MTEmptyMethodOperator',
#superclass : 'MTBlockBasedMutantOperator',
#superclass : 'MTPredicateBasedMutantOperator',
#category : 'MuTalk-Model-Operators',
#package : 'MuTalk-Model',
#tag : 'Operators'
}

{ #category : 'applying' }
MTEmptyMethodOperator >> appliesToNode: aNode [

^ aNode isSequence and: [ aNode parent isMethod ]
]

{ #category : 'printing' }
MTEmptyMethodOperator >> description [

Expand All @@ -17,10 +23,3 @@ MTEmptyMethodOperator >> newExpression [

^ [ :anOldNode | RBSequenceNode statements: #() ]
]

{ #category : 'applying' }
MTEmptyMethodOperator >> nodeSelectionPredicate [

^ [ :aNode |
aNode isSequence and: [ aNode parent isMethod] ]
]
17 changes: 8 additions & 9 deletions src/MuTalk-Model/MTLiteralBooleanNegateOperator.class.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Class {
#name : 'MTLiteralBooleanNegateOperator',
#superclass : 'MTBlockBasedMutantOperator',
#superclass : 'MTPredicateBasedMutantOperator',
#category : 'MuTalk-Model-Operators',
#package : 'MuTalk-Model',
#tag : 'Operators'
}

{ #category : 'applying' }
MTLiteralBooleanNegateOperator >> appliesToNode: aNode [

^ aNode isLiteralNode & aNode isLiteralArray not and: [
{ true. false } includes: aNode value ]
]

{ #category : 'printing' }
MTLiteralBooleanNegateOperator >> description [

Expand All @@ -17,11 +24,3 @@ MTLiteralBooleanNegateOperator >> newExpression [

^ [ :anOldNode | RBLiteralValueNode value: anOldNode value not ]
]

{ #category : 'applying' }
MTLiteralBooleanNegateOperator >> nodeSelectionPredicate [

^ [ :aNode |
aNode isLiteralNode & aNode isLiteralArray not and: [
{ true. false } includes: aNode value ] ]
]
15 changes: 8 additions & 7 deletions src/MuTalk-Model/MTLiteralIntegersDecreaseOperator.class.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Class {
#name : 'MTLiteralIntegersDecreaseOperator',
#superclass : 'MTBlockBasedMutantOperator',
#superclass : 'MTPredicateBasedMutantOperator',
#category : 'MuTalk-Model-Operators',
#package : 'MuTalk-Model',
#tag : 'Operators'
}

{ #category : 'applying' }
MTLiteralIntegersDecreaseOperator >> appliesToNode: aNode [

^ aNode isLiteralNode & aNode isLiteralArray not and: [
aNode value isInteger ]
]

{ #category : 'printing' }
MTLiteralIntegersDecreaseOperator >> description [

Expand All @@ -17,9 +24,3 @@ MTLiteralIntegersDecreaseOperator >> newExpression [

^ [ :anOldNode | RBLiteralValueNode value: anOldNode value - 1 ]
]

{ #category : 'applying' }
MTLiteralIntegersDecreaseOperator >> nodeSelectionPredicate [

^ [ :aNode | aNode isLiteralNode & aNode isLiteralArray not and: [ aNode value isInteger ] ]
]
15 changes: 8 additions & 7 deletions src/MuTalk-Model/MTLiteralIntegersIncreaseOperator.class.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Class {
#name : 'MTLiteralIntegersIncreaseOperator',
#superclass : 'MTBlockBasedMutantOperator',
#superclass : 'MTPredicateBasedMutantOperator',
#category : 'MuTalk-Model-Operators',
#package : 'MuTalk-Model',
#tag : 'Operators'
}

{ #category : 'applying' }
MTLiteralIntegersIncreaseOperator >> appliesToNode: aNode [

^ aNode isLiteralNode & aNode isLiteralArray not and: [
aNode value isInteger ]
]

{ #category : 'printing' }
MTLiteralIntegersIncreaseOperator >> description [

Expand All @@ -17,9 +24,3 @@ MTLiteralIntegersIncreaseOperator >> newExpression [

^ [ :anOldNode | RBLiteralValueNode value: anOldNode value + 1 ]
]

{ #category : 'applying' }
MTLiteralIntegersIncreaseOperator >> nodeSelectionPredicate [

^ [ :aNode | aNode isLiteralNode & aNode isLiteralArray not and: [ aNode value isInteger ] ]
]
17 changes: 8 additions & 9 deletions src/MuTalk-Model/MTLiteralIntegersToZeroOperator.class.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Class {
#name : 'MTLiteralIntegersToZeroOperator',
#superclass : 'MTBlockBasedMutantOperator',
#superclass : 'MTPredicateBasedMutantOperator',
#category : 'MuTalk-Model-Operators',
#package : 'MuTalk-Model',
#tag : 'Operators'
}

{ #category : 'applying' }
MTLiteralIntegersToZeroOperator >> appliesToNode: aNode [

^ aNode isLiteralNode & aNode isLiteralArray not and: [
aNode value isInteger and: [ aNode value isZero not ] ]
]

{ #category : 'printing' }
MTLiteralIntegersToZeroOperator >> description [

Expand All @@ -17,11 +24,3 @@ MTLiteralIntegersToZeroOperator >> newExpression [

^ [ :anOldNode | RBLiteralValueNode value: 0 ]
]

{ #category : 'applying' }
MTLiteralIntegersToZeroOperator >> nodeSelectionPredicate [

^ [ :aNode |
aNode isLiteralNode & aNode isLiteralArray not and: [
aNode value isInteger and: [aNode value isZero not] ] ]
]
17 changes: 8 additions & 9 deletions src/MuTalk-Model/MTLiteralStringChangeOperator.class.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Class {
#name : 'MTLiteralStringChangeOperator',
#superclass : 'MTBlockBasedMutantOperator',
#superclass : 'MTPredicateBasedMutantOperator',
#category : 'MuTalk-Model-Operators',
#package : 'MuTalk-Model',
#tag : 'Operators'
}

{ #category : 'applying' }
MTLiteralStringChangeOperator >> appliesToNode: aNode [

^ aNode isLiteralNode & aNode isLiteralArray not and: [
aNode value isString and: [ aNode value ~= self stringReplaced ] ]
]

{ #category : 'printing' }
MTLiteralStringChangeOperator >> description [

Expand All @@ -18,14 +25,6 @@ MTLiteralStringChangeOperator >> newExpression [
^ [ :anOldNode | RBLiteralValueNode value: self stringReplaced ]
]

{ #category : 'applying' }
MTLiteralStringChangeOperator >> nodeSelectionPredicate [

^ [ :aNode |
aNode isLiteralNode & aNode isLiteralArray not and: [
aNode value isString and: [ aNode value ~= self stringReplaced ] ] ]
]

{ #category : 'applying' }
MTLiteralStringChangeOperator >> stringReplaced [
^ 'rAnDoM-MuTalk-StRiNg'
Expand Down
17 changes: 8 additions & 9 deletions src/MuTalk-Model/MTLiteralStringToEmptyOperator.class.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Class {
#name : 'MTLiteralStringToEmptyOperator',
#superclass : 'MTBlockBasedMutantOperator',
#superclass : 'MTPredicateBasedMutantOperator',
#category : 'MuTalk-Model-Operators',
#package : 'MuTalk-Model',
#tag : 'Operators'
}

{ #category : 'applying' }
MTLiteralStringToEmptyOperator >> appliesToNode: aNode [

^ aNode isLiteralNode & aNode isLiteralArray not and: [
aNode value isString and: [ aNode value isNotEmpty ] ]
]

{ #category : 'printing' }
MTLiteralStringToEmptyOperator >> description [

Expand All @@ -17,11 +24,3 @@ MTLiteralStringToEmptyOperator >> newExpression [

^ [ :anOldNode | RBLiteralValueNode value: '' ]
]

{ #category : 'applying' }
MTLiteralStringToEmptyOperator >> nodeSelectionPredicate [

^ [ :aNode |
aNode isLiteralNode & aNode isLiteralArray not and: [
aNode value isString and: [aNode value isNotEmpty ] ] ]
]
Loading

0 comments on commit 4b2e2ea

Please sign in to comment.