forked from pharo-contributions/mutalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pharo-contributions#70 from DurieuxPol/feat/utilities
Imported MuTalk-Utilities
- Loading branch information
Showing
11 changed files
with
577 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Package { #name : #BaselineOfMuTalk } | ||
Package { #name : 'BaselineOfMuTalk' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/MuTalk-Utilities-Tests/MTAuxiliarClassForMatrix.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Class { | ||
#name : 'MTAuxiliarClassForMatrix', | ||
#superclass : 'Object', | ||
#instVars : [ | ||
'counter' | ||
], | ||
#category : 'MuTalk-Utilities-Tests', | ||
#package : 'MuTalk-Utilities-Tests' | ||
} | ||
|
||
{ #category : 'initialization' } | ||
MTAuxiliarClassForMatrix >> initialize [ | ||
|
||
super initialize. | ||
counter := 0 | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTAuxiliarClassForMatrix >> minus: aNumber [ | ||
|
||
counter := counter - aNumber. | ||
^ self reset | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTAuxiliarClassForMatrix >> plus: aNumber [ | ||
|
||
counter := counter + aNumber. | ||
^ self reset | ||
] | ||
|
||
{ #category : 'resetting' } | ||
MTAuxiliarClassForMatrix >> reset [ | ||
|
||
| count | | ||
count := counter. | ||
counter := 0. | ||
^ count | ||
] |
28 changes: 28 additions & 0 deletions
28
src/MuTalk-Utilities-Tests/MTAuxiliarClassForMatrixTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Class { | ||
#name : 'MTAuxiliarClassForMatrixTest', | ||
#superclass : 'TestCase', | ||
#instVars : [ | ||
'obj' | ||
], | ||
#category : 'MuTalk-Utilities-Tests', | ||
#package : 'MuTalk-Utilities-Tests' | ||
} | ||
|
||
{ #category : 'running' } | ||
MTAuxiliarClassForMatrixTest >> setUp [ | ||
|
||
super setUp. | ||
obj := MTAuxiliarClassForMatrix new | ||
] | ||
|
||
{ #category : 'running' } | ||
MTAuxiliarClassForMatrixTest >> testMinus [ | ||
|
||
self assert: (obj minus: 10) equals: -10 | ||
] | ||
|
||
{ #category : 'running' } | ||
MTAuxiliarClassForMatrixTest >> testPlus [ | ||
|
||
self assert: (obj plus: 10) equals: 10 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
Class { | ||
#name : 'MTMatrixTest', | ||
#superclass : 'TestCase', | ||
#instVars : [ | ||
'matrix', | ||
'trivialMutant', | ||
'equivalentMutants', | ||
'includedMutants' | ||
], | ||
#category : 'MuTalk-Utilities-Tests', | ||
#package : 'MuTalk-Utilities-Tests' | ||
} | ||
|
||
{ #category : 'running' } | ||
MTMatrixTest >> setUp [ | ||
|
||
super setUp. | ||
matrix := MTMatrix forAClass: MTAuxiliarClassForMatrix. | ||
matrix build. | ||
self setUpVariablesForTest | ||
] | ||
|
||
{ #category : 'initialization' } | ||
MTMatrixTest >> setUpVariablesForTest [ | ||
|
||
| mutations minusMutants plusMutants | | ||
mutations := matrix analysis mutations. | ||
minusMutants := Set withAll: (mutations select: [ :mut | | ||
mut originalMethod | ||
= (MTAuxiliarClassForMatrix >> #minus:) ]). | ||
plusMutants := Set withAll: (mutations select: [ :mut | | ||
mut originalMethod | ||
= (MTAuxiliarClassForMatrix >> #plus:) ]). | ||
trivialMutant := Array with: | ||
(matrix analysis mutations detect: [ :mut | | ||
mut originalMethod | ||
= (MTAuxiliarClassForMatrix >> #reset) ]). | ||
equivalentMutants := Set with: minusMutants with: plusMutants. | ||
includedMutants := Dictionary new. | ||
mutations do: [ :mutant | | ||
mutant originalMethod = (MTAuxiliarClassForMatrix >> #minus:) | ||
ifTrue: [ includedMutants at: mutant put: minusMutants ]. | ||
mutant originalMethod = (MTAuxiliarClassForMatrix >> #plus:) | ||
ifTrue: [ includedMutants at: mutant put: plusMutants ]. | ||
mutant originalMethod = (MTAuxiliarClassForMatrix >> #reset) | ||
ifTrue: [ includedMutants at: mutant put: mutations asSet ] ] | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTMatrixTest >> testEqualBooleanCollections [ | ||
|
||
| a1 a2 a3 a4 | | ||
a1 := #( false false true true true false ). | ||
a2 := #( false false true true true false ). | ||
a3 := #( false false true true false false ). | ||
a4 := #( false true true false ). | ||
|
||
self assert: | ||
(matrix booleanCollection1: a1 equalsBooleanCollection2: a2). | ||
self deny: | ||
(matrix booleanCollection1: a1 equalsBooleanCollection2: a3). | ||
self deny: | ||
(matrix booleanCollection1: a1 equalsBooleanCollection2: a4) | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTMatrixTest >> testEquivalentMutants [ | ||
|
||
self assert: matrix equivalentMutants equals: equivalentMutants | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTMatrixTest >> testIncludeBooleanCollections [ | ||
|
||
| a1 a2 a3 a4 a5 | | ||
a1 := #( false false true true true false ). | ||
a2 := #( false false true true true false ). | ||
a3 := #( false false true false false false ). | ||
a4 := #( true false true true false false ). | ||
a5 := #( false true true false ). | ||
|
||
self assert: | ||
(matrix booleanCollection1: a1 includesBooleanCollection2: a2). | ||
self assert: | ||
(matrix booleanCollection1: a1 includesBooleanCollection2: a3). | ||
self deny: | ||
(matrix booleanCollection1: a1 includesBooleanCollection2: a4). | ||
self deny: | ||
(matrix booleanCollection1: a1 includesBooleanCollection2: a5). | ||
self deny: | ||
(matrix booleanCollection1: a3 includesBooleanCollection2: a1) | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTMatrixTest >> testIncludedMutants [ | ||
|
||
self assert: matrix includedMutants equals: includedMutants | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTMatrixTest >> testTrivialMutants [ | ||
|
||
self assert: matrix trivialMutants equals: trivialMutant | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package { #name : 'MuTalk-Utilities-Tests' } |
Oops, something went wrong.