From 3d79bf07841ad8112b452830cdf2bfb78564c972 Mon Sep 17 00:00:00 2001 From: YUNCHENG WANG <yunchengw@student.unimelb.edu.au> Date: Sun, 2 Sep 2018 22:15:22 +1000 Subject: [PATCH] Assignment-1 --- .idea/vcs.xml | 6 + examples/BTest/B1.s | 1 + examples/BTest/B10.s | 8 + examples/BTest/B11.s | 4 + examples/BTest/B12.s | 5 + examples/BTest/B13.s | 5 + examples/BTest/B14.s | 5 + examples/BTest/B15.s | 5 + examples/BTest/B16.s | 5 + examples/BTest/B17.s | 5 + examples/BTest/B18.s | 5 + examples/BTest/B19.s | 5 + examples/BTest/B2.s | 1 + examples/BTest/B20.s | 5 + examples/BTest/B21.s | 5 + examples/BTest/B22.s | 5 + examples/BTest/B23.s | 5 + examples/BTest/B24.s | 5 + examples/BTest/B25.s | 5 + examples/BTest/B26.s | 9 + examples/BTest/B27.s | 5 + examples/BTest/B3.s | 5 + examples/BTest/B4.s | 1 + examples/BTest/B5.s | 1 + examples/BTest/B6.s | 1 + examples/BTest/B7.s | 1 + examples/BTest/B8.s | 1 + examples/BTest/B9.s | 1 + examples/PTest/EC211.s | 1 + examples/PTest/EC212.s | 1 + examples/PTest/EC22.S | 1 + examples/PTest/EC3111A.s | 5 + examples/PTest/EC3111D.s | 5 + examples/PTest/EC3111M.s | 5 + examples/PTest/EC3111S.s | 5 + examples/PTest/EC3112.s | 5 + examples/PTest/EC31211.s | 5 + examples/PTest/EC31212.s | 2 + examples/PTest/EC31213.s | 5 + examples/PTest/EC3122.s | 2 + examples/PTest/EC31311.s | 5 + examples/PTest/EC31312.s | 5 + examples/PTest/EC31313.s | 5 + examples/PTest/EC3132.s | 5 + examples/PTest/EC3141.s | 5 + examples/PTest/EC31421.s | 5 + examples/PTest/EC31422.s | 5 + examples/PTest/EC3143.s | 5 + examples/PTest/EC31511.s | 5 + examples/PTest/EC31512.s | 5 + examples/PTest/EC31513.s | 5 + examples/PTest/EC3152.s | 5 + examples/PTest/EC316.s | 5 + examples/PTest/EC32.s | 2 + examples/PTest/empty.s | 0 .../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 | 187 +++++++++++++++- test/swen90006/machine/PartitioningTests.java | 199 ++++++++++++++++-- 62 files changed, 591 insertions(+), 29 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 examples/BTest/B1.s create mode 100644 examples/BTest/B10.s create mode 100644 examples/BTest/B11.s create mode 100644 examples/BTest/B12.s create mode 100644 examples/BTest/B13.s create mode 100644 examples/BTest/B14.s create mode 100644 examples/BTest/B15.s create mode 100644 examples/BTest/B16.s create mode 100644 examples/BTest/B17.s create mode 100644 examples/BTest/B18.s create mode 100644 examples/BTest/B19.s create mode 100644 examples/BTest/B2.s create mode 100644 examples/BTest/B20.s create mode 100644 examples/BTest/B21.s create mode 100644 examples/BTest/B22.s create mode 100644 examples/BTest/B23.s create mode 100644 examples/BTest/B24.s create mode 100644 examples/BTest/B25.s create mode 100644 examples/BTest/B26.s create mode 100644 examples/BTest/B27.s create mode 100644 examples/BTest/B3.s create mode 100644 examples/BTest/B4.s create mode 100644 examples/BTest/B5.s create mode 100644 examples/BTest/B6.s create mode 100644 examples/BTest/B7.s create mode 100644 examples/BTest/B8.s create mode 100644 examples/BTest/B9.s create mode 100644 examples/PTest/EC211.s create mode 100644 examples/PTest/EC212.s create mode 100644 examples/PTest/EC22.S create mode 100644 examples/PTest/EC3111A.s create mode 100644 examples/PTest/EC3111D.s create mode 100644 examples/PTest/EC3111M.s create mode 100644 examples/PTest/EC3111S.s create mode 100644 examples/PTest/EC3112.s create mode 100644 examples/PTest/EC31211.s create mode 100644 examples/PTest/EC31212.s create mode 100644 examples/PTest/EC31213.s create mode 100644 examples/PTest/EC3122.s create mode 100644 examples/PTest/EC31311.s create mode 100644 examples/PTest/EC31312.s create mode 100644 examples/PTest/EC31313.s create mode 100644 examples/PTest/EC3132.s create mode 100644 examples/PTest/EC3141.s create mode 100644 examples/PTest/EC31421.s create mode 100644 examples/PTest/EC31422.s create mode 100644 examples/PTest/EC3143.s create mode 100644 examples/PTest/EC31511.s create mode 100644 examples/PTest/EC31512.s create mode 100644 examples/PTest/EC31513.s create mode 100644 examples/PTest/EC3152.s create mode 100644 examples/PTest/EC316.s create mode 100644 examples/PTest/EC32.s create mode 100644 examples/PTest/empty.s diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/examples/BTest/B1.s b/examples/BTest/B1.s new file mode 100644 index 0000000..d51cddb --- /dev/null +++ b/examples/BTest/B1.s @@ -0,0 +1 @@ +;EMPTY FILE \ No newline at end of file diff --git a/examples/BTest/B10.s b/examples/BTest/B10.s new file mode 100644 index 0000000..1afcb6b --- /dev/null +++ b/examples/BTest/B10.s @@ -0,0 +1,8 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +ADD R0 R1 R2 ;2+1=3 +SUB R1 R0 R2 ;3-1=2 +MUL R0 R1 R2 ;2*1=2 +DIV R1 R0 R2 ;2/1=2 +RET R1 \ No newline at end of file diff --git a/examples/BTest/B11.s b/examples/BTest/B11.s new file mode 100644 index 0000000..7b41ef4 --- /dev/null +++ b/examples/BTest/B11.s @@ -0,0 +1,4 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +ADD R0 R1 R2 diff --git a/examples/BTest/B12.s b/examples/BTest/B12.s new file mode 100644 index 0000000..5575af0 --- /dev/null +++ b/examples/BTest/B12.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +MOV R0 -65536 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B13.s b/examples/BTest/B13.s new file mode 100644 index 0000000..d3be7a6 --- /dev/null +++ b/examples/BTest/B13.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +MOV R0 -65535 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B14.s b/examples/BTest/B14.s new file mode 100644 index 0000000..d51bc0a --- /dev/null +++ b/examples/BTest/B14.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +MOV R0 65535 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B15.s b/examples/BTest/B15.s new file mode 100644 index 0000000..25ed290 --- /dev/null +++ b/examples/BTest/B15.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +MOV R0 65536 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B16.s b/examples/BTest/B16.s new file mode 100644 index 0000000..ac24dfc --- /dev/null +++ b/examples/BTest/B16.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +LDR R0 R1 -3 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B17.s b/examples/BTest/B17.s new file mode 100644 index 0000000..0cad351 --- /dev/null +++ b/examples/BTest/B17.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +LDR R0 R1 -2 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B18.s b/examples/BTest/B18.s new file mode 100644 index 0000000..1f6fa0f --- /dev/null +++ b/examples/BTest/B18.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +LDR R0 R1 65533 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B19.s b/examples/BTest/B19.s new file mode 100644 index 0000000..84b4d19 --- /dev/null +++ b/examples/BTest/B19.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +LDR R0 R1 65534 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B2.s b/examples/BTest/B2.s new file mode 100644 index 0000000..8604c4d --- /dev/null +++ b/examples/BTest/B2.s @@ -0,0 +1 @@ +RET R0 \ No newline at end of file diff --git a/examples/BTest/B20.s b/examples/BTest/B20.s new file mode 100644 index 0000000..3c08248 --- /dev/null +++ b/examples/BTest/B20.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JMP -4 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B21.s b/examples/BTest/B21.s new file mode 100644 index 0000000..8b59a4b --- /dev/null +++ b/examples/BTest/B21.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JMP -3 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B22.s b/examples/BTest/B22.s new file mode 100644 index 0000000..f63fee7 --- /dev/null +++ b/examples/BTest/B22.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JMP 1 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B23.s b/examples/BTest/B23.s new file mode 100644 index 0000000..5b3e0ca --- /dev/null +++ b/examples/BTest/B23.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JMP 2 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B24.s b/examples/BTest/B24.s new file mode 100644 index 0000000..a6351e0 --- /dev/null +++ b/examples/BTest/B24.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JZ R0 -4 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B25.s b/examples/BTest/B25.s new file mode 100644 index 0000000..ae601b7 --- /dev/null +++ b/examples/BTest/B25.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JZ R0 -3 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B26.s b/examples/BTest/B26.s new file mode 100644 index 0000000..3059fd8 --- /dev/null +++ b/examples/BTest/B26.s @@ -0,0 +1,9 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +MOV R3 1 +JZ R0 2 +MOV R3 0 +MOV R1 1 +SUB R1 R2 R3 +RET R1 \ No newline at end of file diff --git a/examples/BTest/B27.s b/examples/BTest/B27.s new file mode 100644 index 0000000..2e41e24 --- /dev/null +++ b/examples/BTest/B27.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JZ R0 2 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B3.s b/examples/BTest/B3.s new file mode 100644 index 0000000..2eea206 --- /dev/null +++ b/examples/BTest/B3.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +ADD R0 R1 R2 +RET R0 \ No newline at end of file diff --git a/examples/BTest/B4.s b/examples/BTest/B4.s new file mode 100644 index 0000000..8604c4d --- /dev/null +++ b/examples/BTest/B4.s @@ -0,0 +1 @@ +RET R0 \ No newline at end of file diff --git a/examples/BTest/B5.s b/examples/BTest/B5.s new file mode 100644 index 0000000..86edb84 --- /dev/null +++ b/examples/BTest/B5.s @@ -0,0 +1 @@ +ADD R0 R1 R2 \ No newline at end of file diff --git a/examples/BTest/B6.s b/examples/BTest/B6.s new file mode 100644 index 0000000..8604c4d --- /dev/null +++ b/examples/BTest/B6.s @@ -0,0 +1 @@ +RET R0 \ No newline at end of file diff --git a/examples/BTest/B7.s b/examples/BTest/B7.s new file mode 100644 index 0000000..cdeec3e --- /dev/null +++ b/examples/BTest/B7.s @@ -0,0 +1 @@ +RET R31 \ No newline at end of file diff --git a/examples/BTest/B8.s b/examples/BTest/B8.s new file mode 100644 index 0000000..1483efc --- /dev/null +++ b/examples/BTest/B8.s @@ -0,0 +1 @@ +RET R32 \ No newline at end of file diff --git a/examples/BTest/B9.s b/examples/BTest/B9.s new file mode 100644 index 0000000..8469c09 --- /dev/null +++ b/examples/BTest/B9.s @@ -0,0 +1 @@ +RET R-1 \ No newline at end of file diff --git a/examples/PTest/EC211.s b/examples/PTest/EC211.s new file mode 100644 index 0000000..8604c4d --- /dev/null +++ b/examples/PTest/EC211.s @@ -0,0 +1 @@ +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC212.s b/examples/PTest/EC212.s new file mode 100644 index 0000000..1483efc --- /dev/null +++ b/examples/PTest/EC212.s @@ -0,0 +1 @@ +RET R32 \ No newline at end of file diff --git a/examples/PTest/EC22.S b/examples/PTest/EC22.S new file mode 100644 index 0000000..5d991ec --- /dev/null +++ b/examples/PTest/EC22.S @@ -0,0 +1 @@ +MOV R0 1 \ No newline at end of file diff --git a/examples/PTest/EC3111A.s b/examples/PTest/EC3111A.s new file mode 100644 index 0000000..2eea206 --- /dev/null +++ b/examples/PTest/EC3111A.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +ADD R0 R1 R2 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC3111D.s b/examples/PTest/EC3111D.s new file mode 100644 index 0000000..d8c6a67 --- /dev/null +++ b/examples/PTest/EC3111D.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +DIV R0 R1 R2 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC3111M.s b/examples/PTest/EC3111M.s new file mode 100644 index 0000000..e61ac84 --- /dev/null +++ b/examples/PTest/EC3111M.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +MUL R0 R1 R2 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC3111S.s b/examples/PTest/EC3111S.s new file mode 100644 index 0000000..b543328 --- /dev/null +++ b/examples/PTest/EC3111S.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +SUB R0 R1 R2 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC3112.s b/examples/PTest/EC3112.s new file mode 100644 index 0000000..bab9a3f --- /dev/null +++ b/examples/PTest/EC3112.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +ADD R0 R1 R32 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31211.s b/examples/PTest/EC31211.s new file mode 100644 index 0000000..5575af0 --- /dev/null +++ b/examples/PTest/EC31211.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +MOV R0 -65536 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31212.s b/examples/PTest/EC31212.s new file mode 100644 index 0000000..382980e --- /dev/null +++ b/examples/PTest/EC31212.s @@ -0,0 +1,2 @@ +MOV R0 1 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31213.s b/examples/PTest/EC31213.s new file mode 100644 index 0000000..25ed290 --- /dev/null +++ b/examples/PTest/EC31213.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +MOV R0 65536 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC3122.s b/examples/PTest/EC3122.s new file mode 100644 index 0000000..69766ec --- /dev/null +++ b/examples/PTest/EC3122.s @@ -0,0 +1,2 @@ +MOV R32 1 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31311.s b/examples/PTest/EC31311.s new file mode 100644 index 0000000..a7dbc03 --- /dev/null +++ b/examples/PTest/EC31311.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +LDR R0 R1 -4 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31312.s b/examples/PTest/EC31312.s new file mode 100644 index 0000000..585f0a3 --- /dev/null +++ b/examples/PTest/EC31312.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +LDR R0 R1 1 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31313.s b/examples/PTest/EC31313.s new file mode 100644 index 0000000..6221697 --- /dev/null +++ b/examples/PTest/EC31313.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +LDR R0 R1 65535 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC3132.s b/examples/PTest/EC3132.s new file mode 100644 index 0000000..ceaa7a9 --- /dev/null +++ b/examples/PTest/EC3132.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +LDR R0 R32 1 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC3141.s b/examples/PTest/EC3141.s new file mode 100644 index 0000000..e914b7b --- /dev/null +++ b/examples/PTest/EC3141.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JMP -5 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31421.s b/examples/PTest/EC31421.s new file mode 100644 index 0000000..f63fee7 --- /dev/null +++ b/examples/PTest/EC31421.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JMP 1 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31422.s b/examples/PTest/EC31422.s new file mode 100644 index 0000000..036a0dc --- /dev/null +++ b/examples/PTest/EC31422.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JMP 0 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC3143.s b/examples/PTest/EC3143.s new file mode 100644 index 0000000..bd8be61 --- /dev/null +++ b/examples/PTest/EC3143.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JMP 7 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31511.s b/examples/PTest/EC31511.s new file mode 100644 index 0000000..a6351e0 --- /dev/null +++ b/examples/PTest/EC31511.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JZ R0 -4 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31512.s b/examples/PTest/EC31512.s new file mode 100644 index 0000000..0b15a7e --- /dev/null +++ b/examples/PTest/EC31512.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JZ R0 1 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC31513.s b/examples/PTest/EC31513.s new file mode 100644 index 0000000..0f37848 --- /dev/null +++ b/examples/PTest/EC31513.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JZ R0 5 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC3152.s b/examples/PTest/EC3152.s new file mode 100644 index 0000000..496b79b --- /dev/null +++ b/examples/PTest/EC3152.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +JZ R32 1 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC316.s b/examples/PTest/EC316.s new file mode 100644 index 0000000..d98c65e --- /dev/null +++ b/examples/PTest/EC316.s @@ -0,0 +1,5 @@ +MOV R0 0 +MOV R1 2 +MOV R2 1 +XCHG R0 R1 +RET R0 \ No newline at end of file diff --git a/examples/PTest/EC32.s b/examples/PTest/EC32.s new file mode 100644 index 0000000..e62e7e6 --- /dev/null +++ b/examples/PTest/EC32.s @@ -0,0 +1,2 @@ +MOV R0 1 +MOV R2 1 \ No newline at end of file diff --git a/examples/PTest/empty.s b/examples/PTest/empty.s new file mode 100644 index 0000000..e69de29 diff --git a/mutants/mutant-1/swen90006/machine/Machine.java b/mutants/mutant-1/swen90006/machine/Machine.java index 9bf5731..e40898f 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..3dd0f55 100644 --- a/mutants/mutant-2/swen90006/machine/Machine.java +++ b/mutants/mutant-2/swen90006/machine/Machine.java @@ -198,7 +198,7 @@ public class Machine toks = inst.split("\\s+"); /* check minimum number of tokens */ - if (toks.length < 2){ + if (toks.length >= 2){ throw new InvalidInstructionException(); } diff --git a/mutants/mutant-3/swen90006/machine/Machine.java b/mutants/mutant-3/swen90006/machine/Machine.java index 9bf5731..b41468e 100644 --- a/mutants/mutant-3/swen90006/machine/Machine.java +++ b/mutants/mutant-3/swen90006/machine/Machine.java @@ -206,7 +206,7 @@ public class Machine if (toks.length != 4){ throw new InvalidInstructionException(); } - int rd = parseReg(toks[1]); + int rd = parseReg(toks[1])+1; int rs1 = parseReg(toks[2]); int rs2 = parseReg(toks[3]); do_add(rd,rs1,rs2); diff --git a/mutants/mutant-4/swen90006/machine/Machine.java b/mutants/mutant-4/swen90006/machine/Machine.java index 9bf5731..e0040cf 100644 --- a/mutants/mutant-4/swen90006/machine/Machine.java +++ b/mutants/mutant-4/swen90006/machine/Machine.java @@ -266,7 +266,7 @@ public class Machine throw new InvalidInstructionException(); } int offs = parseOffset(toks[1]); - pc = pc + offs; + pc = pc - offs; count++; continue; /* avoid default increment of pc below */ } else if (toks[0].equals(INSTRUCTION_JZ)){ diff --git a/mutants/mutant-5/swen90006/machine/Machine.java b/mutants/mutant-5/swen90006/machine/Machine.java index 9bf5731..821b744 100644 --- a/mutants/mutant-5/swen90006/machine/Machine.java +++ b/mutants/mutant-5/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/test/swen90006/machine/BoundaryTests.java b/test/swen90006/machine/BoundaryTests.java index 61ce1ca..528bc73 100644 --- a/test/swen90006/machine/BoundaryTests.java +++ b/test/swen90006/machine/BoundaryTests.java @@ -43,13 +43,12 @@ public class BoundaryTests //the assertTrue method is used to check whether something holds. assertTrue(list.contains("a")); } - //Test test opens a file and executes the machine @Test public void aFileOpenTest() { - final List<String> lines = readInstructions("examples/array.s"); - Machine m = new Machine(); - assertEquals(m.execute(lines), 45); + final List<String> lines = readInstructions("examples/array.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 45); } //To test an exception, specify the expected exception after the @Test @@ -63,13 +62,13 @@ public class BoundaryTests //This test should fail. //To provide additional feedback when a test fails, an error message //can be included - @Test public void aFailedTest() - { - //include a message for better feedback - final int expected = 2; - final int actual = 1 + 2; - assertEquals("Some failure message", expected, actual); - } +// @Test public void aFailedTest() +// { +// //include a message for better feedback +// final int expected = 2; +// final int actual = 1 + 2; +// assertEquals("Some failure message", expected, actual); +// } //Read in a file containing a program and convert into a list of //string instructions @@ -87,4 +86,170 @@ public class BoundaryTests } return lines; } + + @Test(expected = NoReturnValueException.class) + public void B1Test() { + final List<String> lines = readInstructions("examples/BTest/B1.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void B2Test() { + final List<String> lines = readInstructions("examples/BTest/B2.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(timeout = 5000) + public void B3Test() { + final List<String> lines = readInstructions("examples/BTest/B3.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 3); + } + @Test(timeout = 5000) + public void B4Test() { + final List<String> lines = readInstructions("examples/BTest/B4.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(expected = NoReturnValueException.class) + public void B5Test() { + final List<String> lines = readInstructions("examples/BTest/B5.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void B6Test() { + final List<String> lines = readInstructions("examples/BTest/B6.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(timeout = 5000) + public void B7Test() { + final List<String> lines = readInstructions("examples/BTest/B7.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(expected = InvalidInstructionException.class) + public void B8Test() { + final List<String> lines = readInstructions("examples/BTest/B8.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = InvalidInstructionException.class) + public void B9Test() { + final List<String> lines = readInstructions("examples/BTest/B9.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void B10Test() { + final List<String> lines = readInstructions("examples/BTest/B10.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 2); + } + @Test(expected = NoReturnValueException.class) + public void B11Test() { + final List<String> lines = readInstructions("examples/BTest/B11.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = InvalidInstructionException.class) + public void B12Test() { + final List<String> lines = readInstructions("examples/BTest/B12.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void B13Test() { + final List<String> lines = readInstructions("examples/BTest/B13.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), -65535); + } + @Test(timeout = 5000) + public void B14Test() { + final List<String> lines = readInstructions("examples/BTest/B14.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 65535); + } + @Test(expected = InvalidInstructionException.class) + public void B15Test() { + final List<String> lines = readInstructions("examples/BTest/B15.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void B16Test() { + final List<String> lines = readInstructions("examples/BTest/B16.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines),0); + } + @Test(timeout = 5000) + public void B17Test() { + final List<String> lines = readInstructions("examples/BTest/B17.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(timeout = 5000) + public void B18Test() { + final List<String> lines = readInstructions("examples/BTest/B18.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(timeout = 5000) + public void B19Test() { + final List<String> lines = readInstructions("examples/BTest/B19.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(expected = NoReturnValueException.class) + public void B20Test() { + final List<String> lines = readInstructions("examples/BTest/B20.s"); + Machine m = new Machine(); + m.execute(lines); + } + //INFINITE LOOP +// @Test(timeout = 5000) +// public void B21Test() { +// final List<String> lines = readInstructions("examples/BTest/B21.s"); +// Machine m = new Machine(); +// assertEquals(m.execute(lines), 0); +// } + @Test(timeout = 5000) + public void B22Test() { + final List<String> lines = readInstructions("examples/BTest/B22.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(expected = NoReturnValueException.class) + public void B23Test() { + final List<String> lines = readInstructions("examples/BTest/B23.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = NoReturnValueException.class) + public void B24Test() { + final List<String> lines = readInstructions("examples/BTest/B24.s"); + Machine m = new Machine(); + m.execute(lines); + } + //INFINITE LOOP +// @Test(timeout = 5000) +// public void B25Test() { +// final List<String> lines = readInstructions("examples/BTest/B25.s"); +// Machine m = new Machine(); +// assertEquals(m.execute(lines), 0); +// } + @Test(timeout = 5000) + public void B26Test() { + final List<String> lines = readInstructions("examples/BTest/B26.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(expected = NoReturnValueException.class) + public void B27Test() { + final List<String> lines = readInstructions("examples/BTest/B27.s"); + Machine m = new Machine(); + m.execute(lines); + } + } diff --git a/test/swen90006/machine/PartitioningTests.java b/test/swen90006/machine/PartitioningTests.java index 5494b44..d7d288c 100644 --- a/test/swen90006/machine/PartitioningTests.java +++ b/test/swen90006/machine/PartitioningTests.java @@ -44,14 +44,14 @@ public class PartitioningTests assertTrue(list.contains("a")); } - //Test test opens a file and executes the machine - @Test public void aFileOpenTest() + //Test test opens a file and executes the machine + @Test public void aFileOpenTest() { - final List<String> lines = readInstructions("examples/array.s"); - Machine m = new Machine(); - assertEquals(m.execute(lines), 45); + final List<String> lines = readInstructions("examples/array.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 45); } - + //To test an exception, specify the expected exception after the @Test @Test(expected = java.io.IOException.class) public void anExceptionTest() @@ -63,13 +63,13 @@ public class PartitioningTests //This test should fail. //To provide additional feedback when a test fails, an error message //can be included - @Test public void aFailedTest() - { - //include a message for better feedback - final int expected = 2; - final int actual = 1 + 2; - assertEquals("Some failure message", expected, actual); - } +// @Test public void aFailedTest() +// { +// //include a message for better feedback +// final int expected = 2; +// final int actual = 1 + 2; +// assertEquals("Some failure message", expected, actual); +// } //Read in a file containing a program and convert into a list of //string instructions @@ -87,4 +87,177 @@ public class PartitioningTests } return lines; } + + @Test(expected = NoReturnValueException.class) + public void EC1Test(){ + final List<String> lines = readInstructions("examples/PTest/empty.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test (timeout = 5000) + public void EC211Test() + { + final List<String> lines = readInstructions("examples/PTest/EC211.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(expected = InvalidInstructionException.class) + public void EC212Test() { + final List<String> lines = readInstructions("examples/PTest/EC212.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = NoReturnValueException.class) + public void EC22Test(){ + final List<String> lines = readInstructions("examples/PTest/EC22.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = NoReturnValueException.class) + public void EC32Test(){ + final List<String> lines = readInstructions("examples/PTest/EC32.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void EC3111ATest() + { + final List<String> lines = readInstructions("examples/PTest/EC3111A.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 3); + } + @Test(timeout = 5000) + public void EC3111STest() + { + final List<String> lines = readInstructions("examples/PTest/EC3111S.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 1); + } + @Test(timeout = 5000) + public void EC3111MTest() + { + final List<String> lines = readInstructions("examples/PTest/EC3111M.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 2); + } + @Test(timeout = 5000) + public void EC3111DTest() + { + final List<String> lines = readInstructions("examples/PTest/EC3111D.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 2); + } + @Test(expected = InvalidInstructionException.class) + public void EC3112Test() { + final List<String> lines = readInstructions("examples/PTest/EC3112.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = InvalidInstructionException.class) + public void EC31211Test() { + final List<String> lines = readInstructions("examples/PTest/EC31211.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void EC31212Test() + { + final List<String> lines = readInstructions("examples/PTest/EC31212.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 1); + } + @Test(expected = InvalidInstructionException.class) + public void EC31213Test() { + final List<String> lines = readInstructions("examples/PTest/EC31213.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = InvalidInstructionException.class) + public void EC3122Test() { + final List<String> lines = readInstructions("examples/PTest/EC3122.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void EC31311Test() { + final List<String> lines = readInstructions("examples/PTest/EC31311.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(timeout = 5000) + public void EC31312Test() { + final List<String> lines = readInstructions("examples/PTest/EC31312.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(timeout = 5000) + public void EC31313Test() { + final List<String> lines = readInstructions("examples/PTest/EC31313.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(expected = InvalidInstructionException.class) + public void EC3132Test() { + final List<String> lines = readInstructions("examples/PTest/EC3132.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = NoReturnValueException.class) + public void EC3141Test() { + final List<String> lines = readInstructions("examples/PTest/EC3141.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void EC31421Test() { + final List<String> lines = readInstructions("examples/PTest/EC31421.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + // INFINITE LOOP +// @Test(timeout = 5000) +// public void EC31422Test() { +// final List<String> lines = readInstructions("examples/PTest/EC31422.s"); +// Machine m = new Machine(); +// assertEquals(m.execute(lines), 0); +// } + @Test(expected = NoReturnValueException.class) + public void EC3143Test() { + final List<String> lines = readInstructions("examples/PTest/EC3143.s"); + Machine m = new Machine(); + m.execute(lines); + } + // INFINITE LOOP + @Test(expected = NoReturnValueException.class) + public void EC31511Test() { + final List<String> lines = readInstructions("examples/PTest/EC31511.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(timeout = 5000) + public void EC31512Test() { + final List<String> lines = readInstructions("examples/PTest/EC31512.s"); + Machine m = new Machine(); + assertEquals(m.execute(lines), 0); + } + @Test(expected = NoReturnValueException.class) + public void EC31513Test() { + final List<String> lines = readInstructions("examples/PTest/EC31513.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = InvalidInstructionException.class) + public void EC3152Test() { + final List<String> lines = readInstructions("examples/PTest/EC3152.s"); + Machine m = new Machine(); + m.execute(lines); + } + @Test(expected = InvalidInstructionException.class) + public void EC316Test() { + final List<String> lines = readInstructions("examples/PTest/EC316.s"); + Machine m = new Machine(); + m.execute(lines); + } + + } -- GitLab