From 322641dc2b232be301747d7d014d3732d1d95613 Mon Sep 17 00:00:00 2001 From: Henry Coles Date: Thu, 3 Mar 2022 16:37:52 +0000 Subject: [PATCH] remove pit rv operators --- .../engine/gregor/mutators/rv/ABSMutator.java | 229 --------- .../gregor/mutators/rv/AOD1Mutator.java | 109 ----- .../gregor/mutators/rv/AOD2Mutator.java | 123 ----- .../gregor/mutators/rv/AOR1Mutator.java | 116 ----- .../gregor/mutators/rv/AOR2Mutator.java | 116 ----- .../gregor/mutators/rv/AOR3Mutator.java | 116 ----- .../gregor/mutators/rv/AOR4Mutator.java | 116 ----- .../mutators/rv/AbstractCRCRVisitor.java | 185 ------- .../gregor/mutators/rv/CRCR1Mutator.java | 79 --- .../gregor/mutators/rv/CRCR2Mutator.java | 79 --- .../gregor/mutators/rv/CRCR3Mutator.java | 79 --- .../gregor/mutators/rv/CRCR4Mutator.java | 78 --- .../gregor/mutators/rv/CRCR5Mutator.java | 79 --- .../gregor/mutators/rv/CRCR6Mutator.java | 79 --- .../gregor/mutators/rv/OBBN1Mutator.java | 66 --- .../gregor/mutators/rv/OBBN2Mutator.java | 93 ---- .../gregor/mutators/rv/OBBN3Mutator.java | 107 ---- .../gregor/mutators/rv/ROR1Mutator.java | 84 ---- .../gregor/mutators/rv/ROR2Mutator.java | 84 ---- .../gregor/mutators/rv/ROR3Mutator.java | 84 ---- .../gregor/mutators/rv/ROR4Mutator.java | 84 ---- .../gregor/mutators/rv/ROR5Mutator.java | 92 ---- .../gregor/mutators/rv/RVMutatorGroups.java | 42 -- .../gregor/mutators/rv/UOI1Mutator.java | 323 ------------ .../gregor/mutators/rv/UOI2Mutator.java | 320 ------------ .../gregor/mutators/rv/UOI3Mutator.java | 326 ------------- .../gregor/mutators/rv/UOI4Mutator.java | 335 ------------- ...iontest.engine.gregor.MethodMutatorFactory | 25 - ...tiontest.engine.gregor.config.MutatorGroup | 1 - .../engine/gregor/config/MutatorTest.java | 93 +--- .../gregor/mutators/rv/ABSMutatorTest.java | 425 ---------------- .../gregor/mutators/rv/AOD1MutatorTest.java | 458 ------------------ .../gregor/mutators/rv/AOD2MutatorTest.java | 458 ------------------ .../gregor/mutators/rv/AOR1MutatorTest.java | 458 ------------------ .../gregor/mutators/rv/AOR2MutatorTest.java | 458 ------------------ .../gregor/mutators/rv/AOR3MutatorTest.java | 458 ------------------ .../gregor/mutators/rv/AOR4MutatorTest.java | 458 ------------------ .../engine/gregor/mutators/rv/CRCR1Test.java | 350 ------------- .../engine/gregor/mutators/rv/CRCR2Test.java | 351 -------------- .../engine/gregor/mutators/rv/CRCR3Test.java | 354 -------------- .../engine/gregor/mutators/rv/CRCR4Test.java | 351 -------------- .../engine/gregor/mutators/rv/CRCR5Test.java | 383 --------------- .../engine/gregor/mutators/rv/CRCR6Test.java | 382 --------------- .../gregor/mutators/rv/OBBN1MutatorTest.java | 103 ---- .../gregor/mutators/rv/OBBN2MutatorTest.java | 103 ---- .../gregor/mutators/rv/OBBN3MutatorTest.java | 103 ---- .../gregor/mutators/rv/ROR1MutatorTest.java | 343 ------------- .../gregor/mutators/rv/ROR2MutatorTest.java | 343 ------------- .../gregor/mutators/rv/ROR3MutatorTest.java | 343 ------------- .../gregor/mutators/rv/ROR4MutatorTest.java | 343 ------------- .../gregor/mutators/rv/ROR5MutatorTest.java | 444 ----------------- .../gregor/mutators/rv/UOI1MutatorTest.java | 455 ----------------- .../gregor/mutators/rv/UOI2MutatorTest.java | 454 ----------------- .../gregor/mutators/rv/UOI3MutatorTest.java | 425 ---------------- .../gregor/mutators/rv/UOI4MutatorTest.java | 425 ---------------- 55 files changed, 1 insertion(+), 12969 deletions(-) delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ABSMutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD1Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD2Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR1Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR2Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR3Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR4Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AbstractCRCRVisitor.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR1Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR2Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR3Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR4Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR5Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR6Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN1Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN2Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN3Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR1Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR2Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR3Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR4Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR5Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/RVMutatorGroups.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI1Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI2Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI3Mutator.java delete mode 100644 pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI4Mutator.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ABSMutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD1MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD2MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR1MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR2MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR3MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR4MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR1Test.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR2Test.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR3Test.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR4Test.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR5Test.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR6Test.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN1MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN2MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN3MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR1MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR2MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR3MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR4MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR5MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI1MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI2MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI3MutatorTest.java delete mode 100644 pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI4MutatorTest.java diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ABSMutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ABSMutator.java deleted file mode 100644 index f292785e8..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ABSMutator.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutator designed to insert (-) in front of Integer, Float, Long, Double - * variable values. - * - * Applicable for array values, static and non static fields and local - * variables. - */ -public enum ABSMutator implements MethodMutatorFactory { - - ABS; - - public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, - final MethodVisitor methodVisitor) { - return new ABSMethodVisitor(this, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } -} - -class ABSMethodVisitor extends MethodVisitor { - - private final MethodMutatorFactory factory; - private final MutationContext context; - - ABSMethodVisitor(final MethodMutatorFactory factory, final MutationContext context, - final MethodVisitor delegateMethodVisitor) { - super(ASMVersion.ASM_VERSION, delegateMethodVisitor); - this.factory = factory; - this.context = context; - } - - private boolean shouldMutate(String message) { - if (this.context.getClassInfo().isEnum()) { - return false; - } - final MutationIdentifier newId = this.context.registerMutation(this.factory, message); - return this.context.shouldMutate(newId); - } - - // Local variables - @Override - public void visitVarInsn(int opcode, int var) { - mv.visitVarInsn(opcode, var); // push the variable. - - switch (opcode) { - case Opcodes.ILOAD: - if (this.shouldMutate("Negated integer local variable number " + var)) { - mv.visitInsn(Opcodes.INEG); - } - break; - - case Opcodes.FLOAD: - if (this.shouldMutate("Negated float local variable number " + var)) { - mv.visitInsn(Opcodes.FNEG); - } - break; - - case Opcodes.LLOAD: - if (this.shouldMutate("Negated long local variable number " + var)) { - mv.visitInsn(Opcodes.LNEG); - } - break; - - case Opcodes.DLOAD: - if (this.shouldMutate("Negated double local variable number " + var)) { - mv.visitInsn(Opcodes.DNEG); - } - break; - default: - break; - } - } - - // Fields, static or not. - @Override - public void visitFieldInsn(int opcode, String owner, String name, String desc) { - - mv.visitFieldInsn(opcode, owner, name, desc); - - // non static - if (opcode == Opcodes.GETFIELD) { - if (desc.equals("I")) { - if (this.shouldMutate("Negated integer field " + name)) { - mv.visitInsn(Opcodes.INEG); - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Negated float field " + name)) { - mv.visitInsn(Opcodes.FNEG); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Negated long field " + name)) { - mv.visitInsn(Opcodes.LNEG); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Negated double field " + name)) { - mv.visitInsn(Opcodes.DNEG); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Negated byte field " + name)) { - mv.visitInsn(Opcodes.INEG); - mv.visitInsn(Opcodes.I2B); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Negated short field " + name)) { - mv.visitInsn(Opcodes.INEG); - mv.visitInsn(Opcodes.I2S); - return; - } - } - } - - // static - if (opcode == Opcodes.GETSTATIC) { - if (desc.equals("I")) { - if (this.shouldMutate("Negated integer static field " + name)) { - mv.visitInsn(Opcodes.INEG); - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Negated float static field " + name)) { - mv.visitInsn(Opcodes.FNEG); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Negated long static field " + name)) { - mv.visitInsn(Opcodes.LNEG); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Negated double static field " + name)) { - mv.visitInsn(Opcodes.DNEG); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Negated byte static field " + name)) { - mv.visitInsn(Opcodes.INEG); - mv.visitInsn(Opcodes.I2B); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Negated short static field " + name)) { - mv.visitInsn(Opcodes.INEG); - mv.visitInsn(Opcodes.I2S); - return; - } - } - } - } - - @Override - public void visitInsn(final int opcode) { - mv.visitInsn(opcode); - switch (opcode) { - // ARRAYS I F L D , loading - case Opcodes.IALOAD: - if (this.shouldMutate("Negated integer array field")) { - mv.visitInsn(Opcodes.INEG); - } - break; - - case Opcodes.FALOAD: - if (this.shouldMutate("Negated float array field")) { - mv.visitInsn(Opcodes.FNEG); - } - break; - - case Opcodes.LALOAD: - if (this.shouldMutate("Negated long array field")) { - mv.visitInsn(Opcodes.LNEG); - } - break; - - case Opcodes.DALOAD: - if (this.shouldMutate("Negated double array field")) { - mv.visitInsn(Opcodes.DNEG); - } - break; - - case Opcodes.BALOAD: - if (this.shouldMutate("Negated byte array field")) { - mv.visitInsn(Opcodes.INEG); - mv.visitInsn(Opcodes.I2B); - } - break; - - case Opcodes.SALOAD: - if (this.shouldMutate("Negated short array field")) { - mv.visitInsn(Opcodes.INEG); - mv.visitInsn(Opcodes.I2S); - } - break; - - default: - break; - } - } -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD1Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD1Mutator.java deleted file mode 100644 index b8bae1b86..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD1Mutator.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutator that replaces (a+b) by a; - * Does the same for the operators (*,/,%,-). - */ -public enum AOD1Mutator implements MethodMutatorFactory { - - AOD1; - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new AODMethodVisitor1(this, context, methodInfo, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } -} - -class AODMethodVisitor1 extends MethodVisitor { - - private final MethodMutatorFactory factory; - private final MutationContext context; - private final MethodInfo info; - - AODMethodVisitor1(final MethodMutatorFactory factory, - final MutationContext context, final MethodInfo info, final MethodVisitor delegateMethodVisitor) { - super(ASMVersion.ASM_VERSION, delegateMethodVisitor); - this.factory = factory; - this.context = context; - this.info = info; - } - - private boolean shouldMutate(String expression) { - if (this.info.isGeneratedEnumMethod()) { - return false; - } else { - final MutationIdentifier newId = this.context.registerMutation( - this.factory, "Replaced " + expression + " operation with first member"); - return this.context.shouldMutate(newId); - } - } - - @Override - public void visitInsn(int opcode) { - switch (opcode) { - case Opcodes.IADD: - case Opcodes.ISUB: - case Opcodes.IMUL: - case Opcodes.IDIV: - case Opcodes.IREM: - if (this.shouldMutate("integer")) { - mv.visitInsn(Opcodes.POP); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.FADD: - case Opcodes.FSUB: - case Opcodes.FMUL: - case Opcodes.FDIV: - case Opcodes.FREM: - if (this.shouldMutate("float")) { - mv.visitInsn(Opcodes.POP); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.LADD: - case Opcodes.LSUB: - case Opcodes.LMUL: - case Opcodes.LDIV: - case Opcodes.LREM: - if (this.shouldMutate("long")) { - mv.visitInsn(Opcodes.POP2); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.DADD: - case Opcodes.DSUB: - case Opcodes.DMUL: - case Opcodes.DDIV: - case Opcodes.DREM: - if (this.shouldMutate("double")) { - mv.visitInsn(Opcodes.POP2); - } else { - mv.visitInsn(opcode); - } - break; - default: - mv.visitInsn(opcode); - break; - } - } -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD2Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD2Mutator.java deleted file mode 100644 index fd9b5824e..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD2Mutator.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.commons.LocalVariablesSorter; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutator that replaces (a+b) by b; - * Does the same for the operators (*,/,%,-). - */ -public enum AOD2Mutator implements MethodMutatorFactory { - - AOD2; - - public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new AODMethodVisitor2(this, context, methodInfo, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } -} - -class AODMethodVisitor2 extends LocalVariablesSorter { - - private final MethodMutatorFactory factory; - private final MutationContext context; - private final MethodInfo info; - - AODMethodVisitor2( final MethodMutatorFactory factory, final MutationContext context, final MethodInfo info, - final MethodVisitor delegateMethodVisitor) { - super(ASMVersion.ASM_VERSION, info.getAccess(), info.getMethodDescriptor(), delegateMethodVisitor); - this.factory = factory; - this.context = context; - this.info = info; - } - - private boolean shouldMutate(String expression) { - if (this.info.isGeneratedEnumMethod()) { - return false; - } else { - final MutationIdentifier newId = this.context.registerMutation(this.factory, - "Replaced " + expression + " operation by second member"); - return this.context.shouldMutate(newId); - } - - } - - @Override - public void visitInsn(int opcode) { - switch (opcode) { - case Opcodes.IADD: - case Opcodes.ISUB: - case Opcodes.IMUL: - case Opcodes.IDIV: - case Opcodes.IREM: - if (this.shouldMutate("integer")) { - int storage = this.newLocal(Type.INT_TYPE); - mv.visitVarInsn(Opcodes.ISTORE, storage); - mv.visitInsn(Opcodes.POP); - mv.visitVarInsn(Opcodes.ILOAD, storage); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.FADD: - case Opcodes.FSUB: - case Opcodes.FMUL: - case Opcodes.FDIV: - case Opcodes.FREM: - if (this.shouldMutate("float")) { - int storage = this.newLocal(Type.FLOAT_TYPE); - mv.visitVarInsn(Opcodes.FSTORE, storage); - mv.visitInsn(Opcodes.POP); - mv.visitVarInsn(Opcodes.FLOAD, storage); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.LADD: - case Opcodes.LSUB: - case Opcodes.LMUL: - case Opcodes.LDIV: - case Opcodes.LREM: - if (this.shouldMutate("long")) { - int storage = this.newLocal(Type.LONG_TYPE); - mv.visitVarInsn(Opcodes.LSTORE, storage); - mv.visitInsn(Opcodes.POP2); - mv.visitVarInsn(Opcodes.LLOAD, storage); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.DADD: - case Opcodes.DSUB: - case Opcodes.DMUL: - case Opcodes.DDIV: - case Opcodes.DREM: - if (this.shouldMutate("double")) { - int storage = this.newLocal(Type.DOUBLE_TYPE); - mv.visitVarInsn(Opcodes.DSTORE, storage); - mv.visitInsn(Opcodes.POP2); - mv.visitVarInsn(Opcodes.DLOAD, storage); - } else { - mv.visitInsn(opcode); - } - break; - default: - mv.visitInsn(opcode); - break; - } - } -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR1Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR1Mutator.java deleted file mode 100644 index 4a4c6dddd..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR1Mutator.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractInsnMutator; -import org.pitest.mutationtest.engine.gregor.InsnSubstitution; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; -import org.pitest.mutationtest.engine.gregor.ZeroOperandMutation; - -import java.util.HashMap; -import java.util.Map; - -public enum AOR1Mutator implements MethodMutatorFactory { - - AOR1; - - @Override - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new AOR1MethodVisitor(this, methodInfo, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - @Override - public String getName() { - return name(); - } - -} - -class AOR1MethodVisitor extends AbstractInsnMutator { - - AOR1MethodVisitor(final MethodMutatorFactory factory, - final MethodInfo methodInfo, final MutationContext context, - final MethodVisitor writer) { - super(factory, methodInfo, context, writer); - } - - private static final Map MUTATIONS = new HashMap<>(); - - static { - MUTATIONS.put(Opcodes.IADD, new InsnSubstitution(Opcodes.ISUB, - "Replaced integer addition with subtraction")); - MUTATIONS.put(Opcodes.ISUB, new InsnSubstitution(Opcodes.IADD, - "Replaced integer subtraction with addition")); - MUTATIONS.put(Opcodes.IMUL, new InsnSubstitution(Opcodes.IDIV, - "Replaced integer multiplication with division")); - MUTATIONS.put(Opcodes.IDIV, new InsnSubstitution(Opcodes.IMUL, - "Replaced integer division with multiplication")); - MUTATIONS.put(Opcodes.IREM, new InsnSubstitution(Opcodes.IMUL, - "Replaced integer modulus with multiplication")); - - // longs - MUTATIONS.put(Opcodes.LADD, new InsnSubstitution(Opcodes.LSUB, - "Replaced long addition with subtraction")); - MUTATIONS.put(Opcodes.LSUB, new InsnSubstitution(Opcodes.LADD, - "Replaced long subtraction with addition")); - MUTATIONS.put(Opcodes.LMUL, new InsnSubstitution(Opcodes.LDIV, - "Replaced long multiplication with division")); - MUTATIONS.put(Opcodes.LDIV, new InsnSubstitution(Opcodes.LMUL, - "Replaced long division with multiplication")); - MUTATIONS.put(Opcodes.LREM, new InsnSubstitution(Opcodes.LMUL, - "Replaced long modulus with multiplication")); - - // floats - MUTATIONS.put(Opcodes.FADD, new InsnSubstitution(Opcodes.FSUB, - "Replaced float addition with subtraction")); - MUTATIONS.put(Opcodes.FSUB, new InsnSubstitution(Opcodes.FADD, - "Replaced float subtraction with addition")); - MUTATIONS.put(Opcodes.FMUL, new InsnSubstitution(Opcodes.FDIV, - "Replaced float multiplication with division")); - MUTATIONS.put(Opcodes.FDIV, new InsnSubstitution(Opcodes.FMUL, - "Replaced float division with multiplication")); - MUTATIONS.put(Opcodes.FREM, new InsnSubstitution(Opcodes.FMUL, - "Replaced float modulus with multiplication")); - - // doubles - MUTATIONS.put(Opcodes.DADD, new InsnSubstitution(Opcodes.DSUB, - "Replaced double addition with subtraction")); - MUTATIONS.put(Opcodes.DSUB, new InsnSubstitution(Opcodes.DADD, - "Replaced double subtraction with addition")); - MUTATIONS.put(Opcodes.DMUL, new InsnSubstitution(Opcodes.DDIV, - "Replaced double multiplication with division")); - MUTATIONS.put(Opcodes.DDIV, new InsnSubstitution(Opcodes.DMUL, - "Replaced double division with multiplication")); - MUTATIONS.put(Opcodes.DREM, new InsnSubstitution(Opcodes.DMUL, - "Replaced double modulus with multiplication")); - - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR2Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR2Mutator.java deleted file mode 100644 index 8299d996d..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR2Mutator.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractInsnMutator; -import org.pitest.mutationtest.engine.gregor.InsnSubstitution; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; -import org.pitest.mutationtest.engine.gregor.ZeroOperandMutation; - -import java.util.HashMap; -import java.util.Map; - -public enum AOR2Mutator implements MethodMutatorFactory { - - AOR2; - - @Override - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new AOR2MethodVisitor(this, methodInfo, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - @Override - public String getName() { - return name(); - } - -} - -class AOR2MethodVisitor extends AbstractInsnMutator { - - AOR2MethodVisitor(final MethodMutatorFactory factory, - final MethodInfo methodInfo, final MutationContext context, - final MethodVisitor writer) { - super(factory, methodInfo, context, writer); - } - - private static final Map MUTATIONS = new HashMap<>(); - - static { - MUTATIONS.put(Opcodes.IADD, new InsnSubstitution(Opcodes.IMUL, - "Replaced integer addition with multiplication")); - MUTATIONS.put(Opcodes.ISUB, new InsnSubstitution(Opcodes.IMUL, - "Replaced integer subtraction with multiplication")); - MUTATIONS.put(Opcodes.IMUL, new InsnSubstitution(Opcodes.IREM, - "Replaced integer multiplication with modulus")); - MUTATIONS.put(Opcodes.IDIV, new InsnSubstitution(Opcodes.IREM, - "Replaced integer division with modulus")); - MUTATIONS.put(Opcodes.IREM, new InsnSubstitution(Opcodes.IDIV, - "Replaced integer modulus with division")); - - // longs - MUTATIONS.put(Opcodes.LADD, new InsnSubstitution(Opcodes.LMUL, - "Replaced long addition with multiplication")); - MUTATIONS.put(Opcodes.LSUB, new InsnSubstitution(Opcodes.LMUL, - "Replaced long subtraction with multiplication")); - MUTATIONS.put(Opcodes.LMUL, new InsnSubstitution(Opcodes.LREM, - "Replaced long multiplication with modulus")); - MUTATIONS.put(Opcodes.LDIV, new InsnSubstitution(Opcodes.LREM, - "Replaced long division with modulus")); - MUTATIONS.put(Opcodes.LREM, new InsnSubstitution(Opcodes.LDIV, - "Replaced long modulus with division")); - - // floats - MUTATIONS.put(Opcodes.FADD, new InsnSubstitution(Opcodes.FMUL, - "Replaced float addition with multiplication")); - MUTATIONS.put(Opcodes.FSUB, new InsnSubstitution(Opcodes.FMUL, - "Replaced float subtraction with multiplication")); - MUTATIONS.put(Opcodes.FMUL, new InsnSubstitution(Opcodes.FREM, - "Replaced float multiplication with modulus")); - MUTATIONS.put(Opcodes.FDIV, new InsnSubstitution(Opcodes.FREM, - "Replaced float division with modulus")); - MUTATIONS.put(Opcodes.FREM, new InsnSubstitution(Opcodes.FDIV, - "Replaced float modulus with division")); - - // doubles - MUTATIONS.put(Opcodes.DADD, new InsnSubstitution(Opcodes.DMUL, - "Replaced double addition with multiplication")); - MUTATIONS.put(Opcodes.DSUB, new InsnSubstitution(Opcodes.DMUL, - "Replaced double subtraction with multiplication")); - MUTATIONS.put(Opcodes.DMUL, new InsnSubstitution(Opcodes.DREM, - "Replaced double multiplication with modulus")); - MUTATIONS.put(Opcodes.DDIV, new InsnSubstitution(Opcodes.DREM, - "Replaced double division with modulus")); - MUTATIONS.put(Opcodes.DREM, new InsnSubstitution(Opcodes.DDIV, - "Replaced double modulus with division")); - - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR3Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR3Mutator.java deleted file mode 100644 index a9b13355a..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR3Mutator.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractInsnMutator; -import org.pitest.mutationtest.engine.gregor.InsnSubstitution; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; -import org.pitest.mutationtest.engine.gregor.ZeroOperandMutation; - -import java.util.HashMap; -import java.util.Map; - -public enum AOR3Mutator implements MethodMutatorFactory { - - AOR3; - - @Override - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new AOR3MethodVisitor(this, methodInfo, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - @Override - public String getName() { - return name(); - } - -} - -class AOR3MethodVisitor extends AbstractInsnMutator { - - AOR3MethodVisitor(final MethodMutatorFactory factory, - final MethodInfo methodInfo, final MutationContext context, - final MethodVisitor writer) { - super(factory, methodInfo, context, writer); - } - - private static final Map MUTATIONS = new HashMap<>(); - - static { - MUTATIONS.put(Opcodes.IADD, new InsnSubstitution(Opcodes.IDIV, - "Replaced integer addition with division")); - MUTATIONS.put(Opcodes.ISUB, new InsnSubstitution(Opcodes.IDIV, - "Replaced integer subtraction with division")); - MUTATIONS.put(Opcodes.IMUL, new InsnSubstitution(Opcodes.IADD, - "Replaced integer multiplication with addition")); - MUTATIONS.put(Opcodes.IDIV, new InsnSubstitution(Opcodes.IADD, - "Replaced integer division with addition")); - MUTATIONS.put(Opcodes.IREM, new InsnSubstitution(Opcodes.IADD, - "Replaced integer modulus with addition")); - - // longs - MUTATIONS.put(Opcodes.LADD, new InsnSubstitution(Opcodes.LDIV, - "Replaced long addition with division")); - MUTATIONS.put(Opcodes.LSUB, new InsnSubstitution(Opcodes.LDIV, - "Replaced long subtraction with division")); - MUTATIONS.put(Opcodes.LMUL, new InsnSubstitution(Opcodes.LADD, - "Replaced long multiplication with addition")); - MUTATIONS.put(Opcodes.LDIV, new InsnSubstitution(Opcodes.LADD, - "Replaced long division with addition")); - MUTATIONS.put(Opcodes.LREM, new InsnSubstitution(Opcodes.LADD, - "Replaced long modulus with addition")); - - // floats - MUTATIONS.put(Opcodes.FADD, new InsnSubstitution(Opcodes.FDIV, - "Replaced float addition with division")); - MUTATIONS.put(Opcodes.FSUB, new InsnSubstitution(Opcodes.FDIV, - "Replaced float subtraction with division")); - MUTATIONS.put(Opcodes.FMUL, new InsnSubstitution(Opcodes.FADD, - "Replaced float multiplication with addition")); - MUTATIONS.put(Opcodes.FDIV, new InsnSubstitution(Opcodes.FADD, - "Replaced float division with addition")); - MUTATIONS.put(Opcodes.FREM, new InsnSubstitution(Opcodes.FADD, - "Replaced float modulus with addition")); - - // doubles - MUTATIONS.put(Opcodes.DADD, new InsnSubstitution(Opcodes.DDIV, - "Replaced double addition with division")); - MUTATIONS.put(Opcodes.DSUB, new InsnSubstitution(Opcodes.DDIV, - "Replaced double subtraction with division")); - MUTATIONS.put(Opcodes.DMUL, new InsnSubstitution(Opcodes.DADD, - "Replaced double multiplication with addition")); - MUTATIONS.put(Opcodes.DDIV, new InsnSubstitution(Opcodes.DADD, - "Replaced double division with addition")); - MUTATIONS.put(Opcodes.DREM, new InsnSubstitution(Opcodes.DADD, - "Replaced double modulus with addition")); - - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR4Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR4Mutator.java deleted file mode 100644 index 234eb9620..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR4Mutator.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractInsnMutator; -import org.pitest.mutationtest.engine.gregor.InsnSubstitution; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; -import org.pitest.mutationtest.engine.gregor.ZeroOperandMutation; - -import java.util.HashMap; -import java.util.Map; - -public enum AOR4Mutator implements MethodMutatorFactory { - - AOR4; - - @Override - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new AOR4MethodVisitor(this, methodInfo, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - @Override - public String getName() { - return name(); - } - -} - -class AOR4MethodVisitor extends AbstractInsnMutator { - - AOR4MethodVisitor(final MethodMutatorFactory factory, - final MethodInfo methodInfo, final MutationContext context, - final MethodVisitor writer) { - super(factory, methodInfo, context, writer); - } - - private static final Map MUTATIONS = new HashMap<>(); - - static { - MUTATIONS.put(Opcodes.IADD, new InsnSubstitution(Opcodes.IREM, - "Replaced integer addition with modulus")); - MUTATIONS.put(Opcodes.ISUB, new InsnSubstitution(Opcodes.IREM, - "Replaced integer subtraction with modulus")); - MUTATIONS.put(Opcodes.IMUL, new InsnSubstitution(Opcodes.ISUB, - "Replaced integer multiplication with subtraction")); - MUTATIONS.put(Opcodes.IDIV, new InsnSubstitution(Opcodes.ISUB, - "Replaced integer division with subtraction")); - MUTATIONS.put(Opcodes.IREM, new InsnSubstitution(Opcodes.ISUB, - "Replaced integer modulus with subtraction")); - - // longs - MUTATIONS.put(Opcodes.LADD, new InsnSubstitution(Opcodes.LREM, - "Replaced long addition with modulus")); - MUTATIONS.put(Opcodes.LSUB, new InsnSubstitution(Opcodes.LREM, - "Replaced long subtraction with modulus")); - MUTATIONS.put(Opcodes.LMUL, new InsnSubstitution(Opcodes.LSUB, - "Replaced long multiplication with subtraction")); - MUTATIONS.put(Opcodes.LDIV, new InsnSubstitution(Opcodes.LSUB, - "Replaced long division with subtraction")); - MUTATIONS.put(Opcodes.LREM, new InsnSubstitution(Opcodes.LSUB, - "Replaced long modulus with subtraction")); - - // floats - MUTATIONS.put(Opcodes.FADD, new InsnSubstitution(Opcodes.FREM, - "Replaced float addition with modulus")); - MUTATIONS.put(Opcodes.FSUB, new InsnSubstitution(Opcodes.FREM, - "Replaced float subtraction with modulus")); - MUTATIONS.put(Opcodes.FMUL, new InsnSubstitution(Opcodes.FSUB, - "Replaced float multiplication with subtraction")); - MUTATIONS.put(Opcodes.FDIV, new InsnSubstitution(Opcodes.FSUB, - "Replaced float division with subtraction")); - MUTATIONS.put(Opcodes.FREM, new InsnSubstitution(Opcodes.FSUB, - "Replaced float modulus with subtraction")); - - // doubles - MUTATIONS.put(Opcodes.DADD, new InsnSubstitution(Opcodes.DREM, - "Replaced double addition with modulus")); - MUTATIONS.put(Opcodes.DSUB, new InsnSubstitution(Opcodes.DREM, - "Replaced double subtraction with modulus")); - MUTATIONS.put(Opcodes.DMUL, new InsnSubstitution(Opcodes.DSUB, - "Replaced double multiplication with subtraction")); - MUTATIONS.put(Opcodes.DDIV, new InsnSubstitution(Opcodes.DSUB, - "Replaced double division with subtraction")); - MUTATIONS.put(Opcodes.DREM, new InsnSubstitution(Opcodes.DSUB, - "Replaced double modulus with subtraction")); - - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AbstractCRCRVisitor.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AbstractCRCRVisitor.java deleted file mode 100644 index 8cda7379b..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AbstractCRCRVisitor.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; -import org.pitest.util.PitError; - -public abstract class AbstractCRCRVisitor extends MethodVisitor { - final MutationContext context; - final MethodMutatorFactory factory; - - AbstractCRCRVisitor(final MutationContext context, - final MethodVisitor delegateVisitor, final MethodMutatorFactory factory) { - super(ASMVersion.ASM_VERSION, delegateVisitor); - this.context = context; - this.factory = factory; - } - - abstract void mutate(Double constant); - - abstract void mutate(Float constant); - - abstract void mutate(Integer constant); - - abstract void mutate(Long constant); - - void mutate(final Number constant) { - - if (constant instanceof Integer) { - mutate((Integer) constant); - } else if (constant instanceof Long) { - mutate((Long) constant); - } else if (constant instanceof Float) { - mutate((Float) constant); - } else if (constant instanceof Double) { - mutate((Double) constant); - } else { - throw new PitError("Unsupported subtype of Number found:" - + constant.getClass()); - } - - } - - boolean shouldMutate(final T constant, - final T replacement) { - final MutationIdentifier mutationId = this.context.registerMutation( - this.factory, "Substituted " + constant + " with " - + replacement); - - return this.context.shouldMutate(mutationId); - } - - void translateToByteCode(final Double constant) { - if (constant == 0D) { - super.visitInsn(Opcodes.DCONST_0); - } else if (constant == 1D) { - super.visitInsn(Opcodes.DCONST_1); - } else { - super.visitLdcInsn(constant); - } - } - - void translateToByteCode(final Float constant) { - if (constant == 0.0F) { - super.visitInsn(Opcodes.FCONST_0); - } else if (constant == 1.0F) { - super.visitInsn(Opcodes.FCONST_1); - } else if (constant == 2.0F) { - super.visitInsn(Opcodes.FCONST_2); - } else { - super.visitLdcInsn(constant); - } - } - - void translateToByteCode(final Integer constant) { - switch (constant) { - case -1: - super.visitInsn(Opcodes.ICONST_M1); - break; - case 0: - super.visitInsn(Opcodes.ICONST_0); - break; - case 1: - super.visitInsn(Opcodes.ICONST_1); - break; - case 2: - super.visitInsn(Opcodes.ICONST_2); - break; - case 3: - super.visitInsn(Opcodes.ICONST_3); - break; - case 4: - super.visitInsn(Opcodes.ICONST_4); - break; - case 5: - super.visitInsn(Opcodes.ICONST_5); - break; - default: - super.visitLdcInsn(constant); - break; - } - } - - void translateToByteCode(final Long constant) { - if (constant == 0L) { - super.visitInsn(Opcodes.LCONST_0); - } else if (constant == 1L) { - super.visitInsn(Opcodes.LCONST_1); - } else { - super.visitLdcInsn(constant); - } - } - - Number translateToNumber(final int opcode) { - switch (opcode) { - case Opcodes.ICONST_M1: - return -1; - case Opcodes.ICONST_0: - return 0; - case Opcodes.ICONST_1: - return 1; - case Opcodes.ICONST_2: - return 2; - case Opcodes.ICONST_3: - return 3; - case Opcodes.ICONST_4: - return 4; - case Opcodes.ICONST_5: - return 5; - case Opcodes.LCONST_0: - return 0L; - case Opcodes.LCONST_1: - return 1L; - case Opcodes.FCONST_0: - return 0F; - case Opcodes.FCONST_1: - return 1F; - case Opcodes.FCONST_2: - return 2F; - case Opcodes.DCONST_0: - return 0D; - case Opcodes.DCONST_1: - return 1D; - default: - return null; - } - } - - @Override - public void visitInsn(final int opcode) { - - final Number inlineConstant = translateToNumber(opcode); - - if (inlineConstant == null) { - super.visitInsn(opcode); - return; - } - - mutate(inlineConstant); - } - - @Override - public void visitIntInsn(final int opcode, final int operand) { - if ((opcode == Opcodes.BIPUSH) || (opcode == Opcodes.SIPUSH)) { - mutate(operand); - } else { - super.visitIntInsn(opcode, operand); - } - } - - @Override - public void visitLdcInsn(final Object constant) { - // do not mutate strings or .class here - if (constant instanceof Number) { - mutate((Number) constant); - } else { - super.visitLdcInsn(constant); - } - } - -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR1Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR1Mutator.java deleted file mode 100644 index 18eb62efa..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR1Mutator.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - - -import org.objectweb.asm.MethodVisitor; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutator that replaces an inline constant with 1; - */ -public enum CRCR1Mutator implements MethodMutatorFactory { - - CRCR1; - - private final class CRCRVisitor1 extends AbstractCRCRVisitor { - - CRCRVisitor1(final MutationContext context, - final MethodVisitor delegateVisitor) { - super(context, delegateVisitor, CRCR1Mutator.this); - } - - void mutate(final Double constant) { - final Double replacement = 1D; - - if (constant != 1D && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Float constant) { - final Float replacement = 1F; - - if (constant != 1F && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Integer constant) { - final Integer replacement = 1; - - if (constant != 1 && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Long constant) { - - final Long replacement = 1L; - - if (constant != 1L && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - - } - } - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new CRCRVisitor1(context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } - -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR2Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR2Mutator.java deleted file mode 100644 index f6a4bdc79..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR2Mutator.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - - -import org.objectweb.asm.MethodVisitor; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutator that replaces an inline constant with 0; - */ -public enum CRCR2Mutator implements MethodMutatorFactory { - - CRCR2; - - private final class CRCRVisitor1 extends AbstractCRCRVisitor { - - CRCRVisitor1(final MutationContext context, - final MethodVisitor delegateVisitor) { - super(context, delegateVisitor, CRCR2Mutator.this); - } - - void mutate(final Double constant) { - final Double replacement = 0D; - - if (constant != 0D && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Float constant) { - final Float replacement = 0F; - - if (constant != 0F && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Integer constant) { - final Integer replacement = 0; - - if (constant != 0 && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Long constant) { - - final Long replacement = 0L; - - if (constant != 0L && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - - } - } - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new CRCRVisitor1(context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } - -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR3Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR3Mutator.java deleted file mode 100644 index b55f0fba5..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR3Mutator.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - - -import org.objectweb.asm.MethodVisitor; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutator that replaces an inline constant with -1; - */ -public enum CRCR3Mutator implements MethodMutatorFactory { - - CRCR3; - - private final class CRCRVisitor1 extends AbstractCRCRVisitor { - - CRCRVisitor1(final MutationContext context, - final MethodVisitor delegateVisitor) { - super(context, delegateVisitor, CRCR3Mutator.this); - } - - void mutate(final Double constant) { - final Double replacement = -1D; - - if ((! constant.equals(-1D)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Float constant) { - final Float replacement = -1F; - - if ((! constant.equals(-1F)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Integer constant) { - final Integer replacement = -1; - - if ((! constant.equals(-1)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Long constant) { - - final Long replacement = -1L; - - if ((! constant.equals(-1L)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - - } - } - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new CRCRVisitor1(context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } - -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR4Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR4Mutator.java deleted file mode 100644 index ddfecb6e7..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR4Mutator.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - - -import org.objectweb.asm.MethodVisitor; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutator that replaces an inline constant with -constant or with maxValue for minValue of int and long; - */ -public enum CRCR4Mutator implements MethodMutatorFactory { - - CRCR4; - - private final class CRCRVisitor1 extends AbstractCRCRVisitor { - - CRCRVisitor1(final MutationContext context, - final MethodVisitor delegateVisitor) { - super(context, delegateVisitor, CRCR4Mutator.this); - } - - void mutate(final Double constant) { - final Double replacement = -constant; - - if ((! constant.equals(0D)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Float constant) { - final Float replacement = -constant; - - if ((! constant.equals(0F)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Integer constant) { - final Integer replacement = (constant == Integer.MIN_VALUE) ? Integer.MAX_VALUE : -constant; - - if ((! constant.equals(0)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Long constant) { - final Long replacement = (constant == Long.MIN_VALUE) ? Long.MAX_VALUE : -constant; - - if ((! constant.equals(0L)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - - } - } - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new CRCRVisitor1(context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } - -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR5Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR5Mutator.java deleted file mode 100644 index 251ea8da6..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR5Mutator.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - - -import org.objectweb.asm.MethodVisitor; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutator that replaces an inline constant with constant + 1 - * Does not mutate if precision would make the mutant equivalent; - */ -public enum CRCR5Mutator implements MethodMutatorFactory { - - CRCR5; - - private final class CRCRVisitor1 extends AbstractCRCRVisitor { - - CRCRVisitor1(final MutationContext context, - final MethodVisitor delegateVisitor) { - super(context, delegateVisitor, CRCR5Mutator.this); - } - - void mutate(final Double constant) { - final Double replacement = constant + 1D; - - if ((! constant.equals(replacement)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Float constant) { - final Float replacement = constant + 1F; - - if ((! constant.equals(replacement)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Integer constant) { - final Integer replacement = constant + 1; - - if ((! constant.equals(replacement)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Long constant) { - final Long replacement = constant + 1L; - - if ((! constant.equals(replacement)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - - } - } - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new CRCRVisitor1(context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } - -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR6Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR6Mutator.java deleted file mode 100644 index 3060f3406..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR6Mutator.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - - -import org.objectweb.asm.MethodVisitor; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutator that replaces an inline constant with constant-1; - * Does not mutate if precision would make the mutant equivalent - */ -public enum CRCR6Mutator implements MethodMutatorFactory { - - CRCR6; - - private final class CRCRVisitor1 extends AbstractCRCRVisitor { - - CRCRVisitor1(final MutationContext context, - final MethodVisitor delegateVisitor) { - super(context, delegateVisitor, CRCR6Mutator.this); - } - - void mutate(final Double constant) { - final Double replacement = constant - 1D; - - if ((! constant.equals(replacement)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Float constant) { - final Float replacement = constant - 1F; - - if ((! constant.equals(replacement)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Integer constant) { - final Integer replacement = constant - 1; - - if ((! constant.equals(replacement)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - } - - void mutate(final Long constant) { - final Long replacement = constant - 1L; - - if ((! constant.equals(replacement)) && shouldMutate(constant, replacement)) { - translateToByteCode(replacement); - } else { - translateToByteCode(constant); - } - - } - } - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new CRCRVisitor1(context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } - -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN1Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN1Mutator.java deleted file mode 100644 index 252c14dde..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN1Mutator.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import java.util.HashMap; -import java.util.Map; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractInsnMutator; -import org.pitest.mutationtest.engine.gregor.InsnSubstitution; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; -import org.pitest.mutationtest.engine.gregor.ZeroOperandMutation; - -/** - * Replaces bitwise "and" and "or" with each other - */ -public enum OBBN1Mutator implements MethodMutatorFactory { - - OBBN1; - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new OBBN1MethodVisitor(this, methodInfo, context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } - -} - -class OBBN1MethodVisitor extends AbstractInsnMutator { - - OBBN1MethodVisitor(final MethodMutatorFactory factory, - final MethodInfo methodInfo, final MutationContext context, - final MethodVisitor writer) { - super(factory, methodInfo, context, writer); - } - - private static final Map MUTATIONS = new HashMap<>(); - - static { - // integers - MUTATIONS.put(Opcodes.IAND, new InsnSubstitution(Opcodes.IOR, - "Replaced integer and with or")); - MUTATIONS.put(Opcodes.IOR, new InsnSubstitution(Opcodes.IAND, - "Replaced integer or with and")); - - // longs - MUTATIONS.put(Opcodes.LAND, new InsnSubstitution(Opcodes.LOR, - "Replaced long and with or")); - MUTATIONS.put(Opcodes.LOR, new InsnSubstitution(Opcodes.LAND, - "Replaced long or with and")); - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN2Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN2Mutator.java deleted file mode 100644 index c086ba9d5..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN2Mutator.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Replaces bitwise "and" and "or" by the first member - */ -public enum OBBN2Mutator implements MethodMutatorFactory { - - OBBN2; - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new OBBNMethodVisitor2(this, context, methodInfo, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } -} - -class OBBNMethodVisitor2 extends MethodVisitor { - - private final MethodMutatorFactory factory; - private final MutationContext context; - private final MethodInfo info; - - OBBNMethodVisitor2(final MethodMutatorFactory factory, - final MutationContext context, final MethodInfo info, final MethodVisitor delegateMethodVisitor) { - super(ASMVersion.ASM_VERSION, delegateMethodVisitor); - this.factory = factory; - this.context = context; - this.info = info; - } - - private boolean shouldMutate(String expression) { - if (info.isGeneratedEnumMethod()) { - return false; - } else { - final MutationIdentifier newId = this.context.registerMutation( - this.factory, "Replaced " + expression + " by first member"); - return this.context.shouldMutate(newId); - } - - } - - @Override - public void visitInsn(int opcode) { - switch (opcode) { - case Opcodes.IAND: - if (this.shouldMutate("integer and")) { - mv.visitInsn(Opcodes.POP); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.IOR: - if (this.shouldMutate("integer or")) { - mv.visitInsn(Opcodes.POP); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.LAND: - if (this.shouldMutate("long and")) { - mv.visitInsn(Opcodes.POP2); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.LOR: - if (this.shouldMutate("long or")) { - mv.visitInsn(Opcodes.POP2); - } else { - mv.visitInsn(opcode); - } - break; - default: - mv.visitInsn(opcode); - break; - } - } -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN3Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN3Mutator.java deleted file mode 100644 index 1a76ad2d8..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN3Mutator.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.commons.LocalVariablesSorter; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Replaces bitwise "and" and "or" by the second member - */ -public enum OBBN3Mutator implements MethodMutatorFactory { - - OBBN3; - - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new OBBNMethodVisitor3(this, context, methodInfo, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } -} - -class OBBNMethodVisitor3 extends LocalVariablesSorter { - - private final MethodMutatorFactory factory; - private final MutationContext context; - private final MethodInfo info; - - OBBNMethodVisitor3(final MethodMutatorFactory factory, - final MutationContext context, final MethodInfo info, final MethodVisitor delegateMethodVisitor) { - super(ASMVersion.ASM_VERSION, info.getAccess(), info.getMethodDescriptor(), delegateMethodVisitor); - this.factory = factory; - this.context = context; - this.info = info; - } - - private boolean shouldMutate(String expression) { - if (info.isGeneratedEnumMethod()) { - return false; - } else { - final MutationIdentifier newId = this.context.registerMutation( - this.factory, "Replace " + expression + " by second member"); - return this.context.shouldMutate(newId); - } - - } - - @Override - public void visitInsn(int opcode) { - switch (opcode) { - case Opcodes.IAND: - if (this.shouldMutate("integer and")) { - int storage = this.newLocal(Type.INT_TYPE); - mv.visitVarInsn(Opcodes.ISTORE,storage); - mv.visitInsn(Opcodes.POP); - mv.visitVarInsn(Opcodes.ILOAD,storage); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.IOR: - if (this.shouldMutate("integer or")) { - int storage = this.newLocal(Type.INT_TYPE); - mv.visitVarInsn(Opcodes.ISTORE,storage); - mv.visitInsn(Opcodes.POP); - mv.visitVarInsn(Opcodes.ILOAD,storage); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.LAND: - if (this.shouldMutate("long and")) { - int storage = this.newLocal(Type.LONG_TYPE); - mv.visitVarInsn(Opcodes.LSTORE,storage); - mv.visitInsn(Opcodes.POP2); - mv.visitVarInsn(Opcodes.LLOAD,storage); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.LOR: - if (this.shouldMutate("long or")) { - int storage = this.newLocal(Type.LONG_TYPE); - mv.visitVarInsn(Opcodes.LSTORE,storage); - mv.visitInsn(Opcodes.POP2); - mv.visitVarInsn(Opcodes.LLOAD,storage); - } else { - mv.visitInsn(opcode); - } - break; - default: - mv.visitInsn(opcode); - break; - } - } -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR1Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR1Mutator.java deleted file mode 100644 index 5dc78a36f..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR1Mutator.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractJumpMutator; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -import java.util.HashMap; -import java.util.Map; - -public enum ROR1Mutator implements MethodMutatorFactory { - - ROR1; - - @Override - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new ROR1MethodVisitor(this, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - @Override - public String getName() { - return name(); - } - -} - -class ROR1MethodVisitor extends AbstractJumpMutator { - - private static final Map MUTATIONS = new HashMap<>(); - - static { - MUTATIONS.put(Opcodes.IFLT, new Substitution(Opcodes.IFLE, "Less than to less or equal")); - MUTATIONS.put(Opcodes.IF_ICMPLT, new Substitution(Opcodes.IF_ICMPLE, - "Less than to less or equal")); - MUTATIONS.put(Opcodes.IFLE, new Substitution(Opcodes.IFLT, "Less or equal to less than")); - MUTATIONS.put(Opcodes.IF_ICMPLE, new Substitution(Opcodes.IF_ICMPLT, - "Less or equal to less than")); - MUTATIONS.put(Opcodes.IFGT, new Substitution(Opcodes.IFLT, "greater than to less than")); - MUTATIONS.put(Opcodes.IF_ICMPGT, new Substitution(Opcodes.IF_ICMPLT, - "greater than to less than")); - MUTATIONS.put(Opcodes.IFGE, new Substitution(Opcodes.IFLT, "greater or equal to less than")); - MUTATIONS.put(Opcodes.IF_ICMPGE, new Substitution(Opcodes.IF_ICMPLT, - "greater or equal to less than")); - MUTATIONS.put(Opcodes.IFEQ, new Substitution(Opcodes.IFLT, "equal to less than")); - MUTATIONS.put(Opcodes.IF_ICMPEQ, new Substitution(Opcodes.IF_ICMPLT, - "equal to less than")); - MUTATIONS.put(Opcodes.IFNE, new Substitution(Opcodes.IFLT, "not equal to less than")); - MUTATIONS.put(Opcodes.IF_ICMPNE, new Substitution(Opcodes.IF_ICMPLT, - "not equal to less than")); - } - - ROR1MethodVisitor(final MethodMutatorFactory factory, - final MutationContext context, final MethodVisitor delegateMethodVisitor) { - super(factory, context, delegateMethodVisitor); - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR2Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR2Mutator.java deleted file mode 100644 index 1860316ec..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR2Mutator.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractJumpMutator; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -import java.util.HashMap; -import java.util.Map; - -public enum ROR2Mutator implements MethodMutatorFactory { - - ROR2; - - @Override - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new ROR2MethodVisitor(this, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - @Override - public String getName() { - return name(); - } - -} - -class ROR2MethodVisitor extends AbstractJumpMutator { - - private static final Map MUTATIONS = new HashMap<>(); - - static { - MUTATIONS.put(Opcodes.IFLT, new Substitution(Opcodes.IFGT, "Less than to greater than")); - MUTATIONS.put(Opcodes.IF_ICMPLT, new Substitution(Opcodes.IF_ICMPGT, - "Less than to greater than")); - MUTATIONS.put(Opcodes.IFLE, new Substitution(Opcodes.IFGT, "Less or equal to greater than")); - MUTATIONS.put(Opcodes.IF_ICMPLE, new Substitution(Opcodes.IF_ICMPGT, - "Less or equal to greater than")); - MUTATIONS.put(Opcodes.IFGT, new Substitution(Opcodes.IFLE, "greater than to less or equal")); - MUTATIONS.put(Opcodes.IF_ICMPGT, new Substitution(Opcodes.IF_ICMPLE, - "greater than to less or equal")); - MUTATIONS.put(Opcodes.IFGE, new Substitution(Opcodes.IFLE, "greater or equal to less or equal")); - MUTATIONS.put(Opcodes.IF_ICMPGE, new Substitution(Opcodes.IF_ICMPLE, - "greater or equal to less or equal")); - MUTATIONS.put(Opcodes.IFEQ, new Substitution(Opcodes.IFLE, "equal to less or equal")); - MUTATIONS.put(Opcodes.IF_ICMPEQ, new Substitution(Opcodes.IF_ICMPLE, - "equal to less or equal")); - MUTATIONS.put(Opcodes.IFNE, new Substitution(Opcodes.IFLE, "not equal to less or equal")); - MUTATIONS.put(Opcodes.IF_ICMPNE, new Substitution(Opcodes.IF_ICMPLE, - "not equal to less or equal")); - } - - ROR2MethodVisitor(final MethodMutatorFactory factory, - final MutationContext context, final MethodVisitor delegateMethodVisitor) { - super(factory, context, delegateMethodVisitor); - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR3Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR3Mutator.java deleted file mode 100644 index ee82eeb40..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR3Mutator.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractJumpMutator; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -import java.util.HashMap; -import java.util.Map; - -public enum ROR3Mutator implements MethodMutatorFactory { - - ROR3; - - @Override - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new ROR3MethodVisitor(this, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - @Override - public String getName() { - return name(); - } - -} - -class ROR3MethodVisitor extends AbstractJumpMutator { - - private static final Map MUTATIONS = new HashMap<>(); - - static { - MUTATIONS.put(Opcodes.IFLT, new Substitution(Opcodes.IFGE, "Less than to greater or equal")); - MUTATIONS.put(Opcodes.IF_ICMPLT, new Substitution(Opcodes.IF_ICMPGE, - "Less than to greater or equal")); - MUTATIONS.put(Opcodes.IFLE, new Substitution(Opcodes.IFGE, "Less or equal to greater or equal")); - MUTATIONS.put(Opcodes.IF_ICMPLE, new Substitution(Opcodes.IF_ICMPGE, - "Less or equal to greater or equal")); - MUTATIONS.put(Opcodes.IFGT, new Substitution(Opcodes.IFGE, "greater than to greater or equal")); - MUTATIONS.put(Opcodes.IF_ICMPGT, new Substitution(Opcodes.IF_ICMPGE, - "greater than to greater or equal")); - MUTATIONS.put(Opcodes.IFGE, new Substitution(Opcodes.IFGT, "greater or equal to greater than")); - MUTATIONS.put(Opcodes.IF_ICMPGE, new Substitution(Opcodes.IF_ICMPGT, - "greater or equal to greater than")); - MUTATIONS.put(Opcodes.IFEQ, new Substitution(Opcodes.IFGT, "equal to greater than")); - MUTATIONS.put(Opcodes.IF_ICMPEQ, new Substitution(Opcodes.IF_ICMPGT, - "equal to greater than")); - MUTATIONS.put(Opcodes.IFNE, new Substitution(Opcodes.IFGT, "not equal to greater than")); - MUTATIONS.put(Opcodes.IF_ICMPNE, new Substitution(Opcodes.IF_ICMPGT, - "not equal to greater than")); - } - - ROR3MethodVisitor(final MethodMutatorFactory factory, - final MutationContext context, final MethodVisitor delegateMethodVisitor) { - super(factory, context, delegateMethodVisitor); - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR4Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR4Mutator.java deleted file mode 100644 index 863e0c4e9..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR4Mutator.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractJumpMutator; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -import java.util.HashMap; -import java.util.Map; - -public enum ROR4Mutator implements MethodMutatorFactory { - - ROR4; - - @Override - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new ROR4MethodVisitor(this, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - @Override - public String getName() { - return name(); - } - -} - -class ROR4MethodVisitor extends AbstractJumpMutator { - - private static final Map MUTATIONS = new HashMap<>(); - - static { - MUTATIONS.put(Opcodes.IFLT, new Substitution(Opcodes.IFEQ, "Less than to equal")); - MUTATIONS.put(Opcodes.IF_ICMPLT, new Substitution(Opcodes.IF_ICMPEQ, - "Less than to equal")); - MUTATIONS.put(Opcodes.IFLE, new Substitution(Opcodes.IFEQ, "Less or equal to equal")); - MUTATIONS.put(Opcodes.IF_ICMPLE, new Substitution(Opcodes.IF_ICMPEQ, - "Less or equal to equal")); - MUTATIONS.put(Opcodes.IFGT, new Substitution(Opcodes.IFEQ, "greater than to equal")); - MUTATIONS.put(Opcodes.IF_ICMPGT, new Substitution(Opcodes.IF_ICMPEQ, - "greater than to equal")); - MUTATIONS.put(Opcodes.IFGE, new Substitution(Opcodes.IFEQ, "greater or equal to equal")); - MUTATIONS.put(Opcodes.IF_ICMPGE, new Substitution(Opcodes.IF_ICMPEQ, - "greater or equal to equal")); - MUTATIONS.put(Opcodes.IFEQ, new Substitution(Opcodes.IFGE, "equal to greater or equal")); - MUTATIONS.put(Opcodes.IF_ICMPEQ, new Substitution(Opcodes.IF_ICMPGE, - "equal to greater or equal")); - MUTATIONS.put(Opcodes.IFNE, new Substitution(Opcodes.IFGE, "not equal to greater or equal")); - MUTATIONS.put(Opcodes.IF_ICMPNE, new Substitution(Opcodes.IF_ICMPGE, - "not equal to greater or equal")); - } - - ROR4MethodVisitor(final MethodMutatorFactory factory, - final MutationContext context, final MethodVisitor delegateMethodVisitor) { - super(factory, context, delegateMethodVisitor); - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR5Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR5Mutator.java deleted file mode 100644 index 6a58528e4..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR5Mutator.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.mutationtest.engine.gregor.AbstractJumpMutator; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -import java.util.HashMap; -import java.util.Map; - -public enum ROR5Mutator implements MethodMutatorFactory { - - ROR5; - - @Override - public MethodVisitor create(final MutationContext context, - final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new ROR5MethodVisitor(this, context, methodVisitor); - } - - @Override - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - @Override - public String getName() { - return name(); - } - -} - -class ROR5MethodVisitor extends AbstractJumpMutator { - - private static final Map MUTATIONS = new HashMap<>(); - - static { - MUTATIONS.put(Opcodes.IFLT, new Substitution(Opcodes.IFNE, "Less than to not equal")); - MUTATIONS.put(Opcodes.IF_ICMPLT, new Substitution(Opcodes.IF_ICMPNE, - "Less than to not equal")); - MUTATIONS.put(Opcodes.IFLE, new Substitution(Opcodes.IFNE, "Less or equal to not equal")); - MUTATIONS.put(Opcodes.IF_ICMPLE, new Substitution(Opcodes.IF_ICMPNE, - "Less or equal to not equal")); - MUTATIONS.put(Opcodes.IFGT, new Substitution(Opcodes.IFNE, "greater than to not equal")); - MUTATIONS.put(Opcodes.IF_ICMPGT, new Substitution(Opcodes.IF_ICMPNE, - "greater than to not equal")); - MUTATIONS.put(Opcodes.IFGE, new Substitution(Opcodes.IFNE, "greater or equal to not equal")); - MUTATIONS.put(Opcodes.IF_ICMPGE, new Substitution(Opcodes.IF_ICMPNE, - "greater or equal to not equal")); - MUTATIONS.put(Opcodes.IFEQ, new Substitution(Opcodes.IFNE, "equal to not equal")); - MUTATIONS.put(Opcodes.IF_ICMPEQ, new Substitution(Opcodes.IF_ICMPNE, - "equal to not equal")); - MUTATIONS.put(Opcodes.IFNULL, new Substitution(Opcodes.IFNONNULL, - "equal to not equal")); - MUTATIONS.put(Opcodes.IF_ACMPEQ, new Substitution(Opcodes.IF_ACMPNE, - "equal to not equal")); - MUTATIONS.put(Opcodes.IFNE, new Substitution(Opcodes.IFEQ, "not equal to equal")); - MUTATIONS.put(Opcodes.IF_ICMPNE, new Substitution(Opcodes.IF_ICMPEQ, - "not equal to equal")); - MUTATIONS.put(Opcodes.IFNONNULL, new Substitution(Opcodes.IFNULL, - "not equal to equal")); - MUTATIONS.put(Opcodes.IF_ACMPNE, new Substitution(Opcodes.IF_ACMPEQ, - "not equal to equal")); - } - - ROR5MethodVisitor(final MethodMutatorFactory factory, - final MutationContext context, final MethodVisitor delegateMethodVisitor) { - super(factory, context, delegateMethodVisitor); - } - - @Override - protected Map getMutations() { - return MUTATIONS; - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/RVMutatorGroups.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/RVMutatorGroups.java deleted file mode 100644 index 861b21512..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/RVMutatorGroups.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.config.MutatorGroup; - -import java.util.List; -import java.util.Map; - -public class RVMutatorGroups implements MutatorGroup { - @Override - public void register(Map> mutators) { - /* - * mutators that mutate binary arithmetic operations. - */ - mutators.put("AOR", gather(mutators,"AOR1", "AOR2", "AOR3", "AOR4")); - - /* - * mutators that replace a binary arithmetic operations with one of its members. - */ - mutators.put("AOD", gather(mutators,"AOD1", "AOD2")); - - /* - * mutators that replace an inline constant a with 0, 1, -1, a+1 or a-1 . - */ - mutators.put("CRCR", gather(mutators,"CRCR1", "CRCR2", "CRCR3", "CRCR4", - "CRCR5", "CRCR6")); - /* - * mutators that replace an bitwise ands and ors. - */ - mutators.put("OBBN", gather(mutators,"OBBN1", "OBBN2", "OBBN3")); - - /* - * mutators that replace conditional operators. - */ - mutators.put("ROR", gather(mutators,"ROR1", "ROR2", "ROR3", "ROR4", "ROR5")); - - /* - * mutators that insert increments. - */ - mutators.put("UOI", gather(mutators,"UOI1", "UOI2", "UOI3", "UOI4")); - } -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI1Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI1Mutator.java deleted file mode 100644 index 7d83a9a8e..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI1Mutator.java +++ /dev/null @@ -1,323 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutation operator changing (a) to (a++) - */ -public enum UOI1Mutator implements MethodMutatorFactory { - - UOI1; - - public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new UOI1MethodVisitor(this, context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } -} - -class UOI1MethodVisitor extends MethodVisitor { - - private final MethodMutatorFactory factory; - private final MutationContext context; - - UOI1MethodVisitor(final MethodMutatorFactory factory, final MutationContext context, - final MethodVisitor delegateMethodVisitor) { - super(ASMVersion.ASM_VERSION, delegateMethodVisitor); - this.factory = factory; - this.context = context; - - } - - private boolean shouldMutate(String description) { - if (context.getClassInfo().isEnum()) { - return false; - } else { - final MutationIdentifier newId = this.context.registerMutation(this.factory, description); - return this.context.shouldMutate(newId); - } - } - - @Override - public void visitVarInsn(int opcode, int var) { - mv.visitVarInsn(opcode, var); - - switch (opcode) { - case Opcodes.ILOAD: - if (this.shouldMutate("Incremented (a++) integer local variable number " + var)) { - mv.visitIincInsn(var, 1); - } - break; - case Opcodes.FLOAD: - if (this.shouldMutate("Incremented (a++) float local variable number " + var)) { - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FADD); - mv.visitVarInsn(Opcodes.FSTORE, var); - } - break; - case Opcodes.LLOAD: - if (this.shouldMutate("Incremented (a++) long local variable number " + var)) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LADD); - mv.visitVarInsn(Opcodes.LSTORE, var); - } - break; - case Opcodes.DLOAD: - if (this.shouldMutate("Incremented (a++) double local variable number " + var)) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DADD); - mv.visitVarInsn(Opcodes.DSTORE, var); - } - break; - - default: - break; - } - } - - // ARRAYS - @Override - public void visitInsn(final int opcode) { - // I F L D + BS - switch (opcode) { - case Opcodes.IALOAD: - if (this.shouldMutate("Incremented (a++) integer array field")) { - mv.visitInsn(Opcodes.DUP2); // stack = ... [array] [index] [array] [index] - mv.visitInsn(opcode); // stack = ... [array] [index] [array[index]] - mv.visitInsn(Opcodes.DUP_X2); //stack = ... [array[index]] [array] [index] [array[index]] - mv.visitInsn(Opcodes.ICONST_1); //stack = ... [array[index]] [array] [index] [array[index]] [1] - mv.visitInsn(Opcodes.IADD); //stack = ... [array[index]] [array] [index] [array[index] + 1] - mv.visitInsn(Opcodes.IASTORE); //stack = ... [array[index]] - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.FALOAD: - if (this.shouldMutate("Incremented (a++) float array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FADD); - mv.visitInsn(Opcodes.FASTORE); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.LALOAD: - if (this.shouldMutate("Incremented (a++) long array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP2_X2); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LADD); - mv.visitInsn(Opcodes.LASTORE); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.DALOAD: - if (this.shouldMutate("Incremented (a++) double array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP2_X2); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DADD); - mv.visitInsn(Opcodes.DASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.BALOAD: - if (this.shouldMutate("Incremented (a++) byte array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2B); - mv.visitInsn(Opcodes.BASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.SALOAD: - if (this.shouldMutate("Incremented (a++) short array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2S); - mv.visitInsn(Opcodes.SASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - default: - mv.visitInsn(opcode); - break; - } - } - - // PARAMETERS, static or not. - @Override - public void visitFieldInsn(int opcode, String owner, String name, String desc) { - // GETFIELD I,F,L,D + B,S - if ((opcode == Opcodes.GETFIELD)) { - if (desc.equals("I")) { - if (this.shouldMutate("Incremented (a++) integer field " + name)) { - mv.visitInsn(Opcodes.DUP); // stack = ... [ref] [ref] - mv.visitFieldInsn(opcode, owner, name, desc); // stack = [ref] [ref.field] - mv.visitInsn(Opcodes.DUP_X1); // stack = ... [ref.field] [ref] [ref.field] - mv.visitInsn(Opcodes.ICONST_1);//stack = ... [ref.field] [ref] [ref.field] [1] - mv.visitInsn(Opcodes.IADD); // stack = ... [ref.field] [ref] [ref.field +1] - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); // stack = ... [ref.field] - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Incremented (a++) float field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FADD); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Incremented (a++) long field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP2_X1); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LADD); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Incremented (a++) double field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP2_X1); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DADD); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Incremented (a++) byte field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2B); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Incremented (a++) short field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2S); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - } - - // GETSTATIC I,F,L,D + B,S - if (opcode == Opcodes.GETSTATIC) { - if (desc.equals("I")) { - if (this.shouldMutate("Incremented (a++) static integer field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Incremented (a++) static float field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FADD); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Incremented (a++) static long field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LADD); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Incremented (a++) static double field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DADD); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Incremented (a++) static byte field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2B); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Incremented (a++) static short field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2S); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - } - mv.visitFieldInsn(opcode, owner, name, desc); - } -} \ No newline at end of file diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI2Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI2Mutator.java deleted file mode 100644 index 2c95cb54d..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI2Mutator.java +++ /dev/null @@ -1,320 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutation operator changing (a) to (a--) - */ -public enum UOI2Mutator implements MethodMutatorFactory { - - UOI2; - - public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, final MethodVisitor methodVisitor) { - return new UOI2MethodVisitor(this, context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } -} - -class UOI2MethodVisitor extends MethodVisitor { - - private final MethodMutatorFactory factory; - private final MutationContext context; - - UOI2MethodVisitor(final MethodMutatorFactory factory, final MutationContext context, - final MethodVisitor delegateMethodVisitor) { - super(ASMVersion.ASM_VERSION, delegateMethodVisitor); - this.factory = factory; - this.context = context; - } - - private boolean shouldMutate(String description) { - if (context.getClassInfo().isEnum()) { - return false; - } else { - final MutationIdentifier newId = this.context.registerMutation(this.factory, description); - return this.context.shouldMutate(newId); - } - } - - @Override - public void visitVarInsn(int opcode, int var) { - mv.visitVarInsn(opcode, var); - switch (opcode) { - case Opcodes.ILOAD: - if (this.shouldMutate("Decremented (a--) integer local variable number " + var)) { - mv.visitIincInsn(var, -1); - } - break; - case Opcodes.FLOAD: - if (this.shouldMutate("Decremented (a--) float local variable number " + var)) { - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FSUB); - mv.visitVarInsn(Opcodes.FSTORE, var); - } - break; - case Opcodes.LLOAD: - if (this.shouldMutate("Decremented (a--) long local variable number " + var)) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LSUB); - mv.visitVarInsn(Opcodes.LSTORE, var); - } - break; - case Opcodes.DLOAD: - if (this.shouldMutate("Decremented (a--) double local variable number " + var)) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DSUB); - mv.visitVarInsn(Opcodes.DSTORE, var); - } - break; - default: - break; - } - } - - // ARRAYS - @Override - public void visitInsn(final int opcode) { - // I F L D + BS - switch (opcode) { - case Opcodes.IALOAD: - if (this.shouldMutate("Decremented (a--) integer array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.IASTORE); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.FALOAD: - if (this.shouldMutate("Decremented (a--) float array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FSUB); - mv.visitInsn(Opcodes.FASTORE); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.LALOAD: - if (this.shouldMutate("Decremented (a--) long array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP2_X2); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LSUB); - mv.visitInsn(Opcodes.LASTORE); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.DALOAD: - if (this.shouldMutate("Decremented (a--) double array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP2_X2); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DSUB); - mv.visitInsn(Opcodes.DASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.BALOAD: - if (this.shouldMutate("Decremented (a--) byte array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2B); - mv.visitInsn(Opcodes.BASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.SALOAD: - if (this.shouldMutate("Decremented (a--) short array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2S); - mv.visitInsn(Opcodes.SASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - default: - mv.visitInsn(opcode); - break; - } - } - - // PARAMETERS, static or not. - @Override - public void visitFieldInsn(int opcode, String owner, String name, String desc) { - // GETFIELD I,F,L,D + B,S - if ((opcode == Opcodes.GETFIELD)) { - if (desc.equals("I")) { - if (this.shouldMutate("Decremented (a--) integer field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Decremented (a--) float field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FSUB); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Decremented (a--) long field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP2_X1); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LSUB); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Decremented (a--) double field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP2_X1); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DSUB); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Decremented (a--) byte field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2B); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Decremented (a--) short field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2S); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - } - - // GETSTATIC I,F,L,D + B,S - if (opcode == Opcodes.GETSTATIC) { - if (desc.equals("I")) { - if (this.shouldMutate("Decremented (a--) static integer field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Decremented (a--) static float field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FSUB); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Decremented (a--) static long field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LSUB); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Decremented (a--) static double field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DSUB); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Decremented (a--) static byte field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2B); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Decremented (a--) static short field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DUP); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2S); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - } - mv.visitFieldInsn(opcode, owner, name, desc); - } -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI3Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI3Mutator.java deleted file mode 100644 index 268f5495c..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI3Mutator.java +++ /dev/null @@ -1,326 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutation operator changing (a) to (++a) - */ -public enum UOI3Mutator implements MethodMutatorFactory { - - UOI3; - - public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, - final MethodVisitor methodVisitor) { - return new UOIMethodVisitor3(this, context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } -} - -class UOIMethodVisitor3 extends MethodVisitor { - - private final MethodMutatorFactory factory; - private final MutationContext context; - - UOIMethodVisitor3(final MethodMutatorFactory factory, final MutationContext context, - final MethodVisitor delegateMethodVisitor) { - super(ASMVersion.ASM_VERSION, delegateMethodVisitor); - this.factory = factory; - this.context = context; - } - - private boolean shouldMutate(String description) { - if (context.getClassInfo().isEnum()) { - return false; - } else { - final MutationIdentifier newId = this.context.registerMutation(this.factory, description); - return this.context.shouldMutate(newId); - } - } - - @Override - public void visitVarInsn(int opcode, int var) { - switch (opcode) { - case Opcodes.ILOAD: - if (this.shouldMutate("Incremented (++a) integer local variable number " + var)) { - mv.visitIincInsn(var, 1); - } - mv.visitVarInsn(opcode, var); - break; - case Opcodes.FLOAD: - if (this.shouldMutate("Incremented (++a) float local variable number " + var)) { - mv.visitVarInsn(opcode, var); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FADD); - mv.visitVarInsn(Opcodes.FSTORE, var); - } - mv.visitVarInsn(opcode, var); - break; - case Opcodes.LLOAD: - if (this.shouldMutate("Incremented (++a) long local variable number " + var)) { - mv.visitVarInsn(opcode, var); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LADD); - mv.visitVarInsn(Opcodes.LSTORE, var); - } - mv.visitVarInsn(opcode, var); - break; - case Opcodes.DLOAD: - if (this.shouldMutate("Incremented (++a) double local variable number " + var)) { - mv.visitVarInsn(opcode, var); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DADD); - mv.visitVarInsn(Opcodes.DSTORE, var); - } - mv.visitVarInsn(opcode, var); - break; - default: - mv.visitVarInsn(opcode, var); - break; - } - } - - // ARRAYS - @Override - public void visitInsn(final int opcode) { - // I F L D + BS - switch (opcode) { - case Opcodes.IALOAD: - if (this.shouldMutate("Incremented (++a) integer array field")) { - mv.visitInsn(Opcodes.DUP2); // stack = ... [array] [index] [array] [index] - mv.visitInsn(opcode); // stack = ... [array] [index] [array[index]] - mv.visitInsn(Opcodes.ICONST_1); // stack = ... [array] [index] [array[index]] [1] - mv.visitInsn(Opcodes.IADD); // stack = ... [array] [index] [array[index]+1] - mv.visitInsn(Opcodes.DUP_X2); // stack = ... [array[index]+1] [array] [index] [array[index]+1] - mv.visitInsn(Opcodes.IASTORE); // stack = ... [array[index]+1] - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.FALOAD: - if (this.shouldMutate("Incremented (++a) float array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FADD); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.FASTORE); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.LALOAD: - if (this.shouldMutate("Incremented (++a) long array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LADD); - mv.visitInsn(Opcodes.DUP2_X2); - mv.visitInsn(Opcodes.LASTORE); - } else { - mv.visitInsn(opcode); - } - break; - case Opcodes.DALOAD: - if (this.shouldMutate("Incremented (++a) double array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DADD); - mv.visitInsn(Opcodes.DUP2_X2); - mv.visitInsn(Opcodes.DASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.BALOAD: - if (this.shouldMutate("Incremented (++a) byte array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2B); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.BASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.SALOAD: - if (this.shouldMutate("Incremented (++a) short array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2S); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.SASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - default: - mv.visitInsn(opcode); - break; - } - } - - // PARAMETERS, static or not. - @Override - public void visitFieldInsn(int opcode, String owner, String name, String desc) { - // GETFIELD I,F,L,D + B,S - if ((opcode == Opcodes.GETFIELD)) { - if (desc.equals("I")) { - if (this.shouldMutate("Incremented (++a) integer field " + name)) { - mv.visitInsn(Opcodes.DUP); // stack = .. [ref] [ref] - mv.visitFieldInsn(opcode, owner, name, desc); // stack = ... [ref] [ref.field] - mv.visitInsn(Opcodes.ICONST_1); // stack = ... [ref] [ref.field] [1] - mv.visitInsn(Opcodes.IADD); // stack = ... [ref] [ref.field + 1] - mv.visitInsn(Opcodes.DUP_X1); // stack = ... [ref.field +1] [ref] [ref.field +1] - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); // stack = ... [ref.field +1] - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Incremented (++a) float field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FADD); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Incremented (++a) long field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LADD); - mv.visitInsn(Opcodes.DUP2_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Incremented (++a) double field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DADD); - mv.visitInsn(Opcodes.DUP2_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Incremented (++a) byte field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2B); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Incremented (++a) short field " + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2S); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - } - - // GETSTATIC I,F,L,D + B,S - if (opcode == Opcodes.GETSTATIC) { - if (desc.equals("I")) { - if (this.shouldMutate("Incremented (++a) static integer field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Incremented (++a) static float field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FADD); - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Incremented (++a) static long field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LADD); - mv.visitInsn(Opcodes.DUP2); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Incremented (++a) static double field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DADD); - mv.visitInsn(Opcodes.DUP2); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Incremented (++a) static byte field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2B); - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Incremented (++a) static short field " + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.IADD); - mv.visitInsn(Opcodes.I2S); - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - } - mv.visitFieldInsn(opcode, owner, name, desc); - } - -} diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI4Mutator.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI4Mutator.java deleted file mode 100644 index 7b57a7b6a..000000000 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI4Mutator.java +++ /dev/null @@ -1,335 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.pitest.bytecode.ASMVersion; -import org.pitest.mutationtest.engine.MutationIdentifier; -import org.pitest.mutationtest.engine.gregor.MethodInfo; -import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; -import org.pitest.mutationtest.engine.gregor.MutationContext; - -/** - * Mutation operator changing (a) to (--a) - */ -public enum UOI4Mutator implements MethodMutatorFactory { - - UOI4; - - public MethodVisitor create(final MutationContext context, final MethodInfo methodInfo, - final MethodVisitor methodVisitor) { - return new UOI4MethodVisitor(this, context, methodVisitor); - } - - public String getGloballyUniqueId() { - return this.getClass().getName(); - } - - public String getName() { - return name(); - } -} - -class UOI4MethodVisitor extends MethodVisitor { - - private final MethodMutatorFactory factory; - private final MutationContext context; - - UOI4MethodVisitor(final MethodMutatorFactory factory, final MutationContext context, - final MethodVisitor delegateMethodVisitor) { - super(ASMVersion.ASM_VERSION, delegateMethodVisitor); - this.factory = factory; - this.context = context; - } - - private boolean shouldMutate(String description) { - if (context.getClassInfo().isEnum()) { - return false; - } else { - final MutationIdentifier newId = this.context.registerMutation(this.factory, description); - return this.context.shouldMutate(newId); - } - } - - @Override - public void visitVarInsn(int opcode, int var) { - switch (opcode) { - case Opcodes.ILOAD: - if (this.shouldMutate("Decremented (--a) integer local variable number " + var)) { - mv.visitIincInsn(var, -1); - } - mv.visitVarInsn(opcode, var); - - break; - - case Opcodes.FLOAD: - if (this.shouldMutate("Decremented (--a) float local variable number " + var)) { - mv.visitVarInsn(opcode, var); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FSUB); - mv.visitVarInsn(Opcodes.FSTORE, var); - } - mv.visitVarInsn(opcode, var); - - break; - - case Opcodes.LLOAD: - if (this.shouldMutate("Decremented (--a) long local variable number " + var)) { - mv.visitVarInsn(opcode, var); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LSUB); - mv.visitVarInsn(Opcodes.LSTORE, var); - } - mv.visitVarInsn(opcode, var); - break; - - case Opcodes.DLOAD: - if (this.shouldMutate("Decremented (--a) double local variable number " + var)) { - mv.visitVarInsn(opcode, var); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DSUB); - mv.visitVarInsn(Opcodes.DSTORE, var); - } - mv.visitVarInsn(opcode, var); - break; - - default: - mv.visitVarInsn(opcode, var); - break; - } - } - - // ARRAYS - @Override - public void visitInsn(final int opcode) { - // I F L D + BS - switch (opcode) { - case Opcodes.IALOAD: - if (this.shouldMutate("Decremented (--a) integer array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.IASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.FALOAD: - if (this.shouldMutate("Decremented (--a) float array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FSUB); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.FASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.LALOAD: - if (this.shouldMutate("Decremented (--a) long array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LSUB); - mv.visitInsn(Opcodes.DUP2_X2); - mv.visitInsn(Opcodes.LASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.DALOAD: - if (this.shouldMutate("Decremented (--a) double array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DSUB); - mv.visitInsn(Opcodes.DUP2_X2); - mv.visitInsn(Opcodes.DASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.BALOAD: - if (this.shouldMutate("Decremented (--a) byte array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2B); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.BASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - case Opcodes.SALOAD: - if (this.shouldMutate("Decremented (--a) short array field")) { - mv.visitInsn(Opcodes.DUP2); - mv.visitInsn(opcode); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2S); - mv.visitInsn(Opcodes.DUP_X2); - mv.visitInsn(Opcodes.SASTORE); - } else { - mv.visitInsn(opcode); - } - break; - - default: - mv.visitInsn(opcode); - break; - } - } - - // PARAMETERS, static or not. - @Override - public void visitFieldInsn(int opcode, String owner, String name, String desc) { - - // GETFIELD I,F,L,D + B,S - if ((opcode == Opcodes.GETFIELD)) { - if (desc.equals("I")) { - if (this.shouldMutate("Decremented (--a) integer field" + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Decremented (--a) float field" + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FSUB); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Decremented (--a) long field" + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LSUB); - mv.visitInsn(Opcodes.DUP2_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Decremented (--a) double field" + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DSUB); - mv.visitInsn(Opcodes.DUP2_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Decremented (--a) double field" + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2B); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Decremented (--a) short field" + name)) { - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2S); - mv.visitInsn(Opcodes.DUP_X1); - mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc); - return; - } - } - } - - // GETSTATIC I,F,L,D + B,S - if (opcode == Opcodes.GETSTATIC) { - if (desc.equals("I")) { - if (this.shouldMutate("Decremented (--a) static integer field" + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("F")) { - if (this.shouldMutate("Decremented (--a) static float field" + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.FCONST_1); - mv.visitInsn(Opcodes.FSUB); - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("J")) { - if (this.shouldMutate("Decremented (--a) static long field" + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.LCONST_1); - mv.visitInsn(Opcodes.LSUB); - mv.visitInsn(Opcodes.DUP2); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("D")) { - if (this.shouldMutate("Decremented (--a) static double field" + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.DCONST_1); - mv.visitInsn(Opcodes.DSUB); - mv.visitInsn(Opcodes.DUP2); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("B")) { - if (this.shouldMutate("Decremented (--a) static byte field" + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2B); - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - if (desc.equals("S")) { - if (this.shouldMutate("Decremented (--a) static short field" + name)) { - mv.visitFieldInsn(opcode, owner, name, desc); - mv.visitInsn(Opcodes.ICONST_1); - mv.visitInsn(Opcodes.ISUB); - mv.visitInsn(Opcodes.I2S); - mv.visitInsn(Opcodes.DUP); - mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc); - return; - } - } - } - mv.visitFieldInsn(opcode, owner, name, desc); - } -} diff --git a/pitest/src/main/resources/META-INF/services/org.pitest.mutationtest.engine.gregor.MethodMutatorFactory b/pitest/src/main/resources/META-INF/services/org.pitest.mutationtest.engine.gregor.MethodMutatorFactory index d8db433ef..4f6dad7d2 100644 --- a/pitest/src/main/resources/META-INF/services/org.pitest.mutationtest.engine.gregor.MethodMutatorFactory +++ b/pitest/src/main/resources/META-INF/services/org.pitest.mutationtest.engine.gregor.MethodMutatorFactory @@ -26,28 +26,3 @@ org.pitest.mutationtest.engine.gregor.mutators.experimental.ReturnValuesMutator org.pitest.mutationtest.engine.gregor.mutators.experimental.SwitchMutator org.pitest.mutationtest.engine.gregor.mutators.experimental.BigDecimalMutator org.pitest.mutationtest.engine.gregor.mutators.experimental.BigIntegerMutator -org.pitest.mutationtest.engine.gregor.mutators.rv.ABSMutator -org.pitest.mutationtest.engine.gregor.mutators.rv.AOD1Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.AOD2Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.AOR1Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.AOR2Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.AOR3Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.AOR4Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR1Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR2Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR3Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR4Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR5Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR6Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.OBBN1Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.OBBN2Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.OBBN3Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.ROR1Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.ROR2Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.ROR3Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.ROR4Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.ROR5Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.UOI1Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.UOI2Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.UOI3Mutator -org.pitest.mutationtest.engine.gregor.mutators.rv.UOI4Mutator diff --git a/pitest/src/main/resources/META-INF/services/org.pitest.mutationtest.engine.gregor.config.MutatorGroup b/pitest/src/main/resources/META-INF/services/org.pitest.mutationtest.engine.gregor.config.MutatorGroup index 4f15e72c7..ad1ee4558 100644 --- a/pitest/src/main/resources/META-INF/services/org.pitest.mutationtest.engine.gregor.config.MutatorGroup +++ b/pitest/src/main/resources/META-INF/services/org.pitest.mutationtest.engine.gregor.config.MutatorGroup @@ -1,6 +1,5 @@ org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutatorGroup org.pitest.mutationtest.engine.gregor.mutators.returns.ReturnsMutatorGroup org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutatorGroup -org.pitest.mutationtest.engine.gregor.mutators.rv.RVMutatorGroups org.pitest.mutationtest.engine.gregor.config.StandardMutatorGroups \ No newline at end of file diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/config/MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/config/MutatorTest.java index 1bc9637c0..33143ce63 100644 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/config/MutatorTest.java +++ b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/config/MutatorTest.java @@ -22,36 +22,10 @@ import java.util.List; import org.junit.Test; -import org.pitest.mutationtest.engine.MutationEngine; import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory; import org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator; import org.pitest.mutationtest.engine.gregor.mutators.InvertNegsMutator; import org.pitest.mutationtest.engine.gregor.mutators.MathMutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.ABSMutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.AOD1Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.AOD2Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.AOR1Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.AOR2Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.AOR3Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.AOR4Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR1Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR2Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR3Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR4Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR5Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.CRCR6Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.OBBN1Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.OBBN2Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.OBBN3Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.ROR1Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.ROR2Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.ROR3Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.ROR4Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.ROR5Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.UOI1Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.UOI2Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.UOI3Mutator; -import org.pitest.mutationtest.engine.gregor.mutators.rv.UOI4Mutator; public class MutatorTest { @@ -184,71 +158,6 @@ public void providesExperimentalMutators() { assertProvides("EXPERIMENTAL_BIG_INTEGER"); } - @Test - public void providesResearchMutators() { - assertProvides("AOR1"); - assertProvides("AOR2"); - assertProvides("AOR3"); - assertProvides("AOR4"); - - assertProvides("ABS"); - - assertProvides("AOD1"); - assertProvides("AOD2"); - - assertProvides("CRCR1"); - assertProvides("CRCR2"); - assertProvides("CRCR3"); - assertProvides("CRCR4"); - assertProvides("CRCR5"); - assertProvides("CRCR6"); - - assertProvides("OBBN1"); - assertProvides("OBBN2"); - assertProvides("OBBN3"); - - assertProvides("ROR1"); - assertProvides("ROR2"); - assertProvides("ROR3"); - assertProvides("ROR4"); - assertProvides("ROR5"); - - assertProvides("UOI1"); - assertProvides("UOI2"); - assertProvides("UOI3"); - assertProvides("UOI4"); - } - - @Test - public void providesAORGroup() { - assertGroupHasSize("AOR", 4); - } - - @Test - public void providesAODGroup() { - assertGroupHasSize("AOD", 2); - } - - @Test - public void providesCRCRGroup() { - assertGroupHasSize("CRCR", 6); - } - - @Test - public void providesOBBNGroup() { - assertGroupHasSize("OBBN", 3); - } - - @Test - public void providesRORGroup() { - assertGroupHasSize("ROR", 5); - } - - @Test - public void providesUOIGroup() { - assertGroupHasSize("UOI", 4); - } - @Test public void shouldReturnRequestedMutators() { assertThat(parseStrings("MATH", "INVERT_NEGS")).containsAll( @@ -275,7 +184,7 @@ public void allContainsReplaceMethodMutator() { @Test public void allMutatorIdsReturnsKeysForAllMutators() { - List incompleteSample = asList("DEFAULTS", "INCREMENTS", "EMPTY_RETURNS", "AOR"); + List incompleteSample = asList("DEFAULTS", "INCREMENTS", "EMPTY_RETURNS"); // method is used by pitclipse assertThat(Mutator.allMutatorIds()).containsAll(incompleteSample); diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ABSMutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ABSMutatorTest.java deleted file mode 100644 index 337e21833..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ABSMutatorTest.java +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import java.util.concurrent.Callable; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -public class ABSMutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(mutateOnlyCallMethod(), ABSMutator.ABS); - } - - private static class HasILoad implements Callable { - @Override - public String call() { - int i = 20; - return "" + i; - } - } - - @Test - public void shouldReplaceIntegerLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasILoad.class); - assertMutantCallableReturns(new HasILoad(), mutant, "-20"); - } - - private static class HasFLoad implements Callable { - @Override - public String call() { - float f = 20; - return "" + f; - } - } - - @Test - public void shouldReplaceFloatLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFLoad.class); - assertMutantCallableReturns(new HasFLoad(), mutant, "-20.0"); - } - - private static class HasLLoad implements Callable { - @Override - public String call() { - long l = 20; - return "" + l; - } - } - - @Test - public void shouldReplaceLongLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLLoad.class); - assertMutantCallableReturns(new HasLLoad(), mutant, "-20"); - } - - private static class HasDLoad implements Callable { - @Override - public String call() { - double d = 20; - return "" + d; - } - } - - @Test - public void shouldReplaceDoubleLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDLoad.class); - assertMutantCallableReturns(new HasDLoad(), mutant, "-20.0"); - } - - private static class HasIGetField implements Callable { - private int i; - - public HasIGetField(int i) { - this.i = i; - } - - @Override - public String call() { - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerField() throws Exception { - final Mutant mutant = getFirstMutant(HasIGetField.class); - assertMutantCallableReturns(new HasIGetField(20), mutant, "-20"); - assertMutantCallableReturns(new HasIGetField(-20), mutant, "20"); - } - - private static class HasFGetField implements Callable { - private float f; - - public HasFGetField(float f) { - this.f = f; - } - - @Override - public String call() { - return "" + this.f; - } - } - - @Test - public void shouldReplaceFloatField() throws Exception { - final Mutant mutant = getFirstMutant(HasFGetField.class); - assertMutantCallableReturns(new HasFGetField(20), mutant, "-20.0"); - assertMutantCallableReturns(new HasFGetField(-20), mutant, "20.0"); - } - - private static class HasJGetField implements Callable { - private long l; - - public HasJGetField(long l) { - this.l = l; - } - - @Override - public String call() { - return "" + this.l; - } - } - - @Test - public void shouldReplaceLongField() throws Exception { - final Mutant mutant = getFirstMutant(HasJGetField.class); - assertMutantCallableReturns(new HasJGetField(20), mutant, "-20"); - assertMutantCallableReturns(new HasJGetField(-20), mutant, "20"); - } - - private static class HasDGetField implements Callable { - private double d; - - public HasDGetField(double d) { - this.d = d; - } - - @Override - public String call() { - return "" + this.d; - } - } - - @Test - public void shouldReplaceDoubleField() throws Exception { - final Mutant mutant = getFirstMutant(HasDGetField.class); - assertMutantCallableReturns(new HasDGetField(20), mutant, "-20.0"); - assertMutantCallableReturns(new HasDGetField(-20), mutant, "20.0"); - } - - private static class HasBGetField implements Callable { - private byte b; - - public HasBGetField(byte b) { - this.b = b; - } - - @Override - public String call() { - return "" + this.b; - } - } - - @Test - public void shouldReplaceByteField() throws Exception { - final Mutant mutant = getFirstMutant(HasBGetField.class); - assertMutantCallableReturns(new HasBGetField((byte)20), mutant, "-20"); - assertMutantCallableReturns(new HasBGetField((byte)-20), mutant, "20"); - } - - private static class HasSGetField implements Callable { - private short s; - - public HasSGetField(short s) { - this.s = s; - } - - @Override - public String call() { - return "" + this.s; - } - } - - @Test - public void shouldReplaceShortField() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetField.class); - assertMutantCallableReturns(new HasSGetField((short)20), mutant, "-20"); - assertMutantCallableReturns(new HasSGetField((short)-20), mutant, "20"); - } - - private static class HasIGetStaticField implements Callable { - private static int value; - private int i; - - public HasIGetStaticField(int i) { - this.i = i; - } - - @Override - public String call() { - value = this.i; - return "" + value; - } - } - - @Test - public void shouldReplaceIntegerStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasIGetStaticField.class, 1); - assertMutantCallableReturns(new HasIGetStaticField(20), mutant, "-20"); - assertMutantCallableReturns(new HasIGetStaticField(-20), mutant, "20"); - } - - private static class HasFGetStaticField implements Callable { - private static float value; - private float f; - - public HasFGetStaticField(float f) { - this.f = f; - } - - @Override - public String call() { - value = this.f; - return "" + value; - } - } - - @Test - public void shouldReplaceFloatStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasFGetStaticField.class, 1); - assertMutantCallableReturns(new HasFGetStaticField(20), mutant, "-20.0"); - assertMutantCallableReturns(new HasFGetStaticField(-20), mutant, "20.0"); - } - - private static class HasJGetStaticField implements Callable { - private static long value; - private long l; - - public HasJGetStaticField(long l) { - this.l = l; - } - - @Override - public String call() { - value = this.l; - return "" + value; - } - } - - @Test - public void shouldReplaceLongStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasJGetStaticField.class, 1); - assertMutantCallableReturns(new HasJGetStaticField(20), mutant, "-20"); - assertMutantCallableReturns(new HasJGetStaticField(-20), mutant, "20"); - } - - private static class HasDGetStaticField implements Callable { - private static double value; - private double d; - - public HasDGetStaticField(double d) { - this.d = d; - } - - @Override - public String call() { - value = this.d; - return "" + value; - } - } - - @Test - public void shouldReplaceDoubleStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasDGetStaticField.class, 1); - assertMutantCallableReturns(new HasDGetStaticField(20), mutant, "-20.0"); - assertMutantCallableReturns(new HasDGetStaticField(-20), mutant, "20.0"); - } - - private static class HasBGetStaticField implements Callable { - private static byte value; - private byte b; - - public HasBGetStaticField(byte b) { - this.b = b; - } - - @Override - public String call() { - value = this.b; - return "" + value; - } - } - - @Test - public void shouldReplaceByteStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasBGetStaticField.class, 1); - assertMutantCallableReturns(new HasBGetStaticField((byte)20), mutant, "-20"); - assertMutantCallableReturns(new HasBGetStaticField((byte)-20), mutant, "20"); - } - - private static class HasSGetStaticField implements Callable { - private static short value; - private short s; - - public HasSGetStaticField(short s) { - this.s = s; - } - - @Override - public String call() { - value = this.s; - return "" + value; - } - } - - @Test - public void shouldReplaceShortStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasSGetStaticField.class, 1); - assertMutantCallableReturns(new HasSGetStaticField((short)20), mutant, "-20"); - assertMutantCallableReturns(new HasSGetStaticField((short)-20), mutant, "20"); - } - - private static class HasIaload implements Callable { - @Override - public String call() { - int[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceIntegerArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasIaload.class); - assertMutantCallableReturns(new HasIaload(), mutant, "-20"); - } - - private static class HasFaload implements Callable { - @Override - public String call() { - float[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceFloatArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFaload.class); - assertMutantCallableReturns(new HasFaload(), mutant, "-20.0"); - } - - private static class HasLaload implements Callable { - @Override - public String call() { - long[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceLongArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLaload.class); - assertMutantCallableReturns(new HasLaload(), mutant, "-20"); - } - - private static class HasDaload implements Callable { - - @Override - public String call() { - double[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceDoubleArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDaload.class); - assertMutantCallableReturns(new HasDaload(), mutant, "-20.0"); - } - - private static class HasBaload implements Callable { - - @Override - public String call() { - byte[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceByteArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasBaload.class); - assertMutantCallableReturns(new HasBaload(), mutant, "-20"); - } - - private static class HasSGetSaload implements Callable { - @Override - public String call() { - short[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceShortArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetSaload.class); - assertMutantCallableReturns(new HasSGetSaload(), mutant, "-20"); - } - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD1MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD1MutatorTest.java deleted file mode 100644 index 57094a460..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD1MutatorTest.java +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class AOD1MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(AOD1Mutator.AOD1); - } - - private static class HasIAdd implements Callable { - private int i; - - HasIAdd(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerAdditionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIAdd.class); - assertMutantCallableReturns(new HasIAdd(2), mutant, "2"); - assertMutantCallableReturns(new HasIAdd(20), mutant, "20"); - } - - private static class HasISub implements Callable { - private int i; - - HasISub(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerSubtractionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasISub.class); - assertMutantCallableReturns(new HasISub(2), mutant, "2"); - assertMutantCallableReturns(new HasISub(20), mutant, "20"); - } - - private static class HasIMul implements Callable { - private int i; - - HasIMul(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerMultiplicationWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIMul.class); - assertMutantCallableReturns(new HasIMul(2), mutant, "2"); - assertMutantCallableReturns(new HasIMul(20), mutant, "20"); - } - - private static class HasIDiv implements Callable { - private int i; - - HasIDiv(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerDivisionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIDiv.class); - assertMutantCallableReturns(new HasIDiv(2), mutant, "2"); - assertMutantCallableReturns(new HasIDiv(20), mutant, "20"); - } - - private static class HasIRem implements Callable { - private int i; - - HasIRem(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerModulusWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIRem.class); - assertMutantCallableReturns(new HasIRem(2), mutant, "2"); - assertMutantCallableReturns(new HasIRem(3), mutant, "3"); - } - - - // LONGS - private static class HasLAdd implements Callable { - private long i; - - HasLAdd(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongAdditionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLAdd.class); - assertMutantCallableReturns(new HasLAdd(2), mutant, "2"); - assertMutantCallableReturns(new HasLAdd(20), mutant, "20"); - } - - private static class HasLSub implements Callable { - private long i; - - HasLSub(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongSubtractionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLSub.class); - assertMutantCallableReturns(new HasLSub(2), mutant, "2"); - assertMutantCallableReturns(new HasLSub(20), mutant, "20"); - } - - private static class HasLMul implements Callable { - private long i; - - HasLMul(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongMultiplicationWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLMul.class); - assertMutantCallableReturns(new HasLMul(2), mutant, "2"); - assertMutantCallableReturns(new HasLMul(20), mutant, "20"); - } - - private static class HasLDiv implements Callable { - private long i; - - HasLDiv(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongDivisionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLDiv.class); - assertMutantCallableReturns(new HasLDiv(2), mutant, "2"); - assertMutantCallableReturns(new HasLDiv(20), mutant, "20"); - } - - - private static class HasLRem implements Callable { - private long i; - - HasLRem(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongModulusWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLRem.class); - assertMutantCallableReturns(new HasLRem(2), mutant, "2"); - assertMutantCallableReturns(new HasLRem(3), mutant, "3"); - } - - - // FLOATS - private static class HasFADD implements Callable { - private float i; - - HasFADD(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatAdditionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFADD.class); - assertMutantCallableReturns(new HasFADD(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFADD(20), mutant, "20.0"); - } - - private static class HasFSUB implements Callable { - private float i; - - HasFSUB(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatSubtractionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFSUB.class); - assertMutantCallableReturns(new HasFSUB(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFSUB(20), mutant, "20.0"); - } - - private static class HasFMUL implements Callable { - private float i; - - HasFMUL(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatMultiplicationWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFMUL.class); - assertMutantCallableReturns(new HasFMUL(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFMUL(20), mutant, "20.0"); - } - - private static class HasFDIV implements Callable { - private float i; - - HasFDIV(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatDivisionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFDIV.class); - assertMutantCallableReturns(new HasFDIV(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFDIV(20), mutant, "20.0"); - } - - private static class HasFREM implements Callable { - private float i; - - HasFREM(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatModulusWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFREM.class); - assertMutantCallableReturns(new HasFREM(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFREM(3), mutant, "3.0"); - } - - // double - - private static class HasDADD implements Callable { - private double i; - - HasDADD(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleAdditionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDADD.class); - assertMutantCallableReturns(new HasDADD(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDADD(20), mutant, "20.0"); - } - - private static class HasDSUB implements Callable { - private double i; - - HasDSUB(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleSubtractionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDSUB.class); - assertMutantCallableReturns(new HasDSUB(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDSUB(20), mutant, "20.0"); - } - - private static class HasDMUL implements Callable { - private double i; - - HasDMUL(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleMultiplicationWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDMUL.class); - assertMutantCallableReturns(new HasDMUL(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDMUL(20), mutant, "20.0"); - } - - private static class HasDDIV implements Callable { - private double i; - - HasDDIV(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleDivisionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDDIV.class); - assertMutantCallableReturns(new HasDDIV(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDDIV(20), mutant, "20.0"); - } - - private static class HasDREM implements Callable { - private double i; - - HasDREM(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoublerModulusWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDREM.class); - assertMutantCallableReturns(new HasDREM(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDREM(3), mutant, "3.0"); - } - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD2MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD2MutatorTest.java deleted file mode 100644 index 61300d0f3..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOD2MutatorTest.java +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class AOD2MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(AOD2Mutator.AOD2); - } - - private static class HasIAdd implements Callable { - private int i; - - HasIAdd(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 + this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerAdditionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIAdd.class); - assertMutantCallableReturns(new HasIAdd(2), mutant, "2"); - assertMutantCallableReturns(new HasIAdd(20), mutant, "20"); - } - - private static class HasISub implements Callable { - private int i; - - HasISub(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 - this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerSubtractionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasISub.class); - assertMutantCallableReturns(new HasISub(2), mutant, "2"); - assertMutantCallableReturns(new HasISub(20), mutant, "20"); - } - - private static class HasIMul implements Callable { - private int i; - - HasIMul(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 * this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerMultiplicationWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIMul.class); - assertMutantCallableReturns(new HasIMul(2), mutant, "2"); - assertMutantCallableReturns(new HasIMul(20), mutant, "20"); - } - - private static class HasIDiv implements Callable { - private int i; - - HasIDiv(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 / this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerDivisionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIDiv.class); - assertMutantCallableReturns(new HasIDiv(2), mutant, "2"); - assertMutantCallableReturns(new HasIDiv(20), mutant, "20"); - } - - private static class HasIRem implements Callable { - private int i; - - HasIRem(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 % this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerModulusWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIRem.class); - assertMutantCallableReturns(new HasIRem(2), mutant, "2"); - assertMutantCallableReturns(new HasIRem(3), mutant, "3"); - } - - - // LONGS - private static class HasLAdd implements Callable { - private long i; - - HasLAdd(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 + this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongAdditionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLAdd.class); - assertMutantCallableReturns(new HasLAdd(2), mutant, "2"); - assertMutantCallableReturns(new HasLAdd(20), mutant, "20"); - } - - private static class HasLSub implements Callable { - private long i; - - HasLSub(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 - this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongSubtractionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLSub.class); - assertMutantCallableReturns(new HasLSub(2), mutant, "2"); - assertMutantCallableReturns(new HasLSub(20), mutant, "20"); - } - - private static class HasLMul implements Callable { - private long i; - - HasLMul(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 * this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongMultiplicationWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLMul.class); - assertMutantCallableReturns(new HasLMul(2), mutant, "2"); - assertMutantCallableReturns(new HasLMul(20), mutant, "20"); - } - - private static class HasLDiv implements Callable { - private long i; - - HasLDiv(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 / this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongDivisionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLDiv.class); - assertMutantCallableReturns(new HasLDiv(2), mutant, "2"); - assertMutantCallableReturns(new HasLDiv(20), mutant, "20"); - } - - - private static class HasLRem implements Callable { - private long i; - - HasLRem(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 % this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongModulusWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLRem.class); - assertMutantCallableReturns(new HasLRem(2), mutant, "2"); - assertMutantCallableReturns(new HasLRem(3), mutant, "3"); - } - - - // FLOATS - private static class HasFADD implements Callable { - private float i; - - HasFADD(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 + this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatAdditionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFADD.class); - assertMutantCallableReturns(new HasFADD(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFADD(20), mutant, "20.0"); - } - - private static class HasFSUB implements Callable { - private float i; - - HasFSUB(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 - this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatSubtractionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFSUB.class); - assertMutantCallableReturns(new HasFSUB(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFSUB(20), mutant, "20.0"); - } - - private static class HasFMUL implements Callable { - private float i; - - HasFMUL(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 * this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatMultiplicationWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFMUL.class); - assertMutantCallableReturns(new HasFMUL(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFMUL(20), mutant, "20.0"); - } - - private static class HasFDIV implements Callable { - private float i; - - HasFDIV(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 / this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatDivisionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFDIV.class); - assertMutantCallableReturns(new HasFDIV(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFDIV(20), mutant, "20.0"); - } - - private static class HasFREM implements Callable { - private float i; - - HasFREM(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 % this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatModulusWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasFREM.class); - assertMutantCallableReturns(new HasFREM(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFREM(3), mutant, "3.0"); - } - - // double - - private static class HasDADD implements Callable { - private double i; - - HasDADD(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 + this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleAdditionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDADD.class); - assertMutantCallableReturns(new HasDADD(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDADD(20), mutant, "20.0"); - } - - private static class HasDSUB implements Callable { - private double i; - - HasDSUB(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 - this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleSubtractionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDSUB.class); - assertMutantCallableReturns(new HasDSUB(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDSUB(20), mutant, "20.0"); - } - - private static class HasDMUL implements Callable { - private double i; - - HasDMUL(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 * this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleMultiplicationWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDMUL.class); - assertMutantCallableReturns(new HasDMUL(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDMUL(20), mutant, "20.0"); - } - - private static class HasDDIV implements Callable { - private double i; - - HasDDIV(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 / this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleDivisionWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDDIV.class); - assertMutantCallableReturns(new HasDDIV(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDDIV(20), mutant, "20.0"); - } - - private static class HasDREM implements Callable { - private double i; - - HasDREM(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = 1 % this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoublerModulusWithFistMember() throws Exception { - final Mutant mutant = getFirstMutant(HasDREM.class); - assertMutantCallableReturns(new HasDREM(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDREM(3), mutant, "3.0"); - } - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR1MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR1MutatorTest.java deleted file mode 100644 index e16b7a894..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR1MutatorTest.java +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class AOR1MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(AOR1Mutator.AOR1); - } - - private static class HasIAdd implements Callable { - private int i; - - HasIAdd(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerAdditionWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasIAdd.class); - assertMutantCallableReturns(new HasIAdd(2), mutant, "1"); - assertMutantCallableReturns(new HasIAdd(20), mutant, "19"); - } - - private static class HasISub implements Callable { - private int i; - - HasISub(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerSubtractionWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasISub.class); - assertMutantCallableReturns(new HasISub(2), mutant, "3"); - assertMutantCallableReturns(new HasISub(20), mutant, "21"); - } - - private static class HasIMul implements Callable { - private int i; - - HasIMul(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerMultiplicationWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasIMul.class); - assertMutantCallableReturns(new HasIMul(2), mutant, "1"); - assertMutantCallableReturns(new HasIMul(20), mutant, "10"); - } - - private static class HasIDiv implements Callable { - private int i; - - HasIDiv(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerDivisionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasIDiv.class); - assertMutantCallableReturns(new HasIDiv(2), mutant, "4"); - assertMutantCallableReturns(new HasIDiv(20), mutant, "40"); - } - - private static class HasIRem implements Callable { - private int i; - - HasIRem(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerModulusWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasIRem.class); - assertMutantCallableReturns(new HasIRem(2), mutant, "4"); - assertMutantCallableReturns(new HasIRem(3), mutant, "6"); - } - - - // LONGS - private static class HasLAdd implements Callable { - private long i; - - HasLAdd(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongAdditionWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasLAdd.class); - assertMutantCallableReturns(new HasLAdd(2), mutant, "1"); - assertMutantCallableReturns(new HasLAdd(20), mutant, "19"); - } - - private static class HasLSub implements Callable { - private long i; - - HasLSub(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongSubtractionWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasLSub.class); - assertMutantCallableReturns(new HasLSub(2), mutant, "3"); - assertMutantCallableReturns(new HasLSub(20), mutant, "21"); - } - - private static class HasLMul implements Callable { - private long i; - - HasLMul(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongMultiplicationWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasLMul.class); - assertMutantCallableReturns(new HasLMul(2), mutant, "1"); - assertMutantCallableReturns(new HasLMul(20), mutant, "10"); - } - - private static class HasLDiv implements Callable { - private long i; - - HasLDiv(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongDivisionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasLDiv.class); - assertMutantCallableReturns(new HasLDiv(2), mutant, "4"); - assertMutantCallableReturns(new HasLDiv(20), mutant, "40"); - } - - - private static class HasLRem implements Callable { - private long i; - - HasLRem(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongModulusWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasLRem.class); - assertMutantCallableReturns(new HasLRem(2), mutant, "4"); - assertMutantCallableReturns(new HasLRem(3), mutant, "6"); - } - - - // FLOATS - private static class HasFADD implements Callable { - private float i; - - HasFADD(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatAdditionWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasFADD.class); - assertMutantCallableReturns(new HasFADD(2), mutant, "1.0"); - assertMutantCallableReturns(new HasFADD(20), mutant, "19.0"); - } - - private static class HasFSUB implements Callable { - private float i; - - HasFSUB(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatSubtractionWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasFSUB.class); - assertMutantCallableReturns(new HasFSUB(2), mutant, "3.0"); - assertMutantCallableReturns(new HasFSUB(20), mutant, "21.0"); - } - - private static class HasFMUL implements Callable { - private float i; - - HasFMUL(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatMultiplicationWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasFMUL.class); - assertMutantCallableReturns(new HasFMUL(2), mutant, "1.0"); - assertMutantCallableReturns(new HasFMUL(20), mutant, "10.0"); - } - - private static class HasFDIV implements Callable { - private float i; - - HasFDIV(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatDivisionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasFDIV.class); - assertMutantCallableReturns(new HasFDIV(2), mutant, "4.0"); - assertMutantCallableReturns(new HasFDIV(20), mutant, "40.0"); - } - - private static class HasFREM implements Callable { - private float i; - - HasFREM(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatModulusWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasFREM.class); - assertMutantCallableReturns(new HasFREM(2), mutant, "4.0"); - assertMutantCallableReturns(new HasFREM(3), mutant, "6.0"); - } - - // double - - private static class HasDADD implements Callable { - private double i; - - HasDADD(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleAdditionWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasDADD.class); - assertMutantCallableReturns(new HasDADD(2), mutant, "1.0"); - assertMutantCallableReturns(new HasDADD(20), mutant, "19.0"); - } - - private static class HasDSUB implements Callable { - private double i; - - HasDSUB(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleSubtractionWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasDSUB.class); - assertMutantCallableReturns(new HasDSUB(2), mutant, "3.0"); - assertMutantCallableReturns(new HasDSUB(20), mutant, "21.0"); - } - - private static class HasDMUL implements Callable { - private double i; - - HasDMUL(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleMultiplicationWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasDMUL.class); - assertMutantCallableReturns(new HasDMUL(2), mutant, "1.0"); - assertMutantCallableReturns(new HasDMUL(20), mutant, "10.0"); - } - - private static class HasDDIV implements Callable { - private double i; - - HasDDIV(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleDivisionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasDDIV.class); - assertMutantCallableReturns(new HasDDIV(2), mutant, "4.0"); - assertMutantCallableReturns(new HasDDIV(20), mutant, "40.0"); - } - - private static class HasDREM implements Callable { - private double i; - - HasDREM(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoublerModulusWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasDREM.class); - assertMutantCallableReturns(new HasDREM(2), mutant, "4.0"); - assertMutantCallableReturns(new HasDREM(3), mutant, "6.0"); - } - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR2MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR2MutatorTest.java deleted file mode 100644 index d80087544..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR2MutatorTest.java +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class AOR2MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(AOR2Mutator.AOR2); - } - - private static class HasIAdd implements Callable { - private int i; - - HasIAdd(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerAdditionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasIAdd.class); - assertMutantCallableReturns(new HasIAdd(2), mutant, "2"); - assertMutantCallableReturns(new HasIAdd(20), mutant, "20"); - } - - private static class HasISub implements Callable { - private int i; - - HasISub(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerSubtractionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasISub.class); - assertMutantCallableReturns(new HasISub(2), mutant, "2"); - assertMutantCallableReturns(new HasISub(20), mutant, "20"); - } - - private static class HasIMul implements Callable { - private int i; - - HasIMul(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerMultiplicationWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasIMul.class); - assertMutantCallableReturns(new HasIMul(2), mutant, "0"); - assertMutantCallableReturns(new HasIMul(19), mutant, "1"); - } - - private static class HasIDiv implements Callable { - private int i; - - HasIDiv(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerDivisionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasIDiv.class); - assertMutantCallableReturns(new HasIDiv(2), mutant, "0"); - assertMutantCallableReturns(new HasIDiv(19), mutant, "1"); - } - - private static class HasIRem implements Callable { - private int i; - - HasIRem(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerModulusWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasIRem.class); - assertMutantCallableReturns(new HasIRem(2), mutant, "1"); - assertMutantCallableReturns(new HasIRem(20), mutant, "10"); - } - - - // LONGS - private static class HasLAdd implements Callable { - private long i; - - HasLAdd(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongAdditionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasLAdd.class); - assertMutantCallableReturns(new HasLAdd(2), mutant, "2"); - assertMutantCallableReturns(new HasLAdd(20), mutant, "20"); - } - - private static class HasLSub implements Callable { - private long i; - - HasLSub(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongSubtractionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasLSub.class); - assertMutantCallableReturns(new HasLSub(2), mutant, "2"); - assertMutantCallableReturns(new HasLSub(20), mutant, "20"); - } - - private static class HasLMul implements Callable { - private long i; - - HasLMul(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongMultiplicationWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasLMul.class); - assertMutantCallableReturns(new HasLMul(2), mutant, "0"); - assertMutantCallableReturns(new HasLMul(19), mutant, "1"); - } - - private static class HasLDiv implements Callable { - private long i; - - HasLDiv(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongDivisionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasLDiv.class); - assertMutantCallableReturns(new HasLDiv(2), mutant, "0"); - assertMutantCallableReturns(new HasLDiv(19), mutant, "1"); - } - - - private static class HasLRem implements Callable { - private long i; - - HasLRem(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongModulusWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasLRem.class); - assertMutantCallableReturns(new HasLRem(2), mutant, "1"); - assertMutantCallableReturns(new HasLRem(20), mutant, "10"); - } - - - // FLOATS - private static class HasFADD implements Callable { - private float i; - - HasFADD(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatAdditionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasFADD.class); - assertMutantCallableReturns(new HasFADD(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFADD(20), mutant, "20.0"); - } - - private static class HasFSUB implements Callable { - private float i; - - HasFSUB(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatSubtractionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasFSUB.class); - assertMutantCallableReturns(new HasFSUB(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFSUB(20), mutant, "20.0"); - } - - private static class HasFMUL implements Callable { - private float i; - - HasFMUL(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatMultiplicationWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasFMUL.class); - assertMutantCallableReturns(new HasFMUL(2), mutant, "0.0"); - assertMutantCallableReturns(new HasFMUL(19), mutant, "1.0"); - } - - private static class HasFDIV implements Callable { - private float i; - - HasFDIV(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatDivisionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasFDIV.class); - assertMutantCallableReturns(new HasFDIV(2), mutant, "0.0"); - assertMutantCallableReturns(new HasFDIV(19), mutant, "1.0"); - } - - private static class HasFREM implements Callable { - private float i; - - HasFREM(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatModulusWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasFREM.class); - assertMutantCallableReturns(new HasFREM(2), mutant, "1.0"); - assertMutantCallableReturns(new HasFREM(3), mutant, "1.5"); - } - - // double - - private static class HasDADD implements Callable { - private double i; - - HasDADD(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleAdditionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasDADD.class); - assertMutantCallableReturns(new HasDADD(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDADD(20), mutant, "20.0"); - } - - private static class HasDSUB implements Callable { - private double i; - - HasDSUB(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleSubtractionWithMultiplication() throws Exception { - final Mutant mutant = getFirstMutant(HasDSUB.class); - assertMutantCallableReturns(new HasDSUB(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDSUB(20), mutant, "20.0"); - } - - private static class HasDMUL implements Callable { - private double i; - - HasDMUL(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleMultiplicationWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasDMUL.class); - assertMutantCallableReturns(new HasDMUL(2), mutant, "0.0"); - assertMutantCallableReturns(new HasDMUL(19), mutant, "1.0"); - } - - private static class HasDDIV implements Callable { - private double i; - - HasDDIV(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleDivisionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasDDIV.class); - assertMutantCallableReturns(new HasDDIV(2), mutant, "0.0"); - assertMutantCallableReturns(new HasDDIV(19), mutant, "1.0"); - } - - private static class HasDREM implements Callable { - private double i; - - HasDREM(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoublerModulusWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasDREM.class); - assertMutantCallableReturns(new HasDREM(2), mutant, "1.0"); - assertMutantCallableReturns(new HasDREM(3), mutant, "1.5"); - } - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR3MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR3MutatorTest.java deleted file mode 100644 index 7c3414375..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR3MutatorTest.java +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class AOR3MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(AOR3Mutator.AOR3); - } - - private static class HasIAdd implements Callable { - private int i; - - HasIAdd(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerAdditionWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasIAdd.class); - assertMutantCallableReturns(new HasIAdd(2), mutant, "2"); - assertMutantCallableReturns(new HasIAdd(20), mutant, "20"); - } - - private static class HasISub implements Callable { - private int i; - - HasISub(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerSubtractionWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasISub.class); - assertMutantCallableReturns(new HasISub(2), mutant, "2"); - assertMutantCallableReturns(new HasISub(20), mutant, "20"); - } - - private static class HasIMul implements Callable { - private int i; - - HasIMul(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerMultiplicationAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasIMul.class); - assertMutantCallableReturns(new HasIMul(2), mutant, "4"); - assertMutantCallableReturns(new HasIMul(19), mutant, "21"); - } - - private static class HasIDiv implements Callable { - private int i; - - HasIDiv(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerDivisionWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasIDiv.class); - assertMutantCallableReturns(new HasIDiv(2), mutant, "4"); - assertMutantCallableReturns(new HasIDiv(19), mutant, "21"); - } - - private static class HasIRem implements Callable { - private int i; - - HasIRem(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerModulusWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasIRem.class); - assertMutantCallableReturns(new HasIRem(2), mutant, "4"); - assertMutantCallableReturns(new HasIRem(20), mutant, "22"); - } - - - // LONGS - private static class HasLAdd implements Callable { - private long i; - - HasLAdd(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongAdditionWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasLAdd.class); - assertMutantCallableReturns(new HasLAdd(2), mutant, "2"); - assertMutantCallableReturns(new HasLAdd(20), mutant, "20"); - } - - private static class HasLSub implements Callable { - private long i; - - HasLSub(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongSubtractionWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasLSub.class); - assertMutantCallableReturns(new HasLSub(2), mutant, "2"); - assertMutantCallableReturns(new HasLSub(20), mutant, "20"); - } - - private static class HasLMul implements Callable { - private long i; - - HasLMul(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongMultiplicationWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasLMul.class); - assertMutantCallableReturns(new HasLMul(2), mutant, "4"); - assertMutantCallableReturns(new HasLMul(19), mutant, "21"); - } - - private static class HasLDiv implements Callable { - private long i; - - HasLDiv(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongDivisionWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasLDiv.class); - assertMutantCallableReturns(new HasLDiv(2), mutant, "4"); - assertMutantCallableReturns(new HasLDiv(19), mutant, "21"); - } - - - private static class HasLRem implements Callable { - private long i; - - HasLRem(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongModulusWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasLRem.class); - assertMutantCallableReturns(new HasLRem(2), mutant, "4"); - assertMutantCallableReturns(new HasLRem(20), mutant, "22"); - } - - - // FLOATS - private static class HasFADD implements Callable { - private float i; - - HasFADD(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatAdditionWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasFADD.class); - assertMutantCallableReturns(new HasFADD(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFADD(20), mutant, "20.0"); - } - - private static class HasFSUB implements Callable { - private float i; - - HasFSUB(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatSubtractionWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasFSUB.class); - assertMutantCallableReturns(new HasFSUB(2), mutant, "2.0"); - assertMutantCallableReturns(new HasFSUB(20), mutant, "20.0"); - } - - private static class HasFMUL implements Callable { - private float i; - - HasFMUL(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatMultiplicationWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasFMUL.class); - assertMutantCallableReturns(new HasFMUL(2), mutant, "4.0"); - assertMutantCallableReturns(new HasFMUL(19), mutant, "21.0"); - } - - private static class HasFDIV implements Callable { - private float i; - - HasFDIV(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatDivisionWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasFDIV.class); - assertMutantCallableReturns(new HasFDIV(2), mutant, "4.0"); - assertMutantCallableReturns(new HasFDIV(19), mutant, "21.0"); - } - - private static class HasFREM implements Callable { - private float i; - - HasFREM(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatModulusWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasFREM.class); - assertMutantCallableReturns(new HasFREM(2), mutant, "4.0"); - assertMutantCallableReturns(new HasFREM(3), mutant, "5.0"); - } - - // double - - private static class HasDADD implements Callable { - private double i; - - HasDADD(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleAdditionWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasDADD.class); - assertMutantCallableReturns(new HasDADD(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDADD(20), mutant, "20.0"); - } - - private static class HasDSUB implements Callable { - private double i; - - HasDSUB(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleSubtractionWithDivision() throws Exception { - final Mutant mutant = getFirstMutant(HasDSUB.class); - assertMutantCallableReturns(new HasDSUB(2), mutant, "2.0"); - assertMutantCallableReturns(new HasDSUB(20), mutant, "20.0"); - } - - private static class HasDMUL implements Callable { - private double i; - - HasDMUL(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleMultiplicationWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasDMUL.class); - assertMutantCallableReturns(new HasDMUL(2), mutant, "4.0"); - assertMutantCallableReturns(new HasDMUL(19), mutant, "21.0"); - } - - private static class HasDDIV implements Callable { - private double i; - - HasDDIV(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleDivisionWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasDDIV.class); - assertMutantCallableReturns(new HasDDIV(2), mutant, "4.0"); - assertMutantCallableReturns(new HasDDIV(19), mutant, "21.0"); - } - - private static class HasDREM implements Callable { - private double i; - - HasDREM(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoublerModulusWithAddition() throws Exception { - final Mutant mutant = getFirstMutant(HasDREM.class); - assertMutantCallableReturns(new HasDREM(2), mutant, "4.0"); - assertMutantCallableReturns(new HasDREM(3), mutant, "5.0"); - } - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR4MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR4MutatorTest.java deleted file mode 100644 index 02abace33..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/AOR4MutatorTest.java +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class AOR4MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(AOR4Mutator.AOR4); - } - - private static class HasIAdd implements Callable { - private int i; - - HasIAdd(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerAdditionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasIAdd.class); - assertMutantCallableReturns(new HasIAdd(2), mutant, "0"); - assertMutantCallableReturns(new HasIAdd(20), mutant, "0"); - } - - private static class HasISub implements Callable { - private int i; - - HasISub(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerSubtractionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasISub.class); - assertMutantCallableReturns(new HasISub(2), mutant, "0"); - assertMutantCallableReturns(new HasISub(20), mutant, "0"); - } - - private static class HasIMul implements Callable { - private int i; - - HasIMul(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerMultiplicationSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasIMul.class); - assertMutantCallableReturns(new HasIMul(2), mutant, "0"); - assertMutantCallableReturns(new HasIMul(19), mutant, "17"); - } - - private static class HasIDiv implements Callable { - private int i; - - HasIDiv(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerDivisionWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasIDiv.class); - assertMutantCallableReturns(new HasIDiv(2), mutant, "0"); - assertMutantCallableReturns(new HasIDiv(19), mutant, "17"); - } - - private static class HasIRem implements Callable { - private int i; - - HasIRem(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerModulusWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasIRem.class); - assertMutantCallableReturns(new HasIRem(2), mutant, "0"); - assertMutantCallableReturns(new HasIRem(20), mutant, "18"); - } - - - // LONGS - private static class HasLAdd implements Callable { - private long i; - - HasLAdd(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongAdditionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasLAdd.class); - assertMutantCallableReturns(new HasLAdd(2), mutant, "0"); - assertMutantCallableReturns(new HasLAdd(20), mutant, "0"); - } - - private static class HasLSub implements Callable { - private long i; - - HasLSub(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongSubtractionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasLSub.class); - assertMutantCallableReturns(new HasLSub(2), mutant, "0"); - assertMutantCallableReturns(new HasLSub(20), mutant, "0"); - } - - private static class HasLMul implements Callable { - private long i; - - HasLMul(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongMultiplicationWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasLMul.class); - assertMutantCallableReturns(new HasLMul(2), mutant, "0"); - assertMutantCallableReturns(new HasLMul(19), mutant, "17"); - } - - private static class HasLDiv implements Callable { - private long i; - - HasLDiv(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongDivisionWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasLDiv.class); - assertMutantCallableReturns(new HasLDiv(2), mutant, "0"); - assertMutantCallableReturns(new HasLDiv(19), mutant, "17"); - } - - - private static class HasLRem implements Callable { - private long i; - - HasLRem(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongModulusWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasLRem.class); - assertMutantCallableReturns(new HasLRem(2), mutant, "0"); - assertMutantCallableReturns(new HasLRem(20), mutant, "18"); - } - - - // FLOATS - private static class HasFADD implements Callable { - private float i; - - HasFADD(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatAdditionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasFADD.class); - assertMutantCallableReturns(new HasFADD(2), mutant, "0.0"); - assertMutantCallableReturns(new HasFADD(20), mutant, "0.0"); - } - - private static class HasFSUB implements Callable { - private float i; - - HasFSUB(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatSubtractionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasFSUB.class); - assertMutantCallableReturns(new HasFSUB(2), mutant, "0.0"); - assertMutantCallableReturns(new HasFSUB(20), mutant, "0.0"); - } - - private static class HasFMUL implements Callable { - private float i; - - HasFMUL(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatMultiplicationWithASubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasFMUL.class); - assertMutantCallableReturns(new HasFMUL(2), mutant, "0.0"); - assertMutantCallableReturns(new HasFMUL(19), mutant, "17.0"); - } - - private static class HasFDIV implements Callable { - private float i; - - HasFDIV(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatDivisionWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasFDIV.class); - assertMutantCallableReturns(new HasFDIV(2), mutant, "0.0"); - assertMutantCallableReturns(new HasFDIV(19), mutant, "17.0"); - } - - private static class HasFREM implements Callable { - private float i; - - HasFREM(final float i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceFloatModulusWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasFREM.class); - assertMutantCallableReturns(new HasFREM(2), mutant, "0.0"); - assertMutantCallableReturns(new HasFREM(3), mutant, "1.0"); - } - - // double - - private static class HasDADD implements Callable { - private double i; - - HasDADD(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i++; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleAdditionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasDADD.class); - assertMutantCallableReturns(new HasDADD(2), mutant, "0.0"); - assertMutantCallableReturns(new HasDADD(20), mutant, "0.0"); - } - - private static class HasDSUB implements Callable { - private double i; - - HasDSUB(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i--; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleSubtractionWithModulus() throws Exception { - final Mutant mutant = getFirstMutant(HasDSUB.class); - assertMutantCallableReturns(new HasDSUB(2), mutant, "0.0"); - assertMutantCallableReturns(new HasDSUB(20), mutant, "0.0"); - } - - private static class HasDMUL implements Callable { - private double i; - - HasDMUL(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i * 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleMultiplicationWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasDMUL.class); - assertMutantCallableReturns(new HasDMUL(2), mutant, "0.0"); - assertMutantCallableReturns(new HasDMUL(19), mutant, "17.0"); - } - - private static class HasDDIV implements Callable { - private double i; - - HasDDIV(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i / 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoubleDivisionWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasDDIV.class); - assertMutantCallableReturns(new HasDDIV(2), mutant, "0.0"); - assertMutantCallableReturns(new HasDDIV(19), mutant, "17.0"); - } - - private static class HasDREM implements Callable { - private double i; - - HasDREM(final double i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i % 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceDoublerModulusWithSubtraction() throws Exception { - final Mutant mutant = getFirstMutant(HasDREM.class); - assertMutantCallableReturns(new HasDREM(2), mutant, "0.0"); - assertMutantCallableReturns(new HasDREM(3), mutant, "1.0"); - } - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR1Test.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR1Test.java deleted file mode 100644 index 14de1489d..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR1Test.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class CRCR1Test extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyInlineConstants() { - createTesteeWith(CRCR1Mutator.CRCR1); - } - - private static class HasIntegerICONST0 implements Callable { - - @Override - public Integer call() throws Exception { - return 0; - } - - } - - @Test - public void shouldReplaceInteger0With1() throws Exception{ - final Mutant mutant = getFirstMutant(HasIntegerICONST0.class); - assertMutantCallableReturns(new HasIntegerICONST0(), mutant, 1); - } - - private static class HasIntegerICONST1 implements Callable { - - @Override - public Integer call() throws Exception { - return 1; - } - - } - - @Test - public void shouldNotReplaceInteger1() throws Exception { - assertNoMutants(HasIntegerICONST1.class); - } - - private static class HasIntegerICONST2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2; - } - - } - - @Test - public void shouldReplaceInteger2With1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST2.class); - assertMutantCallableReturns(new HasIntegerICONST2(), mutant, 1); - } - - private static class HasIntegerICONST3 implements Callable { - - @Override - public Integer call() throws Exception { - return 3; - } - - } - - @Test - public void shouldReplaceInteger3With1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST3.class); - assertMutantCallableReturns(new HasIntegerICONST3(), mutant, 1); - } - - private static class HasIntegerICONST4 implements Callable { - - @Override - public Integer call() throws Exception { - return 4; - } - - } - - @Test - public void shouldReplaceInteger4With1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST4.class); - assertMutantCallableReturns(new HasIntegerICONST4(), mutant, 1); - } - - private static class HasIntegerICONST5 implements Callable { - - @Override - public Integer call() throws Exception { - return 5; - } - - } - - @Test - public void shouldReplaceInteger5With1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST5.class); - assertMutantCallableReturns(new HasIntegerICONST5(), mutant, 1); - } - - private static class HasIntegerLDC implements Callable { - - @Override - public Integer call() throws Exception { - return 987654321; - } - - } - - @Test - public void shouldReplaceLargeIntegerConstantsWith1() - throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC.class); - assertMutantCallableReturns(new HasIntegerLDC(), mutant, 1); - } - - private static class HasIntegerICONSTM1 implements Callable { - - @Override - public Integer call() throws Exception { - return -1; - } - - } - - @Test - public void shouldReplaceIntegerMinus1With1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONSTM1.class); - assertMutantCallableReturns(new HasIntegerICONSTM1(), mutant, 1); - } - - private static class HasBIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 28; - } - - } - - @Test - public void shouldReplaceSmallIntegerConstantsWith1() - throws Exception { - final Mutant mutant = getFirstMutant(HasBIPUSH.class); - assertMutantCallableReturns(new HasBIPUSH(), mutant, 1); - } - - private static class HasSIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 32700; - } - - } - - @Test - public void shouldReplaceMediumIntegerConstantsWith1() - throws Exception { - final Mutant mutant = getFirstMutant(HasSIPUSH.class); - assertMutantCallableReturns(new HasSIPUSH(), mutant, 1); - } - - - private static class HasIntegerLDC2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2144567; - } - - } - - @Test - public void shouldReplaceIntegerLdcWith1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC2.class); - assertMutantCallableReturns(new HasIntegerLDC2(), mutant, - 1); - } - - private static class HasLongLCONST0 implements Callable { - - @Override - public Long call() throws Exception { - return 0L; - } - - } - - @Test - public void shouldReplaceLong0With1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLCONST0.class); - assertMutantCallableReturns(new HasLongLCONST1(), mutant, 1L); } - - private static class HasLongLCONST1 implements Callable { - - @Override - public Long call() throws Exception { - return 1L; - } - - } - - @Test - public void shouldReplaceLong1With0(){ - assertNoMutants(HasLongLCONST1.class); - } - - private static class HasLongLDC implements Callable { - - @Override - public Long call() throws Exception { - return 2999999999L; - } - - } - - @Test - public void shouldReplaceLongLDCWith1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLDC.class); - assertMutantCallableReturns(new HasLongLDC(), mutant, 1L); - } - - /* - * Double and Float - */ - - private static class HasFloatFCONST0 implements Callable { - - @Override - public Float call() throws Exception { - return 0.0F; - } - - } - - @Test - public void shouldReplaceFloat0With1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST0.class); - assertMutantCallableReturns(new HasFloatFCONST0(), mutant, 1.0F); - } - - private static class HasFloatFCONST1 implements Callable { - - @Override - public Float call() throws Exception { - return 1.0F; - } - - } - - @Test - public void shouldNotReplaceFloat1(){ - assertNoMutants(HasFloatFCONST1.class); - } - - private static class HasFloatFCONST2 implements Callable { - - @Override - public Float call() throws Exception { - return 2.0F; - } - - } - - @Test - public void shouldReplaceFloat2With1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST2.class); - assertMutantCallableReturns(new HasFloatFCONST2(), mutant, 1.0F); - } - - private static class HasFloatLDC implements Callable { - - @Override - public Float call() throws Exception { - return 8364.123F; - } - - } - - @Test - public void shouldReplaceFloatWith1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatLDC.class); - assertMutantCallableReturns(new HasFloatLDC(), mutant, 1.0F); - } - - private static class HasDoubleDCONST0 implements Callable { - - @Override - public Double call() throws Exception { - return 0.0D; - } - - } - - @Test - public void shouldNotReplaceDouble1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleDCONST0.class); - assertMutantCallableReturns(new HasDoubleDCONST0(), mutant, 1.0D); - } - - private static class HasDoubleDCONST1 implements Callable { - - @Override - public Double call() throws Exception { - return 1.0D; - } - - } - - @Test - public void shoulNotdReplaceDouble1W() throws Exception { - assertNoMutants(HasDoubleDCONST1.class); - } - - private static class HasDoubleLDC implements Callable { - - @Override - public Double call() throws Exception { - return 123456789.123D; - } - - } - - @Test - public void shouldReplaceDoubleWith1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleLDC.class); - assertMutantCallableReturns(new HasDoubleLDC(), mutant, 1.0D); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR2Test.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR2Test.java deleted file mode 100644 index cb1100091..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR2Test.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import java.util.concurrent.Callable; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -public class CRCR2Test extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyInlineConstants() { - createTesteeWith(CRCR2Mutator.CRCR2); - } - - private static class HasIntegerICONST0 implements Callable { - - @Override - public Integer call() throws Exception { - return 0; - } - - } - - @Test - public void shouldNotReplaceInteger0() { - assertNoMutants(HasIntegerICONST0.class); - } - - private static class HasIntegerICONST1 implements Callable { - - @Override - public Integer call() throws Exception { - return 1; - } - - } - - @Test - public void shouldReplaceInteger1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST1.class); - assertMutantCallableReturns(new HasIntegerICONST1(), mutant, 0); - } - - private static class HasIntegerICONST2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2; - } - - } - - @Test - public void shouldReplaceInteger2With0() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST2.class); - assertMutantCallableReturns(new HasIntegerICONST2(), mutant, 0); - } - - private static class HasIntegerICONST3 implements Callable { - - @Override - public Integer call() throws Exception { - return 3; - } - - } - - @Test - public void shouldReplaceInteger3With0() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST3.class); - assertMutantCallableReturns(new HasIntegerICONST3(), mutant, 0); - } - - private static class HasIntegerICONST4 implements Callable { - - @Override - public Integer call() throws Exception { - return 4; - } - - } - - @Test - public void shouldReplaceInteger4With0() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST4.class); - assertMutantCallableReturns(new HasIntegerICONST4(), mutant, 0); - } - - private static class HasIntegerICONST5 implements Callable { - - @Override - public Integer call() throws Exception { - return 5; - } - - } - - @Test - public void shouldReplaceInteger5With0() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST5.class); - assertMutantCallableReturns(new HasIntegerICONST5(), mutant, 0); - } - - private static class HasIntegerLDC implements Callable { - - @Override - public Integer call() throws Exception { - return 987654321; - } - - } - - @Test - public void shouldReplaceLargeIntegerConstantsWith0() - throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC.class); - assertMutantCallableReturns(new HasIntegerLDC(), mutant, 0); - } - - private static class HasIntegerICONSTM1 implements Callable { - - @Override - public Integer call() throws Exception { - return -1; - } - - } - - @Test - public void shouldReplaceIntegerMinus1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONSTM1.class); - assertMutantCallableReturns(new HasIntegerICONSTM1(), mutant, 0); - } - - private static class HasBIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 28; - } - - } - - @Test - public void shouldReplaceSmallIntegerConstantsWith0() - throws Exception { - final Mutant mutant = getFirstMutant(HasBIPUSH.class); - assertMutantCallableReturns(new HasBIPUSH(), mutant, 0); - } - - private static class HasSIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 32700; - } - - } - - @Test - public void shouldReplaceMediumIntegerConstantsWith0() - throws Exception { - final Mutant mutant = getFirstMutant(HasSIPUSH.class); - assertMutantCallableReturns(new HasSIPUSH(), mutant, 0); - } - - - private static class HasIntegerLDC2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2144567; - } - - } - - @Test - public void shouldReplaceIntegerLdcWith0() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC2.class); - assertMutantCallableReturns(new HasIntegerLDC2(), mutant, - 0); - } - - private static class HasLongLCONST0 implements Callable { - - @Override - public Long call() throws Exception { - return 0L; - } - - } - - @Test - public void shouldNotReplaceLong0() throws Exception { - assertNoMutants(HasLongLCONST0.class); - } - - private static class HasLongLCONST1 implements Callable { - - @Override - public Long call() throws Exception { - return 1L; - } - - } - - @Test - public void shouldReplaceLong1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLCONST1.class); - assertMutantCallableReturns(new HasLongLCONST1(), mutant, 0L); - } - - private static class HasLongLDC implements Callable { - - @Override - public Long call() throws Exception { - return 2999999999L; - } - - } - - @Test - public void shouldReplaceLongLDCWith0() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLDC.class); - assertMutantCallableReturns(new HasLongLDC(), mutant, 0L); - } - - /* - * Double and Float - */ - - private static class HasFloatFCONST0 implements Callable { - - @Override - public Float call() throws Exception { - return 0.0F; - } - - } - - @Test - public void shouldNotReplaceFloat0() throws Exception { - assertNoMutants(HasFloatFCONST0.class); - } - - private static class HasFloatFCONST1 implements Callable { - - @Override - public Float call() throws Exception { - return 1.0F; - } - - } - - @Test - public void shouldReplaceFloat1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST1.class); - assertMutantCallableReturns(new HasFloatFCONST1(), mutant, 0.0F); - } - - private static class HasFloatFCONST2 implements Callable { - - @Override - public Float call() throws Exception { - return 2.0F; - } - - } - - @Test - public void shouldReplaceFloat2With0() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST2.class); - assertMutantCallableReturns(new HasFloatFCONST2(), mutant, 0.0F); - } - - private static class HasFloatLDC implements Callable { - - @Override - public Float call() throws Exception { - return 8364.123F; - } - - } - - @Test - public void shouldReplaceFloatWith0() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatLDC.class); - assertMutantCallableReturns(new HasFloatLDC(), mutant, 0.0F); - } - - private static class HasDoubleDCONST0 implements Callable { - - @Override - public Double call() throws Exception { - return 0.0D; - } - - } - - @Test - public void shouldNotReplaceDouble0() throws Exception { - assertNoMutants(HasDoubleDCONST0.class); - } - - private static class HasDoubleDCONST1 implements Callable { - - @Override - public Double call() throws Exception { - return 1.0D; - } - - } - - @Test - public void shouldReplaceDouble1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleDCONST1.class); - assertMutantCallableReturns(new HasDoubleDCONST1(), mutant, 0.0D); - } - - private static class HasDoubleLDC implements Callable { - - @Override - public Double call() throws Exception { - return 123456789.123D; - } - - } - - @Test - public void shouldReplaceDoubleWith0() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleLDC.class); - assertMutantCallableReturns(new HasDoubleLDC(), mutant, 0.0D); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR3Test.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR3Test.java deleted file mode 100644 index 888a4bb8c..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR3Test.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class CRCR3Test extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyInlineConstants() { - createTesteeWith(CRCR3Mutator.CRCR3); - } - - private static class HasIntegerICONST0 implements Callable { - - @Override - public Integer call() throws Exception { - return 0; - } - - } - - @Test - public void shouldReplaceInteger0WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST0.class); - assertMutantCallableReturns(new HasIntegerICONST0(), mutant, -1); - } - - private static class HasIntegerICONST1 implements Callable { - - @Override - public Integer call() throws Exception { - return 1; - } - - } - - @Test - public void shouldReplaceInteger1WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST1.class); - assertMutantCallableReturns(new HasIntegerICONST1(), mutant, -1); - } - - private static class HasIntegerICONST2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2; - } - - } - - @Test - public void shouldReplaceInteger2WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST2.class); - assertMutantCallableReturns(new HasIntegerICONST2(), mutant, -1); - } - - private static class HasIntegerICONST3 implements Callable { - - @Override - public Integer call() throws Exception { - return 3; - } - - } - - @Test - public void shouldReplaceInteger3WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST3.class); - assertMutantCallableReturns(new HasIntegerICONST3(), mutant, -1); - } - - private static class HasIntegerICONST4 implements Callable { - - @Override - public Integer call() throws Exception { - return 4; - } - - } - - @Test - public void shouldReplaceInteger4WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST4.class); - assertMutantCallableReturns(new HasIntegerICONST4(), mutant, -1); - } - - private static class HasIntegerICONST5 implements Callable { - - @Override - public Integer call() throws Exception { - return 5; - } - - } - - @Test - public void shouldReplaceInteger5WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST5.class); - assertMutantCallableReturns(new HasIntegerICONST5(), mutant, -1); - } - - private static class HasIntegerLDC implements Callable { - - @Override - public Integer call() throws Exception { - return 987654321; - } - - } - - @Test - public void shouldReplaceLargeIntegerConstantsWithMinus1() - throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC.class); - assertMutantCallableReturns(new HasIntegerLDC(), mutant, -1); - } - - private static class HasIntegerICONSTM1 implements Callable { - - @Override - public Integer call() throws Exception { - return -1; - } - - } - - @Test - public void shouldNotReplaceIntegerMinus1() { - assertNoMutants(HasIntegerICONSTM1.class); - } - - private static class HasBIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 28; - } - - } - - @Test - public void shouldReplaceSmallIntegerConstantsWithMinus1() - throws Exception { - final Mutant mutant = getFirstMutant(HasBIPUSH.class); - assertMutantCallableReturns(new HasBIPUSH(), mutant, -1); - } - - private static class HasSIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 32700; - } - - } - - @Test - public void shouldReplaceMediumIntegerConstantsWithMinus1() - throws Exception { - final Mutant mutant = getFirstMutant(HasSIPUSH.class); - assertMutantCallableReturns(new HasSIPUSH(), mutant, -1); - } - - - private static class HasIntegerLDC2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2144567; - } - - } - - @Test - public void shouldReplaceIntegerLdcWithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC2.class); - assertMutantCallableReturns(new HasIntegerLDC2(), mutant, - -1); - } - - private static class HasLongLCONST0 implements Callable { - - @Override - public Long call() throws Exception { - return 0L; - } - - } - - @Test - public void shouldReplaceLong0WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLCONST0.class); - assertMutantCallableReturns(new HasLongLCONST0(), mutant,-1L); - } - - private static class HasLongLCONST1 implements Callable { - - @Override - public Long call() throws Exception { - return 1L; - } - - } - - @Test - public void shouldReplaceLong1WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLCONST1.class); - assertMutantCallableReturns(new HasLongLCONST1(), mutant, -1L); - } - - private static class HasLongLDC implements Callable { - - @Override - public Long call() throws Exception { - return 2999999999L; - } - - } - - @Test - public void shouldReplaceLongLDCWithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLDC.class); - assertMutantCallableReturns(new HasLongLDC(), mutant, -1L); - } - - /* - * Double and Float - */ - - private static class HasFloatFCONST0 implements Callable { - - @Override - public Float call() throws Exception { - return 0.0F; - } - - } - - @Test - public void shouldReplaceFloat0WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST0.class); - assertMutantCallableReturns(new HasFloatFCONST0(), mutant, -1F); - } - - private static class HasFloatFCONST1 implements Callable { - - @Override - public Float call() throws Exception { - return 1.0F; - } - - } - - @Test - public void shouldReplaceFloat1WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST1.class); - assertMutantCallableReturns(new HasFloatFCONST1(), mutant, -1F); - } - - private static class HasFloatFCONST2 implements Callable { - - @Override - public Float call() throws Exception { - return 2.0F; - } - - } - - @Test - public void shouldReplaceFloat2WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST2.class); - assertMutantCallableReturns(new HasFloatFCONST2(), mutant, -1F); - } - - private static class HasFloatLDC implements Callable { - - @Override - public Float call() throws Exception { - return 8364.123F; - } - - } - - @Test - public void shouldReplaceFloatWithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatLDC.class); - assertMutantCallableReturns(new HasFloatLDC(), mutant, -1.0F); - } - - private static class HasDoubleDCONST0 implements Callable { - - @Override - public Double call() throws Exception { - return 0.0D; - } - - } - - @Test - public void shouldReplaceDouble0WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleDCONST0.class); - assertMutantCallableReturns(new HasDoubleDCONST0(), mutant, -1D); - } - - private static class HasDoubleDCONST1 implements Callable { - - @Override - public Double call() throws Exception { - return 1.0D; - } - - } - - @Test - public void shouldReplaceDouble1WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleDCONST1.class); - assertMutantCallableReturns(new HasDoubleDCONST1(), mutant, -1D); - } - - private static class HasDoubleLDC implements Callable { - - @Override - public Double call() throws Exception { - return 123456789.123D; - } - - } - - @Test - public void shouldReplaceDoubleWithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleLDC.class); - assertMutantCallableReturns(new HasDoubleLDC(), mutant, -1D); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR4Test.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR4Test.java deleted file mode 100644 index 38d4dc2c4..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR4Test.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class CRCR4Test extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyInlineConstants() { - createTesteeWith(CRCR4Mutator.CRCR4); - } - - private static class HasIntegerICONST0 implements Callable { - - @Override - public Integer call() throws Exception { - return 0; - } - - } - - @Test - public void shouldNotReplaceInteger0() { - assertNoMutants(HasIntegerICONST0.class); - } - - private static class HasIntegerICONST1 implements Callable { - - @Override - public Integer call() throws Exception { - return 1; - } - - } - - @Test - public void shouldReplaceInteger1WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST1.class); - assertMutantCallableReturns(new HasIntegerICONST1(), mutant, -1); - } - - private static class HasIntegerICONST2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2; - } - - } - - @Test - public void shouldReplaceInteger2WithMinus2() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST2.class); - assertMutantCallableReturns(new HasIntegerICONST2(), mutant, -2); - } - - private static class HasIntegerICONST3 implements Callable { - - @Override - public Integer call() throws Exception { - return 3; - } - - } - - @Test - public void shouldReplaceInteger3WithMinus3() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST3.class); - assertMutantCallableReturns(new HasIntegerICONST3(), mutant, -3); - } - - private static class HasIntegerICONST4 implements Callable { - - @Override - public Integer call() throws Exception { - return 4; - } - - } - - @Test - public void shouldReplaceInteger4WithMinus4() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST4.class); - assertMutantCallableReturns(new HasIntegerICONST4(), mutant, -4); - } - - private static class HasIntegerICONST5 implements Callable { - - @Override - public Integer call() throws Exception { - return 5; - } - - } - - @Test - public void shouldReplaceInteger5WithMinus5() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST5.class); - assertMutantCallableReturns(new HasIntegerICONST5(), mutant, -5); - } - - private static class HasIntegerLDC implements Callable { - - @Override - public Integer call() throws Exception { - return 987654321; - } - - } - - @Test - public void shouldReplaceLargeIntegerConstantsWithMinusConstant() - throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC.class); - assertMutantCallableReturns(new HasIntegerLDC(), mutant, -987654321); - } - - private static class HasIntegerICONSTM1 implements Callable { - - @Override - public Integer call() throws Exception { - return -1; - } - - } - - @Test - public void shouldReplaceIntegerMinus1With1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONSTM1.class); - assertMutantCallableReturns(new HasIntegerICONSTM1(), mutant, 1); - } - - private static class HasBIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 28; - } - - } - - @Test - public void shouldReplaceSmallIntegerConstantsWithMinusConstant() - throws Exception { - final Mutant mutant = getFirstMutant(HasBIPUSH.class); - assertMutantCallableReturns(new HasBIPUSH(), mutant, -28); - } - - private static class HasSIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 32700; - } - - } - - @Test - public void shouldReplaceMediumIntegerConstantsWithMinusConstant() - throws Exception { - final Mutant mutant = getFirstMutant(HasSIPUSH.class); - assertMutantCallableReturns(new HasSIPUSH(), mutant, -32700); - } - - - private static class HasIntegerLDC2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2144567; - } - - } - - @Test - public void shouldReplaceIntegerLdcWithMinusConstant() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC2.class); - assertMutantCallableReturns(new HasIntegerLDC2(), mutant, - -2144567); - } - - private static class HasLongLCONST0 implements Callable { - - @Override - public Long call() throws Exception { - return 0L; - } - - } - - @Test - public void shouldNotReplaceLong0() { - assertNoMutants(HasLongLCONST0.class); - } - - private static class HasLongLCONST1 implements Callable { - - @Override - public Long call() throws Exception { - return 1L; - } - - } - - @Test - public void shouldReplaceLong1WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLCONST1.class); - assertMutantCallableReturns(new HasLongLCONST1(), mutant, -1L); - } - - private static class HasLongLDC implements Callable { - - @Override - public Long call() throws Exception { - return 2999999999L; - } - - } - - @Test - public void shouldReplaceLongLDCWithMinusConstant() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLDC.class); - assertMutantCallableReturns(new HasLongLDC(), mutant, -2999999999L); - } - - /* - * Double and Float - */ - - private static class HasFloatFCONST0 implements Callable { - - @Override - public Float call() throws Exception { - return 0.0F; - } - - } - - @Test - public void shouldNotReplaceFloat0(){ - assertNoMutants(HasFloatFCONST0.class); - } - - private static class HasFloatFCONST1 implements Callable { - - @Override - public Float call() throws Exception { - return 1.0F; - } - - } - - @Test - public void shouldReplaceFloat1WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST1.class); - assertMutantCallableReturns(new HasFloatFCONST1(), mutant, -1F); - } - - private static class HasFloatFCONST2 implements Callable { - - @Override - public Float call() throws Exception { - return 2.0F; - } - - } - - @Test - public void shouldReplaceFloat2WithMinus2() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST2.class); - assertMutantCallableReturns(new HasFloatFCONST2(), mutant, -2F); - } - - private static class HasFloatLDC implements Callable { - - @Override - public Float call() throws Exception { - return 8364.123F; - } - - } - - @Test - public void shouldReplaceFloatWithMinusConstant() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatLDC.class); - assertMutantCallableReturns(new HasFloatLDC(), mutant, -8364.123F); - } - - private static class HasDoubleDCONST0 implements Callable { - - @Override - public Double call() throws Exception { - return 0.0D; - } - - } - - @Test - public void shouldNotReplaceDouble0() { - assertNoMutants(HasDoubleDCONST0.class); - } - - private static class HasDoubleDCONST1 implements Callable { - - @Override - public Double call() throws Exception { - return 1.0D; - } - - } - - @Test - public void shouldReplaceDouble1WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleDCONST1.class); - assertMutantCallableReturns(new HasDoubleDCONST1(), mutant, -1D); - } - - private static class HasDoubleLDC implements Callable { - - @Override - public Double call() throws Exception { - return 123456789.123D; - } - - } - - @Test - public void shouldReplaceDoubleWithMinusConstant() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleLDC.class); - assertMutantCallableReturns(new HasDoubleLDC(), mutant, -123456789.123D); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR5Test.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR5Test.java deleted file mode 100644 index 7f41d16f4..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR5Test.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class CRCR5Test extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyInlineConstants() { - createTesteeWith(CRCR5Mutator.CRCR5); - } - - private static class HasIntegerICONST0 implements Callable { - - @Override - public Integer call() throws Exception { - return 0; - } - - } - - @Test - public void shouldReplaceInteger0With1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST0.class); - assertMutantCallableReturns(new HasIntegerICONST0(), mutant, 1); - } - - private static class HasIntegerICONST1 implements Callable { - - @Override - public Integer call() throws Exception { - return 1; - } - - } - - @Test - public void shouldReplaceInteger1With2() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST1.class); - assertMutantCallableReturns(new HasIntegerICONST1(), mutant, 2); - } - - private static class HasIntegerICONST2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2; - } - - } - - @Test - public void shouldReplaceInteger2With3() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST2.class); - assertMutantCallableReturns(new HasIntegerICONST2(), mutant, 3); - } - - private static class HasIntegerICONST3 implements Callable { - - @Override - public Integer call() throws Exception { - return 3; - } - - } - - @Test - public void shouldReplaceInteger3With4() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST3.class); - assertMutantCallableReturns(new HasIntegerICONST3(), mutant, 4); - } - - private static class HasIntegerICONST4 implements Callable { - - @Override - public Integer call() throws Exception { - return 4; - } - - } - - @Test - public void shouldReplaceInteger4With5() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST4.class); - assertMutantCallableReturns(new HasIntegerICONST4(), mutant, 5); - } - - private static class HasIntegerICONST5 implements Callable { - - @Override - public Integer call() throws Exception { - return 5; - } - - } - - @Test - public void shouldReplaceInteger5With6() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST5.class); - assertMutantCallableReturns(new HasIntegerICONST5(), mutant, 6); - } - - private static class HasIntegerLDC implements Callable { - - @Override - public Integer call() throws Exception { - return 987654321; - } - - } - - @Test - public void shouldReplaceLargeIntegerConstantsWithConstantPlus1() - throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC.class); - assertMutantCallableReturns(new HasIntegerLDC(), mutant, 987654322); - } - - private static class HasIntegerICONSTM1 implements Callable { - - @Override - public Integer call() throws Exception { - return -1; - } - - } - - @Test - public void shouldReplaceIntegerMinus1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONSTM1.class); - assertMutantCallableReturns(new HasIntegerICONSTM1(), mutant, 0); - } - - private static class HasBIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 28; - } - - } - - @Test - public void shouldReplaceSmallIntegerConstantsWithConstantPlus1() - throws Exception { - final Mutant mutant = getFirstMutant(HasBIPUSH.class); - assertMutantCallableReturns(new HasBIPUSH(), mutant, 29); - } - - private static class HasSIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 32700; - } - - } - - @Test - public void shouldReplaceMediumIntegerConstantsWithConstantPlus1() - throws Exception { - final Mutant mutant = getFirstMutant(HasSIPUSH.class); - assertMutantCallableReturns(new HasSIPUSH(), mutant, 32701); - } - - - private static class HasIntegerLDC2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2144567; - } - - } - - @Test - public void shouldReplaceIntegerLdcWithConstantPlus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC2.class); - assertMutantCallableReturns(new HasIntegerLDC2(), mutant, - 2144568); - } - - private static class HasLongLCONST0 implements Callable { - - @Override - public Long call() throws Exception { - return 0L; - } - - } - - @Test - public void shouldReplaceLong0With1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLCONST0.class); - assertMutantCallableReturns(new HasLongLCONST0(), mutant, 1L); - } - - private static class HasLongLCONST1 implements Callable { - - @Override - public Long call() throws Exception { - return 1L; - } - - } - - @Test - public void shouldReplaceLong1With2() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLCONST1.class); - assertMutantCallableReturns(new HasLongLCONST1(), mutant, 2L); - } - - private static class HasLongLDC implements Callable { - - @Override - public Long call() throws Exception { - return 2999999999L; - } - - } - - @Test - public void shouldReplaceLongLDCWithConstantPlus1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLDC.class); - assertMutantCallableReturns(new HasLongLDC(), mutant, 3000000000L); - } - - /* - * Double and Float - */ - - private static class HasFloatFCONST0 implements Callable { - - @Override - public Float call() throws Exception { - return 0.0F; - } - - } - - @Test - public void shouldReplaceFloat0With1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST0.class); - assertMutantCallableReturns(new HasFloatFCONST0(), mutant, 1F); - } - - private static class HasFloatFCONST1 implements Callable { - - @Override - public Float call() throws Exception { - return 1.0F; - } - - } - - @Test - public void shouldReplaceFloat1With2() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST1.class); - assertMutantCallableReturns(new HasFloatFCONST1(), mutant, 2F); - } - - private static class HasFloatFCONST2 implements Callable { - - @Override - public Float call() throws Exception { - return 2.0F; - } - - } - - @Test - public void shouldReplaceFloat2With3() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST2.class); - assertMutantCallableReturns(new HasFloatFCONST2(), mutant, 3F); - } - - private static class HasFloatLDC implements Callable { - - @Override - public Float call() throws Exception { - return 8364.123F; - } - - } - - @Test - public void shouldReplaceFloatWithConstantPlus1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatLDC.class); - assertMutantCallableReturns(new HasFloatLDC(), mutant, 8365.123F); - } - - private static class HasLargeFloatLDC implements Callable { - - @Override - public Float call() throws Exception { - return 1.6777216E7F; - } - - } - - @Test - public void shouldNotReplaceLargeFloat() { - assertNoMutants(HasLargeFloatLDC.class); - } - - private static class HasDoubleDCONST0 implements Callable { - - @Override - public Double call() throws Exception { - return 0.0D; - } - - } - - @Test - public void shouldReplaceDouble0With1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleDCONST0.class); - assertMutantCallableReturns(new HasDoubleDCONST0(), mutant, 1D); - } - - private static class HasDoubleDCONST1 implements Callable { - - @Override - public Double call() throws Exception { - return 1.0D; - } - - } - - @Test - public void shouldReplaceDouble1With2() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleDCONST1.class); - assertMutantCallableReturns(new HasDoubleDCONST1(), mutant, 2D); - } - - private static class HasDoubleLDC implements Callable { - - @Override - public Double call() throws Exception { - return 123456789.123D; - } - - } - - @Test - public void shouldReplaceDoubleWithConstantPlus1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleLDC.class); - assertMutantCallableReturns(new HasDoubleLDC(), mutant, 1.23456790123E8); - } - - private static class HasLargeDoubleLDC implements Callable { - - @Override - public Double call() throws Exception { - return 1.0E16D; - } - - } - - @Test - public void shouldNotReplaceLargeDouble() { - assertNoMutants(HasLargeDoubleLDC.class); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR6Test.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR6Test.java deleted file mode 100644 index 86b03c8c4..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/CRCR6Test.java +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Copyright 2011 Henry Coles and Stefan Penndorf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class CRCR6Test extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyInlineConstants() { - createTesteeWith(CRCR6Mutator.CRCR6); - } - - private static class HasIntegerICONST0 implements Callable { - - @Override - public Integer call() throws Exception { - return 0; - } - - } - - @Test - public void shouldReplaceInteger0WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST0.class); - assertMutantCallableReturns(new HasIntegerICONST0(), mutant, -1); - } - - private static class HasIntegerICONST1 implements Callable { - - @Override - public Integer call() throws Exception { - return 1; - } - - } - - @Test - public void shouldReplaceInteger1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST1.class); - assertMutantCallableReturns(new HasIntegerICONST1(), mutant, 0); - } - - private static class HasIntegerICONST2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2; - } - - } - - @Test - public void shouldReplaceInteger2With1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST2.class); - assertMutantCallableReturns(new HasIntegerICONST2(), mutant, 1); - } - - private static class HasIntegerICONST3 implements Callable { - - @Override - public Integer call() throws Exception { - return 3; - } - - } - - @Test - public void shouldReplaceInteger3With2() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST3.class); - assertMutantCallableReturns(new HasIntegerICONST3(), mutant, 2); - } - - private static class HasIntegerICONST4 implements Callable { - - @Override - public Integer call() throws Exception { - return 4; - } - - } - - @Test - public void shouldReplaceInteger4With3() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST4.class); - assertMutantCallableReturns(new HasIntegerICONST4(), mutant, 3); - } - - private static class HasIntegerICONST5 implements Callable { - - @Override - public Integer call() throws Exception { - return 5; - } - - } - - @Test - public void shouldReplaceInteger5With4() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONST5.class); - assertMutantCallableReturns(new HasIntegerICONST5(), mutant, 4); - } - - private static class HasIntegerLDC implements Callable { - - @Override - public Integer call() throws Exception { - return 987654321; - } - - } - - @Test - public void shouldReplaceLargeIntegerConstantsWithConstantMinus1() - throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC.class); - assertMutantCallableReturns(new HasIntegerLDC(), mutant, 987654320); - } - - private static class HasIntegerICONSTM1 implements Callable { - - @Override - public Integer call() throws Exception { - return -1; - } - - } - - @Test - public void shouldReplaceIntegerMinus1WithMinus2() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerICONSTM1.class); - assertMutantCallableReturns(new HasIntegerICONSTM1(), mutant, -2); - } - - private static class HasBIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 28; - } - - } - - @Test - public void shouldReplaceSmallIntegerConstantsWithConstantMinus1() - throws Exception { - final Mutant mutant = getFirstMutant(HasBIPUSH.class); - assertMutantCallableReturns(new HasBIPUSH(), mutant, 27); - } - - private static class HasSIPUSH implements Callable { - - @Override - public Integer call() throws Exception { - return 32700; - } - - } - - @Test - public void shouldReplaceMediumIntegerConstantsWithConstantMinus1() - throws Exception { - final Mutant mutant = getFirstMutant(HasSIPUSH.class); - assertMutantCallableReturns(new HasSIPUSH(), mutant, 32699); - } - - - private static class HasIntegerLDC2 implements Callable { - - @Override - public Integer call() throws Exception { - return 2144567; - } - - } - - @Test - public void shouldReplaceIntegerLdcWithConstantMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasIntegerLDC2.class); - assertMutantCallableReturns(new HasIntegerLDC2(), mutant, 2144566); - } - - private static class HasLongLCONST0 implements Callable { - - @Override - public Long call() throws Exception { - return 0L; - } - - } - - @Test - public void shouldReplaceLong0WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLCONST0.class); - assertMutantCallableReturns(new HasLongLCONST0(), mutant, -1L); - } - - private static class HasLongLCONST1 implements Callable { - - @Override - public Long call() throws Exception { - return 1L; - } - - } - - @Test - public void shouldReplaceLong1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLCONST1.class); - assertMutantCallableReturns(new HasLongLCONST1(), mutant, 0L); - } - - private static class HasLongLDC implements Callable { - - @Override - public Long call() throws Exception { - return 2999999999L; - } - - } - - @Test - public void shouldReplaceLongLDCWithConstantMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasLongLDC.class); - assertMutantCallableReturns(new HasLongLDC(), mutant, 2999999998L); - } - - /* - * Double and Float - */ - - private static class HasFloatFCONST0 implements Callable { - - @Override - public Float call() throws Exception { - return 0.0F; - } - - } - - @Test - public void shouldReplaceFloat0WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST0.class); - assertMutantCallableReturns(new HasFloatFCONST0(), mutant, -1F); - } - - private static class HasFloatFCONST1 implements Callable { - - @Override - public Float call() throws Exception { - return 1.0F; - } - - } - - @Test - public void shouldReplaceFloat1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST1.class); - assertMutantCallableReturns(new HasFloatFCONST1(), mutant, 0F); - } - - private static class HasFloatFCONST2 implements Callable { - - @Override - public Float call() throws Exception { - return 2.0F; - } - - } - - @Test - public void shouldReplaceFloat2With1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatFCONST2.class); - assertMutantCallableReturns(new HasFloatFCONST2(), mutant, 1F); - } - - private static class HasFloatLDC implements Callable { - - @Override - public Float call() throws Exception { - return 8364.123F; - } - - } - - @Test - public void shouldReplaceFloatWithConstantMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasFloatLDC.class); - assertMutantCallableReturns(new HasFloatLDC(), mutant, 8363.123F); - } - - private static class HasLargeFloatLDC implements Callable { - - @Override - public Float call() throws Exception { - return 1.6777216E8F; - } - - } - - @Test - public void shouldNotReplaceLargeFloat() { - assertNoMutants(HasLargeFloatLDC.class); - } - - private static class HasDoubleDCONST0 implements Callable { - - @Override - public Double call() throws Exception { - return 0.0D; - } - - } - - @Test - public void shouldReplaceDouble0WithMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleDCONST0.class); - assertMutantCallableReturns(new HasDoubleDCONST0(), mutant, -1D); - } - - private static class HasDoubleDCONST1 implements Callable { - - @Override - public Double call() throws Exception { - return 1.0D; - } - - } - - @Test - public void shouldReplaceDouble1With0() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleDCONST1.class); - assertMutantCallableReturns(new HasDoubleDCONST1(), mutant, 0D); - } - - private static class HasDoubleLDC implements Callable { - - @Override - public Double call() throws Exception { - return 123456789.123D; - } - - } - - @Test - public void shouldReplaceDoubleWithConstantMinus1() throws Exception { - final Mutant mutant = getFirstMutant(HasDoubleLDC.class); - assertMutantCallableReturns(new HasDoubleLDC(), mutant, 123456788.123D); - } - - private static class HasLargeDoubleLDC implements Callable { - - @Override - public Double call() throws Exception { - return 1.0E16D; - } - - } - - @Test - public void shouldNotReplaceLargeDouble() { - assertNoMutants(HasLargeDoubleLDC.class); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN1MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN1MutatorTest.java deleted file mode 100644 index 25eef53f6..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN1MutatorTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class OBBN1MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(OBBN1Mutator.OBBN1); - } - - private static class HasIOr implements Callable { - private int i; - - HasIOr(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i | 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerBitwiseOrsWithAnds() throws Exception { - final Mutant mutant = getFirstMutant(HasIOr.class); - assertMutantCallableReturns(new HasIOr(1), mutant, "0"); - assertMutantCallableReturns(new HasIOr(4), mutant, "0"); - } - - private static class HasIAnd implements Callable { - private int i; - - HasIAnd(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i & 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerBitwiseAndsWithOrs() throws Exception { - final Mutant mutant = getFirstMutant(HasIAnd.class); - assertMutantCallableReturns(new HasIAnd(1), mutant, "3"); - assertMutantCallableReturns(new HasIAnd(4), mutant, "6"); - } - - - // LONGS - - private static class HasLOr implements Callable { - private long i; - - HasLOr(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i | 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongBitwiseOrsWithAnds() throws Exception { - final Mutant mutant = getFirstMutant(HasLOr.class); - assertMutantCallableReturns(new HasLOr(1), mutant, "0"); - assertMutantCallableReturns(new HasLOr(4), mutant, "0"); - } - - private static class HasLAnd implements Callable { - private long i; - - HasLAnd(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i & 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongBitwiseAndsWithOrs() throws Exception { - final Mutant mutant = getFirstMutant(HasLAnd.class); - assertMutantCallableReturns(new HasLAnd(1), mutant, "3"); - assertMutantCallableReturns(new HasLAnd(4), mutant, "6"); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN2MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN2MutatorTest.java deleted file mode 100644 index bee8050f6..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN2MutatorTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class OBBN2MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(OBBN2Mutator.OBBN2); - } - - private static class HasIOr implements Callable { - private int i; - - HasIOr(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i | 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerBitwiseOrsWithFirstMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIOr.class); - assertMutantCallableReturns(new HasIOr(1), mutant, "1"); - assertMutantCallableReturns(new HasIOr(4), mutant, "4"); - } - - private static class HasIAnd implements Callable { - private int i; - - HasIAnd(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i & 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerBitwiseAndsWithFirstMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIAnd.class); - assertMutantCallableReturns(new HasIAnd(1), mutant, "1"); - assertMutantCallableReturns(new HasIAnd(4), mutant, "4"); - } - - - // LONGS - - private static class HasLOr implements Callable { - private long i; - - HasLOr(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i | 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongBitwiseOrsWithFirstMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLOr.class); - assertMutantCallableReturns(new HasLOr(1), mutant, "1"); - assertMutantCallableReturns(new HasLOr(4), mutant, "4"); - } - - private static class HasLAnd implements Callable { - private long i; - - HasLAnd(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = this.i & 2; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongBitwiseAndsWithFirstMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLAnd.class); - assertMutantCallableReturns(new HasLAnd(1), mutant, "1"); - assertMutantCallableReturns(new HasLAnd(4), mutant, "4"); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN3MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN3MutatorTest.java deleted file mode 100644 index 400383747..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/OBBN3MutatorTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class OBBN3MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(OBBN3Mutator.OBBN3); - } - - private static class HasIOr implements Callable { - private int i; - - HasIOr(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 | this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerBitwiseOrsWithSecondMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIOr.class); - assertMutantCallableReturns(new HasIOr(1), mutant, "1"); - assertMutantCallableReturns(new HasIOr(4), mutant, "4"); - } - - private static class HasIAnd implements Callable { - private int i; - - HasIAnd(final int i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 & this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerBitwiseAndsWithFirstMember() throws Exception { - final Mutant mutant = getFirstMutant(HasIAnd.class); - assertMutantCallableReturns(new HasIAnd(1), mutant, "1"); - assertMutantCallableReturns(new HasIAnd(4), mutant, "4"); - } - - - // LONGS - - private static class HasLOr implements Callable { - private long i; - - HasLOr(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 | this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongBitwiseOrsWithFirstMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLOr.class); - assertMutantCallableReturns(new HasLOr(1), mutant, "1"); - assertMutantCallableReturns(new HasLOr(4), mutant, "4"); - } - - private static class HasLAnd implements Callable { - private long i; - - HasLAnd(final long i) { - this.i = i; - } - - @Override - public String call() { - this.i = 2 & this.i; - return "" + this.i; - } - } - - @Test - public void shouldReplaceLongBitwiseAndsWithFirstMember() throws Exception { - final Mutant mutant = getFirstMutant(HasLAnd.class); - assertMutantCallableReturns(new HasLAnd(1), mutant, "1"); - assertMutantCallableReturns(new HasLAnd(4), mutant, "4"); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR1MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR1MutatorTest.java deleted file mode 100644 index 3a575a169..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR1MutatorTest.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class ROR1MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyConditionals() { - createTesteeWith(ROR1Mutator.ROR1); - } - - private static int getZeroButPreventInlining() { - return 0; - } - - private static class HasIFLT implements Callable { - private final int i; - - HasIFLT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i >= 0) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIFLTWithIFLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLT.class); - assertMutantCallableReturns(new HasIFLT(1), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIFLT(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFLT(-1), mutant, "was < zero"); - } - - private static class HasIF_ICMPLT implements Callable { - private final int i; - - HasIF_ICMPLT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i >= j) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLTWithIF_ICMPLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLT.class); - assertMutantCallableReturns(new HasIF_ICMPLT(1), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(-1), mutant, "was < zero"); - } - - private static class HasIFLE implements Callable { - private final int i; - - HasIFLE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i > 0) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIFLEWithIFLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLE.class); - assertMutantCallableReturns(new HasIFLE(1), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFLE(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFLE(-1), mutant, "was <= zero"); - } - - private static class HasIF_ICMPLE implements Callable { - private final int i; - - HasIF_ICMPLE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i > j) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLEWithIF_ICMPLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLE.class); - assertMutantCallableReturns(new HasIF_ICMPLE(1), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(-1), mutant, "was <= zero"); - } - - private static class HasIFGT implements Callable { - private final int i; - - HasIFGT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i <= 0) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIFGTWithIFLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGT.class); - assertMutantCallableReturns(new HasIFGT(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFGT(0), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFGT(-1), mutant, "was > zero"); - } - - private static class HasIF_ICMPGT implements Callable { - private final int i; - - HasIF_ICMPGT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i <= j) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGTWithIF_ICMPLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGT.class); - assertMutantCallableReturns(new HasIF_ICMPGT(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(0), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(-1), mutant, "was > zero"); - } - - private static class HasIFGE implements Callable { - private final int i; - - HasIFGE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i < 0) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIFGEWithIFLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGE.class); - assertMutantCallableReturns(new HasIFGE(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFGE(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFGE(-1), mutant, "was >= zero"); - } - - private static class HasIF_ICMPGE implements Callable { - private final int i; - - HasIF_ICMPGE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i < j) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGEWithIF_ICMPLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGE.class); - assertMutantCallableReturns(new HasIF_ICMPGE(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(-1), mutant, "was >= zero"); - } - - private static class HasIFEQ implements Callable { - private final int i; - - HasIFEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i != 0) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIFEQWithIFLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFEQ.class); - assertMutantCallableReturns(new HasIFEQ(1), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFEQ(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFEQ(-1), mutant, "was zero"); - } - - private static class HasIF_ICMPEQ implements Callable { - private final int i; - - HasIF_ICMPEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i != j) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPEQWithIF_CMPLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPEQ.class); - assertMutantCallableReturns(new HasIF_ICMPEQ(1), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(-1), mutant, "was zero"); - } - - - private static class HasIFNE implements Callable { - private final int i; - - HasIFNE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i == 0) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIFNEWithIFLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFNE.class); - assertMutantCallableReturns(new HasIFNE(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIFNE(0), mutant, "was zero"); - assertMutantCallableReturns(new HasIFNE(-1), mutant, "was not zero"); - } - - private static class HasIF_ICMPNE implements Callable { - private final int i; - - HasIF_ICMPNE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i == j) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPNEWithIF_CMPLT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPNE.class); - assertMutantCallableReturns(new HasIF_ICMPNE(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(0), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(-1), mutant, "was not zero"); - } - - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR2MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR2MutatorTest.java deleted file mode 100644 index f171900e1..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR2MutatorTest.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class ROR2MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyConditionals() { - createTesteeWith(ROR2Mutator.ROR2); - } - - private static int getZeroButPreventInlining() { - return 0; - } - - private static class HasIFLT implements Callable { - private final int i; - - HasIFLT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i >= 0) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIFLTWithIFGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLT.class); - assertMutantCallableReturns(new HasIFLT(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFLT(0), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIFLT(-1), mutant, "was >= zero"); - } - - private static class HasIF_ICMPLT implements Callable { - private final int i; - - HasIF_ICMPLT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i >= j) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLTWithIF_ICMPGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLT.class); - assertMutantCallableReturns(new HasIF_ICMPLT(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(0), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(-1), mutant, "was >= zero"); - } - - private static class HasIFLE implements Callable { - private final int i; - - HasIFLE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i > 0) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIFLEWithIFGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLE.class); - assertMutantCallableReturns(new HasIFLE(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFLE(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFLE(-1), mutant, "was > zero"); - } - - private static class HasIF_ICMPLE implements Callable { - private final int i; - - HasIF_ICMPLE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i > j) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLEWithIF_ICMPGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLE.class); - assertMutantCallableReturns(new HasIF_ICMPLE(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(-1), mutant, "was > zero"); - } - - private static class HasIFGT implements Callable { - private final int i; - - HasIFGT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i <= 0) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIFGTWithIFLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGT.class); - assertMutantCallableReturns(new HasIFGT(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFGT(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFGT(-1), mutant, "was > zero"); - } - - private static class HasIF_ICMPGT implements Callable { - private final int i; - - HasIF_ICMPGT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i <= j) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGTWithIF_ICMPLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGT.class); - assertMutantCallableReturns(new HasIF_ICMPGT(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(-1), mutant, "was > zero"); - } - - private static class HasIFGE implements Callable { - private final int i; - - HasIFGE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i < 0) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIFGEWithIFLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGE.class); - assertMutantCallableReturns(new HasIFGE(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFGE(0), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIFGE(-1), mutant, "was >= zero"); - } - - private static class HasIF_ICMPGE implements Callable { - private final int i; - - HasIF_ICMPGE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i < j) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGEWithIF_ICMPLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGE.class); - assertMutantCallableReturns(new HasIF_ICMPGE(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(0), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(-1), mutant, "was >= zero"); - } - - private static class HasIFEQ implements Callable { - private final int i; - - HasIFEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i != 0) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIFEQWithIFLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFEQ.class); - assertMutantCallableReturns(new HasIFEQ(1), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFEQ(0), mutant, "was zero"); - assertMutantCallableReturns(new HasIFEQ(-1), mutant, "was zero"); - } - - private static class HasIF_ICMPEQ implements Callable { - private final int i; - - HasIF_ICMPEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i != j) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPEQWithIF_CMPLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPEQ.class); - assertMutantCallableReturns(new HasIF_ICMPEQ(1), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(0), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(-1), mutant, "was zero"); - } - - - private static class HasIFNE implements Callable { - private final int i; - - HasIFNE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i == 0) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIFNEWithIFLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFNE.class); - assertMutantCallableReturns(new HasIFNE(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIFNE(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFNE(-1), mutant, "was not zero"); - } - - private static class HasIF_ICMPNE implements Callable { - private final int i; - - HasIF_ICMPNE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i == j) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPNEWithIF_CMPLE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPNE.class); - assertMutantCallableReturns(new HasIF_ICMPNE(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(-1), mutant, "was not zero"); - } - - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR3MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR3MutatorTest.java deleted file mode 100644 index 4d98c15af..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR3MutatorTest.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class ROR3MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyConditionals() { - createTesteeWith(ROR3Mutator.ROR3); - } - - private static int getZeroButPreventInlining() { - return 0; - } - - private static class HasIFLT implements Callable { - private final int i; - - HasIFLT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i >= 0) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIFLTWithIFGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLT.class); - assertMutantCallableReturns(new HasIFLT(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFLT(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFLT(-1), mutant, "was >= zero"); - } - - private static class HasIF_ICMPLT implements Callable { - private final int i; - - HasIF_ICMPLT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i >= j) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLTWithIF_ICMPGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLT.class); - assertMutantCallableReturns(new HasIF_ICMPLT(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(-1), mutant, "was >= zero"); - } - - private static class HasIFLE implements Callable { - private final int i; - - HasIFLE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i > 0) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIFLEWithIFGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLE.class); - assertMutantCallableReturns(new HasIFLE(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFLE(0), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFLE(-1), mutant, "was > zero"); - } - - private static class HasIF_ICMPLE implements Callable { - private final int i; - - HasIF_ICMPLE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i > j) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLEWithIF_ICMPGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLE.class); - assertMutantCallableReturns(new HasIF_ICMPLE(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(0), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(-1), mutant, "was > zero"); - } - - private static class HasIFGT implements Callable { - private final int i; - - HasIFGT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i <= 0) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIFGTWithIFGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGT.class); - assertMutantCallableReturns(new HasIFGT(1), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFGT(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFGT(-1), mutant, "was <= zero"); - } - - private static class HasIF_ICMPGT implements Callable { - private final int i; - - HasIF_ICMPGT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i <= j) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGTWithIF_ICMPGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGT.class); - assertMutantCallableReturns(new HasIF_ICMPGT(1), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(-1), mutant, "was <= zero"); - } - - private static class HasIFGE implements Callable { - private final int i; - - HasIFGE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i < 0) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIFGEWithIFGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGE.class); - assertMutantCallableReturns(new HasIFGE(1), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIFGE(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFGE(-1), mutant, "was < zero"); - } - - private static class HasIF_ICMPGE implements Callable { - private final int i; - - HasIF_ICMPGE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i < j) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGEWithIF_ICMPGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGE.class); - assertMutantCallableReturns(new HasIF_ICMPGE(1), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(-1), mutant, "was < zero"); - } - - private static class HasIFEQ implements Callable { - private final int i; - - HasIFEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i != 0) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIFEQWithIFGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFEQ.class); - assertMutantCallableReturns(new HasIFEQ(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIFEQ(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFEQ(-1), mutant, "was not zero"); - } - - private static class HasIF_ICMPEQ implements Callable { - private final int i; - - HasIF_ICMPEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i != j) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPEQWithIF_CMPGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPEQ.class); - assertMutantCallableReturns(new HasIF_ICMPEQ(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(-1), mutant, "was not zero"); - } - - - private static class HasIFNE implements Callable { - private final int i; - - HasIFNE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i == 0) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIFNEWithIFGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIFNE.class); - assertMutantCallableReturns(new HasIFNE(1), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFNE(0), mutant, "was zero"); - assertMutantCallableReturns(new HasIFNE(-1), mutant, "was zero"); - } - - private static class HasIF_ICMPNE implements Callable { - private final int i; - - HasIF_ICMPNE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i == j) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPNEWithIF_CMPGT() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPNE.class); - assertMutantCallableReturns(new HasIF_ICMPNE(1), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(0), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(-1), mutant, "was zero"); - } - - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR4MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR4MutatorTest.java deleted file mode 100644 index 23afe1c43..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR4MutatorTest.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class ROR4MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyConditionals() { - createTesteeWith(ROR4Mutator.ROR4); - } - - private static int getZeroButPreventInlining() { - return 0; - } - - private static class HasIFLT implements Callable { - private final int i; - - HasIFLT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i >= 0) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIFLTWithIFEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLT.class); - assertMutantCallableReturns(new HasIFLT(1), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIFLT(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFLT(-1), mutant, "was >= zero"); - } - - private static class HasIF_ICMPLT implements Callable { - private final int i; - - HasIF_ICMPLT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i >= j) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLTWithIF_ICMPEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLT.class); - assertMutantCallableReturns(new HasIF_ICMPLT(1), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(-1), mutant, "was >= zero"); - } - - private static class HasIFLE implements Callable { - private final int i; - - HasIFLE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i > 0) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIFLEWithIFEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLE.class); - assertMutantCallableReturns(new HasIFLE(1), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFLE(0), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFLE(-1), mutant, "was > zero"); - } - - private static class HasIF_ICMPLE implements Callable { - private final int i; - - HasIF_ICMPLE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i > j) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLEWithIF_ICMPEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLE.class); - assertMutantCallableReturns(new HasIF_ICMPLE(1), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(0), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(-1), mutant, "was > zero"); - } - - private static class HasIFGT implements Callable { - private final int i; - - HasIFGT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i <= 0) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIFGTWithIFEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGT.class); - assertMutantCallableReturns(new HasIFGT(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFGT(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFGT(-1), mutant, "was <= zero"); - } - - private static class HasIF_ICMPGT implements Callable { - private final int i; - - HasIF_ICMPGT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i <= j) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGTWithIF_ICMPEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGT.class); - assertMutantCallableReturns(new HasIF_ICMPGT(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(-1), mutant, "was <= zero"); - } - - private static class HasIFGE implements Callable { - private final int i; - - HasIFGE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i < 0) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIFGEWithIFEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGE.class); - assertMutantCallableReturns(new HasIFGE(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFGE(0), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIFGE(-1), mutant, "was < zero"); - } - - private static class HasIF_ICMPGE implements Callable { - private final int i; - - HasIF_ICMPGE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i < j) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGEWithIF_ICMPEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGE.class); - assertMutantCallableReturns(new HasIF_ICMPGE(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(0), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(-1), mutant, "was < zero"); - } - - private static class HasIFEQ implements Callable { - private final int i; - - HasIFEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i != 0) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIFEQWithIFGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFEQ.class); - assertMutantCallableReturns(new HasIFEQ(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIFEQ(0), mutant, "was zero"); - assertMutantCallableReturns(new HasIFEQ(-1), mutant, "was not zero"); - } - - private static class HasIF_ICMPEQ implements Callable { - private final int i; - - HasIF_ICMPEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i != j) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPEQWithIF_CMPGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPEQ.class); - assertMutantCallableReturns(new HasIF_ICMPEQ(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(0), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(-1), mutant, "was not zero"); - } - - - private static class HasIFNE implements Callable { - private final int i; - - HasIFNE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i == 0) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIFNEWithIFGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFNE.class); - assertMutantCallableReturns(new HasIFNE(1), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFNE(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFNE(-1), mutant, "was zero"); - } - - private static class HasIF_ICMPNE implements Callable { - private final int i; - - HasIF_ICMPNE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i == j) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPNEWithIF_CMPGE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPNE.class); - assertMutantCallableReturns(new HasIF_ICMPNE(1), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(-1), mutant, "was zero"); - } - - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR5MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR5MutatorTest.java deleted file mode 100644 index 3c5390c11..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/ROR5MutatorTest.java +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class ROR5MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyConditionals() { - createTesteeWith(ROR5Mutator.ROR5); - } - - private static int getZeroButPreventInlining() { - return 0; - } - - private static class HasIFLT implements Callable { - private final int i; - - HasIFLT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i >= 0) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIFLTWithIFNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLT.class); - assertMutantCallableReturns(new HasIFLT(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFLT(0), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIFLT(-1), mutant, "was < zero"); - } - - private static class HasIF_ICMPLT implements Callable { - private final int i; - - HasIF_ICMPLT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i >= j) { - return "was >= zero"; - } else { - return "was < zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLTWithIF_ICMPNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLT.class); - assertMutantCallableReturns(new HasIF_ICMPLT(1), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(0), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIF_ICMPLT(-1), mutant, "was < zero"); - } - - private static class HasIFLE implements Callable { - private final int i; - - HasIFLE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i > 0) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIFLEWithIFNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFLE.class); - assertMutantCallableReturns(new HasIFLE(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFLE(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFLE(-1), mutant, "was <= zero"); - } - - private static class HasIF_ICMPLE implements Callable { - private final int i; - - HasIF_ICMPLE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i > j) { - return "was > zero"; - } else { - return "was <= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPLEWithIF_ICMPNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPLE.class); - assertMutantCallableReturns(new HasIF_ICMPLE(1), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(0), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPLE(-1), mutant, "was <= zero"); - } - - private static class HasIFGT implements Callable { - private final int i; - - HasIFGT(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i <= 0) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIFGTWithIFNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGT.class); - assertMutantCallableReturns(new HasIFGT(1), mutant, "was > zero"); - assertMutantCallableReturns(new HasIFGT(0), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIFGT(-1), mutant, "was > zero"); - } - - private static class HasIF_ICMPGT implements Callable { - private final int i; - - HasIF_ICMPGT(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i <= j) { - return "was <= zero"; - } else { - return "was > zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGTWithIF_ICMPNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGT.class); - assertMutantCallableReturns(new HasIF_ICMPGT(1), mutant, "was > zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(0), mutant, "was <= zero"); - assertMutantCallableReturns(new HasIF_ICMPGT(-1), mutant, "was > zero"); - } - - private static class HasIFGE implements Callable { - private final int i; - - HasIFGE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i < 0) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIFGEWithIFNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFGE.class); - assertMutantCallableReturns(new HasIFGE(1), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIFGE(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIFGE(-1), mutant, "was >= zero"); - } - - private static class HasIF_ICMPGE implements Callable { - private final int i; - - HasIF_ICMPGE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i < j) { - return "was < zero"; - } else { - return "was >= zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPGEWithIF_ICMPNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPGE.class); - assertMutantCallableReturns(new HasIF_ICMPGE(1), mutant, "was >= zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(0), mutant, "was < zero"); - assertMutantCallableReturns(new HasIF_ICMPGE(-1), mutant, "was >= zero"); - } - - private static class HasIFEQ implements Callable { - private final int i; - - HasIFEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i != 0) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIFEQWithIFNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIFEQ.class); - assertMutantCallableReturns(new HasIFEQ(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIFEQ(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFEQ(-1), mutant, "was zero"); - } - - private static class HasIF_ICMPEQ implements Callable { - private final int i; - - HasIF_ICMPEQ(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i != j) { - return "was not zero"; - } else { - return "was zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPEQWithIF_CMPNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPEQ.class); - assertMutantCallableReturns(new HasIF_ICMPEQ(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPEQ(-1), mutant, "was zero"); - } - - - private static class HasIFNULL implements Callable { - private final Object i; - - HasIFNULL(final Object i) { - this.i = i; - } - - @Override - public String call() { - if (this.i != null) { - return "was not null"; - } else { - return "was null"; - } - } - } - - @Test - public void shouldReplaceIFNULLWithIFNONNULL() throws Exception { - final Mutant mutant = getFirstMutant(HasIFNULL.class); - assertMutantCallableReturns(new HasIFNULL(null), mutant, "was not null"); - assertMutantCallableReturns(new HasIFNULL("foo"), mutant, "was null"); - } - - private static class HasIF_ACMPEQ implements Callable { - private final Object i; - - HasIF_ACMPEQ(final Object i) { - this.i = i; - } - - @Override - public String call() { - final Object integer = Integer.class; - if (this.i != integer) { - return "was not integer"; - } else { - return "was integer"; - } - } - } - - @Test - public void shouldReplaceIF_ACMPEQWithIF_CMPNE() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ACMPEQ.class); - assertMutantCallableReturns(new HasIF_ACMPEQ(String.class), mutant, - "was integer"); - assertMutantCallableReturns(new HasIF_ACMPEQ(Integer.class), mutant, - "was not integer"); - } - - private static class HasIFNE implements Callable { - private final int i; - - HasIFNE(final int i) { - this.i = i; - } - - @Override - public String call() { - if (this.i == 0) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIFNEWithIFEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIFNE.class); - assertMutantCallableReturns(new HasIFNE(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIFNE(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIFNE(-1), mutant, "was zero"); - } - - private static class HasIF_ICMPNE implements Callable { - private final int i; - - HasIF_ICMPNE(final int i) { - this.i = i; - } - - @Override - public String call() { - final int j = getZeroButPreventInlining(); - if (this.i == j) { - return "was zero"; - } else { - return "was not zero"; - } - } - } - - @Test - public void shouldReplaceIF_ICMPNEWithIF_CMPEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ICMPNE.class); - assertMutantCallableReturns(new HasIF_ICMPNE(1), mutant, "was zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(0), mutant, "was not zero"); - assertMutantCallableReturns(new HasIF_ICMPNE(-1), mutant, "was zero"); - } - - private static class HasIFNONNULL implements Callable { - private final Object i; - - HasIFNONNULL(final Object i) { - this.i = i; - } - - @Override - public String call() { - if (this.i == null) { - return "was null"; - } else { - return "was not null"; - } - } - } - - @Test - public void shouldReplaceIFNONNULLWithIFNULL() throws Exception { - final Mutant mutant = getFirstMutant(HasIFNONNULL.class); - assertMutantCallableReturns(new HasIFNONNULL(null), mutant, "was not null"); - assertMutantCallableReturns(new HasIFNONNULL("foo"), mutant, "was null"); - } - - private static class HasIF_ACMPNE implements Callable { - private final Object i; - - HasIF_ACMPNE(final Object i) { - this.i = i; - } - - @Override - public String call() { - final Object integer = Integer.class; - if (this.i == integer) { - return "was integer"; - } else { - return "was not integer"; - } - } - } - - @Test - public void shouldReplaceIF_ACMPNEWithIF_CMPEQ() throws Exception { - final Mutant mutant = getFirstMutant(HasIF_ACMPNE.class); - printMutant(mutant); - assertMutantCallableReturns(new HasIF_ACMPNE(String.class), mutant, - "was integer"); - assertMutantCallableReturns(new HasIF_ACMPNE(Integer.class), mutant, - "was not integer"); - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI1MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI1MutatorTest.java deleted file mode 100644 index 021f65578..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI1MutatorTest.java +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class UOI1MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(mutateOnlyCallMethod(), UOI1Mutator.UOI1); - } - - private static class HasILoad implements Callable { - @Override - public String call() { - int i = 20; - consume(i); - return "" + i; - } - } - - @Test - public void shouldReplaceIntegerLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasILoad.class); - assertMutantCallableReturns(new HasILoad(), mutant, "21"); - } - - private static class HasFLoad implements Callable { - @Override - public String call() { - float f = 20; - consume(f); - return "" + f; - } - } - - @Test - public void shouldReplaceFloatLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFLoad.class); - assertMutantCallableReturns(new HasFLoad(), mutant, "21.0"); - } - - private static class HasLLoad implements Callable { - @Override - public String call() { - long l = 20; - consume(l); - return "" + l; - } - } - - @Test - public void shouldReplaceLongLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLLoad.class); - assertMutantCallableReturns(new HasLLoad(), mutant, "21"); - } - - private static class HasDLoad implements Callable { - @Override - public String call() { - double d = 20; - consume(d); - return "" + d; - } - } - - @Test - public void shouldReplaceDoubleLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDLoad.class); - assertMutantCallableReturns(new HasDLoad(), mutant, "21.0"); - } - - private static class HasIGetField implements Callable { - private int i; - - public HasIGetField(int i) { - this.i = i; - } - - @Override - public String call() { - consume(this.i); - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerField() throws Exception { - final Mutant mutant = getFirstMutant(HasIGetField.class); - assertMutantCallableReturns(new HasIGetField(20), mutant, "21"); - assertMutantCallableReturns(new HasIGetField(-20), mutant, "-19"); - } - - private static class HasFGetField implements Callable { - private float f; - - public HasFGetField(float f) { - this.f = f; - } - - @Override - public String call() { - consume(this.f); - return "" + this.f; - } - } - - @Test - public void shouldReplaceFloatField() throws Exception { - final Mutant mutant = getFirstMutant(HasFGetField.class); - assertMutantCallableReturns(new HasFGetField(20), mutant, "21.0"); - assertMutantCallableReturns(new HasFGetField(-20), mutant, "-19.0"); - } - - private static class HasJGetField implements Callable { - private long l; - - public HasJGetField(long l) { - this.l = l; - } - - @Override - public String call() { - consume(this.l); - return "" + this.l; - } - } - - @Test - public void shouldReplaceLongField() throws Exception { - final Mutant mutant = getFirstMutant(HasJGetField.class); - assertMutantCallableReturns(new HasJGetField(20), mutant, "21"); - assertMutantCallableReturns(new HasJGetField(-20), mutant, "-19"); - } - - private static class HasDGetField implements Callable { - private double d; - - public HasDGetField(double d) { - this.d = d; - } - - @Override - public String call() { - consume(this.d); - return "" + this.d; - } - } - - @Test - public void shouldReplaceDoubleField() throws Exception { - final Mutant mutant = getFirstMutant(HasDGetField.class); - assertMutantCallableReturns(new HasDGetField(20), mutant, "21.0"); - assertMutantCallableReturns(new HasDGetField(-20), mutant, "-19.0"); - } - - private static class HasBGetField implements Callable { - private byte b; - - public HasBGetField(byte b) { - this.b = b; - } - - @Override - public String call() { - consume(this.b); - return "" + this.b; - } - } - - @Test - public void shouldReplaceByteField() throws Exception { - final Mutant mutant = getFirstMutant(HasBGetField.class); - assertMutantCallableReturns(new HasBGetField((byte)20), mutant, "21"); - assertMutantCallableReturns(new HasBGetField((byte)-20), mutant, "-19"); - } - - private static class HasSGetField implements Callable { - private short s; - - public HasSGetField(short s) { - this.s = s; - } - - @Override - public String call() { - consume(this.s); - return "" + this.s; - } - } - - @Test - public void shouldReplaceShortField() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetField.class); - assertMutantCallableReturns(new HasSGetField((short)20), mutant, "21"); - assertMutantCallableReturns(new HasSGetField((short)-20), mutant, "-19"); - } - - private static class HasIGetStaticField implements Callable { - private static int value; - private int i; - - public HasIGetStaticField(int i) { - this.i = i; - } - - @Override - public String call() { - value = this.i; - this.i = value; - return "" + value; - } - } - - @Test - public void shouldReplaceIntegerStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasIGetStaticField.class, 1); - assertMutantCallableReturns(new HasIGetStaticField(20), mutant, "21"); - assertMutantCallableReturns(new HasIGetStaticField(-20), mutant, "-19"); - } - - private static class HasFGetStaticField implements Callable { - private static float value; - private float f; - - public HasFGetStaticField(float f) { - this.f = f; - } - - @Override - public String call() { - value = this.f; - this.f = value; - return "" + value; - } - } - - @Test - public void shouldReplaceFloatStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasFGetStaticField.class, 1); - assertMutantCallableReturns(new HasFGetStaticField(20), mutant, "21.0"); - assertMutantCallableReturns(new HasFGetStaticField(-20), mutant, "-19.0"); - } - - private static class HasJGetStaticField implements Callable { - private static long value; - private long l; - - public HasJGetStaticField(long l) { - this.l = l; - } - - @Override - public String call() { - value = this.l; - this.l = value; - return "" + value; - } - } - - @Test - public void shouldReplaceLongStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasJGetStaticField.class, 1); - assertMutantCallableReturns(new HasJGetStaticField(20), mutant, "21"); - assertMutantCallableReturns(new HasJGetStaticField(-20), mutant, "-19"); - } - - private static class HasDGetStaticField implements Callable { - private static double value; - private double d; - - public HasDGetStaticField(double d) { - this.d = d; - } - - @Override - public String call() { - value = this.d; - this.d = value; - return "" + value; - } - } - - @Test - public void shouldReplaceDoubleStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasDGetStaticField.class, 1); - assertMutantCallableReturns(new HasDGetStaticField(20), mutant, "21.0"); - assertMutantCallableReturns(new HasDGetStaticField(-20), mutant, "-19.0"); - } - - private static class HasBGetStaticField implements Callable { - private static byte value; - private byte b; - - public HasBGetStaticField(byte b) { - this.b = b; - } - - @Override - public String call() { - value = this.b; - this.b = value; - return "" + value; - } - } - - @Test - public void shouldReplaceByteStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasBGetStaticField.class, 1); - assertMutantCallableReturns(new HasBGetStaticField((byte)20), mutant, "21"); - assertMutantCallableReturns(new HasBGetStaticField((byte)-20), mutant, "-19"); - } - - private static class HasSGetStaticField implements Callable { - private static short value; - private short s; - - public HasSGetStaticField(short s) { - this.s = s; - } - - @Override - public String call() { - value = this.s; - this.s = value; - return "" + value; - } - } - - @Test - public void shouldReplaceShortStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasSGetStaticField.class, 1); - assertMutantCallableReturns(new HasSGetStaticField((short)20), mutant, "21"); - assertMutantCallableReturns(new HasSGetStaticField((short)-20), mutant, "-19"); - } - - private static class HasIaload implements Callable { - @Override - public String call() { - int[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceIntegerArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasIaload.class); - assertMutantCallableReturns(new HasIaload(), mutant, "21"); - } - - private static class HasFaload implements Callable { - @Override - public String call() { - float[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceFloatArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFaload.class); - assertMutantCallableReturns(new HasFaload(), mutant, "21.0"); - } - - private static class HasLaload implements Callable { - @Override - public String call() { - long[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceLongArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLaload.class); - assertMutantCallableReturns(new HasLaload(), mutant, "21"); - } - - private static class HasDaload implements Callable { - - @Override - public String call() { - double[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceDoubleArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDaload.class); - assertMutantCallableReturns(new HasDaload(), mutant, "21.0"); - } - - private static class HasBaload implements Callable { - - @Override - public String call() { - byte[] value = {20}; - consume(value[0]); - return "" + value[0]++; - } - } - - @Test - public void shouldReplaceByteArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasBaload.class); - assertMutantCallableReturns(new HasBaload(), mutant, "21"); - } - - private static class HasSGetSaload implements Callable { - @Override - public String call() { - short[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceShortArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetSaload.class); - assertMutantCallableReturns(new HasSGetSaload(), mutant, "21"); - } - - - private static void consume(long value) { - - } - - private static void consume(double value) { - - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI2MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI2MutatorTest.java deleted file mode 100644 index f17134a08..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI2MutatorTest.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class UOI2MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(mutateOnlyCallMethod(), UOI2Mutator.UOI2); - } - - private static class HasILoad implements Callable { - @Override - public String call() { - int i = 20; - consume(i); - return "" + i; - } - } - - @Test - public void shouldReplaceIntegerLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasILoad.class); - assertMutantCallableReturns(new HasILoad(), mutant, "19"); - } - - private static class HasFLoad implements Callable { - @Override - public String call() { - float f = 20; - consume(f); - return "" + f; - } - } - - @Test - public void shouldReplaceFloatLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFLoad.class); - assertMutantCallableReturns(new HasFLoad(), mutant, "19.0"); - } - - private static class HasLLoad implements Callable { - @Override - public String call() { - long l = 20; - consume(l); - return "" + l; - } - } - - @Test - public void shouldReplaceLongLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLLoad.class); - assertMutantCallableReturns(new HasLLoad(), mutant, "19"); - } - - private static class HasDLoad implements Callable { - @Override - public String call() { - double d = 20; - consume(d); - return "" + d; - } - } - - @Test - public void shouldReplaceDoubleLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDLoad.class); - assertMutantCallableReturns(new HasDLoad(), mutant, "19.0"); - } - - private static class HasIGetField implements Callable { - private int i; - - public HasIGetField(int i) { - this.i = i; - } - - @Override - public String call() { - consume(this.i); - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerField() throws Exception { - final Mutant mutant = getFirstMutant(HasIGetField.class); - assertMutantCallableReturns(new HasIGetField(20), mutant, "19"); - assertMutantCallableReturns(new HasIGetField(-20), mutant, "-21"); - } - - private static class HasFGetField implements Callable { - private float f; - - public HasFGetField(float f) { - this.f = f; - } - - @Override - public String call() { - consume(this.f); - return "" + this.f; - } - } - - @Test - public void shouldReplaceFloatField() throws Exception { - final Mutant mutant = getFirstMutant(HasFGetField.class); - assertMutantCallableReturns(new HasFGetField(20), mutant, "19.0"); - assertMutantCallableReturns(new HasFGetField(-20), mutant, "-21.0"); - } - - private static class HasJGetField implements Callable { - private long l; - - public HasJGetField(long l) { - this.l = l; - } - - @Override - public String call() { - consume(this.l); - return "" + this.l; - } - } - - @Test - public void shouldReplaceLongField() throws Exception { - final Mutant mutant = getFirstMutant(HasJGetField.class); - assertMutantCallableReturns(new HasJGetField(20), mutant, "19"); - assertMutantCallableReturns(new HasJGetField(-20), mutant, "-21"); - } - - private static class HasDGetField implements Callable { - private double d; - - public HasDGetField(double d) { - this.d = d; - } - - @Override - public String call() { - consume(this.d); - return "" + this.d; - } - } - - @Test - public void shouldReplaceDoubleField() throws Exception { - final Mutant mutant = getFirstMutant(HasDGetField.class); - assertMutantCallableReturns(new HasDGetField(20), mutant, "19.0"); - assertMutantCallableReturns(new HasDGetField(-20), mutant, "-21.0"); - } - - private static class HasBGetField implements Callable { - private byte b; - - public HasBGetField(byte b) { - this.b = b; - } - - @Override - public String call() { - consume(this.b); - return "" + this.b; - } - } - - @Test - public void shouldReplaceByteField() throws Exception { - final Mutant mutant = getFirstMutant(HasBGetField.class); - assertMutantCallableReturns(new HasBGetField((byte)20), mutant, "19"); - assertMutantCallableReturns(new HasBGetField((byte)-20), mutant, "-21"); - } - - private static class HasSGetField implements Callable { - private short s; - - public HasSGetField(short s) { - this.s = s; - } - - @Override - public String call() { - consume(this.s); - return "" + this.s; - } - } - - @Test - public void shouldReplaceShortField() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetField.class); - assertMutantCallableReturns(new HasSGetField((short)20), mutant, "19"); - assertMutantCallableReturns(new HasSGetField((short)-20), mutant, "-21"); - } - - private static class HasIGetStaticField implements Callable { - private static int value; - private int i; - - public HasIGetStaticField(int i) { - this.i = i; - } - - @Override - public String call() { - value = this.i; - this.i = value; - return "" + value; - } - } - - @Test - public void shouldReplaceIntegerStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasIGetStaticField.class, 1); - assertMutantCallableReturns(new HasIGetStaticField(20), mutant, "19"); - assertMutantCallableReturns(new HasIGetStaticField(-20), mutant, "-21"); - } - - private static class HasFGetStaticField implements Callable { - private static float value; - private float f; - - public HasFGetStaticField(float f) { - this.f = f; - } - - @Override - public String call() { - value = this.f; - this.f = value; - return "" + value; - } - } - - @Test - public void shouldReplaceFloatStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasFGetStaticField.class, 1); - assertMutantCallableReturns(new HasFGetStaticField(20), mutant, "19.0"); - assertMutantCallableReturns(new HasFGetStaticField(-20), mutant, "-21.0"); - } - - private static class HasJGetStaticField implements Callable { - private static long value; - private long l; - - public HasJGetStaticField(long l) { - this.l = l; - } - - @Override - public String call() { - value = this.l; - this.l = value; - return "" + value; - } - } - - @Test - public void shouldReplaceLongStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasJGetStaticField.class, 1); - assertMutantCallableReturns(new HasJGetStaticField(20), mutant, "19"); - assertMutantCallableReturns(new HasJGetStaticField(-20), mutant, "-21"); - } - - private static class HasDGetStaticField implements Callable { - private static double value; - private double d; - - public HasDGetStaticField(double d) { - this.d = d; - } - - @Override - public String call() { - value = this.d; - this.d = value; - return "" + value; - } - } - - @Test - public void shouldReplaceDoubleStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasDGetStaticField.class, 1); - assertMutantCallableReturns(new HasDGetStaticField(20), mutant, "19.0"); - assertMutantCallableReturns(new HasDGetStaticField(-20), mutant, "-21.0"); - } - - private static class HasBGetStaticField implements Callable { - private static byte value; - private byte b; - - public HasBGetStaticField(byte b) { - this.b = b; - } - - @Override - public String call() { - value = this.b; - this.b = value; - return "" + value; - } - } - - @Test - public void shouldReplaceByteStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasBGetStaticField.class, 1); - assertMutantCallableReturns(new HasBGetStaticField((byte)20), mutant, "19"); - assertMutantCallableReturns(new HasBGetStaticField((byte)-20), mutant, "-21"); - } - - private static class HasSGetStaticField implements Callable { - private static short value; - private short s; - - public HasSGetStaticField(short s) { - this.s = s; - } - - @Override - public String call() { - value = this.s; - this.s = value; - return "" + value; - } - } - - @Test - public void shouldReplaceShortStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasSGetStaticField.class, 1); - assertMutantCallableReturns(new HasSGetStaticField((short)20), mutant, "19"); - assertMutantCallableReturns(new HasSGetStaticField((short)-20), mutant, "-21"); - } - - private static class HasIaload implements Callable { - @Override - public String call() { - int[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceIntegerArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasIaload.class); - assertMutantCallableReturns(new HasIaload(), mutant, "19"); - } - - private static class HasFaload implements Callable { - @Override - public String call() { - float[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceFloatArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFaload.class); - assertMutantCallableReturns(new HasFaload(), mutant, "19.0"); - } - - private static class HasLaload implements Callable { - @Override - public String call() { - long[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceLongArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLaload.class); - assertMutantCallableReturns(new HasLaload(), mutant, "19"); - } - - private static class HasDaload implements Callable { - - @Override - public String call() { - double[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceDoubleArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDaload.class); - assertMutantCallableReturns(new HasDaload(), mutant, "19.0"); - } - - private static class HasBaload implements Callable { - - @Override - public String call() { - byte[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceByteArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasBaload.class); - assertMutantCallableReturns(new HasBaload(), mutant, "19"); - } - - private static class HasSGetSaload implements Callable { - @Override - public String call() { - short[] value = {20}; - consume(value[0]); - return "" + value[0]; - } - } - - @Test - public void shouldReplaceShortArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetSaload.class); - assertMutantCallableReturns(new HasSGetSaload(), mutant, "19"); - } - - private static void consume(long value) { - - } - - private static void consume(double value) { - - } -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI3MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI3MutatorTest.java deleted file mode 100644 index a4159ce5d..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI3MutatorTest.java +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class UOI3MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(mutateOnlyCallMethod(), UOI3Mutator.UOI3); - } - - private static class HasILoad implements Callable { - @Override - public String call() { - int i = 20; - return "" + i; - } - } - - @Test - public void shouldReplaceIntegerLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasILoad.class); - assertMutantCallableReturns(new HasILoad(), mutant, "21"); - } - - private static class HasFLoad implements Callable { - @Override - public String call() { - float f = 20; - return "" + f; - } - } - - @Test - public void shouldReplaceFloatLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFLoad.class); - assertMutantCallableReturns(new HasFLoad(), mutant, "21.0"); - } - - private static class HasLLoad implements Callable { - @Override - public String call() { - long l = 20; - return "" + l; - } - } - - @Test - public void shouldReplaceLongLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLLoad.class); - assertMutantCallableReturns(new HasLLoad(), mutant, "21"); - } - - private static class HasDLoad implements Callable { - @Override - public String call() { - double d = 20; - return "" + d; - } - } - - @Test - public void shouldReplaceDoubleLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDLoad.class); - assertMutantCallableReturns(new HasDLoad(), mutant, "21.0"); - } - - private static class HasIGetField implements Callable { - private int i; - - public HasIGetField(int i) { - this.i = i; - } - - @Override - public String call() { - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerField() throws Exception { - final Mutant mutant = getFirstMutant(HasIGetField.class); - assertMutantCallableReturns(new HasIGetField(20), mutant, "21"); - assertMutantCallableReturns(new HasIGetField(-20), mutant, "-19"); - } - - private static class HasFGetField implements Callable { - private float f; - - public HasFGetField(float f) { - this.f = f; - } - - @Override - public String call() { - return "" + this.f; - } - } - - @Test - public void shouldReplaceFloatField() throws Exception { - final Mutant mutant = getFirstMutant(HasFGetField.class); - assertMutantCallableReturns(new HasFGetField(20), mutant, "21.0"); - assertMutantCallableReturns(new HasFGetField(-20), mutant, "-19.0"); - } - - private static class HasJGetField implements Callable { - private long l; - - public HasJGetField(long l) { - this.l = l; - } - - @Override - public String call() { - return "" + this.l; - } - } - - @Test - public void shouldReplaceLongField() throws Exception { - final Mutant mutant = getFirstMutant(HasJGetField.class); - assertMutantCallableReturns(new HasJGetField(20), mutant, "21"); - assertMutantCallableReturns(new HasJGetField(-20), mutant, "-19"); - } - - private static class HasDGetField implements Callable { - private double d; - - public HasDGetField(double d) { - this.d = d; - } - - @Override - public String call() { - return "" + this.d; - } - } - - @Test - public void shouldReplaceDoubleField() throws Exception { - final Mutant mutant = getFirstMutant(HasDGetField.class); - assertMutantCallableReturns(new HasDGetField(20), mutant, "21.0"); - assertMutantCallableReturns(new HasDGetField(-20), mutant, "-19.0"); - } - - private static class HasBGetField implements Callable { - private byte b; - - public HasBGetField(byte b) { - this.b = b; - } - - @Override - public String call() { - return "" + this.b; - } - } - - @Test - public void shouldReplaceByteField() throws Exception { - final Mutant mutant = getFirstMutant(HasBGetField.class); - assertMutantCallableReturns(new HasBGetField((byte)20), mutant, "21"); - assertMutantCallableReturns(new HasBGetField((byte)-20), mutant, "-19"); - } - - private static class HasSGetField implements Callable { - private short s; - - public HasSGetField(short s) { - this.s = s; - } - - @Override - public String call() { - return "" + this.s; - } - } - - @Test - public void shouldReplaceShortField() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetField.class); - assertMutantCallableReturns(new HasSGetField((short)20), mutant, "21"); - assertMutantCallableReturns(new HasSGetField((short)-20), mutant, "-19"); - } - - private static class HasIGetStaticField implements Callable { - private static int value; - private int i; - - public HasIGetStaticField(int i) { - this.i = i; - } - - @Override - public String call() { - value = this.i; - return "" + value; - } - } - - @Test - public void shouldReplaceIntegerStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasIGetStaticField.class, 1); - assertMutantCallableReturns(new HasIGetStaticField(20), mutant, "21"); - assertMutantCallableReturns(new HasIGetStaticField(-20), mutant, "-19"); - } - - private static class HasFGetStaticField implements Callable { - private static float value; - private float f; - - public HasFGetStaticField(float f) { - this.f = f; - } - - @Override - public String call() { - value = this.f; - return "" + value; - } - } - - @Test - public void shouldReplaceFloatStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasFGetStaticField.class, 1); - assertMutantCallableReturns(new HasFGetStaticField(20), mutant, "21.0"); - assertMutantCallableReturns(new HasFGetStaticField(-20), mutant, "-19.0"); - } - - private static class HasJGetStaticField implements Callable { - private static long value; - private long l; - - public HasJGetStaticField(long l) { - this.l = l; - } - - @Override - public String call() { - value = this.l; - return "" + value; - } - } - - @Test - public void shouldReplaceLongStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasJGetStaticField.class, 1); - assertMutantCallableReturns(new HasJGetStaticField(20), mutant, "21"); - assertMutantCallableReturns(new HasJGetStaticField(-20), mutant, "-19"); - } - - private static class HasDGetStaticField implements Callable { - private static double value; - private double d; - - public HasDGetStaticField(double d) { - this.d = d; - } - - @Override - public String call() { - value = this.d; - return "" + value; - } - } - - @Test - public void shouldReplaceDoubleStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasDGetStaticField.class, 1); - assertMutantCallableReturns(new HasDGetStaticField(20), mutant, "21.0"); - assertMutantCallableReturns(new HasDGetStaticField(-20), mutant, "-19.0"); - } - - private static class HasBGetStaticField implements Callable { - private static byte value; - private byte b; - - public HasBGetStaticField(byte b) { - this.b = b; - } - - @Override - public String call() { - value = this.b; - return "" + value; - } - } - - @Test - public void shouldReplaceByteStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasBGetStaticField.class, 1); - assertMutantCallableReturns(new HasBGetStaticField((byte)20), mutant, "21"); - assertMutantCallableReturns(new HasBGetStaticField((byte)-20), mutant, "-19"); - } - - private static class HasSGetStaticField implements Callable { - private static short value; - private short s; - - public HasSGetStaticField(short s) { - this.s = s; - } - - @Override - public String call() { - value = this.s; - return "" + value; - } - } - - @Test - public void shouldReplaceShortStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasSGetStaticField.class, 1); - assertMutantCallableReturns(new HasSGetStaticField((short)20), mutant, "21"); - assertMutantCallableReturns(new HasSGetStaticField((short)-20), mutant, "-19"); - } - - private static class HasIaload implements Callable { - @Override - public String call() { - int[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceIntegerArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasIaload.class); - assertMutantCallableReturns(new HasIaload(), mutant, "21"); - } - - private static class HasFaload implements Callable { - @Override - public String call() { - float[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceFloatArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFaload.class); - assertMutantCallableReturns(new HasFaload(), mutant, "21.0"); - } - - private static class HasLaload implements Callable { - @Override - public String call() { - long[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceLongArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLaload.class); - assertMutantCallableReturns(new HasLaload(), mutant, "21"); - } - - private static class HasDaload implements Callable { - - @Override - public String call() { - double[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceDoubleArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDaload.class); - assertMutantCallableReturns(new HasDaload(), mutant, "21.0"); - } - - private static class HasBaload implements Callable { - - @Override - public String call() { - byte[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceByteArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasBaload.class); - assertMutantCallableReturns(new HasBaload(), mutant, "21"); - } - - private static class HasSGetSaload implements Callable { - @Override - public String call() { - short[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceShortArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetSaload.class); - assertMutantCallableReturns(new HasSGetSaload(), mutant, "21"); - } - -} diff --git a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI4MutatorTest.java b/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI4MutatorTest.java deleted file mode 100644 index 5d89b653d..000000000 --- a/pitest/src/test/java/org/pitest/mutationtest/engine/gregor/mutators/rv/UOI4MutatorTest.java +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Copyright 2010 Henry Coles - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ -package org.pitest.mutationtest.engine.gregor.mutators.rv; - -import org.junit.Before; -import org.junit.Test; -import org.pitest.mutationtest.engine.Mutant; -import org.pitest.mutationtest.engine.gregor.MutatorTestBase; - -import java.util.concurrent.Callable; - -public class UOI4MutatorTest extends MutatorTestBase { - - @Before - public void setupEngineToMutateOnlyMathFunctions() { - createTesteeWith(mutateOnlyCallMethod(), UOI4Mutator.UOI4); - } - - private static class HasILoad implements Callable { - @Override - public String call() { - int i = 20; - return "" + i; - } - } - - @Test - public void shouldReplaceIntegerLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasILoad.class); - assertMutantCallableReturns(new HasILoad(), mutant, "19"); - } - - private static class HasFLoad implements Callable { - @Override - public String call() { - float f = 20; - return "" + f; - } - } - - @Test - public void shouldReplaceFloatLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFLoad.class); - assertMutantCallableReturns(new HasFLoad(), mutant, "19.0"); - } - - private static class HasLLoad implements Callable { - @Override - public String call() { - long l = 20; - return "" + l; - } - } - - @Test - public void shouldReplaceLongLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLLoad.class); - assertMutantCallableReturns(new HasLLoad(), mutant, "19"); - } - - private static class HasDLoad implements Callable { - @Override - public String call() { - double d = 20; - return "" + d; - } - } - - @Test - public void shouldReplaceDoubleLocalVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDLoad.class); - assertMutantCallableReturns(new HasDLoad(), mutant, "19.0"); - } - - private static class HasIGetField implements Callable { - private int i; - - public HasIGetField(int i) { - this.i = i; - } - - @Override - public String call() { - return "" + this.i; - } - } - - @Test - public void shouldReplaceIntegerField() throws Exception { - final Mutant mutant = getFirstMutant(HasIGetField.class); - assertMutantCallableReturns(new HasIGetField(20), mutant, "19"); - assertMutantCallableReturns(new HasIGetField(-20), mutant, "-21"); - } - - private static class HasFGetField implements Callable { - private float f; - - public HasFGetField(float f) { - this.f = f; - } - - @Override - public String call() { - return "" + this.f; - } - } - - @Test - public void shouldReplaceFloatField() throws Exception { - final Mutant mutant = getFirstMutant(HasFGetField.class); - assertMutantCallableReturns(new HasFGetField(20), mutant, "19.0"); - assertMutantCallableReturns(new HasFGetField(-20), mutant, "-21.0"); - } - - private static class HasJGetField implements Callable { - private long l; - - public HasJGetField(long l) { - this.l = l; - } - - @Override - public String call() { - return "" + this.l; - } - } - - @Test - public void shouldReplaceLongField() throws Exception { - final Mutant mutant = getFirstMutant(HasJGetField.class); - assertMutantCallableReturns(new HasJGetField(20), mutant, "19"); - assertMutantCallableReturns(new HasJGetField(-20), mutant, "-21"); - } - - private static class HasDGetField implements Callable { - private double d; - - public HasDGetField(double d) { - this.d = d; - } - - @Override - public String call() { - return "" + this.d; - } - } - - @Test - public void shouldReplaceDoubleField() throws Exception { - final Mutant mutant = getFirstMutant(HasDGetField.class); - assertMutantCallableReturns(new HasDGetField(20), mutant, "19.0"); - assertMutantCallableReturns(new HasDGetField(-20), mutant, "-21.0"); - } - - private static class HasBGetField implements Callable { - private byte b; - - public HasBGetField(byte b) { - this.b = b; - } - - @Override - public String call() { - return "" + this.b; - } - } - - @Test - public void shouldReplaceByteField() throws Exception { - final Mutant mutant = getFirstMutant(HasBGetField.class); - assertMutantCallableReturns(new HasBGetField((byte)20), mutant, "19"); - assertMutantCallableReturns(new HasBGetField((byte)-20), mutant, "-21"); - } - - private static class HasSGetField implements Callable { - private short s; - - public HasSGetField(short s) { - this.s = s; - } - - @Override - public String call() { - return "" + this.s; - } - } - - @Test - public void shouldReplaceShortField() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetField.class); - assertMutantCallableReturns(new HasSGetField((short)20), mutant, "19"); - assertMutantCallableReturns(new HasSGetField((short)-20), mutant, "-21"); - } - - private static class HasIGetStaticField implements Callable { - private static int value; - private int i; - - public HasIGetStaticField(int i) { - this.i = i; - } - - @Override - public String call() { - value = this.i; - return "" + value; - } - } - - @Test - public void shouldReplaceIntegerStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasIGetStaticField.class, 1); - assertMutantCallableReturns(new HasIGetStaticField(20), mutant, "19"); - assertMutantCallableReturns(new HasIGetStaticField(-20), mutant, "-21"); - } - - private static class HasFGetStaticField implements Callable { - private static float value; - private float f; - - public HasFGetStaticField(float f) { - this.f = f; - } - - @Override - public String call() { - value = this.f; - return "" + value; - } - } - - @Test - public void shouldReplaceFloatStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasFGetStaticField.class, 1); - assertMutantCallableReturns(new HasFGetStaticField(20), mutant, "19.0"); - assertMutantCallableReturns(new HasFGetStaticField(-20), mutant, "-21.0"); - } - - private static class HasJGetStaticField implements Callable { - private static long value; - private long l; - - public HasJGetStaticField(long l) { - this.l = l; - } - - @Override - public String call() { - value = this.l; - return "" + value; - } - } - - @Test - public void shouldReplaceLongStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasJGetStaticField.class, 1); - assertMutantCallableReturns(new HasJGetStaticField(20), mutant, "19"); - assertMutantCallableReturns(new HasJGetStaticField(-20), mutant, "-21"); - } - - private static class HasDGetStaticField implements Callable { - private static double value; - private double d; - - public HasDGetStaticField(double d) { - this.d = d; - } - - @Override - public String call() { - value = this.d; - return "" + value; - } - } - - @Test - public void shouldReplaceDoubleStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasDGetStaticField.class, 1); - assertMutantCallableReturns(new HasDGetStaticField(20), mutant, "19.0"); - assertMutantCallableReturns(new HasDGetStaticField(-20), mutant, "-21.0"); - } - - private static class HasBGetStaticField implements Callable { - private static byte value; - private byte b; - - public HasBGetStaticField(byte b) { - this.b = b; - } - - @Override - public String call() { - value = this.b; - return "" + value; - } - } - - @Test - public void shouldReplaceByteStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasBGetStaticField.class, 1); - assertMutantCallableReturns(new HasBGetStaticField((byte)20), mutant, "19"); - assertMutantCallableReturns(new HasBGetStaticField((byte)-20), mutant, "-21"); - } - - private static class HasSGetStaticField implements Callable { - private static short value; - private short s; - - public HasSGetStaticField(short s) { - this.s = s; - } - - @Override - public String call() { - value = this.s; - return "" + value; - } - } - - @Test - public void shouldReplaceShortStaticField() throws Exception { - final Mutant mutant = getNthMutant(HasSGetStaticField.class, 1); - assertMutantCallableReturns(new HasSGetStaticField((short)20), mutant, "19"); - assertMutantCallableReturns(new HasSGetStaticField((short)-20), mutant, "-21"); - } - - private static class HasIaload implements Callable { - @Override - public String call() { - int[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceIntegerArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasIaload.class); - assertMutantCallableReturns(new HasIaload(), mutant, "19"); - } - - private static class HasFaload implements Callable { - @Override - public String call() { - float[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceFloatArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasFaload.class); - assertMutantCallableReturns(new HasFaload(), mutant, "19.0"); - } - - private static class HasLaload implements Callable { - @Override - public String call() { - long[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceLongArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasLaload.class); - assertMutantCallableReturns(new HasLaload(), mutant, "19"); - } - - private static class HasDaload implements Callable { - - @Override - public String call() { - double[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceDoubleArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasDaload.class); - assertMutantCallableReturns(new HasDaload(), mutant, "19.0"); - } - - private static class HasBaload implements Callable { - - @Override - public String call() { - byte[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceByteArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasBaload.class); - assertMutantCallableReturns(new HasBaload(), mutant, "19"); - } - - private static class HasSGetSaload implements Callable { - @Override - public String call() { - short[] value = {20}; - return "" + value[0]; - } - } - - @Test - public void shouldReplaceShortArrayVariable() throws Exception { - final Mutant mutant = getFirstMutant(HasSGetSaload.class); - assertMutantCallableReturns(new HasSGetSaload(), mutant, "19"); - } - -}