diff --git a/mutants/mutant-1/swen90006/machine/Machine.java b/mutants/mutant-1/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..da904beabc190c2e9623e6acde687feda7b346f2 100644 --- a/mutants/mutant-1/swen90006/machine/Machine.java +++ b/mutants/mutant-1/swen90006/machine/Machine.java @@ -3,7 +3,7 @@ package swen90006.machine; import java.util.Arrays; import java.util.List; -public class Machine +public class Machine { /** arithmetic instructions each take three registers as arguments with the * destination register appearing first @@ -12,13 +12,13 @@ public class Machine /** add rd rs1 rs2 =~ rd = rs1 + rs2 */ public static final String INSTRUCTION_ADD = "add"; - /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ + /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ public static final String INSTRUCTION_SUBTRACT = "sub"; - /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ + /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ public static final String INSTRUCTION_MULT = "mul"; - /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ + /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ public static final String INSTRUCTION_DIVIDE = "div"; /** ret rs =~ return rs */ @@ -38,17 +38,17 @@ public class Machine /** jz ra offs =~ if (ra == 0) pc = pc + offs else pc = pc + 1 */ public static final String INSTRUCTION_JZ = "jz"; - + public static final int NUM_REGS = 32; public static final int MAX_REG = (NUM_REGS - 1); public static final int MEMORY_SIZE = 65536; /* 4 x as much memory as a 64 */ public static final int MAX_ADDR = MEMORY_SIZE-1; - + private int[] memory; private int[] regs; private int count = 0; /* counts number of instructions executed so far */ - + public Machine() { memory = new int[MEMORY_SIZE]; @@ -60,17 +60,17 @@ public class Machine { regs[dest] = regs[src1] + regs[src2]; } - + private void do_sub(int dest, int src1, int src2) { regs[dest] = regs[src1] - regs[src2]; } - + private void do_mult(int dest, int src1, int src2) { regs[dest] = regs[src1] * regs[src2]; } - + private void do_div(int dest, int src1, int src2) { if (regs[src2] == 0){ @@ -91,7 +91,8 @@ public class Machine } private void do_store(int a, int offs, int b) { - if (regs[a] + offs > MAX_ADDR){ + //Relational Operator Replacement + if (regs[a] + offs => MAX_ADDR){ /* no op */ }else if(regs[a] + offs < 0){ /* no op */ @@ -152,16 +153,16 @@ public class Machine throw new InvalidInstructionException(); } } - + /** Execute an assembly program. * - * @param prog is the program to execute as an iterable collection of strings, + * @param prog is the program to execute as an iterable collection of strings, * each of which is a single instruction. * @return the program's return value. - * @throws Exception when program has unrecognised or + * @throws Exception when program has unrecognised or * invalid instructions, or when it returns no result when it finishes */ - int execute(List<String> instructions) + int execute(List<String> instructions) throws InvalidInstructionException, NoReturnValueException { @@ -180,7 +181,7 @@ public class Machine break; } String inst = instructions.get(pc); - /* strip leading and trailing whitespace */ + /* strip leading and trailing whitespace */ inst = inst.toLowerCase().replaceAll("^\\s+","").replaceAll("\\s+$",""); /* strip out any comments */ String[] toks = inst.split(";"); diff --git a/mutants/mutant-2/swen90006/machine/Machine.java b/mutants/mutant-2/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..03ee350cf8046646d55f5b27b3b13bb64675eced 100644 --- a/mutants/mutant-2/swen90006/machine/Machine.java +++ b/mutants/mutant-2/swen90006/machine/Machine.java @@ -3,7 +3,7 @@ package swen90006.machine; import java.util.Arrays; import java.util.List; -public class Machine +public class Machine { /** arithmetic instructions each take three registers as arguments with the * destination register appearing first @@ -12,13 +12,13 @@ public class Machine /** add rd rs1 rs2 =~ rd = rs1 + rs2 */ public static final String INSTRUCTION_ADD = "add"; - /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ + /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ public static final String INSTRUCTION_SUBTRACT = "sub"; - /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ + /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ public static final String INSTRUCTION_MULT = "mul"; - /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ + /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ public static final String INSTRUCTION_DIVIDE = "div"; /** ret rs =~ return rs */ @@ -38,17 +38,17 @@ public class Machine /** jz ra offs =~ if (ra == 0) pc = pc + offs else pc = pc + 1 */ public static final String INSTRUCTION_JZ = "jz"; - + public static final int NUM_REGS = 32; public static final int MAX_REG = (NUM_REGS - 1); public static final int MEMORY_SIZE = 65536; /* 4 x as much memory as a 64 */ public static final int MAX_ADDR = MEMORY_SIZE-1; - + private int[] memory; private int[] regs; private int count = 0; /* counts number of instructions executed so far */ - + public Machine() { memory = new int[MEMORY_SIZE]; @@ -60,17 +60,17 @@ public class Machine { regs[dest] = regs[src1] + regs[src2]; } - + private void do_sub(int dest, int src1, int src2) { regs[dest] = regs[src1] - regs[src2]; } - + private void do_mult(int dest, int src1, int src2) { regs[dest] = regs[src1] * regs[src2]; } - + private void do_div(int dest, int src1, int src2) { if (regs[src2] == 0){ @@ -152,16 +152,16 @@ public class Machine throw new InvalidInstructionException(); } } - + /** Execute an assembly program. * - * @param prog is the program to execute as an iterable collection of strings, + * @param prog is the program to execute as an iterable collection of strings, * each of which is a single instruction. * @return the program's return value. - * @throws Exception when program has unrecognised or + * @throws Exception when program has unrecognised or * invalid instructions, or when it returns no result when it finishes */ - int execute(List<String> instructions) + int execute(List<String> instructions) throws InvalidInstructionException, NoReturnValueException { @@ -170,7 +170,8 @@ public class Machine int pc = 0; final int progLength = instructions.size(); while(true){ - if (pc < 0 || pc >= progLength){ + // Relational Operator Replacement + if (pc < 0 || pc > progLength){ /* will cause NoReturnValueException to be thrown * but that is not a bug and and indeed is what the * VM is supposed to do if the pc becomes negative, @@ -180,7 +181,7 @@ public class Machine break; } String inst = instructions.get(pc); - /* strip leading and trailing whitespace */ + /* strip leading and trailing whitespace */ inst = inst.toLowerCase().replaceAll("^\\s+","").replaceAll("\\s+$",""); /* strip out any comments */ String[] toks = inst.split(";"); diff --git a/mutants/mutant-3/swen90006/machine/Machine.java b/mutants/mutant-3/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..42c34f4e7097caef880e9069873049b0068c43dc 100644 --- a/mutants/mutant-3/swen90006/machine/Machine.java +++ b/mutants/mutant-3/swen90006/machine/Machine.java @@ -3,7 +3,7 @@ package swen90006.machine; import java.util.Arrays; import java.util.List; -public class Machine +public class Machine { /** arithmetic instructions each take three registers as arguments with the * destination register appearing first @@ -12,13 +12,13 @@ public class Machine /** add rd rs1 rs2 =~ rd = rs1 + rs2 */ public static final String INSTRUCTION_ADD = "add"; - /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ + /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ public static final String INSTRUCTION_SUBTRACT = "sub"; - /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ + /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ public static final String INSTRUCTION_MULT = "mul"; - /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ + /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ public static final String INSTRUCTION_DIVIDE = "div"; /** ret rs =~ return rs */ @@ -38,17 +38,17 @@ public class Machine /** jz ra offs =~ if (ra == 0) pc = pc + offs else pc = pc + 1 */ public static final String INSTRUCTION_JZ = "jz"; - + public static final int NUM_REGS = 32; public static final int MAX_REG = (NUM_REGS - 1); public static final int MEMORY_SIZE = 65536; /* 4 x as much memory as a 64 */ public static final int MAX_ADDR = MEMORY_SIZE-1; - + private int[] memory; private int[] regs; private int count = 0; /* counts number of instructions executed so far */ - + public Machine() { memory = new int[MEMORY_SIZE]; @@ -60,17 +60,17 @@ public class Machine { regs[dest] = regs[src1] + regs[src2]; } - + private void do_sub(int dest, int src1, int src2) { regs[dest] = regs[src1] - regs[src2]; } - + private void do_mult(int dest, int src1, int src2) { regs[dest] = regs[src1] * regs[src2]; } - + private void do_div(int dest, int src1, int src2) { if (regs[src2] == 0){ @@ -152,16 +152,16 @@ public class Machine throw new InvalidInstructionException(); } } - + /** Execute an assembly program. * - * @param prog is the program to execute as an iterable collection of strings, + * @param prog is the program to execute as an iterable collection of strings, * each of which is a single instruction. * @return the program's return value. - * @throws Exception when program has unrecognised or + * @throws Exception when program has unrecognised or * invalid instructions, or when it returns no result when it finishes */ - int execute(List<String> instructions) + int execute(List<String> instructions) throws InvalidInstructionException, NoReturnValueException { @@ -180,7 +180,7 @@ public class Machine break; } String inst = instructions.get(pc); - /* strip leading and trailing whitespace */ + /* strip leading and trailing whitespace */ inst = inst.toLowerCase().replaceAll("^\\s+","").replaceAll("\\s+$",""); /* strip out any comments */ String[] toks = inst.split(";"); @@ -275,7 +275,8 @@ public class Machine } int ra = parseReg(toks[1]); int offs = parseOffset(toks[2]); - if (regs[ra] == 0){ + // Relational Operator Replacement + if (regs[ra] <= 0){ pc = pc + offs; }else{ pc = pc + 1; diff --git a/mutants/mutant-4/swen90006/machine/Machine.java b/mutants/mutant-4/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..73ff6c39d6bfa8fad8e0145c5e146e812becdefe 100644 --- a/mutants/mutant-4/swen90006/machine/Machine.java +++ b/mutants/mutant-4/swen90006/machine/Machine.java @@ -3,7 +3,7 @@ package swen90006.machine; import java.util.Arrays; import java.util.List; -public class Machine +public class Machine { /** arithmetic instructions each take three registers as arguments with the * destination register appearing first @@ -12,13 +12,13 @@ public class Machine /** add rd rs1 rs2 =~ rd = rs1 + rs2 */ public static final String INSTRUCTION_ADD = "add"; - /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ + /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ public static final String INSTRUCTION_SUBTRACT = "sub"; - /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ + /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ public static final String INSTRUCTION_MULT = "mul"; - /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ + /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ public static final String INSTRUCTION_DIVIDE = "div"; /** ret rs =~ return rs */ @@ -38,17 +38,17 @@ public class Machine /** jz ra offs =~ if (ra == 0) pc = pc + offs else pc = pc + 1 */ public static final String INSTRUCTION_JZ = "jz"; - + public static final int NUM_REGS = 32; public static final int MAX_REG = (NUM_REGS - 1); public static final int MEMORY_SIZE = 65536; /* 4 x as much memory as a 64 */ public static final int MAX_ADDR = MEMORY_SIZE-1; - + private int[] memory; private int[] regs; private int count = 0; /* counts number of instructions executed so far */ - + public Machine() { memory = new int[MEMORY_SIZE]; @@ -60,20 +60,21 @@ public class Machine { regs[dest] = regs[src1] + regs[src2]; } - + private void do_sub(int dest, int src1, int src2) { regs[dest] = regs[src1] - regs[src2]; } - + private void do_mult(int dest, int src1, int src2) { regs[dest] = regs[src1] * regs[src2]; } - + private void do_div(int dest, int src1, int src2) { - if (regs[src2] == 0){ + // Relational Operator Replacement + if (regs[src2] <= 0){ /* no op */ }else{ regs[dest] = regs[src1] / regs[src2]; @@ -152,16 +153,16 @@ public class Machine throw new InvalidInstructionException(); } } - + /** Execute an assembly program. * - * @param prog is the program to execute as an iterable collection of strings, + * @param prog is the program to execute as an iterable collection of strings, * each of which is a single instruction. * @return the program's return value. - * @throws Exception when program has unrecognised or + * @throws Exception when program has unrecognised or * invalid instructions, or when it returns no result when it finishes */ - int execute(List<String> instructions) + int execute(List<String> instructions) throws InvalidInstructionException, NoReturnValueException { @@ -180,7 +181,7 @@ public class Machine break; } String inst = instructions.get(pc); - /* strip leading and trailing whitespace */ + /* strip leading and trailing whitespace */ inst = inst.toLowerCase().replaceAll("^\\s+","").replaceAll("\\s+$",""); /* strip out any comments */ String[] toks = inst.split(";"); diff --git a/mutants/mutant-5/swen90006/machine/Machine.java b/mutants/mutant-5/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..27c8d4f78c91c09ab2825293be3ef28557af1925 100644 --- a/mutants/mutant-5/swen90006/machine/Machine.java +++ b/mutants/mutant-5/swen90006/machine/Machine.java @@ -3,7 +3,7 @@ package swen90006.machine; import java.util.Arrays; import java.util.List; -public class Machine +public class Machine { /** arithmetic instructions each take three registers as arguments with the * destination register appearing first @@ -12,13 +12,13 @@ public class Machine /** add rd rs1 rs2 =~ rd = rs1 + rs2 */ public static final String INSTRUCTION_ADD = "add"; - /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ + /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ public static final String INSTRUCTION_SUBTRACT = "sub"; - /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ + /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ public static final String INSTRUCTION_MULT = "mul"; - /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ + /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ public static final String INSTRUCTION_DIVIDE = "div"; /** ret rs =~ return rs */ @@ -38,17 +38,17 @@ public class Machine /** jz ra offs =~ if (ra == 0) pc = pc + offs else pc = pc + 1 */ public static final String INSTRUCTION_JZ = "jz"; - + public static final int NUM_REGS = 32; public static final int MAX_REG = (NUM_REGS - 1); public static final int MEMORY_SIZE = 65536; /* 4 x as much memory as a 64 */ public static final int MAX_ADDR = MEMORY_SIZE-1; - + private int[] memory; private int[] regs; private int count = 0; /* counts number of instructions executed so far */ - + public Machine() { memory = new int[MEMORY_SIZE]; @@ -60,17 +60,17 @@ public class Machine { regs[dest] = regs[src1] + regs[src2]; } - + private void do_sub(int dest, int src1, int src2) { regs[dest] = regs[src1] - regs[src2]; } - + private void do_mult(int dest, int src1, int src2) { regs[dest] = regs[src1] * regs[src2]; } - + private void do_div(int dest, int src1, int src2) { if (regs[src2] == 0){ @@ -81,7 +81,8 @@ public class Machine } private void do_load(int dest, int src, int offs) { - if (regs[src] + offs > MAX_ADDR){ + // Relational Operator Replacement + if (regs[src] + offs => MAX_ADDR){ /* no op */ }else if(regs[src] + offs < 0){ /* no op */ @@ -152,16 +153,16 @@ public class Machine throw new InvalidInstructionException(); } } - + /** Execute an assembly program. * - * @param prog is the program to execute as an iterable collection of strings, + * @param prog is the program to execute as an iterable collection of strings, * each of which is a single instruction. * @return the program's return value. - * @throws Exception when program has unrecognised or + * @throws Exception when program has unrecognised or * invalid instructions, or when it returns no result when it finishes */ - int execute(List<String> instructions) + int execute(List<String> instructions) throws InvalidInstructionException, NoReturnValueException { @@ -180,7 +181,7 @@ public class Machine break; } String inst = instructions.get(pc); - /* strip leading and trailing whitespace */ + /* strip leading and trailing whitespace */ inst = inst.toLowerCase().replaceAll("^\\s+","").replaceAll("\\s+$",""); /* strip out any comments */ String[] toks = inst.split(";");