forked from pharo-contributions/mutalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMTAbstractMutantOperator.class.st
149 lines (112 loc) · 4.03 KB
/
MTAbstractMutantOperator.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Class {
#name : 'MTAbstractMutantOperator',
#superclass : 'Object',
#category : 'MuTalk-Model-Operators - Abstract',
#package : 'MuTalk-Model',
#tag : 'Operators - Abstract'
}
{ #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
]