|
| 1 | +Class { |
| 2 | + #name : 'MTMatrixTest', |
| 3 | + #superclass : 'TestCase', |
| 4 | + #instVars : [ |
| 5 | + 'matrix', |
| 6 | + 'trivialMutant', |
| 7 | + 'equivalentMutants', |
| 8 | + 'includedMutants' |
| 9 | + ], |
| 10 | + #category : 'MuTalk-Utilities-Tests', |
| 11 | + #package : 'MuTalk-Utilities-Tests' |
| 12 | +} |
| 13 | + |
| 14 | +{ #category : 'running' } |
| 15 | +MTMatrixTest >> setUp [ |
| 16 | + |
| 17 | + super setUp. |
| 18 | + matrix := MTMatrix forAClass: MTAuxiliarClassForMatrix. |
| 19 | + matrix build. |
| 20 | + self setUpVariablesForTest |
| 21 | +] |
| 22 | + |
| 23 | +{ #category : 'initialization' } |
| 24 | +MTMatrixTest >> setUpVariablesForTest [ |
| 25 | + |
| 26 | + | mutations minusMutants plusMutants | |
| 27 | + mutations := matrix analysis mutations. |
| 28 | + minusMutants := Set withAll: (mutations select: [ :mut | |
| 29 | + mut originalMethod |
| 30 | + = (MTAuxiliarClassForMatrix >> #minus:) ]). |
| 31 | + plusMutants := Set withAll: (mutations select: [ :mut | |
| 32 | + mut originalMethod |
| 33 | + = (MTAuxiliarClassForMatrix >> #plus:) ]). |
| 34 | + trivialMutant := Array with: |
| 35 | + (matrix analysis mutations detect: [ :mut | |
| 36 | + mut originalMethod |
| 37 | + = (MTAuxiliarClassForMatrix >> #reset) ]). |
| 38 | + equivalentMutants := Set with: minusMutants with: plusMutants. |
| 39 | + includedMutants := Dictionary new. |
| 40 | + mutations do: [ :mutant | |
| 41 | + mutant originalMethod = (MTAuxiliarClassForMatrix >> #minus:) |
| 42 | + ifTrue: [ includedMutants at: mutant put: minusMutants ]. |
| 43 | + mutant originalMethod = (MTAuxiliarClassForMatrix >> #plus:) |
| 44 | + ifTrue: [ includedMutants at: mutant put: plusMutants ]. |
| 45 | + mutant originalMethod = (MTAuxiliarClassForMatrix >> #reset) |
| 46 | + ifTrue: [ includedMutants at: mutant put: mutations asSet ] ] |
| 47 | +] |
| 48 | + |
| 49 | +{ #category : 'tests' } |
| 50 | +MTMatrixTest >> testEqualBooleanCollections [ |
| 51 | + |
| 52 | + | a1 a2 a3 a4 | |
| 53 | + a1 := #( false false true true true false ). |
| 54 | + a2 := #( false false true true true false ). |
| 55 | + a3 := #( false false true true false false ). |
| 56 | + a4 := #( false true true false ). |
| 57 | + |
| 58 | + self assert: |
| 59 | + (matrix booleanCollection1: a1 equalsBooleanCollection2: a2). |
| 60 | + self deny: |
| 61 | + (matrix booleanCollection1: a1 equalsBooleanCollection2: a3). |
| 62 | + self deny: |
| 63 | + (matrix booleanCollection1: a1 equalsBooleanCollection2: a4) |
| 64 | +] |
| 65 | + |
| 66 | +{ #category : 'tests' } |
| 67 | +MTMatrixTest >> testEquivalentMutants [ |
| 68 | + |
| 69 | + self assert: matrix equivalentMutants equals: equivalentMutants |
| 70 | +] |
| 71 | + |
| 72 | +{ #category : 'tests' } |
| 73 | +MTMatrixTest >> testIncludeBooleanCollections [ |
| 74 | + |
| 75 | + | a1 a2 a3 a4 a5 | |
| 76 | + a1 := #( false false true true true false ). |
| 77 | + a2 := #( false false true true true false ). |
| 78 | + a3 := #( false false true false false false ). |
| 79 | + a4 := #( true false true true false false ). |
| 80 | + a5 := #( false true true false ). |
| 81 | + |
| 82 | + self assert: |
| 83 | + (matrix booleanCollection1: a1 includesBooleanCollection2: a2). |
| 84 | + self assert: |
| 85 | + (matrix booleanCollection1: a1 includesBooleanCollection2: a3). |
| 86 | + self deny: |
| 87 | + (matrix booleanCollection1: a1 includesBooleanCollection2: a4). |
| 88 | + self deny: |
| 89 | + (matrix booleanCollection1: a1 includesBooleanCollection2: a5). |
| 90 | + self deny: |
| 91 | + (matrix booleanCollection1: a3 includesBooleanCollection2: a1) |
| 92 | +] |
| 93 | + |
| 94 | +{ #category : 'tests' } |
| 95 | +MTMatrixTest >> testIncludedMutants [ |
| 96 | + |
| 97 | + self assert: matrix includedMutants equals: includedMutants |
| 98 | +] |
| 99 | + |
| 100 | +{ #category : 'tests' } |
| 101 | +MTMatrixTest >> testTrivialMutants [ |
| 102 | + |
| 103 | + self assert: matrix trivialMutants equals: trivialMutant |
| 104 | +] |
0 commit comments