Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Ranger-Exploring/GreaterIntConstraintMutator.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Class {
#name : 'GreaterIntConstraintMutator',
#superclass : 'IntConstraintMutator',
#category : 'Ranger-Exploring',
#package : 'Ranger-Exploring'
}

{ #category : 'as yet unclassified' }
GreaterIntConstraintMutator >> mutateIsIntegerObjectConstraint: aConstraint [

^ RAGreaterConstraint operands: { aConstraint operands first . RAConstant value: self value }
]

{ #category : 'evaluating' }
GreaterIntConstraintMutator >> value [

^ 1000
]
70 changes: 70 additions & 0 deletions Ranger-Exploring/GreaterIntConstraintMutatorTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Class {
#name : 'GreaterIntConstraintMutatorTest',
#superclass : 'IntConstraintMutatorTest',
#category : 'Ranger-Exploring',
#package : 'Ranger-Exploring'
}

{ #category : 'running' }
GreaterIntConstraintMutatorTest >> setUp [
super setUp.
self mutator: GreaterIntConstraintMutator new
]

{ #category : 'tests' }
GreaterIntConstraintMutatorTest >> testAddGreaterConstraintWithAnOnlyIsInt [

| mutatedConstraints |
path pathConstraints: { isIntA }. "{ int(a) }"

mutatedConstraints := (mutator mutate: path) pathConstraints.

"it should be: { int(a), a > 1000 }"
self assert: mutatedConstraints equals: path pathConstraints,
{ self isGreater: a than: 1000 }.

]

{ #category : 'tests' }
GreaterIntConstraintMutatorTest >> testAddGreaterConstraintWithTwoIsInt [

| mutatedConstraints |
path pathConstraints: { isIntA . isIntB }. "{ int(500), int(400) }"

mutatedConstraints := (mutator mutate: path) pathConstraints.

"it should be: { int(500), 500 > 1000 }"
self assert: mutatedConstraints equals: path pathConstraints,
{ self isGreater: a than: 1000 . self isGreater: b than: 1000 }.

]

{ #category : 'tests' }
GreaterIntConstraintMutatorTest >> testAddGreaterConstraintsWithAddConstraint [
"Given a RAPath with constraints of the form int(a), int(b), int(...),
per each int(x), the mutator will add a new constraint (x > 1000)"

| mutatedConstraints |
path pathConstraints: { isIntA . isIntB . isIntPlus }. "{ int(500), int(400), int(500 + 400) }"

mutatedConstraints := (mutator mutate: path) pathConstraints.

"it should be: { int(500), int(400), int(500 + 400), 500 > 1000, 400 > 1000, 500 + 400 > 1000 }"
self assert: mutatedConstraints equals: path pathConstraints,
{ self isGreater: a than: 1000 . self isGreater: b than: 1000 . self isGreater: aPlusB than: 1000 }.

]

{ #category : 'tests' }
GreaterIntConstraintMutatorTest >> testAddGreaterConstraintsWithAddConstraintAndOtherStuff [

| mutatedConstraints |
path pathConstraints: { isIntA . isCharA . isIntB . isIntPlus }. "{ int(500), int(400), int(500 + 400) }"

mutatedConstraints := (mutator mutate: path) pathConstraints.

"it should be: { int(500), char('c'), int(400), int(500 + 400), 500 > 1000, 400 > 1000, 500 + 400 > 1000 }"
self assert: mutatedConstraints equals: path pathConstraints,
{ self isGreater: a than: 1000 . self isGreater: b than: 1000 . self isGreater: aPlusB than: 1000 }.

]
168 changes: 168 additions & 0 deletions Ranger-Exploring/IdleMutator.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
Class {
#name : 'IdleMutator',
#superclass : 'Mutator',
#category : 'Ranger-Exploring',
#package : 'Ranger-Exploring'
}

{ #category : 'as yet unclassified' }
IdleMutator >> mutateAddConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateAndConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateBitAddConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateBitOrConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateBitShiftConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateDivisionConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateEqualsConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateGreaterConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateGreaterOrEqualsConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsBooleanObjectOfConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsCharacterObjectConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsClassIndexOfConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsContextObjectConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsFloatObjectOfConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsIntegerObjectConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsIntegerObjectOfConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsIntegerToFloatConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsNonCharacterConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateIsNonIntegerConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateLessConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateLessOrEqualsConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateModuloConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateMultiplicationConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateNotEqualsConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateOrConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateQuotientConstraint: aConstraint [

^ aConstraint
]

{ #category : 'as yet unclassified' }
IdleMutator >> mutateSubstractionConstraint: aConstraint [

^ aConstraint
]
26 changes: 26 additions & 0 deletions Ranger-Exploring/IdleMutatorTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Class {
#name : 'IdleMutatorTest',
#superclass : 'MutatorTest',
#category : 'Ranger-Exploring',
#package : 'Ranger-Exploring'
}

{ #category : 'tests' }
IdleMutatorTest >> setUp [
super setUp.
self mutator: IdleMutator new
]

{ #category : 'tests' }
IdleMutatorTest >> testNoMutation [
"Given a simple RAPath, it returns exactly the same RAPath"
| path mutatedPath |

path := RAPath new.
mutatedPath := mutator mutate: path.

self assert: (mutatedPath pathConstraints) equals: path pathConstraints.
self assert: (mutatedPath exitCondition) equals: path exitCondition.
self assert: (mutatedPath parent) equals: path parent.
self assert: (mutatedPath inputs) equals: path inputs.
]
21 changes: 21 additions & 0 deletions Ranger-Exploring/IntConstraintMutator.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Class {
#name : 'IntConstraintMutator',
#superclass : 'IdleMutator',
#category : 'Ranger-Exploring',
#package : 'Ranger-Exploring'
}

{ #category : 'as yet unclassified' }
IntConstraintMutator >> mutateConstraints: someConstraints [

| intConstraints |
intConstraints := someConstraints select: [ :constraint | constraint class = RAIsIntegerObject ].

^ someConstraints copy, (self mutationsByIntConstraints: intConstraints)
]

{ #category : 'as yet unclassified' }
IntConstraintMutator >> mutationsByIntConstraints: intConstraints [

^ intConstraints collect: [ :constraint | self mutateConstraint: constraint ]
]
32 changes: 32 additions & 0 deletions Ranger-Exploring/IntConstraintMutatorTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Class {
#name : 'IntConstraintMutatorTest',
#superclass : 'MutatorTest',
#instVars : [
'a',
'b',
'aPlusB',
'c',
'path',
'isIntA',
'isIntB',
'isIntPlus',
'isCharA'
],
#category : 'Ranger-Exploring',
#package : 'Ranger-Exploring'
}

{ #category : 'running' }
IntConstraintMutatorTest >> setUp [
super setUp.
path := RAPath new.
a := self const: 500.
b := self const: 400.
c := self const: $c.
aPlusB := self add: a to: b.

isIntA := self isInt: a. "int(500)"
isCharA := self isChar: c. "char('c')"
isIntB := self isInt: b. "int(400)"
isIntPlus := self isInt: aPlusB. "int(500 + 400)"
]
18 changes: 18 additions & 0 deletions Ranger-Exploring/LessIntConstraintMutator.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Class {
#name : 'LessIntConstraintMutator',
#superclass : 'IntConstraintMutator',
#category : 'Ranger-Exploring',
#package : 'Ranger-Exploring'
}

{ #category : 'as yet unclassified' }
LessIntConstraintMutator >> mutateIsIntegerObjectConstraint: aConstraint [

^ RALessConstraint operands: { aConstraint operands first . RAConstant value: self value }
]

{ #category : 'evaluating' }
LessIntConstraintMutator >> value [

^ 1000
]
Loading