Skip to content

Commit 99dbb03

Browse files
author
Durieux Pol
committed
refactoring tests
1 parent b73cad7 commit 99dbb03

4 files changed

+78
-48
lines changed

src/MuTalk-Tests/MTMethodMutationTest.class.st

+24-16
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ MTMethodMutationTest >> testAccessing [
1919
operator := MTReplacePlusWithMinusMutantOperator new.
2020
modifiedSource := operator
2121
modifiedSourceFor: compiledMethod
22-
number: 1.
22+
number: 1
23+
newExpression: operator newExpression.
2324
methodMutation := MTMethodMutation
2425
for: compiledMethod
2526
using: operator
2627
nodeNumber: 1
27-
ofClass: MTAuxiliarClassForMTAnalysis.
28+
ofClass: MTAuxiliarClassForMTAnalysis
29+
replacingWith: operator newExpression.
2830
self
2931
assert: methodMutation originalSource
3032
equals: compiledMethod sourceCode asString.
@@ -43,12 +45,14 @@ MTMethodMutationTest >> testAccessingToNodes [
4345
operator := MTReplacePlusWithMinusMutantOperator new.
4446
modifiedSource := operator
4547
modifiedSourceFor: compiledMethod
46-
number: 1.
48+
number: 1
49+
newExpression: operator newExpression.
4750
methodMutation := MTMethodMutation
4851
for: compiledMethod
4952
using: operator
5053
nodeNumber: 1
51-
ofClass: MTAuxiliarClassForMTAnalysis.
54+
ofClass: MTAuxiliarClassForMTAnalysis
55+
replacingWith: operator newExpression.
5256
self
5357
assert: methodMutation nodeToMutate formattedCode
5458
equals: '1 + 2'.
@@ -69,22 +73,23 @@ MTMethodMutationTest >> testMutatedNodeBugFix [
6973
MTMethodMutationTest >> testMutationInfiniteLoop [
7074

7175
| compiledMethod operator modifiedSource methodMutation res |
72-
7376
"This test will execute another test that will time out.
7477
So this test will need a higher time limit"
7578
self timeLimit: self defaultTimeLimit * 2.
76-
79+
7780
compiledMethod := MTFakeInfiniteLoopForTest >> #iterativeFactorial:.
7881
operator := MTReplaceLessOrEqualWithTrueOperator new.
79-
82+
8083
modifiedSource := operator
8184
modifiedSourceFor: compiledMethod
82-
number: 1.
85+
number: 1
86+
newExpression: operator newExpression.
8387
methodMutation := MTMethodMutation
8488
for: compiledMethod
8589
using: operator
8690
nodeNumber: 1
87-
ofClass: MTFakeInfiniteLoopForTest.
91+
ofClass: MTFakeInfiniteLoopForTest
92+
replacingWith: operator newExpression.
8893

8994
methodMutation testCaseReferences: { (MTTestCaseReference
9095
for: #testIterativeFactorial
@@ -99,22 +104,23 @@ MTMethodMutationTest >> testMutationInfiniteLoop [
99104
MTMethodMutationTest >> testMutationInfiniteRecursion [
100105

101106
| compiledMethod operator modifiedSource methodMutation res |
102-
103107
"This test will execute another test that will time out.
104108
So this test will need a higher time limit"
105109
self timeLimit: self defaultTimeLimit * 2.
106-
110+
107111
compiledMethod := MTFakeInfiniteLoopForTest >> #recursiveFactorial:.
108112
operator := MTReplaceIfTrueReceiverWithFalseOperator new.
109-
113+
110114
modifiedSource := operator
111115
modifiedSourceFor: compiledMethod
112-
number: 1.
116+
number: 1
117+
newExpression: operator newExpression.
113118
methodMutation := MTMethodMutation
114119
for: compiledMethod
115120
using: operator
116121
nodeNumber: 1
117-
ofClass: MTFakeInfiniteLoopForTest.
122+
ofClass: MTFakeInfiniteLoopForTest
123+
replacingWith: operator newExpression.
118124

119125
methodMutation testCaseReferences: { (MTTestCaseReference
120126
for: #testRecursiveFactorial
@@ -134,12 +140,14 @@ MTMethodMutationTest >> testMutationRun [
134140
operator := MTReplacePlusWithMinusMutantOperator new.
135141
modifiedSource := operator
136142
modifiedSourceFor: compiledMethod
137-
number: 1.
143+
number: 1
144+
newExpression: operator newExpression.
138145
methodMutation := MTMethodMutation
139146
for: compiledMethod
140147
using: operator
141148
nodeNumber: 1
142-
ofClass: MTAuxiliarClassForMTAnalysis.
149+
ofClass: MTAuxiliarClassForMTAnalysis
150+
replacingWith: operator newExpression.
143151
methodMutation testCaseReferences:
144152
{ (MTTestCaseReference for: #simpleTestCaseRessource in: self class) }.
145153
res := methodMutation runMutantStoppingOnError: true.

src/MuTalk-Tests/MTMutantOperatorTest.class.st

+34-27
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,52 @@ MTMutantOperatorTest class >> packageNamesUnderTest [
1818

1919
{ #category : 'asserts' }
2020
MTMutantOperatorTest >> assertApplyingMutantToFirstSenderInOneSenderMethod [
21-
^ self compareSource:
22-
(self operator
23-
modifiedSourceFor: self class >> #methodWithOneSender
24-
number: 1)
25-
withSourceInMethod: self class >> #methodWithOneSenderModified
26-
replacingSelector: #methodWithOneSender
21+
22+
^ self
23+
compareSource: (self operator
24+
modifiedSourceFor: self class >> #methodWithOneSender
25+
number: 1
26+
newExpression: self operator newExpression)
27+
withSourceInMethod: self class >> #methodWithOneSenderModified
28+
replacingSelector: #methodWithOneSender
2729
]
2830

2931
{ #category : 'asserts' }
3032
MTMutantOperatorTest >> assertApplyingMutantToFirstSenderInTwoSendersMethod [
31-
^self
32-
compareSource:
33-
(self operator
34-
modifiedSourceFor: self class >> #methodWithTwoSenders
35-
number: 1)
36-
withSourceInMethod: self class >> #methodWithTwoSendersModifiedFirst
37-
replacingSelector: #methodWithTwoSenders
33+
34+
^ self
35+
compareSource: (self operator
36+
modifiedSourceFor: self class >> #methodWithTwoSenders
37+
number: 1
38+
newExpression: self operator newExpression)
39+
withSourceInMethod:
40+
self class >> #methodWithTwoSendersModifiedFirst
41+
replacingSelector: #methodWithTwoSenders
3842
]
3943

4044
{ #category : 'asserts' }
4145
MTMutantOperatorTest >> assertApplyingMutantToNonSenderMethod [
42-
^self
43-
compareSource:
44-
(self operator
45-
modifiedSourceFor: self class >> #methodWithNoSenders
46-
number: 1)
47-
withSourceInMethod: self class >> #methodWithNoSenders
48-
replacingSelector: #methodWithNoSenders
46+
47+
^ self
48+
compareSource: (self operator
49+
modifiedSourceFor: self class >> #methodWithNoSenders
50+
number: 1
51+
newExpression: self operator newExpression)
52+
withSourceInMethod: self class >> #methodWithNoSenders
53+
replacingSelector: #methodWithNoSenders
4954
]
5055

5156
{ #category : 'asserts' }
5257
MTMutantOperatorTest >> assertApplyingMutantToSecondSenderInTwoSendersMethod [
53-
^self
54-
compareSource:
55-
(self operator
56-
modifiedSourceFor: self class >> #methodWithTwoSenders
57-
number: 2)
58-
withSourceInMethod: self class >> #methodWithTwoSendersModifiedSecond
59-
replacingSelector: #methodWithTwoSenders
58+
59+
^ self
60+
compareSource: (self operator
61+
modifiedSourceFor: self class >> #methodWithTwoSenders
62+
number: 2
63+
newExpression: self operator newExpression)
64+
withSourceInMethod:
65+
self class >> #methodWithTwoSendersModifiedSecond
66+
replacingSelector: #methodWithTwoSenders
6067
]
6168

6269
{ #category : 'asserts' }

src/MuTalk-Tests/MTResource.class.st

+8-5
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ MTResource >> methodForBuildingMutant [
7070
{ #category : 'building-private' }
7171
MTResource >> mutation [
7272
"Build Mock Object that simulates a Mutant"
73-
| method |
73+
74+
| method operator |
7475
method := self class >> #methodForBuildingMutant.
76+
operator := MTReplacePlusWithMinusMutantOperator new.
7577
^ MTMethodMutation
76-
for: method
77-
using: MTReplacePlusWithMinusMutantOperator new
78-
nodeNumber: 1
79-
ofClass: self class
78+
for: method
79+
using: operator
80+
nodeNumber: 1
81+
ofClass: self class
82+
replacingWith: operator newExpression
8083
]
8184

8285
{ #category : 'running' }

src/MuTalk-Tests/MTSubclassReplacementOperatorTest.class.st

+12
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ MTSubclassReplacementOperatorTest >> assertApplyingMutantToFirstSenderInTwoSende
3030
replacingSelector: #methodWithTwoSenders
3131
]
3232

33+
{ #category : 'asserts' }
34+
MTSubclassReplacementOperatorTest >> assertApplyingMutantToNonSenderMethod [
35+
36+
^ self
37+
compareSource: (self operator
38+
modifiedSourceFor: self class >> #methodWithNoSenders
39+
number: 1
40+
newExpression: self newExpression)
41+
withSourceInMethod: self class >> #methodWithNoSenders
42+
replacingSelector: #methodWithNoSenders
43+
]
44+
3345
{ #category : 'asserts' }
3446
MTSubclassReplacementOperatorTest >> assertApplyingMutantToSecondSenderInTwoSendersMethod [
3547

0 commit comments

Comments
 (0)