Skip to content

Commit

Permalink
Merge pull request pharo-contributions#70 from DurieuxPol/feat/utilities
Browse files Browse the repository at this point in the history
Imported MuTalk-Utilities
  • Loading branch information
guillep authored Jan 25, 2024
2 parents 60f05cc + 1c9bab3 commit 70148a1
Show file tree
Hide file tree
Showing 11 changed files with 577 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/BaselineOfMuTalk/BaselineOfMuTalk.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Class {
#name : #BaselineOfMuTalk,
#superclass : #BaselineOf,
#category : #BaselineOfMuTalk
#name : 'BaselineOfMuTalk',
#superclass : 'BaselineOf',
#category : 'BaselineOfMuTalk',
#package : 'BaselineOfMuTalk'
}

{ #category : #baselines }
{ #category : 'baselines' }
BaselineOfMuTalk >> baseline: spec [
<baseline>

Expand All @@ -16,11 +17,13 @@ BaselineOfMuTalk >> baseline: spec [
package: 'MuTalk-CI' with: [ spec requires: #( 'MuTalk-Model' ) ];
package: 'MuTalk-CI-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-CI' ) ];
package: 'MuTalk-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-TestResources' ) ];
package: 'MuTalk-SpecUI' with: [ spec requires: #('MuTalk-Model') ].
package: 'MuTalk-SpecUI' with: [ spec requires: #('MuTalk-Model') ];
package: 'MuTalk-Utilities' with: [ spec requires: #( 'MuTalk-Model' ) ];
package: 'MuTalk-Utilities-Tests' with: [ spec requires: #( 'MuTalk-Model' 'MuTalk-Utilities' ) ].

spec
group: 'default'
with:
#( 'TestCoverage' 'MuTalk-Model' 'MuTalk-TestResources' 'MuTalk-Tests'
'MuTalk-CI' 'MuTalk-CI-Tests' 'MuTalk-SpecUI' ) ]
'MuTalk-CI' 'MuTalk-CI-Tests' 'MuTalk-SpecUI' 'MuTalk-Utilities' 'MuTalk-Utilities-Tests' ) ]
]
2 changes: 1 addition & 1 deletion src/BaselineOfMuTalk/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #BaselineOfMuTalk }
Package { #name : 'BaselineOfMuTalk' }
27 changes: 27 additions & 0 deletions src/MuTalk-Model/MTTestCaseReference.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ MTTestCaseReference class >> forTestCase: aTestCase [
^self for: aTestCase selector in: aTestCase class
]

{ #category : 'comparing' }
MTTestCaseReference >> = anObject [

self == anObject ifTrue: [ ^ true ].
anObject species = self class ifFalse: [ ^ false ].
self testCaseClass = anObject testCaseClass ifFalse: [ ^ false ].
^ self selector = anObject selector
]

{ #category : 'comparing' }
MTTestCaseReference >> hash [

^ selector hash + class hash
]

{ #category : 'initialize' }
MTTestCaseReference >> initializeFor: aSelector in: aClass [
class := aClass.
Expand Down Expand Up @@ -72,7 +87,19 @@ MTTestCaseReference >> runUnchecked [
^ result
]

{ #category : 'accessing' }
MTTestCaseReference >> selector [

^ selector
]

{ #category : 'evaluating' }
MTTestCaseReference >> testCase [
^class selector: selector.
]

{ #category : 'accessing' }
MTTestCaseReference >> testCaseClass [

^ class
]
39 changes: 39 additions & 0 deletions src/MuTalk-Utilities-Tests/MTAuxiliarClassForMatrix.class.st
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 src/MuTalk-Utilities-Tests/MTAuxiliarClassForMatrixTest.class.st
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
]
104 changes: 104 additions & 0 deletions src/MuTalk-Utilities-Tests/MTMatrixTest.class.st
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
]
1 change: 1 addition & 0 deletions src/MuTalk-Utilities-Tests/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'MuTalk-Utilities-Tests' }
Loading

0 comments on commit 70148a1

Please sign in to comment.