diff --git a/.project b/.project new file mode 100644 index 0000000000000000000000000000000000000000..d622d089e8c5d3cbd82904d89a850e5fa1e59442 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>SWEN90006-A1-2018</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + </buildSpec> + <natures> + </natures> +</projectDescription> diff --git a/examples/BV1.s b/examples/BV1.s new file mode 100644 index 0000000000000000000000000000000000000000..be3afd15a506473afb1883ccd542e49f8c60792d --- /dev/null +++ b/examples/BV1.s @@ -0,0 +1,3 @@ + +MOV R10 -65535 +RET R10 \ No newline at end of file diff --git a/examples/BV10.s b/examples/BV10.s new file mode 100644 index 0000000000000000000000000000000000000000..d23bd5bb9c9e3238f36081e829d42b9054969096 --- /dev/null +++ b/examples/BV10.s @@ -0,0 +1,6 @@ +MOV R0 65535 +MOV R1 32768 +MOV R2 32767 +MUL R0 R0 R1 +ADD R0 R0 R2 +RET 0 \ No newline at end of file diff --git a/examples/BV11.s b/examples/BV11.s new file mode 100644 index 0000000000000000000000000000000000000000..8bd37bec045ca1addaace407309b9d51531312ed --- /dev/null +++ b/examples/BV11.s @@ -0,0 +1,7 @@ +MOV R0 65535 +MOV R1 -32768 +MOV R2 -1 +MUL R0 R0 R1 +ADD R0 R0 R1 +ADD R0 R0 R2 +RET R0 \ No newline at end of file diff --git a/examples/BV12.s b/examples/BV12.s new file mode 100644 index 0000000000000000000000000000000000000000..c4a1ebcb9d22eaf080617957b4caaceb92caa795 --- /dev/null +++ b/examples/BV12.s @@ -0,0 +1,5 @@ +MOV R0 65535 +MOV R1 32768 +MUL R0 R0 R1 +ADD R0 R0 R1 +RET R0 \ No newline at end of file diff --git a/examples/BV13.s b/examples/BV13.s new file mode 100644 index 0000000000000000000000000000000000000000..2daacf8c8e04b7c489c52ca5da2e3178f5310ebd --- /dev/null +++ b/examples/BV13.s @@ -0,0 +1,4 @@ +MOV R0 5 +MOV R1 0 +LDR R0 R1 0 +RET R0 \ No newline at end of file diff --git a/examples/BV14.s b/examples/BV14.s new file mode 100644 index 0000000000000000000000000000000000000000..254ed197986441c037d44ee3a0f182d9630d1157 --- /dev/null +++ b/examples/BV14.s @@ -0,0 +1,4 @@ +MOV R0 5 +MOV R1 1 +LDR R0 R1 65534 +RET R0 \ No newline at end of file diff --git a/examples/BV15.s b/examples/BV15.s new file mode 100644 index 0000000000000000000000000000000000000000..830f9e5ba267dbe9011734f89cc5da738f51136b --- /dev/null +++ b/examples/BV15.s @@ -0,0 +1,4 @@ +MOV R0 5 +MOV R1 -1 +LDR R0 R1 0 +RET R0 \ No newline at end of file diff --git a/examples/BV16.s b/examples/BV16.s new file mode 100644 index 0000000000000000000000000000000000000000..ced433babd7e66c52784649360cf4ed7b7457543 --- /dev/null +++ b/examples/BV16.s @@ -0,0 +1,4 @@ +MOV R0 5 +MOV R1 2 +LDR R0 R1 65534 +RET R0 \ No newline at end of file diff --git a/examples/BV17.s b/examples/BV17.s new file mode 100644 index 0000000000000000000000000000000000000000..ef3b1484f67b778e4b3ae748cde242c3b66b38ae --- /dev/null +++ b/examples/BV17.s @@ -0,0 +1,4 @@ +MOV R0 2 +MOV R1 0 +DIV R0 R0 R1 +RET R0 \ No newline at end of file diff --git a/examples/BV18.s b/examples/BV18.s new file mode 100644 index 0000000000000000000000000000000000000000..e864c0b1328b1ffafc4c0018cc4f8bf41e5c6265 --- /dev/null +++ b/examples/BV18.s @@ -0,0 +1,4 @@ +MOV R0 2 +MOV R1 1 +DIV R0 R0 R1 +RET R0 \ No newline at end of file diff --git a/examples/BV19.s b/examples/BV19.s new file mode 100644 index 0000000000000000000000000000000000000000..45b2f52ea251c19be30168a8268e64b5083534e0 --- /dev/null +++ b/examples/BV19.s @@ -0,0 +1,4 @@ +MOV R0 2 +MOV R1 -1 +DIV R0 R0 R1 +RET R0 \ No newline at end of file diff --git a/examples/BV2.s b/examples/BV2.s new file mode 100644 index 0000000000000000000000000000000000000000..75659777adc1d94e42a946c83c2e7a7664f1d370 --- /dev/null +++ b/examples/BV2.s @@ -0,0 +1,2 @@ +MOV R10 65535 +RET R10 \ No newline at end of file diff --git a/examples/BV20.s b/examples/BV20.s new file mode 100644 index 0000000000000000000000000000000000000000..8604c4db1ae8fa7d6b738bf87f8af4a0ed43b652 --- /dev/null +++ b/examples/BV20.s @@ -0,0 +1 @@ +RET R0 \ No newline at end of file diff --git a/examples/BV21.s b/examples/BV21.s new file mode 100644 index 0000000000000000000000000000000000000000..1ee6d521fe6b242a7b24902f6a416832f7e15a5e --- /dev/null +++ b/examples/BV21.s @@ -0,0 +1,6 @@ +MOV R0 1 +MOV R1 1 +JZ R1 3 +SUB R1 R1 R1 +JMP -2 +RET R0 \ No newline at end of file diff --git a/examples/BV22.s b/examples/BV22.s new file mode 100644 index 0000000000000000000000000000000000000000..859f1f022ebf1d1b7a4dac93de23ecdbc25cbc11 --- /dev/null +++ b/examples/BV22.s @@ -0,0 +1 @@ +JMP -1 \ No newline at end of file diff --git a/examples/BV23.s b/examples/BV23.s new file mode 100644 index 0000000000000000000000000000000000000000..ce2cc9687d68906806c0b4741c0e137d545eaef1 --- /dev/null +++ b/examples/BV23.s @@ -0,0 +1,2 @@ +MOV R0 1 +JMP 2 \ No newline at end of file diff --git a/examples/BV3.s b/examples/BV3.s new file mode 100644 index 0000000000000000000000000000000000000000..3a9800166ce2022822f611ad56d8c42eaba44f1b --- /dev/null +++ b/examples/BV3.s @@ -0,0 +1,3 @@ +MOV R10 1 +MOV R11 1 +STR R11 -65536 R10 \ No newline at end of file diff --git a/examples/BV4.s b/examples/BV4.s new file mode 100644 index 0000000000000000000000000000000000000000..a7568567666b0cc3d6a3d887bdc463aa3a03649c --- /dev/null +++ b/examples/BV4.s @@ -0,0 +1,3 @@ +MOV R10 1 +MOV R11 1 +LDR R10 R11 65536 \ No newline at end of file diff --git a/examples/BV5.s b/examples/BV5.s new file mode 100644 index 0000000000000000000000000000000000000000..aa806bca69924d00c7f66501ecb204febbf28936 --- /dev/null +++ b/examples/BV5.s @@ -0,0 +1,4 @@ +MOV R0 1 +MOV R11 1 +ADD R0 R0 R11 +RET R0 \ No newline at end of file diff --git a/examples/BV6.s b/examples/BV6.s new file mode 100644 index 0000000000000000000000000000000000000000..64cf38b5be7a3842c44316123256b696837f1a74 --- /dev/null +++ b/examples/BV6.s @@ -0,0 +1,4 @@ +MOV R31 3 +MOV R1 1 +SUB R31 R31 R1 +RET R31 \ No newline at end of file diff --git a/examples/BV7.s b/examples/BV7.s new file mode 100644 index 0000000000000000000000000000000000000000..b7d23746ab06a6e0d85f8a17308d26bfa93562ee --- /dev/null +++ b/examples/BV7.s @@ -0,0 +1,3 @@ +MOV R1 1 +MOV R2 1 +MUL R-1 R1 R2 \ No newline at end of file diff --git a/examples/BV8.s b/examples/BV8.s new file mode 100644 index 0000000000000000000000000000000000000000..2dc29c50b3069270a52ab99a003a124983240d8a --- /dev/null +++ b/examples/BV8.s @@ -0,0 +1,3 @@ +MOV R1 1 +MOV R2 1 +DIV R32 R1 R2 \ No newline at end of file diff --git a/examples/BV9.s b/examples/BV9.s new file mode 100644 index 0000000000000000000000000000000000000000..6426563e6ef2eb0e6fe7877637e973d2c3c408ec --- /dev/null +++ b/examples/BV9.s @@ -0,0 +1,5 @@ +MOV R0 65535 +MOV R1 -32768 +MUL R0 R0 R1 +ADD R0 R0 R1 +RET R0 \ No newline at end of file diff --git a/examples/EC1.s b/examples/EC1.s new file mode 100644 index 0000000000000000000000000000000000000000..c47e29f399430c999b40392c2087166d0b75de31 --- /dev/null +++ b/examples/EC1.s @@ -0,0 +1,9 @@ +MOV R0 5 + +MOV R1 10 +SUB R0 R0 R1 +STR R0 5 R1 +LDR R0 R0 5 +JMP 2 +MOV R1 20 +RET R0 \ No newline at end of file diff --git a/examples/EC10.s b/examples/EC10.s new file mode 100644 index 0000000000000000000000000000000000000000..5fc21e778986624235713be40cdf2d335343bcab --- /dev/null +++ b/examples/EC10.s @@ -0,0 +1 @@ +MOV R0 -65536 \ No newline at end of file diff --git a/examples/EC11.s b/examples/EC11.s new file mode 100644 index 0000000000000000000000000000000000000000..8e64b746f323e49bb680be489b2e684fb29dd08f --- /dev/null +++ b/examples/EC11.s @@ -0,0 +1,5 @@ +MOV R0 2 +MOV R1 -40000 +MUL R0 R0 R1 +STR R0 100 R1 +RET R0 \ No newline at end of file diff --git a/examples/EC12.s b/examples/EC12.s new file mode 100644 index 0000000000000000000000000000000000000000..7f78ed0f3dfe579e7b8c5e769dab1c2c0e4799e4 --- /dev/null +++ b/examples/EC12.s @@ -0,0 +1,5 @@ +MOV R0 2 +MOV R1 40000 +MUL R0 R0 R1 +LDR R1 R0 100 +RET R0 \ No newline at end of file diff --git a/examples/EC13-1.s b/examples/EC13-1.s new file mode 100644 index 0000000000000000000000000000000000000000..c09ca2c9387ef4011885474762bd57b97d0032d0 --- /dev/null +++ b/examples/EC13-1.s @@ -0,0 +1 @@ +MOVV R0 5 \ No newline at end of file diff --git a/examples/EC13-2.s b/examples/EC13-2.s new file mode 100644 index 0000000000000000000000000000000000000000..d7ffc7f8fc6cf575a5ae31d2d0d165ce614ebf1c --- /dev/null +++ b/examples/EC13-2.s @@ -0,0 +1 @@ +PUSH R0 \ No newline at end of file diff --git a/examples/EC14.s b/examples/EC14.s new file mode 100644 index 0000000000000000000000000000000000000000..743ffad6a477e58ce4dc4317d58efd55a4605dc6 --- /dev/null +++ b/examples/EC14.s @@ -0,0 +1,4 @@ +MOV R0 1 +MOV R1 0 +DIV R0 R0 R1 +RET R0 \ No newline at end of file diff --git a/examples/EC2.s b/examples/EC2.s new file mode 100644 index 0000000000000000000000000000000000000000..e3f76e82f996049c1498b23ac949247a50ab92d3 --- /dev/null +++ b/examples/EC2.s @@ -0,0 +1,3 @@ +MOV R0 1 +MOV R1 5 +DIV R0 R1 R0 \ No newline at end of file diff --git a/examples/EC3.s b/examples/EC3.s new file mode 100644 index 0000000000000000000000000000000000000000..ae117e855a444a378df44df9a8861467dbb53509 --- /dev/null +++ b/examples/EC3.s @@ -0,0 +1,3 @@ +MOV R0 1 +JMP -2 +RET R0 \ No newline at end of file diff --git a/examples/EC4.S b/examples/EC4.S new file mode 100644 index 0000000000000000000000000000000000000000..29ce1917c7e8f48d7ec6eae49393a0b01e266a63 --- /dev/null +++ b/examples/EC4.S @@ -0,0 +1,9 @@ +MOV R0 5 +MOV R1 3 +MOV R2 2 +MOV R3 1 +JZ R1 5 +MUL R0 R0 R2 +SUB R1 R1 R3 +JMP -3 +RET R0 \ No newline at end of file diff --git a/examples/EC5.s b/examples/EC5.s new file mode 100644 index 0000000000000000000000000000000000000000..cd9a4d335a7a2ed1817aac7d9d7d450e62429180 --- /dev/null +++ b/examples/EC5.s @@ -0,0 +1,2 @@ +MOV R0 1 +STR R-1 10000 R0 \ No newline at end of file diff --git a/examples/EC6.s b/examples/EC6.s new file mode 100644 index 0000000000000000000000000000000000000000..47b7c2f4d20933daa338f3405678bc998e76f8ce --- /dev/null +++ b/examples/EC6.s @@ -0,0 +1,2 @@ +MOV R0 1 +LDR R0 R32 10000 \ No newline at end of file diff --git a/examples/EC7.s b/examples/EC7.s new file mode 100644 index 0000000000000000000000000000000000000000..8bd37bec045ca1addaace407309b9d51531312ed --- /dev/null +++ b/examples/EC7.s @@ -0,0 +1,7 @@ +MOV R0 65535 +MOV R1 -32768 +MOV R2 -1 +MUL R0 R0 R1 +ADD R0 R0 R1 +ADD R0 R0 R2 +RET R0 \ No newline at end of file diff --git a/examples/EC8.s b/examples/EC8.s new file mode 100644 index 0000000000000000000000000000000000000000..c4a1ebcb9d22eaf080617957b4caaceb92caa795 --- /dev/null +++ b/examples/EC8.s @@ -0,0 +1,5 @@ +MOV R0 65535 +MOV R1 32768 +MUL R0 R0 R1 +ADD R0 R0 R1 +RET R0 \ No newline at end of file diff --git a/examples/EC9.s b/examples/EC9.s new file mode 100644 index 0000000000000000000000000000000000000000..9ddba8b01cf01c745846215226287bcc585f33b0 --- /dev/null +++ b/examples/EC9.s @@ -0,0 +1 @@ +MOV R0 65536 \ No newline at end of file diff --git a/mutants/mutant-1/swen90006/machine/Machine.java b/mutants/mutant-1/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..cb45d1ead664c38a647ebe2eedf21d3b055d6672 100644 --- a/mutants/mutant-1/swen90006/machine/Machine.java +++ b/mutants/mutant-1/swen90006/machine/Machine.java @@ -2,6 +2,7 @@ package swen90006.machine; import java.util.Arrays; import java.util.List; +import java.Math; public class Machine { @@ -237,7 +238,7 @@ public class Machine } else if (toks[0].equals(INSTRUCTION_RETURN)){ int rs = parseReg(toks[1]); count++; - return regs[rs]; + return Math.abs(regs[rs]); } else if (toks[0].equals(INSTRUCTION_LOAD)){ if (toks.length != 4){ throw new InvalidInstructionException(); diff --git a/mutants/mutant-2/swen90006/machine/Machine.java b/mutants/mutant-2/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..63be597c1dc868017463c46423e8ab5b4128098c 100644 --- a/mutants/mutant-2/swen90006/machine/Machine.java +++ b/mutants/mutant-2/swen90006/machine/Machine.java @@ -168,7 +168,7 @@ public class Machine int instructionsExecuted = 0; int pc = 0; - final int progLength = instructions.size(); + final int progLength = instructions.size()+1; while(true){ if (pc < 0 || pc >= progLength){ /* will cause NoReturnValueException to be thrown diff --git a/mutants/mutant-3/swen90006/machine/Machine.java b/mutants/mutant-3/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..f6ff7c8b9889d7cfd618c56899db42bda9a144c8 100644 --- a/mutants/mutant-3/swen90006/machine/Machine.java +++ b/mutants/mutant-3/swen90006/machine/Machine.java @@ -115,7 +115,7 @@ public class Machine String numstr = s.substring(1); int num = 0; try { - num = Integer.parseInt(numstr); + num = Integer.parseInt(numstr)%31; } catch (Exception e){ throw new InvalidInstructionException(); } diff --git a/mutants/mutant-4/swen90006/machine/Machine.java b/mutants/mutant-4/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..f082b7f5bc18bd672303f2eafbbd4297e9468caf 100644 --- a/mutants/mutant-4/swen90006/machine/Machine.java +++ b/mutants/mutant-4/swen90006/machine/Machine.java @@ -93,7 +93,7 @@ public class Machine private void do_store(int a, int offs, int b) { if (regs[a] + offs > MAX_ADDR){ /* no op */ - }else if(regs[a] + offs < 0){ + }else if(regs[a] + offs <= 0){ /* no op */ }else{ memory[regs[a] + offs] = regs[b]; diff --git a/mutants/mutant-5/swen90006/machine/Machine.java b/mutants/mutant-5/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..511c04ab54619aaa178cc1cc6b5a40b69eefd059 100644 --- a/mutants/mutant-5/swen90006/machine/Machine.java +++ b/mutants/mutant-5/swen90006/machine/Machine.java @@ -83,7 +83,7 @@ public class Machine private void do_load(int dest, int src, int offs) { if (regs[src] + offs > MAX_ADDR){ /* no op */ - }else if(regs[src] + offs < 0){ + }else if(regs[src] + offs <= 0){ /* no op */ }else{ regs[dest] = memory[regs[src] + offs]; diff --git a/test/swen90006/machine/BoundaryTests.java b/test/swen90006/machine/BoundaryTests.java index 61ce1ca647f325fbf452047408c1e22d9befcb99..285be42e2de169f8866bbe40a5cbafa9b8e81cb0 100644 --- a/test/swen90006/machine/BoundaryTests.java +++ b/test/swen90006/machine/BoundaryTests.java @@ -87,4 +87,96 @@ public class BoundaryTests } return lines; } + @Test + public void boundaryTest1() throws Exception { + SimpleDriver.main(new String[]{"examples/BV1.s"}); + } + @Test + public void boundaryTest2() throws Exception { + SimpleDriver.main(new String[]{"examples/BV2.s"}); + } + @Test + public void boundaryTest3() throws Exception { + SimpleDriver.main(new String[]{"examples/BV3.s"}); + } + @Test + public void boundaryTest4() throws Exception { + SimpleDriver.main(new String[]{"examples/BV4.s"}); + } + @Test + public void boundaryTest5() throws Exception { + SimpleDriver.main(new String[]{"examples/BV5.s"}); + } + @Test + public void boundaryTest6() throws Exception { + SimpleDriver.main(new String[]{"examples/BV6.s"}); + } + @Test + public void boundaryTest7() throws Exception { + SimpleDriver.main(new String[]{"examples/BV7.s"}); + } + @Test + public void boundaryTest8() throws Exception { + SimpleDriver.main(new String[]{"examples/BV8.s"}); + } + @Test + public void boundaryTest9() throws Exception { + SimpleDriver.main(new String[]{"examples/BV9.s"}); + } + @Test + public void boundaryTest10() throws Exception { + SimpleDriver.main(new String[]{"examples/BV10.s"}); + } + @Test + public void boundaryTest11() throws Exception { + SimpleDriver.main(new String[]{"examples/BV11.s"}); + } + @Test + public void boundaryTest12() throws Exception { + SimpleDriver.main(new String[]{"examples/BV12.s"}); + } + @Test + public void boundaryTest13() throws Exception { + SimpleDriver.main(new String[]{"examples/BV13.s"}); + } + @Test + public void boundaryTest14() throws Exception { + SimpleDriver.main(new String[]{"examples/BV14.s"}); + } + @Test + public void boundaryTest15() throws Exception { + SimpleDriver.main(new String[]{"examples/BV15.s"}); + } + @Test + public void boundaryTest16() throws Exception { + SimpleDriver.main(new String[]{"examples/BV16.s"}); + } + @Test + public void boundaryTest17() throws Exception { + SimpleDriver.main(new String[]{"examples/BV17.s"}); + } + @Test + public void boundaryTest18() throws Exception { + SimpleDriver.main(new String[]{"examples/BV18.s"}); + } + @Test + public void boundaryTest19() throws Exception { + SimpleDriver.main(new String[]{"examples/BV19.s"}); + } + @Test + public void boundaryTest20() throws Exception { + SimpleDriver.main(new String[]{"examples/BV20.s"}); + } + @Test + public void boundaryTest21() throws Exception { + SimpleDriver.main(new String[]{"examples/BV21.s"}); + } + @Test + public void boundaryTest22() throws Exception { + SimpleDriver.main(new String[]{"examples/BV22.s"}); + } + @Test + public void boundaryTest23() throws Exception { + SimpleDriver.main(new String[]{"examples/BV23.s"}); + } } diff --git a/test/swen90006/machine/PartitioningTests.java b/test/swen90006/machine/PartitioningTests.java index 5494b44f4615351a610fc7b0b649d30b4b2d0a40..3254908e86f2d0d60115dc872b5ea6462a1c1a95 100644 --- a/test/swen90006/machine/PartitioningTests.java +++ b/test/swen90006/machine/PartitioningTests.java @@ -87,4 +87,79 @@ public class PartitioningTests } return lines; } + @Test + public void partitionTest1() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC1.s"}); + + } + @Test + public void partitionTest2() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC2.s"}); + + } + @Test + public void partitionTest3() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC3.s"}); + + } + @Test + public void partitionTest4() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC4.s"}); + + } + @Test + public void partitionTest5() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC5.s"}); + + } + @Test + public void partitionTest6() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC6.s"}); + + } + @Test + public void partitionTest7() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC7.s"}); + + } + @Test + public void partitionTest8() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC8.s"}); + + } + @Test + public void partitionTest9() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC9.s"}); + + } + @Test + public void partitionTest10() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC10.s"}); + + } + @Test + public void partitionTest11() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC11.s"}); + + } + @Test + public void partitionTest12() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC12.s"}); + + } + @Test + public void partitionTest131() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC13-1.s"}); + + } + @Test + public void partitionTest132() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC13-2.s"}); + + } + @Test + public void partitionTest14() throws Exception{ + SimpleDriver.main(new String[]{"examples/EC14.s"}); + + } }