From 8a9ad830198c568d7346edd7483fa6ab2e8c343a Mon Sep 17 00:00:00 2001 From: Jiankun Cai <jiankunc@student.unimelb.edu.au> Date: Sun, 2 Sep 2018 23:51:44 +1000 Subject: [PATCH] Jiankun Cai 877109 Assignment 1 --- examples/B10_1.s | 8 + examples/B10_2.s | 8 + examples/B10_3.s | 8 + examples/B10_4.s | 8 + examples/B10_5.s | 8 + examples/B10_6.s | 8 + examples/B11_1.s | 4 + examples/B11_2.s | 3 + examples/B11_3.s | 7 + examples/B11_4.s | 5 + examples/B12_1.s | 7 + examples/B12_2.s | 7 + examples/B12_3.s | 7 + examples/B12_4.s | 7 + examples/B13_1.s | 4 + examples/B13_2.s | 4 + examples/B13_3.s | 5 + examples/B2_1.s | 5 + examples/B2_2.s | 4 + examples/B2_3.s | 3 + examples/B3_1.s | 4 + examples/B3_2.s | 4 + examples/B3_3.s | 3 + examples/B4_1.s | 4 + examples/B4_2.s | 4 + examples/B4_3.s | 3 + examples/B5_1.s | 4 + examples/B5_2.s | 4 + examples/B5_3.s | 3 + examples/B6_1.s | 3 + examples/B6_2.s | 4 + examples/B6_3.s | 2 + examples/B6_4.s | 2 + examples/B7_1.s | 3 + examples/B7_2.s | 4 + examples/B7_3.s | 2 + examples/B7_4.s | 2 + examples/B8_1.s | 3 + examples/B8_2.s | 2 + examples/B8_3.s | 2 + examples/B8_4.s | 2 + examples/B8_5.s | 2 + examples/B8_6.s | 2 + examples/B9_1.s | 5 + examples/B9_2.s | 5 + examples/B9_3.s | 5 + examples/B9_4.s | 5 + examples/B9_5.s | 5 + examples/B9_6.s | 5 + examples/EC2-1.s | 1 + examples/EC2-10.s | 4 + examples/EC2-11.s | 4 + examples/EC2-12.s | 2 + examples/EC2-13.s | 2 + examples/EC2-14.s | 2 + examples/EC2-15.s | 5 + examples/EC2-16.s | 5 + examples/EC2-17.s | 5 + examples/EC2-18.s | 5 + examples/EC2-19.s | 3 + examples/EC2-2.s | 1 + examples/EC2-20.s | 3 + examples/EC2-21.s | 9 + examples/EC2-22.s | 8 + examples/EC2-23.s | 4 + examples/EC2-24.s | 4 + examples/EC2-25.s | 5 + examples/EC2-3.s | 1 + examples/EC2-4.s | 4 + examples/EC2-5.s | 5 + examples/EC2-6.s | 4 + examples/EC2-7.s | 4 + examples/EC2-8.s | 4 + examples/EC2-9.s | 4 + .../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 +- .../swen90006/machine/BugException.class | Bin 0 -> 580 bytes .../machine/InvalidInstructionException.class | Bin 0 -> 478 bytes .../swen90006/machine/Machine.class | Bin 0 -> 5955 bytes .../machine/NoReturnValueException.class | Bin 0 -> 458 bytes .../swen90006/machine/SimpleDriver.class | Bin 0 -> 2696 bytes .../swen90006/machine/BoundaryTests.class | Bin 0 -> 15400 bytes .../swen90006/machine/PartitioningTests.class | Bin 0 -> 8810 bytes src/swen90006/machine/Machine.java | 570 ++++++++-------- test/swen90006/machine/BoundaryTests.java | 632 +++++++++++++++--- test/swen90006/machine/PartitioningTests.java | 347 ++++++++-- 89 files changed, 1439 insertions(+), 436 deletions(-) create mode 100644 examples/B10_1.s create mode 100644 examples/B10_2.s create mode 100644 examples/B10_3.s create mode 100644 examples/B10_4.s create mode 100644 examples/B10_5.s create mode 100644 examples/B10_6.s create mode 100644 examples/B11_1.s create mode 100644 examples/B11_2.s create mode 100644 examples/B11_3.s create mode 100644 examples/B11_4.s create mode 100644 examples/B12_1.s create mode 100644 examples/B12_2.s create mode 100644 examples/B12_3.s create mode 100644 examples/B12_4.s create mode 100644 examples/B13_1.s create mode 100644 examples/B13_2.s create mode 100644 examples/B13_3.s create mode 100644 examples/B2_1.s create mode 100644 examples/B2_2.s create mode 100644 examples/B2_3.s create mode 100644 examples/B3_1.s create mode 100644 examples/B3_2.s create mode 100644 examples/B3_3.s create mode 100644 examples/B4_1.s create mode 100644 examples/B4_2.s create mode 100644 examples/B4_3.s create mode 100644 examples/B5_1.s create mode 100644 examples/B5_2.s create mode 100644 examples/B5_3.s create mode 100644 examples/B6_1.s create mode 100644 examples/B6_2.s create mode 100644 examples/B6_3.s create mode 100644 examples/B6_4.s create mode 100644 examples/B7_1.s create mode 100644 examples/B7_2.s create mode 100644 examples/B7_3.s create mode 100644 examples/B7_4.s create mode 100644 examples/B8_1.s create mode 100644 examples/B8_2.s create mode 100644 examples/B8_3.s create mode 100644 examples/B8_4.s create mode 100644 examples/B8_5.s create mode 100644 examples/B8_6.s create mode 100644 examples/B9_1.s create mode 100644 examples/B9_2.s create mode 100644 examples/B9_3.s create mode 100644 examples/B9_4.s create mode 100644 examples/B9_5.s create mode 100644 examples/B9_6.s create mode 100644 examples/EC2-1.s create mode 100644 examples/EC2-10.s create mode 100644 examples/EC2-11.s create mode 100644 examples/EC2-12.s create mode 100644 examples/EC2-13.s create mode 100644 examples/EC2-14.s create mode 100644 examples/EC2-15.s create mode 100644 examples/EC2-16.s create mode 100644 examples/EC2-17.s create mode 100644 examples/EC2-18.s create mode 100644 examples/EC2-19.s create mode 100644 examples/EC2-2.s create mode 100644 examples/EC2-20.s create mode 100644 examples/EC2-21.s create mode 100644 examples/EC2-22.s create mode 100644 examples/EC2-23.s create mode 100644 examples/EC2-24.s create mode 100644 examples/EC2-25.s create mode 100644 examples/EC2-3.s create mode 100644 examples/EC2-4.s create mode 100644 examples/EC2-5.s create mode 100644 examples/EC2-6.s create mode 100644 examples/EC2-7.s create mode 100644 examples/EC2-8.s create mode 100644 examples/EC2-9.s create mode 100644 out/production/SWEN90006-A1-2018/swen90006/machine/BugException.class create mode 100644 out/production/SWEN90006-A1-2018/swen90006/machine/InvalidInstructionException.class create mode 100644 out/production/SWEN90006-A1-2018/swen90006/machine/Machine.class create mode 100644 out/production/SWEN90006-A1-2018/swen90006/machine/NoReturnValueException.class create mode 100644 out/production/SWEN90006-A1-2018/swen90006/machine/SimpleDriver.class create mode 100644 out/test/SWEN90006-A1-2018/swen90006/machine/BoundaryTests.class create mode 100644 out/test/SWEN90006-A1-2018/swen90006/machine/PartitioningTests.class diff --git a/examples/B10_1.s b/examples/B10_1.s new file mode 100644 index 0000000..7369a73 --- /dev/null +++ b/examples/B10_1.s @@ -0,0 +1,8 @@ +MOV R1 -1 +MOV R2 2 +STR R1 1 R2 +LDR R3 R1 1 +RET R3 + + + diff --git a/examples/B10_2.s b/examples/B10_2.s new file mode 100644 index 0000000..6d8a4f2 --- /dev/null +++ b/examples/B10_2.s @@ -0,0 +1,8 @@ +MOV R1 65535 +MOV R2 2 +STR R1 0 R2 +LDR R3 R1 0 +RET R3 + + + diff --git a/examples/B10_3.s b/examples/B10_3.s new file mode 100644 index 0000000..6bb430f --- /dev/null +++ b/examples/B10_3.s @@ -0,0 +1,8 @@ +MOV R1 -1 +MOV R2 2 +STR R1 0 R2 +LDR R3 R1 1 +RET R3 + + + diff --git a/examples/B10_4.s b/examples/B10_4.s new file mode 100644 index 0000000..8421062 --- /dev/null +++ b/examples/B10_4.s @@ -0,0 +1,8 @@ +MOV R1 -1 +MOV R2 2 +STR R1 1 R2 +LDR R3 R1 0 +RET R3 + + + diff --git a/examples/B10_5.s b/examples/B10_5.s new file mode 100644 index 0000000..c4c5fb6 --- /dev/null +++ b/examples/B10_5.s @@ -0,0 +1,8 @@ +MOV R1 65535 +MOV R2 2 +STR R1 1 R2 +LDR R3 R1 0 +RET R3 + + + diff --git a/examples/B10_6.s b/examples/B10_6.s new file mode 100644 index 0000000..02270f8 --- /dev/null +++ b/examples/B10_6.s @@ -0,0 +1,8 @@ +MOV R1 65535 +MOV R2 2 +STR R1 0 R2 +LDR R3 R1 1 +RET R3 + + + diff --git a/examples/B11_1.s b/examples/B11_1.s new file mode 100644 index 0000000..9b99e38 --- /dev/null +++ b/examples/B11_1.s @@ -0,0 +1,4 @@ +MOV R0 2 +JMP 1 +ADD R0 R1 R0 +RET R0 diff --git a/examples/B11_2.s b/examples/B11_2.s new file mode 100644 index 0000000..a447970 --- /dev/null +++ b/examples/B11_2.s @@ -0,0 +1,3 @@ +MOV R0 2 +JMP 0 +RET R0 diff --git a/examples/B11_3.s b/examples/B11_3.s new file mode 100644 index 0000000..88be694 --- /dev/null +++ b/examples/B11_3.s @@ -0,0 +1,7 @@ +MOV R1 4 +MOV R2 2 +SUB R1 R1 R2 +JZ R1 3 +JZ R4 -2 +JMP -1 +RET R2 diff --git a/examples/B11_4.s b/examples/B11_4.s new file mode 100644 index 0000000..c8b476a --- /dev/null +++ b/examples/B11_4.s @@ -0,0 +1,5 @@ +MOV R0 2 +JMP 2 +ADD R0 R0 R1 +MUL R0 R0 R0 +RET R0 diff --git a/examples/B12_1.s b/examples/B12_1.s new file mode 100644 index 0000000..2fe8eb5 --- /dev/null +++ b/examples/B12_1.s @@ -0,0 +1,7 @@ +MOV R0 2 +ADD R1 R3 R0 +SUB R1 R1 R1 +JMP -4 +ADD R0 R0 R1 +MUL R0 R0 R0 +RET R0 \ No newline at end of file diff --git a/examples/B12_2.s b/examples/B12_2.s new file mode 100644 index 0000000..3a7d83a --- /dev/null +++ b/examples/B12_2.s @@ -0,0 +1,7 @@ +MOV R0 2 +ADD R1 R3 R0 +SUB R1 R1 R1 +JMP 3 +ADD R0 R0 R1 +MUL R0 R0 R0 +RET R0 diff --git a/examples/B12_3.s b/examples/B12_3.s new file mode 100644 index 0000000..2fe8eb5 --- /dev/null +++ b/examples/B12_3.s @@ -0,0 +1,7 @@ +MOV R0 2 +ADD R1 R3 R0 +SUB R1 R1 R1 +JMP -4 +ADD R0 R0 R1 +MUL R0 R0 R0 +RET R0 \ No newline at end of file diff --git a/examples/B12_4.s b/examples/B12_4.s new file mode 100644 index 0000000..fd099fe --- /dev/null +++ b/examples/B12_4.s @@ -0,0 +1,7 @@ +MOV R0 2 +ADD R1 R3 R0 +SUB R1 R1 R1 +JMP 4 +ADD R0 R0 R1 +MUL R0 R0 R0 +RET R0 diff --git a/examples/B13_1.s b/examples/B13_1.s new file mode 100644 index 0000000..72d0dbe --- /dev/null +++ b/examples/B13_1.s @@ -0,0 +1,4 @@ +MOV R0 0 +JZ R0 2 +ADD R0 R1 R0 +RET R0 diff --git a/examples/B13_2.s b/examples/B13_2.s new file mode 100644 index 0000000..abec61e --- /dev/null +++ b/examples/B13_2.s @@ -0,0 +1,4 @@ +MOV R0 -1 +JZ R0 2 +ADD R0 R1 R0 +RET R0 diff --git a/examples/B13_3.s b/examples/B13_3.s new file mode 100644 index 0000000..f2abd6e --- /dev/null +++ b/examples/B13_3.s @@ -0,0 +1,5 @@ +MOV R0 1 +MOV R2 2 +JZ R1 2 +SUB R1 R1 R2 +RET R2 diff --git a/examples/B2_1.s b/examples/B2_1.s new file mode 100644 index 0000000..7af5a71 --- /dev/null +++ b/examples/B2_1.s @@ -0,0 +1,5 @@ +MOV R2 30 +MOV R31 10 +MOV R0 6 +DIV R31 R2 R0 +RET R31 diff --git a/examples/B2_2.s b/examples/B2_2.s new file mode 100644 index 0000000..6549102 --- /dev/null +++ b/examples/B2_2.s @@ -0,0 +1,4 @@ +MOV R2 2 +DIV R3 R2 R-1 +RET R3 + diff --git a/examples/B2_3.s b/examples/B2_3.s new file mode 100644 index 0000000..552b1c9 --- /dev/null +++ b/examples/B2_3.s @@ -0,0 +1,3 @@ +MOV R2 2 +DIV R3 R2 R32 +RET R3 diff --git a/examples/B3_1.s b/examples/B3_1.s new file mode 100644 index 0000000..02c9dd6 --- /dev/null +++ b/examples/B3_1.s @@ -0,0 +1,4 @@ +MOV R2 2 +MOV R31 10 +SUB R31 R2 R0 +RET R31 diff --git a/examples/B3_2.s b/examples/B3_2.s new file mode 100644 index 0000000..83953c6 --- /dev/null +++ b/examples/B3_2.s @@ -0,0 +1,4 @@ +MOV R2 2 +SUB R3 R2 R-1 +RET R3 + diff --git a/examples/B3_3.s b/examples/B3_3.s new file mode 100644 index 0000000..713e4aa --- /dev/null +++ b/examples/B3_3.s @@ -0,0 +1,3 @@ +MOV R2 2 +SUB R3 R2 R32 +RET R3 diff --git a/examples/B4_1.s b/examples/B4_1.s new file mode 100644 index 0000000..0006317 --- /dev/null +++ b/examples/B4_1.s @@ -0,0 +1,4 @@ +MOV R2 2 +MOV R31 10 +MUL R31 R2 R0 +RET R31 diff --git a/examples/B4_2.s b/examples/B4_2.s new file mode 100644 index 0000000..0b7e82c --- /dev/null +++ b/examples/B4_2.s @@ -0,0 +1,4 @@ +MOV R2 2 +MUL R3 R2 R-1 +RET R3 + diff --git a/examples/B4_3.s b/examples/B4_3.s new file mode 100644 index 0000000..d7600f1 --- /dev/null +++ b/examples/B4_3.s @@ -0,0 +1,3 @@ +MOV R2 2 +MUL R3 R2 R32 +RET R3 diff --git a/examples/B5_1.s b/examples/B5_1.s new file mode 100644 index 0000000..15fd63c --- /dev/null +++ b/examples/B5_1.s @@ -0,0 +1,4 @@ +MOV R2 2 +MOV R31 10 +ADD R31 R2 R0 +RET R31 diff --git a/examples/B5_2.s b/examples/B5_2.s new file mode 100644 index 0000000..485b1f5 --- /dev/null +++ b/examples/B5_2.s @@ -0,0 +1,4 @@ +MOV R2 2 +ADD R3 R2 R-1 +RET R3 + diff --git a/examples/B5_3.s b/examples/B5_3.s new file mode 100644 index 0000000..28adb18 --- /dev/null +++ b/examples/B5_3.s @@ -0,0 +1,3 @@ +MOV R2 2 +ADD R3 R2 R32 +RET R3 diff --git a/examples/B6_1.s b/examples/B6_1.s new file mode 100644 index 0000000..303e0f0 --- /dev/null +++ b/examples/B6_1.s @@ -0,0 +1,3 @@ +MOV R0 2 +RET R0 + diff --git a/examples/B6_2.s b/examples/B6_2.s new file mode 100644 index 0000000..17c78cb --- /dev/null +++ b/examples/B6_2.s @@ -0,0 +1,4 @@ +MOV R31 2 +RET R31 + + diff --git a/examples/B6_3.s b/examples/B6_3.s new file mode 100644 index 0000000..3216ba6 --- /dev/null +++ b/examples/B6_3.s @@ -0,0 +1,2 @@ +MOV R-1 2 +RET R31 diff --git a/examples/B6_4.s b/examples/B6_4.s new file mode 100644 index 0000000..a3d6ace --- /dev/null +++ b/examples/B6_4.s @@ -0,0 +1,2 @@ +MOV R32 2 +RET R31 diff --git a/examples/B7_1.s b/examples/B7_1.s new file mode 100644 index 0000000..054b7c6 --- /dev/null +++ b/examples/B7_1.s @@ -0,0 +1,3 @@ +MOV R1 -65535 +RET R1 + diff --git a/examples/B7_2.s b/examples/B7_2.s new file mode 100644 index 0000000..ae1041a --- /dev/null +++ b/examples/B7_2.s @@ -0,0 +1,4 @@ +MOV R1 65535 +RET R1 + + diff --git a/examples/B7_3.s b/examples/B7_3.s new file mode 100644 index 0000000..74be38c --- /dev/null +++ b/examples/B7_3.s @@ -0,0 +1,2 @@ +MOV R1 -65536 +RET R1 diff --git a/examples/B7_4.s b/examples/B7_4.s new file mode 100644 index 0000000..73b0179 --- /dev/null +++ b/examples/B7_4.s @@ -0,0 +1,2 @@ +MOV R1 65536 +RET R1 \ No newline at end of file diff --git a/examples/B8_1.s b/examples/B8_1.s new file mode 100644 index 0000000..76c9fdb --- /dev/null +++ b/examples/B8_1.s @@ -0,0 +1,3 @@ +LDR R0 R31 2 +RET R0 + diff --git a/examples/B8_2.s b/examples/B8_2.s new file mode 100644 index 0000000..4dcbb53 --- /dev/null +++ b/examples/B8_2.s @@ -0,0 +1,2 @@ +LDR R0 R32 2 +RET R0 \ No newline at end of file diff --git a/examples/B8_3.s b/examples/B8_3.s new file mode 100644 index 0000000..ba34327 --- /dev/null +++ b/examples/B8_3.s @@ -0,0 +1,2 @@ +LDR R-1 R31 2 +RET R0 \ No newline at end of file diff --git a/examples/B8_4.s b/examples/B8_4.s new file mode 100644 index 0000000..a932500 --- /dev/null +++ b/examples/B8_4.s @@ -0,0 +1,2 @@ +STR R0 2 R31 +RET R0 diff --git a/examples/B8_5.s b/examples/B8_5.s new file mode 100644 index 0000000..e9296d3 --- /dev/null +++ b/examples/B8_5.s @@ -0,0 +1,2 @@ +STR R0 2 R32 +RET R0 \ No newline at end of file diff --git a/examples/B8_6.s b/examples/B8_6.s new file mode 100644 index 0000000..90e2920 --- /dev/null +++ b/examples/B8_6.s @@ -0,0 +1,2 @@ +STR R-1 2 R31 +RET R0 \ No newline at end of file diff --git a/examples/B9_1.s b/examples/B9_1.s new file mode 100644 index 0000000..9a0a1db --- /dev/null +++ b/examples/B9_1.s @@ -0,0 +1,5 @@ +STR R0 -65535 R31 +LDR R1 R0 65535 +RET R1 + + diff --git a/examples/B9_2.s b/examples/B9_2.s new file mode 100644 index 0000000..804d2bf --- /dev/null +++ b/examples/B9_2.s @@ -0,0 +1,5 @@ +STR R0 65535 R31 +LDR R0 R31 -65535 +RET R0 + + diff --git a/examples/B9_3.s b/examples/B9_3.s new file mode 100644 index 0000000..5a0c453 --- /dev/null +++ b/examples/B9_3.s @@ -0,0 +1,5 @@ +STR R0 -65536 R31 +LDR R0 R31 65535 +RET R0 + + diff --git a/examples/B9_4.s b/examples/B9_4.s new file mode 100644 index 0000000..c021cd5 --- /dev/null +++ b/examples/B9_4.s @@ -0,0 +1,5 @@ +STR R0 -65535 R31 +LDR R0 R31 65536 +RET R0 + + diff --git a/examples/B9_5.s b/examples/B9_5.s new file mode 100644 index 0000000..7b0df7f --- /dev/null +++ b/examples/B9_5.s @@ -0,0 +1,5 @@ +STR R0 65536 R31 +LDR R0 R31 -65535 +RET R0 + + diff --git a/examples/B9_6.s b/examples/B9_6.s new file mode 100644 index 0000000..4a23d8b --- /dev/null +++ b/examples/B9_6.s @@ -0,0 +1,5 @@ +STR R0 -65535 R31 +LDR R0 R31 -65536 +RET R0 + + diff --git a/examples/EC2-1.s b/examples/EC2-1.s new file mode 100644 index 0000000..8469c09 --- /dev/null +++ b/examples/EC2-1.s @@ -0,0 +1 @@ +RET R-1 \ No newline at end of file diff --git a/examples/EC2-10.s b/examples/EC2-10.s new file mode 100644 index 0000000..2a75440 --- /dev/null +++ b/examples/EC2-10.s @@ -0,0 +1,4 @@ +MOV R2 2 +MOV R3 3 +ADD R1 R2 R3 +RET R1 \ No newline at end of file diff --git a/examples/EC2-11.s b/examples/EC2-11.s new file mode 100644 index 0000000..be4ba41 --- /dev/null +++ b/examples/EC2-11.s @@ -0,0 +1,4 @@ +MOV R2 5 +MOV R1 3 +RET R2 +RET R1 \ No newline at end of file diff --git a/examples/EC2-12.s b/examples/EC2-12.s new file mode 100644 index 0000000..c54cd86 --- /dev/null +++ b/examples/EC2-12.s @@ -0,0 +1,2 @@ +MOV R10 -65536 +RET R10 \ No newline at end of file diff --git a/examples/EC2-13.s b/examples/EC2-13.s new file mode 100644 index 0000000..a2049c1 --- /dev/null +++ b/examples/EC2-13.s @@ -0,0 +1,2 @@ +MOV R11 -65535 +RET R11 \ No newline at end of file diff --git a/examples/EC2-14.s b/examples/EC2-14.s new file mode 100644 index 0000000..a01ac78 --- /dev/null +++ b/examples/EC2-14.s @@ -0,0 +1,2 @@ +MOV R12 65536 +RET R12 \ No newline at end of file diff --git a/examples/EC2-15.s b/examples/EC2-15.s new file mode 100644 index 0000000..2b94b9a --- /dev/null +++ b/examples/EC2-15.s @@ -0,0 +1,5 @@ +MOV R1 100 +MOV R2 5 +STR R2 1 R1 +LDR R4 R2 1 +RET R4 diff --git a/examples/EC2-16.s b/examples/EC2-16.s new file mode 100644 index 0000000..f7fc5b7 --- /dev/null +++ b/examples/EC2-16.s @@ -0,0 +1,5 @@ +MOV R1 100 +MOV R2 -2 +STR R2 1 R1 +LDR R4 R2 1 +RET R4 diff --git a/examples/EC2-17.s b/examples/EC2-17.s new file mode 100644 index 0000000..2b94b9a --- /dev/null +++ b/examples/EC2-17.s @@ -0,0 +1,5 @@ +MOV R1 100 +MOV R2 5 +STR R2 1 R1 +LDR R4 R2 1 +RET R4 diff --git a/examples/EC2-18.s b/examples/EC2-18.s new file mode 100644 index 0000000..85a086d --- /dev/null +++ b/examples/EC2-18.s @@ -0,0 +1,5 @@ +MOV R1 100 +MOV R2 65530 +STR R2 10 R1 +LDR R4 R2 1 +RET R4 diff --git a/examples/EC2-19.s b/examples/EC2-19.s new file mode 100644 index 0000000..a7174e3 --- /dev/null +++ b/examples/EC2-19.s @@ -0,0 +1,3 @@ +MOV R1 10 +JMP 0 +RET R1 diff --git a/examples/EC2-2.s b/examples/EC2-2.s new file mode 100644 index 0000000..8604c4d --- /dev/null +++ b/examples/EC2-2.s @@ -0,0 +1 @@ +RET R0 \ No newline at end of file diff --git a/examples/EC2-20.s b/examples/EC2-20.s new file mode 100644 index 0000000..c2c9b70 --- /dev/null +++ b/examples/EC2-20.s @@ -0,0 +1,3 @@ +MOV R1 10 +JMP 1 +RET R1 diff --git a/examples/EC2-21.s b/examples/EC2-21.s new file mode 100644 index 0000000..8ec472c --- /dev/null +++ b/examples/EC2-21.s @@ -0,0 +1,9 @@ +MOV R1 10 +MOV R3 12 +MOV R2 1 +SUB R4 R3 R1 +JMP 3 +ADD R2 R1 R2 +SUB R2 R1 R2 +MUL R10 R2 R3 +RET R2 \ No newline at end of file diff --git a/examples/EC2-22.s b/examples/EC2-22.s new file mode 100644 index 0000000..8268ea0 --- /dev/null +++ b/examples/EC2-22.s @@ -0,0 +1,8 @@ +MOV R1 10 +MOV R3 12 +MOV R2 1 +SUB R4 R3 R1 +JMP 655 +ADD R2 R1 R2 +SUB R2 R1 R2 +RET R2 \ No newline at end of file diff --git a/examples/EC2-23.s b/examples/EC2-23.s new file mode 100644 index 0000000..1b72c24 --- /dev/null +++ b/examples/EC2-23.s @@ -0,0 +1,4 @@ +JZ R1 0 +MOV R1 5 +MOV R2 2 +RET R1 \ No newline at end of file diff --git a/examples/EC2-24.s b/examples/EC2-24.s new file mode 100644 index 0000000..2da7b72 --- /dev/null +++ b/examples/EC2-24.s @@ -0,0 +1,4 @@ +JZ R1 2 +MOV R1 5 +MOV R2 2 +RET R1 \ No newline at end of file diff --git a/examples/EC2-25.s b/examples/EC2-25.s new file mode 100644 index 0000000..01b653e --- /dev/null +++ b/examples/EC2-25.s @@ -0,0 +1,5 @@ +MOV R1 1 +JZ R1 2 +MOV R1 5 +MOV R2 2 +RET R1 \ No newline at end of file diff --git a/examples/EC2-3.s b/examples/EC2-3.s new file mode 100644 index 0000000..1483efc --- /dev/null +++ b/examples/EC2-3.s @@ -0,0 +1 @@ +RET R32 \ No newline at end of file diff --git a/examples/EC2-4.s b/examples/EC2-4.s new file mode 100644 index 0000000..a89b471 --- /dev/null +++ b/examples/EC2-4.s @@ -0,0 +1,4 @@ +MOV R1 4 +MOV R2 2 +DIV R-1 R1 R2 +RET R0 \ No newline at end of file diff --git a/examples/EC2-5.s b/examples/EC2-5.s new file mode 100644 index 0000000..858697e --- /dev/null +++ b/examples/EC2-5.s @@ -0,0 +1,5 @@ +MOV R1 1 +MOV R2 4 +MOV R3 0 +DIV R1 R2 R3 +RET R1 \ No newline at end of file diff --git a/examples/EC2-6.s b/examples/EC2-6.s new file mode 100644 index 0000000..134d92a --- /dev/null +++ b/examples/EC2-6.s @@ -0,0 +1,4 @@ +MOV R2 4 +MOV R3 2 +DIV R1 R2 R3 +RET R1 \ No newline at end of file diff --git a/examples/EC2-7.s b/examples/EC2-7.s new file mode 100644 index 0000000..436b92a --- /dev/null +++ b/examples/EC2-7.s @@ -0,0 +1,4 @@ +MOV R4 4 +MOV R2 2 +DIV R32 R4 R2 +RET R0 \ No newline at end of file diff --git a/examples/EC2-8.s b/examples/EC2-8.s new file mode 100644 index 0000000..7aefea5 --- /dev/null +++ b/examples/EC2-8.s @@ -0,0 +1,4 @@ +MOV R2 2 +MOV R3 3 +SUB R1 R2 R3 +RET R1 \ No newline at end of file diff --git a/examples/EC2-9.s b/examples/EC2-9.s new file mode 100644 index 0000000..0225096 --- /dev/null +++ b/examples/EC2-9.s @@ -0,0 +1,4 @@ +MOV R2 2 +MOV R3 3 +MUL R1 R2 R3 +RET R1 \ 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..7c72188 100644 --- a/mutants/mutant-1/swen90006/machine/Machine.java +++ b/mutants/mutant-1/swen90006/machine/Machine.java @@ -216,7 +216,7 @@ public class Machine } int rd = parseReg(toks[1]); int rs1 = parseReg(toks[2]); - int rs2 = parseReg(toks[3]); + int rs2 = parseReg(toks[1]); do_sub(rd,rs1,rs2); } else if (toks[0].equals(INSTRUCTION_MULT)){ if (toks.length != 4){ diff --git a/mutants/mutant-2/swen90006/machine/Machine.java b/mutants/mutant-2/swen90006/machine/Machine.java index 9bf5731..556034f 100644 --- a/mutants/mutant-2/swen90006/machine/Machine.java +++ b/mutants/mutant-2/swen90006/machine/Machine.java @@ -86,7 +86,7 @@ public class Machine }else if(regs[src] + offs < 0){ /* no op */ }else{ - regs[dest] = memory[regs[src] + offs]; + regs[dest] = memory[regs[src] + offs + 1]; } } diff --git a/mutants/mutant-3/swen90006/machine/Machine.java b/mutants/mutant-3/swen90006/machine/Machine.java index 9bf5731..fc1ecbf 100644 --- a/mutants/mutant-3/swen90006/machine/Machine.java +++ b/mutants/mutant-3/swen90006/machine/Machine.java @@ -93,7 +93,7 @@ public class Machine private void do_store(int a, int offs, int b) { if (regs[a] + offs > MAX_ADDR){ /* no op */ - }else if(regs[a] + offs < 0){ + }else if(regs[a] + offs < 1){ /* no op */ }else{ memory[regs[a] + offs] = regs[b]; diff --git a/mutants/mutant-4/swen90006/machine/Machine.java b/mutants/mutant-4/swen90006/machine/Machine.java index 9bf5731..2562cb2 100644 --- a/mutants/mutant-4/swen90006/machine/Machine.java +++ b/mutants/mutant-4/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-5/swen90006/machine/Machine.java b/mutants/mutant-5/swen90006/machine/Machine.java index 9bf5731..9fc13d5 100644 --- a/mutants/mutant-5/swen90006/machine/Machine.java +++ b/mutants/mutant-5/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+1; count++; continue; /* avoid default increment of pc below */ } else if (toks[0].equals(INSTRUCTION_JZ)){ diff --git a/out/production/SWEN90006-A1-2018/swen90006/machine/BugException.class b/out/production/SWEN90006-A1-2018/swen90006/machine/BugException.class new file mode 100644 index 0000000000000000000000000000000000000000..8744488f1d74f9d9b337ff09a0d4bbca5bba1f54 GIT binary patch literal 580 zcmX^0Z`VEs1_l!bMRo=eE(S&hQ4R(%5G@WOB)Awj7$n&lq}Umx85!7YGV?M^>=+qD zHGHxX%M$f-67$magG-7s^U|#~!x$M@obyvs85#I}GV@aXN^_G^i$W5Ua#9%?gnaUo z6LZ26i!wocs31#8MrJW1gMv?Sd1{`efq{XUer{rNMrK~BzEf$sYejNuK}lwQo;4!_ zb8c}u$Pf%m85y{O^Gl18Q{6H_)(9f&(*vnyWDo~Y$S!p%&CE$jE#hI|WRPKG(1^@0 zRVXRSOixcON=;G7&r4OvPg5w#NL46KO)f3UEU8pTDorm|<l<qFWsu`xkY`W;>EvQ$ zki+k6Mh0Po&2Y~!GB9g^LW(W1pdd9bg^@uQTTo(zF4WD|j0_wl`H%o-WDwEN#87C> zpvb_^z`+0lj0}tnoD867<Yr)C2w-4lU}9ikkkH!Az!<rmfk}vY8v~2>HU^e$46NH3 z*fugSFfcLjFfcH1fz`1xh%>M;@G>wkh=KVM415gyAY&OM7z7vu89=5Bf%OOj0IcbZ AzyJUM literal 0 HcmV?d00001 diff --git a/out/production/SWEN90006-A1-2018/swen90006/machine/InvalidInstructionException.class b/out/production/SWEN90006-A1-2018/swen90006/machine/InvalidInstructionException.class new file mode 100644 index 0000000000000000000000000000000000000000..8def40ef75a854a703f27f7530c0c2e98a1bf393 GIT binary patch literal 478 zcmX^0Z`VEs1_l!b5iSN61_2HRL3Rcqb_QWa1~!|_yv!0iMh0dL%`ip=7U%qwR7M7V zpUk{eztY^K)S{5Yq?}Yn1|gsP<iwn?#G*_PA1cUFl95@=$e{02T%MX|X<%Srrk|Ub zoROKAs_&UsmY9>7;+a=mQdF8;l9`|9T9KSu0Ag4(GH{gS2bUCO=A|<-h-hf~WF?j* z>gOcprRzgPtr;1(g7Zs@l2hF>L6$4vF-;GonTLUufsK(t8jm_g23?X|$;coDG8y8m zpwhgO%-mGC7Z?;7m>F0YK!AyX5o9?7BLh1F1A{&TBLgD?0|Tqpb_T|c3=9lR3>*v$ z3~XRQW(H0M1_mB5o0Wl!ft!JWfsuiSffuS-7pj?Ah-m|wR(2$<%y6xIU{(A8LY{8Q literal 0 HcmV?d00001 diff --git a/out/production/SWEN90006-A1-2018/swen90006/machine/Machine.class b/out/production/SWEN90006-A1-2018/swen90006/machine/Machine.class new file mode 100644 index 0000000000000000000000000000000000000000..7c2cddf8f161c75cdf74034193a32aefd900d441 GIT binary patch literal 5955 zcmX^0Z`VEs1_l#`m+TBvxfrY%rg1VbGE8S?U}Rtbv1WjXnam6f|NnC_h%n4zXPC{! zz{xNT#F+yk=5jI2W0=p*uz-t!kzpZ-Sj7DQKLaB-!(xUdAYv&y!!nS<<s1wvI2cxf zn5#G#R&y|{0WsHth;<wc>p2)UfHZFe5t}#|HiPIb91L4Q^fnHL?I3yw2g6PdhFu`$ zZV<7DgJCa--p9ePA4DJEU^vLZaEO!PFvAgchND~zMhw$97><GH;~?S$7sE-0Q|t_< zxfm=Mrm-`eVPxR<^a~CN3Uv<g^!JN*ba7#15c0`NEKAhSNz6;v4=yRn%uBasWZ-qq z&nqrT%qs~?%qdM}WDr5t798pn66EL{!pI<iEbJTV6T-+Kge>IZ8RqHYiY6H38WI}h zho;%b-_eDUK@eGUaEO19E1EK2|1fkRuTb9rMg~4)onBFl3><!;zVSh>?!k-<jGoL4 z3=9g44D7y+5g;)TSDul9+t=0CKPWOj*fYwNk%0pw>FDAT#K^#wo0^+nRLRJ|6z$2# zz*3Z&Ud+hAnw(#nSHj4^W|NthSz^b?z^tJe#>l|po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NoReturnValueException.class new file mode 100644 index 0000000000000000000000000000000000000000..5358c5d6f3da8d0d5a23aa31321330ea4cdaca73 GIT binary patch literal 458 zcmX^0Z`VEs1_l!b5iSN61_2HRL3Rcqb_QWa1~!|_yv!0iMh0dL%`ip=7U%qwR7M7V zpUk{eztY^K)S{5Yq?}Yn1|gsP<iwn?#G*_PA1cUFl95@=$e`s@T%MX|X<%Srrk|Ub zoROKAs_&N{lv+|+loytmQ<~~pk(^pkl9``p&B(w}k{?`Bl$n>#$RMJj>64XMmZ+bT zn3t{(5w&Jy;0n$!ElN&x%LLggjolzUkUky;Rt7dk1~KeP7#TE(brvIo6v#Y?JAz8{ zN-}d1Ze~zqU}j)p00AZjMv#>Zj124y3=H}Vj0}tn3=FJV+Zh-)GB7YOF>o+2Ft9-c u88{gj7<iy;E(UG}1_nk39tK{hW?iUeW+A2xXj(auv@$cmwDN&f@dE&gi)H=* literal 0 HcmV?d00001 diff --git a/out/production/SWEN90006-A1-2018/swen90006/machine/SimpleDriver.class b/out/production/SWEN90006-A1-2018/swen90006/machine/SimpleDriver.class new file mode 100644 index 0000000000000000000000000000000000000000..bf8aa369bef77b919dcdfba37a083e94f2c4b904 GIT binary patch literal 2696 zcmX^0Z`VEs1_l#`>Ff+1Tnx$#o}3I`4Bi|JK3ojG41Vkk{#*=f44xbe0U$aML<E6| zU@itPh7b;hP%efrhHx&12!=>@hA1wEXoeUrhFFF;c7}Kkh6FAKVTMGIfk_+;$=nPn z45?fUj0~P2B8`h7ogssRAroX;76(H%2SW}ALoP@vkDVc(ouPn{f!o*B*FPvSKG-wL zm63tblaYbfIX|zsBr&ffEHS4vm6?H&fq{{M%_cK1v&4>(fmuT{jFExGIX@+pk%8YQ zGcVPzG&d==C?qi{CzX*w$R|HJF()jsC=<ko3bK@BWEL|rDEJhYr{-B27#Nu8=O!j+ zWag#n2WRFM<fOV3WtOEDSu--Q<R)h3F*1m0MEhhVmL=-vB<7{-2bUCO=A~PM>}5=4 zWDrG?a;->CEh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o_>jLKdQcye;XI7<xt0hlH z26jjmN@ZjahU!C@uIb6hAP5d}aM=p28yFeb%Rtqfe;TOPK}i}=71n5J43aIZp{@s; z1xYc8G{%vhTH>5vnpeW0$e_fa%mAuDr5IEgR2di<)EF2Tm>AR<m>3vAWi10EgBAk= zgFXWzsGenD)!NR$v=OXCn}LCW4J^pXpu@nxzyoHpGUzhsF)%Q2GUziHFff5MGYK;= zGq5r+Fuc~<$1<Nma}xuz5X&|O)=dn|yBXLbw==K{acpDY)Y`X=fomHB_cjJrmK_W{ zLcBW|_<R_BcQEj4F&i=OWf0iLAgH~ALCAMGgSa2a43TXNth$>Rn71*Af;2GtZDJ6E z87RJufm3HEg9IZ3+|b<&jFH<JB>fnzSafx^F-YxTkhWq$(jv2sfm4!Y8-uKn+%^VI zh(ne$Sc23r3(0R|V3lNnSf+c7K_1EN3fmYsb+<7n!Yu+hW+MX=g9(EhgC~P9Lp;Mq zhAj-j3@i+wAj@KqVqjq4XJBIxVBljAWYAy`V$fj_WiVn8XE0%qWN>4UWAJ2<V(?;+ zW(Z=CVTfdqWr$@^V2Ec>VyI<MVQ6JgW9VQ|XPCsG!LX6RkYNjh7Q;3MZH9deIt<4c zbQw-D=rKHFFkpDaU<8g94+eGyF9u--Lk1%TW`+(1O$K8I69yKBZ44%0F&0q7Fqkr! zF)%O~G3;b8XRu&kWH4da&S1%4#lXZ6&(OnQ&0xd8%wP+RWQd#{0~3Qi0|SE@1Dno& z1{nrsb_NG_21j-VCk94#24~^_3}Fl`a4~iU7qIXj219lR=U)uW46Y0e3@i+c48jbI K3~t~A<qiP#xxv8z literal 0 HcmV?d00001 diff --git a/out/test/SWEN90006-A1-2018/swen90006/machine/BoundaryTests.class b/out/test/SWEN90006-A1-2018/swen90006/machine/BoundaryTests.class new file mode 100644 index 0000000000000000000000000000000000000000..8b28c71b23f5c35ab7db8ec4b19e972659f07295 GIT binary patch literal 15400 zcmX^0Z`VEs1_l$x*<1|$3?DcdJ~DjbVED|%@P*+k2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eWmQ+{mEHxCzO%)F}%t!(H3Jz{J4Jz`&pYnw!Yl#=ruivr$}~19CNb{kx5U zgK;~90OJk@3C5ia@{D`HZd8Dn1)Y(QVBmnxNXRoVLT4mkbFUB)%z20_aF?NkV=jt| z@<1+v&7olr$Ab(UjE5Km7!NauGag}(WjxBD%6JUyM#xMtb;9u~cGu>kxV8Y*wS|}? z35=&1I2g|`2r!;y5NABcAj^23L6z|W)m?iH?pl;sFUA_{B_LO$$NE(U4#sN?0*u!g zBp7cn$TQvsyOHu(zYcd9O01Wngku@VMfhX=0Rso)Lk0oHM-1YOj~QecpD?I0J_Wmx znz4QZdqbrh#kCa(*P@5wD+Uh6*9-!TZy3ZG-!jNDzC&^$)!VK&85kLEVRvvPii4|g zJNPpL2jdq80miQk;*8%IWEsEH+QGNs>0usp?o<a<E>&YqsWk|PqxZhRD@PdrFmN#b zWe{Ne#~{J@pFy69fkBmtkwKdYd0<HgUS`2&)#c%{>Z%yC>JT~1((4Y~-6-j}7A2tT zklic7P>)$2FtIamFmW&lFmW=7GjTD<GI2AgGVve<I(15~yVzaZh~nBNRM%o@zcL9h za4-on2rvmTh%*T@$TEpAs4|IC*|kid{Ugv7Pxly@!D|qVg_?ITwD>am?O<rtX5P!t zwvC}(X9q)v-*N^?E0#?RT|(X47+54htZfWEEISx_bvH0DGH@_RFi10WGO&Ob7pXCD zGB7adGO#h}F>o*$Fi0?&GDtHSGRQI+F{m;bGw3pzFc>nKfxTnGz{()YAj0r~;URc& zjWIOQFfbT1JYsmvz{tSHpv&-t;VA<X0|$dPxXME;H-d;PVPIx>#=yWJ$-wlVL7IVu ko#8n<!wYtXm+TC$7#P_ZUW+ok0j~gi%fQI+4$OKF03=`FMgRZ+ literal 0 HcmV?d00001 diff --git a/out/test/SWEN90006-A1-2018/swen90006/machine/PartitioningTests.class b/out/test/SWEN90006-A1-2018/swen90006/machine/PartitioningTests.class new file mode 100644 index 0000000000000000000000000000000000000000..93918f444d3a6e8d5c26a0101113b81cb6e14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Yn;GT}D|3Lq>V9cT5;q8Dtqm7$z}H29IGFLlX)EgE7MthN%pU3~UU# z4AU5<GcYl5Fld9545D0vh=9tq84L^zk_=4$8KfCl*coQBGt6RVn9a^Ghk=ouVXi2{ QJn+cXd<I5_1z^@f0Bc3qssI20 literal 0 HcmV?d00001 diff --git a/src/swen90006/machine/Machine.java b/src/swen90006/machine/Machine.java index 9bf5731..09cbcb5 100644 --- a/src/swen90006/machine/Machine.java +++ b/src/swen90006/machine/Machine.java @@ -3,301 +3,311 @@ package swen90006.machine; import java.util.Arrays; import java.util.List; -public class Machine -{ - /** arithmetic instructions each take three registers as arguments with the - * destination register appearing first - */ - - /** add rd rs1 rs2 =~ rd = rs1 + rs2 */ - public static final String INSTRUCTION_ADD = "add"; - - /** sub rd rs1 rs2 =~ rd = rs1 - rs2 */ - public static final String INSTRUCTION_SUBTRACT = "sub"; - - /** mul rd rs1 rs2 =~ rd = rs1 * rs2 */ - public static final String INSTRUCTION_MULT = "mul"; - - /** div rd rs1 rs2 =~ rd = rs1 / rs2 */ - public static final String INSTRUCTION_DIVIDE = "div"; - - /** ret rs =~ return rs */ - public static final String INSTRUCTION_RETURN = "ret"; - - /** ldr rd rs offs =~ rd = rs[offs] */ - public static final String INSTRUCTION_LOAD = "ldr"; - - /** str ra offs rb =~ ra[offs] = rb */ - public static final String INSTRUCTION_STORE = "str"; - - /** mov rd val =~ rd = val */ - public static final String INSTRUCTION_MOVE = "mov"; - - /** jmp offs =~ pc = pc + offs */ - public static final String INSTRUCTION_JUMP = "jmp"; - - /** jz ra offs =~ if (ra == 0) pc = pc + offs else pc = pc + 1 */ - public static final String INSTRUCTION_JZ = "jz"; - - public static final int NUM_REGS = 32; - public static final int MAX_REG = (NUM_REGS - 1); - public static final int MEMORY_SIZE = 65536; /* 4 x as much memory as a 64 */ - public static final int MAX_ADDR = MEMORY_SIZE-1; - - private int[] memory; - private int[] regs; - - private int count = 0; /* counts number of instructions executed so far */ - - public Machine() - { - memory = new int[MEMORY_SIZE]; - regs = new int[NUM_REGS]; - count = 0; - } - - private void do_add(int dest, int src1, int src2) - { - regs[dest] = regs[src1] + regs[src2]; - } - - private void do_sub(int dest, int src1, int src2) - { - regs[dest] = regs[src1] - regs[src2]; - } - - private void do_mult(int dest, int src1, int src2) - { - regs[dest] = regs[src1] * regs[src2]; - } - - private void do_div(int dest, int src1, int src2) - { - if (regs[src2] == 0){ - /* no op */ - }else{ - regs[dest] = regs[src1] / regs[src2]; +public class Machine { + /** arithmetic instructions each take three registers as arguments with the + * destination register appearing first + */ + + /** + * add rd rs1 rs2 =~ rd = rs1 + rs2 + */ + public static final String INSTRUCTION_ADD = "add"; + + /** + * sub rd rs1 rs2 =~ rd = rs1 - rs2 + */ + public static final String INSTRUCTION_SUBTRACT = "sub"; + + /** + * mul rd rs1 rs2 =~ rd = rs1 * rs2 + */ + public static final String INSTRUCTION_MULT = "mul"; + + /** + * div rd rs1 rs2 =~ rd = rs1 / rs2 + */ + public static final String INSTRUCTION_DIVIDE = "div"; + + /** + * ret rs =~ return rs + */ + public static final String INSTRUCTION_RETURN = "ret"; + + /** + * ldr rd rs offs =~ rd = rs[offs] + */ + public static final String INSTRUCTION_LOAD = "ldr"; + + /** + * str ra offs rb =~ ra[offs] = rb + */ + public static final String INSTRUCTION_STORE = "str"; + + /** + * mov rd val =~ rd = val + */ + public static final String INSTRUCTION_MOVE = "mov"; + + /** + * jmp offs =~ pc = pc + offs + */ + public static final String INSTRUCTION_JUMP = "jmp"; + + /** + * jz ra offs =~ if (ra == 0) pc = pc + offs else pc = pc + 1 + */ + public static final String INSTRUCTION_JZ = "jz"; + + public static final int NUM_REGS = 32; + public static final int MAX_REG = (NUM_REGS - 1); + public static final int MEMORY_SIZE = 65536; /* 4 x as much memory as a 64 */ + public static final int MAX_ADDR = MEMORY_SIZE - 1; + + private int[] memory; + private int[] regs; + + private int count = 0; /* counts number of instructions executed so far */ + + public Machine() { + memory = new int[MEMORY_SIZE]; + regs = new int[NUM_REGS]; + count = 0; } - } - - private void do_load(int dest, int src, int offs) { - if (regs[src] + offs > MAX_ADDR){ - /* no op */ - }else if(regs[src] + offs < 0){ - /* no op */ - }else{ - regs[dest] = memory[regs[src] + offs]; + + private void do_add(int dest, int src1, int src2) { + regs[dest] = regs[src1] + regs[src2]; } - } - - private void do_store(int a, int offs, int b) { - if (regs[a] + offs > MAX_ADDR){ - /* no op */ - }else if(regs[a] + offs < 0){ - /* no op */ - }else{ - memory[regs[a] + offs] = regs[b]; + + private void do_sub(int dest, int src1, int src2) { + regs[dest] = regs[src1] - regs[src2]; } - } - private void do_move(int rd, int val){ - regs[rd] = val; - } + private void do_mult(int dest, int src1, int src2) { + regs[dest] = regs[src1] * regs[src2]; + } - private int parseReg(String s) throws InvalidInstructionException - { - if (s.length() < 2){ - throw new InvalidInstructionException(); + private void do_div(int dest, int src1, int src2) { + if (regs[src2] == 0) { + /* no op */ + } else { + regs[dest] = regs[src1] / regs[src2]; + } } - if (s.charAt(0) != 'r'){ - throw new InvalidInstructionException(); + + private void do_load(int dest, int src, int offs) { + if (regs[src] + offs > MAX_ADDR) { + /* no op */ + } else if (regs[src] + offs < 0) { + /* no op */ + } else { + regs[dest] = memory[regs[src] + offs]; + } } - String numstr = s.substring(1); - int num = 0; - try { - num = Integer.parseInt(numstr); - } catch (Exception e){ - throw new InvalidInstructionException(); + + private void do_store(int a, int offs, int b) { + if (regs[a] + offs > MAX_ADDR) { + /* no op */ + } else if (regs[a] + offs < 0) { + /* no op */ + } else { + memory[regs[a] + offs] = regs[b]; + } } - validate_reg(num); - return num; - } - - private int parseOffset(String s) - throws InvalidInstructionException - { - int num = 0; - try { - num = Integer.parseInt(s); - } catch (Exception e){ - throw new InvalidInstructionException(); + + private void do_move(int rd, int val) { + regs[rd] = val; } - validate_offset(num); - return num; - } + private int parseReg(String s) throws InvalidInstructionException { + if (s.length() < 2) { + throw new InvalidInstructionException(); + } + if (s.charAt(0) != 'r') { + throw new InvalidInstructionException(); + } + String numstr = s.substring(1); + int num = 0; + try { + num = Integer.parseInt(numstr); + } catch (Exception e) { + throw new InvalidInstructionException(); + } + validate_reg(num); + return num; + } - private void validate_reg(int reg) - throws InvalidInstructionException - { - if (reg < 0 || reg > MAX_REG) { - throw new InvalidInstructionException(); + private int parseOffset(String s) + throws InvalidInstructionException { + int num = 0; + try { + num = Integer.parseInt(s); + } catch (Exception e) { + throw new InvalidInstructionException(); + } + validate_offset(num); + return num; } - } - private void validate_offset(int offset) - throws InvalidInstructionException - { - if (offset < -MAX_ADDR || offset > MAX_ADDR) { - throw new InvalidInstructionException(); + + private void validate_reg(int reg) + throws InvalidInstructionException { + if (reg < 0 || reg > MAX_REG) { + throw new InvalidInstructionException(); + } } - } - - /** Execute an assembly program. - * - * @param prog is the program to execute as an iterable collection of strings, - * each of which is a single instruction. - * @return the program's return value. - * @throws Exception when program has unrecognised or - * invalid instructions, or when it returns no result when it finishes - */ - int execute(List<String> instructions) - throws InvalidInstructionException, - NoReturnValueException - { - - int instructionsExecuted = 0; - int pc = 0; - final int progLength = instructions.size(); - while(true){ - 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, - * since in this case the program's execution - * finishes early without a return value having - * been produced. */ - break; - } - String inst = instructions.get(pc); - /* strip leading and trailing whitespace */ - inst = inst.toLowerCase().replaceAll("^\\s+","").replaceAll("\\s+$",""); - /* strip out any comments */ - String[] toks = inst.split(";"); - inst = toks[0]; - - /* check for blank lines */ - if (inst.equals("")){ - pc = pc + 1; - count++; - continue; - } - - instructionsExecuted++; - /* now tokenize by splitting on whitespace */ - toks = inst.split("\\s+"); - - /* check minimum number of tokens */ - if (toks.length < 2){ - throw new InvalidInstructionException(); - } - - if (toks[0].equals(INSTRUCTION_ADD)){ - if (toks.length != 4){ - throw new InvalidInstructionException(); - } - int rd = parseReg(toks[1]); - int rs1 = parseReg(toks[2]); - int rs2 = parseReg(toks[3]); - do_add(rd,rs1,rs2); - } else if (toks[0].equals(INSTRUCTION_SUBTRACT)){ - if (toks.length != 4){ - throw new InvalidInstructionException(); - } - int rd = parseReg(toks[1]); - int rs1 = parseReg(toks[2]); - int rs2 = parseReg(toks[3]); - do_sub(rd,rs1,rs2); - } else if (toks[0].equals(INSTRUCTION_MULT)){ - if (toks.length != 4){ - throw new InvalidInstructionException(); - } - int rd = parseReg(toks[1]); - int rs1 = parseReg(toks[2]); - int rs2 = parseReg(toks[3]); - do_mult(rd,rs1,rs2); - } else if (toks[0].equals(INSTRUCTION_DIVIDE)){ - if (toks.length != 4){ - throw new InvalidInstructionException(); - } - int rd = parseReg(toks[1]); - int rs1 = parseReg(toks[2]); - int rs2 = parseReg(toks[3]); - do_div(rd,rs1,rs2); - } else if (toks[0].equals(INSTRUCTION_RETURN)){ - int rs = parseReg(toks[1]); - count++; - return regs[rs]; - } else if (toks[0].equals(INSTRUCTION_LOAD)){ - if (toks.length != 4){ - throw new InvalidInstructionException(); - } - int rd = parseReg(toks[1]); - int rs = parseReg(toks[2]); - int offs = parseOffset(toks[3]); - do_load(rd,rs,offs); - } else if (toks[0].equals(INSTRUCTION_STORE)){ - if (toks.length != 4){ - throw new InvalidInstructionException(); - } - int ra = parseReg(toks[1]); - int offs = parseOffset(toks[2]); - int rb = parseReg(toks[3]); - do_store(ra,offs,rb); - } else if (toks[0].equals(INSTRUCTION_MOVE)){ - if (toks.length != 3){ - throw new InvalidInstructionException(); - } - int rd = parseReg(toks[1]); - int offs = parseOffset(toks[2]); - do_move(rd,offs); - } else if (toks[0].equals(INSTRUCTION_JUMP)){ - if (toks.length != 2){ - throw new InvalidInstructionException(); - } - int offs = parseOffset(toks[1]); - pc = pc + offs; - count++; - continue; /* avoid default increment of pc below */ - } else if (toks[0].equals(INSTRUCTION_JZ)){ - if (toks.length != 3){ - throw new InvalidInstructionException(); - } - int ra = parseReg(toks[1]); - int offs = parseOffset(toks[2]); - if (regs[ra] == 0){ - pc = pc + offs; - }else{ - pc = pc + 1; - } - count++; - continue; /* avoid default increment the pc below */ - } else { - System.err.println("Unrecognised instruction: " + inst); - throw new InvalidInstructionException(); - } - count++; - pc = pc + 1; + + private void validate_offset(int offset) + throws InvalidInstructionException { + if (offset < -MAX_ADDR || offset > MAX_ADDR) { + throw new InvalidInstructionException(); + } } - /* got here without returning already... */ - throw new NoReturnValueException(); - } + /** + * Execute an assembly program. + * + * @param prog is the program to execute as an iterable collection of strings, + * each of which is a single instruction. + * @return the program's return value. + * @throws Exception when program has unrecognised or + * invalid instructions, or when it returns no result when it finishes + */ + int execute(List<String> instructions) + throws InvalidInstructionException, + NoReturnValueException { + + int instructionsExecuted = 0; + int pc = 0; + final int progLength = instructions.size(); + while (true) { + 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, + * since in this case the program's execution + * finishes early without a return value having + * been produced. */ + break; + } + String inst = instructions.get(pc); + /* strip leading and trailing whitespace */ + inst = inst.toLowerCase().replaceAll("^\\s+", "").replaceAll("\\s+$", ""); + /* strip out any comments */ + String[] toks = inst.split(";"); + inst = toks[0]; - /** - * get the number of instructions successfully executed by the VM so far - */ - public int getCount(){ - return count; - } + /* check for blank lines */ + if (inst.equals("")) { + pc = pc + 1; + count++; + continue; + } + + instructionsExecuted++; + /* now tokenize by splitting on whitespace */ + toks = inst.split("\\s+"); + + /* check minimum number of tokens */ + if (toks.length < 2) { + throw new InvalidInstructionException(); + } + + if (toks[0].equals(INSTRUCTION_ADD)) { + if (toks.length != 4) { + throw new InvalidInstructionException(); + } + int rd = parseReg(toks[1]); + int rs1 = parseReg(toks[2]); + int rs2 = parseReg(toks[3]); + do_add(rd, rs1, rs2); + } else if (toks[0].equals(INSTRUCTION_SUBTRACT)) { + if (toks.length != 4) { + throw new InvalidInstructionException(); + } + int rd = parseReg(toks[1]); + int rs1 = parseReg(toks[2]); + int rs2 = parseReg(toks[3]); + do_sub(rd, rs1, rs2); + } else if (toks[0].equals(INSTRUCTION_MULT)) { + if (toks.length != 4) { + throw new InvalidInstructionException(); + } + int rd = parseReg(toks[1]); + int rs1 = parseReg(toks[2]); + int rs2 = parseReg(toks[3]); + do_mult(rd, rs1, rs2); + } else if (toks[0].equals(INSTRUCTION_DIVIDE)) { + if (toks.length != 4) { + throw new InvalidInstructionException(); + } + int rd = parseReg(toks[1]); + int rs1 = parseReg(toks[2]); + int rs2 = parseReg(toks[3]); + do_div(rd, rs1, rs2); + } else if (toks[0].equals(INSTRUCTION_RETURN)) { + int rs = parseReg(toks[1]); + count++; + return regs[rs]; + } else if (toks[0].equals(INSTRUCTION_LOAD)) { + if (toks.length != 4) { + throw new InvalidInstructionException(); + } + int rd = parseReg(toks[1]); + int rs = parseReg(toks[2]); + int offs = parseOffset(toks[3]); + do_load(rd, rs, offs); + } else if (toks[0].equals(INSTRUCTION_STORE)) { + if (toks.length != 4) { + throw new InvalidInstructionException(); + } + int ra = parseReg(toks[1]); + int offs = parseOffset(toks[2]); + int rb = parseReg(toks[3]); + do_store(ra, offs, rb); + } else if (toks[0].equals(INSTRUCTION_MOVE)) { + if (toks.length != 3) { + throw new InvalidInstructionException(); + } + int rd = parseReg(toks[1]); + int offs = parseOffset(toks[2]); + do_move(rd, offs); + } else if (toks[0].equals(INSTRUCTION_JUMP)) { + if (toks.length != 2) { + throw new InvalidInstructionException(); + } + int offs = parseOffset(toks[1]); + pc = pc + offs; + count++; + continue; /* avoid default increment of pc below */ + } else if (toks[0].equals(INSTRUCTION_JZ)) { + if (toks.length != 3) { + throw new InvalidInstructionException(); + } + int ra = parseReg(toks[1]); + int offs = parseOffset(toks[2]); + if (regs[ra] == 0) { + pc = pc + offs; + } else { + pc = pc + 1; + } + count++; + continue; /* avoid default increment the pc below */ + } else { + System.err.println("Unrecognised instruction: " + inst); + throw new InvalidInstructionException(); + } + count++; + pc = pc + 1; + } + + /* got here without returning already... */ + throw new NoReturnValueException(); + } + + /** + * get the number of instructions successfully executed by the VM so far + */ + public int getCount() { + return count; + } } diff --git a/test/swen90006/machine/BoundaryTests.java b/test/swen90006/machine/BoundaryTests.java index 61ce1ca..946c097 100644 --- a/test/swen90006/machine/BoundaryTests.java +++ b/test/swen90006/machine/BoundaryTests.java @@ -8,83 +8,561 @@ import java.nio.file.Files; import java.nio.file.FileSystems; import org.junit.*; + import static org.junit.Assert.*; -public class BoundaryTests -{ - //Any method annotated with "@Before" will be executed before each test, - //allowing the tester to set up some shared resources. - @Before public void setUp() - { - } - - //Any method annotated with "@After" will be executed after each test, - //allowing the tester to release any shared resources used in the setup. - @After public void tearDown() - { - } - - //Any method annotation with "@Test" is executed as a test. - @Test public void aTest() - { - //the assertEquals method used to check whether two values are - //equal, using the equals method - final int expected = 2; - final int actual = 1 + 1; - assertEquals(expected, actual); - } - - @Test public void anotherTest() - { - List<String> list = new ArrayList<String>(); - list.add("a"); - list.add("b"); - - //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); - } - - //To test an exception, specify the expected exception after the @Test - @Test(expected = java.io.IOException.class) - public void anExceptionTest() - throws Throwable - { - throw new java.io.IOException(); - } - - //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); - } - - //Read in a file containing a program and convert into a list of - //string instructions - private List<String> readInstructions(String file) - { - Charset charset = Charset.forName("UTF-8"); - List<String> lines = null; - try { - lines = Files.readAllLines(FileSystems.getDefault().getPath(file), charset); - } - catch (Exception e){ - System.err.println("Invalid input file! (stacktrace follows)"); - e.printStackTrace(System.err); - System.exit(1); - } - return lines; - } +public class BoundaryTests { + //Any method annotated with "@Before" will be executed before each test, + //allowing the tester to set up some shared resources. + @Before public void setUp() { + System.out.println("------------------------------SETTING UP-----------------------------"); + } + + //Any method annotated with "@After" will be executed after each test, + //allowing the tester to release any shared resources used in the setup. + @After public void tearDown() { + System.out.println("------------------------------TEARDOWN-------------------------------\n"); + } + + // test case for B1_1 + @Test public void testB1_1() { + System.out.println("Running: test case for B1_1"); + Machine m = new Machine(); + List<String> lines = new ArrayList<String>(); + lines.add("RET R1"); + int expected = m.execute(lines); + assertEquals(expected, 0); + } + + // test case for B1_2 + @Test public void testB1_2() { + System.out.println("Running: test case for B1_2"); + Machine m = new Machine(); + List<String> lines = new ArrayList<String>(); + lines.add("RET R31"); + int expected = m.execute(lines); + assertEquals(expected, 0); + } + + // test case for B1_3 + @Test(expected = InvalidInstructionException.class) + public void testB1_3() throws Throwable { + System.out.println("Running: test case for B1_3"); + Machine m = new Machine(); + List<String> lines = new ArrayList<String>(); + lines.add("RET R-1"); + int expected = m.execute(lines); + } + + // test case for B1_4 + @Test(expected = InvalidInstructionException.class) + public void testB1_4() throws Throwable { + System.out.println("Running: test case for B1_4"); + Machine m = new Machine(); + List<String> lines = new ArrayList<String>(); + lines.add("RET R32"); + int expected = m.execute(lines); + } + + + //test case for B2_1 + @Test public void testB2_1(){ + System.out.println("Running: test case for B2_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B2_1.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + + // test case for B2_2 + @Test(expected = InvalidInstructionException.class) + public void testB2_2() throws Throwable { + System.out.println("Running: test case for B2_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B2_2.s"); + int expected = m.execute(lines); + + } + + // test case for B2_3 + @Test(expected = InvalidInstructionException.class) + public void testB2_3() throws Throwable { + System.out.println("Running: test case for B2_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B2_3.s"); + int expected = m.execute(lines); + + } + + + //test case for B3_1 + @Test public void testB3_1(){ + System.out.println("Running: test case for B3_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B3_1.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + + // test case for B3_2 + @Test(expected = InvalidInstructionException.class) + public void testB3_2() throws Throwable { + System.out.println("Running: test case for B3_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B3_2.s"); + int expected = m.execute(lines); + + } + + // test case for B3_3 + @Test(expected = InvalidInstructionException.class) + public void testB3_3() throws Throwable { + System.out.println("Running: test case for B3_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B3_3.s"); + int expected = m.execute(lines); + } + + //test case for B4_1 + @Test public void testB4_1(){ + System.out.println("Running: test case for B4_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B4_1.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + + // test case for B4_2 + @Test(expected = InvalidInstructionException.class) + public void testB4_2() throws Throwable { + System.out.println("Running: test case for B4_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B4_2.s"); + int expected = m.execute(lines); + + } + + // test case for B4_3 + @Test(expected = InvalidInstructionException.class) + public void testB4_3() throws Throwable { + System.out.println("Running: test case for B4_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B4_3.s"); + int expected = m.execute(lines); + } + + //test case for B5_1 + @Test public void testB5_1(){ + System.out.println("Running: test case for B5_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B5_1.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + // test case for B5_2 + @Test(expected = InvalidInstructionException.class) + public void testB5_2() throws Throwable { + System.out.println("Running: test case for B5_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B5_2.s"); + int expected = m.execute(lines); + + } + + // test case for B5_3 + @Test(expected = InvalidInstructionException.class) + public void testB5_3() throws Throwable { + System.out.println("Running: test case for B5_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B5_3.s"); + int expected = m.execute(lines); + } + + //test case for B6_1 + @Test public void testB6_1(){ + System.out.println("Running: test case for B6_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B6_1.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + //test case for B6_2 + @Test public void testB6_2(){ + System.out.println("Running: test case for B6_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B6_2.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + // test case for B6_3 + @Test(expected = InvalidInstructionException.class) + public void testB6_3() throws Throwable { + System.out.println("Running: test case for B6_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B6_3.s"); + int expected = m.execute(lines); + + } + + // test case for B6_4 + @Test(expected = InvalidInstructionException.class) + public void testB6_4() throws Throwable { + System.out.println("Running: test case for B6_4"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B6_4.s"); + int expected = m.execute(lines); + } + + + //test case for B7_1 + @Test public void testB7_1(){ + System.out.println("Running: test case for B7_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B7_1.s"); + int expected = m.execute(lines); + assertEquals(expected,-65535); + } + + //test case for B7_2 + @Test public void testB7_2(){ + System.out.println("Running: test case for B7_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B7_2.s"); + int expected = m.execute(lines); + assertEquals(expected,65535); + } + + // test case for B7_3 + @Test(expected = InvalidInstructionException.class) + public void testB7_3() throws Throwable { + System.out.println("Running: test case for B7_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B7_3.s"); + int expected = m.execute(lines); + + } + + // test case for B7_4 + @Test(expected = InvalidInstructionException.class) + public void testB7_4() throws Throwable { + System.out.println("Running: test case for B7_4"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B7_4.s"); + int expected = m.execute(lines); + } + + //test case for B8_1 + @Test public void testB8_1(){ + System.out.println("Running: test case for B8_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B8_1.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + // test case for B8_2 + @Test(expected = InvalidInstructionException.class) + public void testB8_2() throws Throwable { + System.out.println("Running: test case for B8_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B8_2.s"); + int expected = m.execute(lines); + } + + // test case for B8_3 + @Test(expected = InvalidInstructionException.class) + public void testB8_3() throws Throwable { + System.out.println("Running: test case for B8_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B8_3.s"); + int expected = m.execute(lines); + } + + //test case for B8_4 + @Test public void testB8_4(){ + System.out.println("Running: test case for B8_4"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B8_4.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + // test case for B8_5 + @Test(expected = InvalidInstructionException.class) + public void testB8_5() throws Throwable { + System.out.println("Running: test case for B8_5"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B8_5.s"); + int expected = m.execute(lines); + } + + // test case for B8_6 + @Test(expected = InvalidInstructionException.class) + public void testB8_6() throws Throwable { + System.out.println("Running: test case for B8_6"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B8_6.s"); + int expected = m.execute(lines); + } + + + //test case for B9_1 + @Test public void testB9_1(){ + System.out.println("Running: test case for B9_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B9_1.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + //test case for B9_2 + @Test public void testB9_2(){ + System.out.println("Running: test case for B9_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B9_2.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + // test case for B9_3 + @Test(expected = InvalidInstructionException.class) + public void testB9_3() throws Throwable { + System.out.println("Running: test case for B9_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B9_3.s"); + int expected = m.execute(lines); + } + + // test case for B9_4 + @Test(expected = InvalidInstructionException.class) + public void testB9_4() throws Throwable { + System.out.println("Running: test case for B9_4"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B9_4.s"); + int expected = m.execute(lines); + } + + // test case for B9_5 + @Test(expected = InvalidInstructionException.class) + public void testB9_5() throws Throwable { + System.out.println("Running: test case for B9_5"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B9_5.s"); + int expected = m.execute(lines); + } + + // test case for B9_6 + @Test(expected = InvalidInstructionException.class) + public void testB9_6() throws Throwable { + System.out.println("Running: test case for B9_6"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B9_6.s"); + int expected = m.execute(lines); + } + + //test case for B10_1 + @Test public void testB10_1(){ + System.out.println("Running: test case for B10_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B10_1.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + //test case for B10_2 + @Test public void testB10_2(){ + System.out.println("Running: test case for B10_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B10_2.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + // test case for B10_3 + @Test + public void testB10_3(){ + System.out.println("Running: test case for B10_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B10_3.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + // test case for B10_4 + @Test + public void testB10_4(){ + System.out.println("Running: test case for B10_4"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B10_4.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + // test case for B10_5 + @Test + public void testB10_5(){ + System.out.println("Running: test case for B10_5"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B10_5.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + // test case for B10_6 + @Test + public void testB10_6(){ + System.out.println("Running: test case for B10_6"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B10_6.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + //test case for B11_1 + @Test public void testB11_1(){ + System.out.println("Running: test case for B11_1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B11_1.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + //test case for B11_2 + @Test public void testB11_2(){ + System.out.println("Running: test case for B11_2"); + System.out.println("this is an infinite loop"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B11_2.s"); +// int expected = m.execute(lines); +// assertEquals(expected,2); + } + + // test case for B11_3 + @Test + public void testB11_3(){ + System.out.println("Running: test case for B11_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B11_3.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + // test case for B11_4 + @Test + public void testB11_4(){ + System.out.println("Running: test case for B11_4"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B11_4.s"); + int expected = m.execute(lines); + assertEquals(expected,4); + } + + // test case for B12_1 + @Test + public void testB12_1(){ + System.out.println("Running: test case for B12_1"); + System.out.println("this is an infinite loop"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B12_1.s"); +// int expected = m.execute(lines); +// assertEquals(expected,2); + } + + // test case for B12_2 + @Test + public void testB12_2(){ + System.out.println("Running: test case for B12_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B12_2.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + // test case for B12_3 + @Test(expected = NoReturnValueException.class) + public void testB12_3() throws Throwable { + System.out.println("Running: test case for B12_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B12_3.s"); + int expected = m.execute(lines); + } + + // test case for B12_4 + @Test(expected = NoReturnValueException.class) + public void testB12_4() throws Throwable { + System.out.println("Running: test case for B12_4"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B12_4.s"); + int expected = m.execute(lines); + } + + // test case for B13_1 + @Test + public void testB13_1(){ + System.out.println("Running: test case for B13_1"); + System.out.println("this is an infinite loop"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B13_1.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + // test case for B13_2 + @Test + public void testB13_2(){ + System.out.println("Running: test case for B13_2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B13_2.s"); + int expected = m.execute(lines); + assertEquals(expected,-1); + } + + // test case for B13_3 + @Test public void testB13_3(){ + System.out.println("Running: test case for B13_3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/B13_3.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + +// @Test public void anotherTest() +// { +// List<String> list = new ArrayList<String>(); +// list.add("a"); +// list.add("b"); +// +// //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); +// } + + //Read in a file containing a program and convert into a list of + //string instructions + private List<String> readInstructions(String file) { + Charset charset = Charset.forName("UTF-8"); + List<String> lines = null; + try { + lines = Files.readAllLines(FileSystems.getDefault().getPath(file), charset); + } catch (Exception e) { + System.err.println("Invalid input file! (stacktrace follows)"); + e.printStackTrace(System.err); + System.exit(1); + } + return lines; + } } diff --git a/test/swen90006/machine/PartitioningTests.java b/test/swen90006/machine/PartitioningTests.java index 5494b44..661cd54 100644 --- a/test/swen90006/machine/PartitioningTests.java +++ b/test/swen90006/machine/PartitioningTests.java @@ -6,85 +6,284 @@ import java.nio.charset.Charset; import java.nio.file.Path; import java.nio.file.Files; import java.nio.file.FileSystems; - import org.junit.*; import static org.junit.Assert.*; public class PartitioningTests { - //Any method annotated with "@Before" will be executed before each test, - //allowing the tester to set up some shared resources. - @Before public void setUp() - { - } - - //Any method annotated with "@After" will be executed after each test, - //allowing the tester to release any shared resources used in the setup. - @After public void tearDown() - { - } - - //Any method annotation with "@Test" is executed as a test. - @Test public void aTest() - { - //the assertEquals method used to check whether two values are - //equal, using the equals method - final int expected = 2; - final int actual = 1 + 1; - assertEquals(expected, actual); - } - - @Test public void anotherTest() - { - List<String> list = new ArrayList<String>(); - list.add("a"); - list.add("b"); - - //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); - } - - //To test an exception, specify the expected exception after the @Test - @Test(expected = java.io.IOException.class) - public void anExceptionTest() - throws Throwable - { - throw new java.io.IOException(); - } - - //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); - } - - //Read in a file containing a program and convert into a list of - //string instructions - private List<String> readInstructions(String file) - { - Charset charset = Charset.forName("UTF-8"); - List<String> lines = null; - try { - lines = Files.readAllLines(FileSystems.getDefault().getPath(file), charset); + //Any method annotated with "@Before" will be executed before each test, + //allowing the tester to set up some shared resources. + @Before public void setUp() throws Exception { + System.out.println("------------------------------SETTING UP-----------------------------"); + } + + //Any method annotated with "@After" will be executed after each test, + //allowing the tester to release any shared resources used in the setup. + @After public void tearDown() throws Exception { + System.out.println("------------------------------TEARDOWN-------------------------------\n"); + } + + // test case for EC2-1 + @Test(expected = InvalidInstructionException.class) + public void testEC2_1() throws Throwable{ + System.out.println("Running: test case for EC2-1"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-1.s"); + int expected = m.execute(lines); + } + + // test case for EC2-2 + @Test + public void testEC2_2() { + System.out.println("Running: test case for EC2-2"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-2.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + // test case for EC2-3 + @Test(expected = InvalidInstructionException.class) + public void testEC2_3() throws Throwable{ + System.out.println("Running: test case for EC2-3"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-3.s"); + int expected = m.execute(lines); + } + + // test case for EC2-4 + @Test(expected = InvalidInstructionException.class) + public void testEC2_4() throws Throwable{ + System.out.println("Running: test case for EC2-4"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-4.s"); + int expected = m.execute(lines); + } + + // test case for EC2-5 + @Test + public void testEC2_5(){ + System.out.println("Running: test case for EC2-5"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-5.s"); + int expected = m.execute(lines); + assertEquals(expected,1); + + } + + // test case for EC2-6 + @Test + public void testEC2_6(){ + System.out.println("Running: test case for EC2-6"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-6.s"); + int expected = m.execute(lines); + assertEquals(expected,2); + } + + // test case for EC2-7 + @Test(expected = InvalidInstructionException.class) + public void testEC2_7() throws Throwable{ + System.out.println("Running: test case for EC2-7"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-7.s"); + int expected = m.execute(lines); + } + + // test case for EC2-8 + @Test + public void testEC2_8(){ + System.out.println("Running: test case for EC2-8"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-8.s"); + int expected = m.execute(lines); + assertEquals(expected,-1); + } + + // test case for EC2-9 + @Test + public void testEC2_9(){ + System.out.println("Running: test case for EC2-9"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-9.s"); + int expected = m.execute(lines); + assertEquals(expected,6); + } + + // test case for EC2-10 + @Test + public void testEC2_10(){ + System.out.println("Running: test case for EC2-10"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-10.s"); + int expected = m.execute(lines); + assertEquals(expected,5); + } + + // test case for EC2-11 + @Test + public void testEC2_11(){ + System.out.println("Running: test case for EC2-11"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-11.s"); + int expected = m.execute(lines); + assertEquals(expected,5); + } + + // test case for EC2-12 + @Test(expected = InvalidInstructionException.class) + public void testEC2_12() throws Throwable{ + System.out.println("Running: test case for EC2-12"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-12.s"); + int expected = m.execute(lines); + } + + // test case for EC2-13 + @Test + public void testEC2_13(){ + System.out.println("Running: test case for EC2-13"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-13.s"); + int expected = m.execute(lines); + assertEquals(expected,-65535); + } + + // test case for EC2-14 + @Test(expected = InvalidInstructionException.class) + public void testEC2_14() throws Throwable{ + System.out.println("Running: test case for EC2-14"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-14.s"); + int expected = m.execute(lines); + } + + // test case for EC2-15 + @Test public void testEC2_15(){ + System.out.println("Running: test case for EC2-15"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-15.s"); + int expected = m.execute(lines); + assertEquals(expected,100); + } + + // test case for EC2-16 + @Test public void testEC2_16() { + System.out.println("Running: test case for EC2-16"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-16.s"); + int expected = m.execute(lines); + assertEquals(expected,0); } - catch (Exception e){ - System.err.println("Invalid input file! (stacktrace follows)"); - e.printStackTrace(System.err); - System.exit(1); + + // test case for EC2-17 + @Test public void testEC2_17(){ + System.out.println("Running: test case for EC2-17"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-17.s"); + int expected = m.execute(lines); + assertEquals(expected,100); + } + + //test case for EC2-18 + @Test public void testEC2_18(){ + System.out.println("Running: test case for EC2-18"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-18.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + // test case for EC2-19 + @Test public void testEC2_19(){ + System.out.println("Running: test case for EC2-19"); + Long t1 = System.currentTimeMillis(); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-19.s"); + System.out.println("this is an infinite loop"); +// int expected = m.execute(lines); +// assertEquals(expected,0); + } + + //test case for EC2-20 + @Test public void testEC2_20(){ + System.out.println("Running: test case for EC2-20"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-20.s"); + int expected = m.execute(lines); + assertEquals(expected,10); + } + + //test case for EC2-21 + @Test public void testEC2_21(){ + System.out.println("Running: test case for EC2-21"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-21.s"); + int expected = m.execute(lines); + assertEquals(expected,1); + } + + //test case for EC2-22 + @Test(expected = NoReturnValueException.class) + public void testEC2_22() throws Throwable{ + System.out.println("Running: test case for EC2-22"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-22.s"); + int expected = m.execute(lines); + } + + + //test case for EC2-23 + @Test public void testEC2_23(){ + System.out.println("Running: test case for EC2-23"); + System.out.println("This is an infinite loop"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-23.s"); +// int expected = m.execute(lines); +// assertEquals(expected,0); + } + + //test case for EC2-24 + @Test public void testEC2_24(){ + System.out.println("Running: test case for EC2-24"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-24.s"); + int expected = m.execute(lines); + assertEquals(expected,0); + } + + //test case for EC2-25 + @Test public void testEC2_25(){ + System.out.println("Running: test case for EC2-25"); + Machine m = new Machine(); + final List<String> lines = readInstructions("./examples/EC2-25.s"); + int expected = m.execute(lines); + assertEquals(expected,5); + } + + //Test test opens a file and executes the machine +// @Test public void aFileOpenTest() +// { +// System.out.println("Running: test open file"); +// final List<String> lines = readInstructions("examples/array.s"); +// Machine m = new Machine(); +// assertEquals(m.execute(lines), 45); +// } + + //Read in a file containing a program and convert into a list of + //string instructions + private List<String> readInstructions(String file) + { + Charset charset = Charset.forName("UTF-8"); + List<String> lines = null; + try { + lines = Files.readAllLines(FileSystems.getDefault().getPath(file), charset); + } + catch (Exception e){ + System.err.println("Invalid input file! (stacktrace follows)"); + e.printStackTrace(System.err); + System.exit(1); + } + return lines; } - return lines; - } } -- GitLab