From 66f95c9cd495d3488f3ece2701efd5eeb4f0690b Mon Sep 17 00:00:00 2001 From: SHIBAO ZHANG <zsb0213@gmail.com> Date: Sun, 2 Sep 2018 23:06:35 +1000 Subject: [PATCH] Final submit for assignment 1 --- examples/BoundaryTests/EC-1.s | 2 + examples/BoundaryTests/EC-10.s | 3 + examples/BoundaryTests/EC-11.s | 7 + examples/BoundaryTests/EC-12.s | 7 + examples/BoundaryTests/EC-13-1.s | 7 + examples/BoundaryTests/EC-13-2.s | 7 + examples/BoundaryTests/EC-14.s | 7 + examples/BoundaryTests/EC-15.s | 5 + examples/BoundaryTests/EC-16.s | 4 + examples/BoundaryTests/EC-17-1.s | 8 + examples/BoundaryTests/EC-17-2.s | 5 + examples/BoundaryTests/EC-18.s | 5 + examples/BoundaryTests/EC-19.s | 5 + examples/BoundaryTests/EC-2.s | 5 + examples/BoundaryTests/EC-20.s | 4 + examples/BoundaryTests/EC-21.s | 3 + examples/BoundaryTests/EC-3.s | 5 + examples/BoundaryTests/EC-4.s | 5 + examples/BoundaryTests/EC-5-1.s | 5 + examples/BoundaryTests/EC-5-2.s | 5 + examples/BoundaryTests/EC-6.s | 5 + examples/BoundaryTests/EC-7.s | 6 + examples/BoundaryTests/EC-8.s | 3 + examples/BoundaryTests/EC-9-1.s | 3 + examples/BoundaryTests/EC-9-2.s | 3 + examples/PartitioningTests/EC-1.s | 2 + examples/PartitioningTests/EC-10.s | 3 + examples/PartitioningTests/EC-11.s | 7 + examples/PartitioningTests/EC-12.s | 7 + examples/PartitioningTests/EC-13.s | 7 + examples/PartitioningTests/EC-14.s | 7 + examples/PartitioningTests/EC-15.s | 5 + examples/PartitioningTests/EC-16.s | 4 + examples/PartitioningTests/EC-17.s | 5 + examples/PartitioningTests/EC-18.s | 5 + examples/PartitioningTests/EC-19.s | 5 + examples/PartitioningTests/EC-2.s | 6 + examples/PartitioningTests/EC-20.s | 4 + examples/PartitioningTests/EC-21.s | 3 + examples/PartitioningTests/EC-3.s | 5 + examples/PartitioningTests/EC-4.s | 5 + examples/PartitioningTests/EC-5.s | 5 + examples/PartitioningTests/EC-6.s | 5 + examples/PartitioningTests/EC-7.s | 6 + examples/PartitioningTests/EC-8.s | 3 + examples/PartitioningTests/EC-9.s | 3 + .../mutant-1/swen90006/machine/Machine.java | 2 +- .../mutant-2/swen90006/machine/Machine.java | 2 +- .../mutant-3/swen90006/machine/Machine.java | 2 +- .../mutant-4/swen90006/machine/Machine.java | 2 +- .../mutant-5/swen90006/machine/Machine.java | 2 +- test/swen90006/machine/BoundaryTests.java | 200 ++++++++++++++++++ test/swen90006/machine/PartitioningTests.java | 168 +++++++++++++++ 53 files changed, 599 insertions(+), 5 deletions(-) create mode 100644 examples/BoundaryTests/EC-1.s create mode 100644 examples/BoundaryTests/EC-10.s create mode 100644 examples/BoundaryTests/EC-11.s create mode 100644 examples/BoundaryTests/EC-12.s create mode 100644 examples/BoundaryTests/EC-13-1.s create mode 100644 examples/BoundaryTests/EC-13-2.s create mode 100644 examples/BoundaryTests/EC-14.s create mode 100644 examples/BoundaryTests/EC-15.s create mode 100644 examples/BoundaryTests/EC-16.s create mode 100644 examples/BoundaryTests/EC-17-1.s create mode 100644 examples/BoundaryTests/EC-17-2.s create mode 100644 examples/BoundaryTests/EC-18.s create mode 100644 examples/BoundaryTests/EC-19.s create mode 100644 examples/BoundaryTests/EC-2.s create mode 100644 examples/BoundaryTests/EC-20.s create mode 100644 examples/BoundaryTests/EC-21.s create mode 100644 examples/BoundaryTests/EC-3.s create mode 100644 examples/BoundaryTests/EC-4.s create mode 100644 examples/BoundaryTests/EC-5-1.s create mode 100644 examples/BoundaryTests/EC-5-2.s create mode 100644 examples/BoundaryTests/EC-6.s create mode 100644 examples/BoundaryTests/EC-7.s create mode 100644 examples/BoundaryTests/EC-8.s create mode 100644 examples/BoundaryTests/EC-9-1.s create mode 100644 examples/BoundaryTests/EC-9-2.s create mode 100644 examples/PartitioningTests/EC-1.s create mode 100644 examples/PartitioningTests/EC-10.s create mode 100644 examples/PartitioningTests/EC-11.s create mode 100644 examples/PartitioningTests/EC-12.s create mode 100644 examples/PartitioningTests/EC-13.s create mode 100644 examples/PartitioningTests/EC-14.s create mode 100644 examples/PartitioningTests/EC-15.s create mode 100644 examples/PartitioningTests/EC-16.s create mode 100644 examples/PartitioningTests/EC-17.s create mode 100644 examples/PartitioningTests/EC-18.s create mode 100644 examples/PartitioningTests/EC-19.s create mode 100644 examples/PartitioningTests/EC-2.s create mode 100644 examples/PartitioningTests/EC-20.s create mode 100644 examples/PartitioningTests/EC-21.s create mode 100644 examples/PartitioningTests/EC-3.s create mode 100644 examples/PartitioningTests/EC-4.s create mode 100644 examples/PartitioningTests/EC-5.s create mode 100644 examples/PartitioningTests/EC-6.s create mode 100644 examples/PartitioningTests/EC-7.s create mode 100644 examples/PartitioningTests/EC-8.s create mode 100644 examples/PartitioningTests/EC-9.s diff --git a/examples/BoundaryTests/EC-1.s b/examples/BoundaryTests/EC-1.s new file mode 100644 index 0000000..6918590 --- /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 0000000..371049b --- /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 0000000..718a3bb --- /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 0000000..78dfdc0 --- /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 0000000..87415a9 --- /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 0000000..6cd9276 --- /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 0000000..970d4c6 --- /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 0000000..d691e19 --- /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 0000000..da8f8d3 --- /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 0000000..ab9978b --- /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 0000000..754e36e --- /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 0000000..6d0ba86 --- /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 0000000..25442e0 --- /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 0000000..8efae02 --- /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 0000000..3e258bd --- /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 0000000..bffb962 --- /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 0000000..87c299f --- /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 0000000..e40015d --- /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 0000000..dbf9aab --- /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 0000000..7129dc5 --- /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 0000000..99483dc --- /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 0000000..9b93069 --- /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 0000000..67584a3 --- /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 0000000..051f2a4 --- /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 0000000..b99fd06 --- /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 0000000..6918590 --- /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 0000000..9909212 --- /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 0000000..545e803 --- /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 0000000..20d07b1 --- /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 0000000..3bb1aca --- /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 0000000..64fee9a --- /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 0000000..d691e19 --- /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 0000000..da8f8d3 --- /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 0000000..754e36e --- /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 0000000..6d0ba86 --- /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 0000000..455f3a9 --- /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 0000000..b246044 --- /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 0000000..046591b --- /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 0000000..bffb962 --- /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 0000000..87c299f --- /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 0000000..e40015d --- /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 0000000..6e516d2 --- /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 0000000..4ffff2e --- /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 0000000..81d646f --- /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 0000000..67584a3 --- /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 0000000..a5a7bc7 --- /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 9bf5731..2562cb2 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 9bf5731..a56907a 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 9bf5731..8ba0f38 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 9bf5731..7c95d0b 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 9bf5731..511c04a 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 61ce1ca..bed7fb4 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 5494b44..9dbabcf 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) -- GitLab