diff --git a/examples/BoundaryTests/EC-1.s b/examples/BoundaryTests/EC-1.s new file mode 100644 index 0000000000000000000000000000000000000000..6918590476571da28a5d03aa804b140930dccb35 --- /dev/null +++ b/examples/BoundaryTests/EC-1.s @@ -0,0 +1,2 @@ +ADD R0 R1 R2 +;; NoReturnValueException \ No newline at end of file diff --git a/examples/BoundaryTests/EC-10.s b/examples/BoundaryTests/EC-10.s new file mode 100644 index 0000000000000000000000000000000000000000..371049be62dbd211909912eff31184fbae007789 --- /dev/null +++ b/examples/BoundaryTests/EC-10.s @@ -0,0 +1,3 @@ +MOV R0 65536 +RET R0 +;; InvalidInstructionException \ No newline at end of file diff --git a/examples/BoundaryTests/EC-11.s b/examples/BoundaryTests/EC-11.s new file mode 100644 index 0000000000000000000000000000000000000000..718a3bb5a325dd57e927fa5a60fb45430289541b --- /dev/null +++ b/examples/BoundaryTests/EC-11.s @@ -0,0 +1,7 @@ +MOV R0 0 +MOV R1 55 +MOV R2 0 +STR R0 0 R1 +LDR R2 R0 0 +RET R2 +;; 55 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-12.s b/examples/BoundaryTests/EC-12.s new file mode 100644 index 0000000000000000000000000000000000000000..78dfdc07914e448ed7546f32c07d985f4bef0627 --- /dev/null +++ b/examples/BoundaryTests/EC-12.s @@ -0,0 +1,7 @@ +MOV R0 -1 +MOV R1 3 +MOV R2 33 +STR R0 0 R1 +LDR R2 R0 0 +RET R2 +;; 33 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-13-1.s b/examples/BoundaryTests/EC-13-1.s new file mode 100644 index 0000000000000000000000000000000000000000..87415a98874b49663143132b0d6c42de36be1f3c --- /dev/null +++ b/examples/BoundaryTests/EC-13-1.s @@ -0,0 +1,7 @@ +MOV R0 55 +MOV R1 0 +MOV R2 0 +STR R1 0 R0 +LDR R2 R1 0 +RET R2 +;; 55 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-13-2.s b/examples/BoundaryTests/EC-13-2.s new file mode 100644 index 0000000000000000000000000000000000000000..6cd9276c4f07d194aad36474bf55dda082b2f239 --- /dev/null +++ b/examples/BoundaryTests/EC-13-2.s @@ -0,0 +1,7 @@ +MOV R0 55 +MOV R1 65535 +MOV R2 0 +STR R1 0 R0 +LDR R2 R1 0 +RET R2 +;; 55 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-14.s b/examples/BoundaryTests/EC-14.s new file mode 100644 index 0000000000000000000000000000000000000000..970d4c6bc773aa4915ab316481c5af8ad3e486e3 --- /dev/null +++ b/examples/BoundaryTests/EC-14.s @@ -0,0 +1,7 @@ +MOV R0 65536 +MOV R1 3 +MOV R2 8 +STR R0 1 R1 +LDR R2 R0 1 +RET R2 +;; 8 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-15.s b/examples/BoundaryTests/EC-15.s new file mode 100644 index 0000000000000000000000000000000000000000..d691e19c8af0a873512d3d29269be4eb3076fa66 --- /dev/null +++ b/examples/BoundaryTests/EC-15.s @@ -0,0 +1,5 @@ +MOV R0 0 +JMP 2 +MOV R0 1 +RET R0 +;; 0 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-16.s b/examples/BoundaryTests/EC-16.s new file mode 100644 index 0000000000000000000000000000000000000000..da8f8d32f64d2572b39fef02af749278f9883339 --- /dev/null +++ b/examples/BoundaryTests/EC-16.s @@ -0,0 +1,4 @@ +MOV R0 0 +JZ R0 -2 +RET R0 +;; 0 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-17-1.s b/examples/BoundaryTests/EC-17-1.s new file mode 100644 index 0000000000000000000000000000000000000000..ab9978bb238f0e421a2343049ab79d54908dfade --- /dev/null +++ b/examples/BoundaryTests/EC-17-1.s @@ -0,0 +1,8 @@ +;; If pc=0 after executed one instruction, it will be an infinite loop, +;; so pc>1 at this case +MOV R0 -1 +MOV R1 1 +ADD R0 R0 R1 +JZ R0 -1 +RET R0 +;; 1 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-17-2.s b/examples/BoundaryTests/EC-17-2.s new file mode 100644 index 0000000000000000000000000000000000000000..754e36e65eea2bffdf3d144e9e93000ca1a679f3 --- /dev/null +++ b/examples/BoundaryTests/EC-17-2.s @@ -0,0 +1,5 @@ +MOV R0 0 +JZ R0 2 +MOV R0 1 +RET R0 +;; 0 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-18.s b/examples/BoundaryTests/EC-18.s new file mode 100644 index 0000000000000000000000000000000000000000..6d0ba86b7eb579a5a9ad0ea699983e48169c2069 --- /dev/null +++ b/examples/BoundaryTests/EC-18.s @@ -0,0 +1,5 @@ +MOV R0 0 +JZ R0 3 +MOV R0 1 +RET R0 +;; 1 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-19.s b/examples/BoundaryTests/EC-19.s new file mode 100644 index 0000000000000000000000000000000000000000..25442e0f358f063ac75511d7165d037ff237c1b5 --- /dev/null +++ b/examples/BoundaryTests/EC-19.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 1 +RET R0 +RET R1 +;; 0 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-2.s b/examples/BoundaryTests/EC-2.s new file mode 100644 index 0000000000000000000000000000000000000000..8efae023810a3b2eb705ef864a630fbe072129a5 --- /dev/null +++ b/examples/BoundaryTests/EC-2.s @@ -0,0 +1,5 @@ +MOV R0 1 +MOV R1 2 +ADD R3 R0 R1 +RET R3 +;; 3 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-20.s b/examples/BoundaryTests/EC-20.s new file mode 100644 index 0000000000000000000000000000000000000000..3e258bd5aa5e4b40f9835278fdbf6c832b1a3441 --- /dev/null +++ b/examples/BoundaryTests/EC-20.s @@ -0,0 +1,4 @@ +MOV R0 0 +JMP 0 +RET R0 +;; \ No newline at end of file diff --git a/examples/BoundaryTests/EC-21.s b/examples/BoundaryTests/EC-21.s new file mode 100644 index 0000000000000000000000000000000000000000..bffb9622890337fa3833276d47a83723f85f02e5 --- /dev/null +++ b/examples/BoundaryTests/EC-21.s @@ -0,0 +1,3 @@ +MOV R0 0 +MOV R1 0 +;; NoReturnValueException \ No newline at end of file diff --git a/examples/BoundaryTests/EC-3.s b/examples/BoundaryTests/EC-3.s new file mode 100644 index 0000000000000000000000000000000000000000..87c299fd606f32cc8fcbe1ab1ff3cd6ae6fdb272 --- /dev/null +++ b/examples/BoundaryTests/EC-3.s @@ -0,0 +1,5 @@ +MOV R0 1 +MOV R1 2 +SUB R3 R0 R1 +RET R3 +;; -1 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-4.s b/examples/BoundaryTests/EC-4.s new file mode 100644 index 0000000000000000000000000000000000000000..e40015d3d72a54e39410fc9b989f65350600f4b6 --- /dev/null +++ b/examples/BoundaryTests/EC-4.s @@ -0,0 +1,5 @@ +MOV R0 1 +MOV R1 2 +MUL R-1 R0 R1 +RET R1 +;; InvalidInstructionException \ No newline at end of file diff --git a/examples/BoundaryTests/EC-5-1.s b/examples/BoundaryTests/EC-5-1.s new file mode 100644 index 0000000000000000000000000000000000000000..dbf9aab74eeec17f852311501dc46d38040de648 --- /dev/null +++ b/examples/BoundaryTests/EC-5-1.s @@ -0,0 +1,5 @@ +MOV R1 2 +MOV R2 2 +MUL R0 R1 R2 +RET R0 +;; 4 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-5-2.s b/examples/BoundaryTests/EC-5-2.s new file mode 100644 index 0000000000000000000000000000000000000000..7129dc5613cad47b16679d903d37daa9017ce999 --- /dev/null +++ b/examples/BoundaryTests/EC-5-2.s @@ -0,0 +1,5 @@ +MOV R1 2 +MOV R2 2 +MUL R31 R1 R2 +RET R31 +;; 4 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-6.s b/examples/BoundaryTests/EC-6.s new file mode 100644 index 0000000000000000000000000000000000000000..99483dc46c413e2529502f321bcc0e569d6172a5 --- /dev/null +++ b/examples/BoundaryTests/EC-6.s @@ -0,0 +1,5 @@ +MOV R1 1 +MOV R2 2 +MUL R32 R1 R2 +RET R32 +;; InvalidInstructionException \ No newline at end of file diff --git a/examples/BoundaryTests/EC-7.s b/examples/BoundaryTests/EC-7.s new file mode 100644 index 0000000000000000000000000000000000000000..9b9306996d9b77e8ffe9f7598a1b610bcaa396cc --- /dev/null +++ b/examples/BoundaryTests/EC-7.s @@ -0,0 +1,6 @@ +MOV R0 0 +MOV R1 2 +MOV R3 3 +MUL R3 R1 R0 +RET R3 +;; 3 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-8.s b/examples/BoundaryTests/EC-8.s new file mode 100644 index 0000000000000000000000000000000000000000..67584a348480319932c997707f4ab3331bf234fa --- /dev/null +++ b/examples/BoundaryTests/EC-8.s @@ -0,0 +1,3 @@ +MOV R0 -65536 +RET R0 +;; InvalidInstructionException \ No newline at end of file diff --git a/examples/BoundaryTests/EC-9-1.s b/examples/BoundaryTests/EC-9-1.s new file mode 100644 index 0000000000000000000000000000000000000000..051f2a458619fbfdc53718165232bff4ff4aadd0 --- /dev/null +++ b/examples/BoundaryTests/EC-9-1.s @@ -0,0 +1,3 @@ +MOV R0 -65535 +RET R0 +;; -65535 \ No newline at end of file diff --git a/examples/BoundaryTests/EC-9-2.s b/examples/BoundaryTests/EC-9-2.s new file mode 100644 index 0000000000000000000000000000000000000000..b99fd06af8982d1b3801eb51d76d39024d110bdb --- /dev/null +++ b/examples/BoundaryTests/EC-9-2.s @@ -0,0 +1,3 @@ +MOV R0 65535 +RET R0 +;; 65535 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-1.s b/examples/PartitioningTests/EC-1.s new file mode 100644 index 0000000000000000000000000000000000000000..6918590476571da28a5d03aa804b140930dccb35 --- /dev/null +++ b/examples/PartitioningTests/EC-1.s @@ -0,0 +1,2 @@ +ADD R0 R1 R2 +;; NoReturnValueException \ No newline at end of file diff --git a/examples/PartitioningTests/EC-10.s b/examples/PartitioningTests/EC-10.s new file mode 100644 index 0000000000000000000000000000000000000000..9909212e24cd77a78d65a2d04d2d91a770ff3088 --- /dev/null +++ b/examples/PartitioningTests/EC-10.s @@ -0,0 +1,3 @@ +MOV R0 65537 +RET R0 +;; InvalidInstructionException \ No newline at end of file diff --git a/examples/PartitioningTests/EC-11.s b/examples/PartitioningTests/EC-11.s new file mode 100644 index 0000000000000000000000000000000000000000..545e803c51dbfe5423d29cd1d25b14b9fb5839e1 --- /dev/null +++ b/examples/PartitioningTests/EC-11.s @@ -0,0 +1,7 @@ +MOV R0 0 +MOV R1 55 +MOV R2 0 +STR R0 0 R1 +LDR R2 R0 0 +RET R2 +;; 55 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-12.s b/examples/PartitioningTests/EC-12.s new file mode 100644 index 0000000000000000000000000000000000000000..20d07b1935f48af1c0c96a2de55e05b4f8ce6f74 --- /dev/null +++ b/examples/PartitioningTests/EC-12.s @@ -0,0 +1,7 @@ +MOV R0 -1 +MOV R1 3 +MOV R2 0 +STR R0 0 R1 +LDR R2 R0 0 +RET R2 +;; 0 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-13.s b/examples/PartitioningTests/EC-13.s new file mode 100644 index 0000000000000000000000000000000000000000..3bb1aca6ffb6c0e7bf30ea1b364a149e75263fde --- /dev/null +++ b/examples/PartitioningTests/EC-13.s @@ -0,0 +1,7 @@ +MOV R0 0 +MOV R1 55 +MOV R2 0 +STR R0 1 R1 +LDR R2 R0 1 +RET R2 +;; 55 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-14.s b/examples/PartitioningTests/EC-14.s new file mode 100644 index 0000000000000000000000000000000000000000..64fee9ae69a8b7d9c981383650aad3448642051d --- /dev/null +++ b/examples/PartitioningTests/EC-14.s @@ -0,0 +1,7 @@ +MOV R0 65535 +MOV R1 3 +MOV R2 0 +STR R0 1 R1 +LDR R2 R0 1 +RET R2 +;; 0 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-15.s b/examples/PartitioningTests/EC-15.s new file mode 100644 index 0000000000000000000000000000000000000000..d691e19c8af0a873512d3d29269be4eb3076fa66 --- /dev/null +++ b/examples/PartitioningTests/EC-15.s @@ -0,0 +1,5 @@ +MOV R0 0 +JMP 2 +MOV R0 1 +RET R0 +;; 0 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-16.s b/examples/PartitioningTests/EC-16.s new file mode 100644 index 0000000000000000000000000000000000000000..da8f8d32f64d2572b39fef02af749278f9883339 --- /dev/null +++ b/examples/PartitioningTests/EC-16.s @@ -0,0 +1,4 @@ +MOV R0 0 +JZ R0 -2 +RET R0 +;; 0 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-17.s b/examples/PartitioningTests/EC-17.s new file mode 100644 index 0000000000000000000000000000000000000000..754e36e65eea2bffdf3d144e9e93000ca1a679f3 --- /dev/null +++ b/examples/PartitioningTests/EC-17.s @@ -0,0 +1,5 @@ +MOV R0 0 +JZ R0 2 +MOV R0 1 +RET R0 +;; 0 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-18.s b/examples/PartitioningTests/EC-18.s new file mode 100644 index 0000000000000000000000000000000000000000..6d0ba86b7eb579a5a9ad0ea699983e48169c2069 --- /dev/null +++ b/examples/PartitioningTests/EC-18.s @@ -0,0 +1,5 @@ +MOV R0 0 +JZ R0 3 +MOV R0 1 +RET R0 +;; 1 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-19.s b/examples/PartitioningTests/EC-19.s new file mode 100644 index 0000000000000000000000000000000000000000..455f3a9a267bfd22db65bf3c13555e93c3540cf2 --- /dev/null +++ b/examples/PartitioningTests/EC-19.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +RET R0 +RET R1 +;; 0 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-2.s b/examples/PartitioningTests/EC-2.s new file mode 100644 index 0000000000000000000000000000000000000000..b2460448b6ae2c5f750959f190bcc568a6fef139 --- /dev/null +++ b/examples/PartitioningTests/EC-2.s @@ -0,0 +1,6 @@ +MOV R0 1 + +MOV R1 2 +ADD R3 R0 R1 +RET R3 +;; 3 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-20.s b/examples/PartitioningTests/EC-20.s new file mode 100644 index 0000000000000000000000000000000000000000..046591bccb0019c6487627d2f397c74c8a7f47a0 --- /dev/null +++ b/examples/PartitioningTests/EC-20.s @@ -0,0 +1,4 @@ +MOV R0 0 +JMP 0 +RET RO +;; \ No newline at end of file diff --git a/examples/PartitioningTests/EC-21.s b/examples/PartitioningTests/EC-21.s new file mode 100644 index 0000000000000000000000000000000000000000..bffb9622890337fa3833276d47a83723f85f02e5 --- /dev/null +++ b/examples/PartitioningTests/EC-21.s @@ -0,0 +1,3 @@ +MOV R0 0 +MOV R1 0 +;; NoReturnValueException \ No newline at end of file diff --git a/examples/PartitioningTests/EC-3.s b/examples/PartitioningTests/EC-3.s new file mode 100644 index 0000000000000000000000000000000000000000..87c299fd606f32cc8fcbe1ab1ff3cd6ae6fdb272 --- /dev/null +++ b/examples/PartitioningTests/EC-3.s @@ -0,0 +1,5 @@ +MOV R0 1 +MOV R1 2 +SUB R3 R0 R1 +RET R3 +;; -1 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-4.s b/examples/PartitioningTests/EC-4.s new file mode 100644 index 0000000000000000000000000000000000000000..e40015d3d72a54e39410fc9b989f65350600f4b6 --- /dev/null +++ b/examples/PartitioningTests/EC-4.s @@ -0,0 +1,5 @@ +MOV R0 1 +MOV R1 2 +MUL R-1 R0 R1 +RET R1 +;; InvalidInstructionException \ No newline at end of file diff --git a/examples/PartitioningTests/EC-5.s b/examples/PartitioningTests/EC-5.s new file mode 100644 index 0000000000000000000000000000000000000000..6e516d225c40a02a0040d78784b758ec64d88964 --- /dev/null +++ b/examples/PartitioningTests/EC-5.s @@ -0,0 +1,5 @@ +MOV R1 2 +MOV R2 2 +MUL R3 R1 R2 +RET R3 +;; 4 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-6.s b/examples/PartitioningTests/EC-6.s new file mode 100644 index 0000000000000000000000000000000000000000..4ffff2eda65ac2a341f9b9db077755052cd55d82 --- /dev/null +++ b/examples/PartitioningTests/EC-6.s @@ -0,0 +1,5 @@ +MOV R0 1 +MOV R1 2 +MUL R32 R0 R1 +RET R1 +;; InvalidInstructionException \ No newline at end of file diff --git a/examples/PartitioningTests/EC-7.s b/examples/PartitioningTests/EC-7.s new file mode 100644 index 0000000000000000000000000000000000000000..81d646f8fd3649a7b7925602d34b2a1ef662502f --- /dev/null +++ b/examples/PartitioningTests/EC-7.s @@ -0,0 +1,6 @@ +MOV R0 0 +MOV R1 1 +MOV R3 0 +MUL R3 R1 R0 +RET R3 +;; 0 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-8.s b/examples/PartitioningTests/EC-8.s new file mode 100644 index 0000000000000000000000000000000000000000..67584a348480319932c997707f4ab3331bf234fa --- /dev/null +++ b/examples/PartitioningTests/EC-8.s @@ -0,0 +1,3 @@ +MOV R0 -65536 +RET R0 +;; InvalidInstructionException \ No newline at end of file diff --git a/examples/PartitioningTests/EC-9.s b/examples/PartitioningTests/EC-9.s new file mode 100644 index 0000000000000000000000000000000000000000..a5a7bc774db0dd465f0775a2ff349d29f7127884 --- /dev/null +++ b/examples/PartitioningTests/EC-9.s @@ -0,0 +1,3 @@ +MOV R0 2 +RET R0 +;; 2 \ 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..2562cb2a55dae777877fa919eafae9ee15054844 100644 --- a/mutants/mutant-1/swen90006/machine/Machine.java +++ b/mutants/mutant-1/swen90006/machine/Machine.java @@ -170,7 +170,7 @@ public class Machine int pc = 0; final int progLength = instructions.size(); while(true){ - if (pc < 0 || pc >= progLength){ + 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, diff --git a/mutants/mutant-2/swen90006/machine/Machine.java b/mutants/mutant-2/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..a56907ab061d2c2cdfa9b43385b06b0bcd136701 100644 --- a/mutants/mutant-2/swen90006/machine/Machine.java +++ b/mutants/mutant-2/swen90006/machine/Machine.java @@ -148,7 +148,7 @@ public class Machine private void validate_offset(int offset) throws InvalidInstructionException { - if (offset < -MAX_ADDR || offset > MAX_ADDR) { + if (offset < -MAX_ADDR || offset >= MAX_ADDR) { throw new InvalidInstructionException(); } } diff --git a/mutants/mutant-3/swen90006/machine/Machine.java b/mutants/mutant-3/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..8ba0f3820b8e69cafb480067d5d882f2995e915e 100644 --- a/mutants/mutant-3/swen90006/machine/Machine.java +++ b/mutants/mutant-3/swen90006/machine/Machine.java @@ -275,7 +275,7 @@ public class Machine } int ra = parseReg(toks[1]); int offs = parseOffset(toks[2]); - if (regs[ra] == 0){ + 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..7c95d0ba3df955a7430500f1bcd350d38f579279 100644 --- a/mutants/mutant-4/swen90006/machine/Machine.java +++ b/mutants/mutant-4/swen90006/machine/Machine.java @@ -73,7 +73,7 @@ public class Machine private void do_div(int dest, int src1, int src2) { - if (regs[src2] == 0){ + if (regs[src1] == 0){ /* no op */ }else{ regs[dest] = regs[src1] / regs[src2]; 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..bed7fb47a5dda6dae891ef766eabff24818d672c 100644 --- a/test/swen90006/machine/BoundaryTests.java +++ b/test/swen90006/machine/BoundaryTests.java @@ -71,6 +71,206 @@ public class BoundaryTests assertEquals("Some failure message", expected, actual); } + @Test(expected = swen90006.machine.NoReturnValueException.class) + public void EC_1() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-1.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_2() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-2.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 3); + } + + @Test + public void EC_3() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-3.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), -1); + } + + @Test (expected = swen90006.machine.InvalidInstructionException.class) + public void EC_4() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-4.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_5_1() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-5-1.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 4); + } + + @Test + public void EC_5_2() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-5-2.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 4); + } + + @Test (expected = swen90006.machine.InvalidInstructionException.class) + public void EC_6() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-6.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_7() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-7.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 3); + } + + @Test (expected = swen90006.machine.InvalidInstructionException.class) + public void EC_8() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-8.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_9_1() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-9-1.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), -65535); + } + + @Test + public void EC_9_2() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-9-2.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 65535); + } + + @Test (expected = swen90006.machine.InvalidInstructionException.class) + public void EC_10() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-10.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_11() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-11.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 55); + } + + @Test + public void EC_12() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-12.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 33); + } + + @Test + public void EC_13_1() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-13-1.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 55); + } + + @Test + public void EC_13_2() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-13-2.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 55); + } + + @Test + public void EC_14() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-14.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 8); + } + + @Test + public void EC_15() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-15.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test + public void EC_16() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-16.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test + public void EC_17_1() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-17-1.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 1); + } + + @Test + public void EC_17_2() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-17-2.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test + public void EC_18() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-18.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 1); + } + + @Test + public void EC_19() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-19.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test(expected = swen90006.machine.NoReturnValueException.class) + public void EC_20() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-20.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test(expected = swen90006.machine.NoReturnValueException.class) + public void EC_21() + { + final List<String> lines = readInstructions("examples/BoundaryTests/EC-21.s"); + Machine m = new Machine(); + m.execute(lines); + } + //Read in a file containing a program and convert into a list of //string instructions private List<String> readInstructions(String file) diff --git a/test/swen90006/machine/PartitioningTests.java b/test/swen90006/machine/PartitioningTests.java index 5494b44f4615351a610fc7b0b649d30b4b2d0a40..9dbabcf991ccebdb756d7baa501c8c1e9d636e05 100644 --- a/test/swen90006/machine/PartitioningTests.java +++ b/test/swen90006/machine/PartitioningTests.java @@ -71,6 +71,174 @@ public class PartitioningTests assertEquals("Some failure message", expected, actual); } + @Test(expected = swen90006.machine.NoReturnValueException.class) + public void EC_1() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-1.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_2() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-2.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 3); + } + + @Test + public void EC_3() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-3.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), -1); + } + + @Test (expected = swen90006.machine.InvalidInstructionException.class) + public void EC_4() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-4.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_5() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-5.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 4); + } + + @Test (expected = swen90006.machine.InvalidInstructionException.class) + public void EC_6() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-6.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_7() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-7.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test (expected = swen90006.machine.InvalidInstructionException.class) + public void EC_8() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-8.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_9() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-9.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 2); + } + + @Test (expected = swen90006.machine.InvalidInstructionException.class) + public void EC_10() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-10.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test + public void EC_11() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-11.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 55); + } + + @Test + public void EC_12() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-12.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test + public void EC_13() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-13.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 55); + } + + @Test + public void EC_14() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-14.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test + public void EC_15() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-15.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test + public void EC_16() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-16.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test + public void EC_17() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-17.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test + public void EC_18() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-18.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 1); + } + + @Test + public void EC_19() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-19.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + + @Test(expected = swen90006.machine.NoReturnValueException.class) + public void EC_20() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-20.s"); + Machine m = new Machine(); + m.execute(lines); + } + + @Test(expected = swen90006.machine.NoReturnValueException.class) + public void EC_21() + { + final List<String> lines = readInstructions("examples/PartitioningTests/EC-21.s"); + Machine m = new Machine(); + m.execute(lines); + } + //Read in a file containing a program and convert into a list of //string instructions private List<String> readInstructions(String file)