diff --git a/examples/BoundaryTests/EC-14.s b/examples/BoundaryTests/EC-14.s index 970d4c6bc773aa4915ab316481c5af8ad3e486e3..94453673fa1d0734d9391bc829045c9e38b32870 100644 --- a/examples/BoundaryTests/EC-14.s +++ b/examples/BoundaryTests/EC-14.s @@ -1,4 +1,4 @@ -MOV R0 65536 +MOV R0 65535 MOV R1 3 MOV R2 8 STR R0 1 R1 diff --git a/examples/BoundaryTests/EC-7.s b/examples/BoundaryTests/EC-7.s index 9b9306996d9b77e8ffe9f7598a1b610bcaa396cc..7f4bfb819f95ef52a83ce70badcdd225568b09f6 100644 --- a/examples/BoundaryTests/EC-7.s +++ b/examples/BoundaryTests/EC-7.s @@ -1,6 +1,6 @@ MOV R0 0 MOV R1 2 -MOV R3 3 -MUL R3 R1 R0 +MOV R3 3 +DIV R3 R1 R0 RET R3 ;; 3 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-14.s b/examples/PartitioningTests/EC-14.s index 64fee9ae69a8b7d9c981383650aad3448642051d..1772954f08f253e3051446548c9fe85956b13f69 100644 --- a/examples/PartitioningTests/EC-14.s +++ b/examples/PartitioningTests/EC-14.s @@ -1,7 +1,7 @@ MOV R0 65535 MOV R1 3 -MOV R2 0 +MOV R2 88 STR R0 1 R1 LDR R2 R0 1 RET R2 -;; 0 \ No newline at end of file +;; 88 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-16.s b/examples/PartitioningTests/EC-16.s index da8f8d32f64d2572b39fef02af749278f9883339..fba2d885e7b4c531bd0f5cc9a30f99cc5ff38c13 100644 --- a/examples/PartitioningTests/EC-16.s +++ b/examples/PartitioningTests/EC-16.s @@ -1,4 +1,5 @@ MOV R0 0 JZ R0 -2 +MOV R0 1 RET R0 -;; 0 \ No newline at end of file +;; 1 \ No newline at end of file diff --git a/examples/PartitioningTests/EC-7.s b/examples/PartitioningTests/EC-7.s index 81d646f8fd3649a7b7925602d34b2a1ef662502f..7f4bfb819f95ef52a83ce70badcdd225568b09f6 100644 --- a/examples/PartitioningTests/EC-7.s +++ b/examples/PartitioningTests/EC-7.s @@ -1,6 +1,6 @@ MOV R0 0 -MOV R1 1 -MOV R3 0 -MUL R3 R1 R0 +MOV R1 2 +MOV R3 3 +DIV R3 R1 R0 RET R3 -;; 0 \ No newline at end of file +;; 3 \ No newline at end of file diff --git a/test/swen90006/machine/BoundaryTests.java b/test/swen90006/machine/BoundaryTests.java index bed7fb47a5dda6dae891ef766eabff24818d672c..b7f3d3395a872b124a7aaf55cb640c9394be3731 100644 --- a/test/swen90006/machine/BoundaryTests.java +++ b/test/swen90006/machine/BoundaryTests.java @@ -25,51 +25,51 @@ public class BoundaryTests } //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); - } + // @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(); - } + // //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); - } + // @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(expected = swen90006.machine.NoReturnValueException.class) public void EC_1() @@ -215,12 +215,12 @@ public class BoundaryTests assertEquals(m.execute(lines), 0); } - @Test + @Test(expected = swen90006.machine.NoReturnValueException.class) public void EC_16() { final List<String> lines = readInstructions("examples/BoundaryTests/EC-16.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 0); + m.execute(lines); } @Test @@ -239,12 +239,12 @@ public class BoundaryTests assertEquals(m.execute(lines), 0); } - @Test + @Test(expected = swen90006.machine.NoReturnValueException.class) public void EC_18() { final List<String> lines = readInstructions("examples/BoundaryTests/EC-18.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 1); + m.execute(lines); } @Test @@ -255,13 +255,13 @@ public class BoundaryTests assertEquals(m.execute(lines), 0); } - @Test(expected = swen90006.machine.NoReturnValueException.class) - public void EC_20() - { - final List<String> lines = readInstructions("examples/BoundaryTests/EC-20.s"); - Machine m = new Machine(); - m.execute(lines); - } + // @Test(expected = swen90006.machine.NoReturnValueException.class) + // public void EC_20() + // { + // final List<String> lines = readInstructions("examples/BoundaryTests/EC-20.s"); + // Machine m = new Machine(); + // m.execute(lines); + // } @Test(expected = swen90006.machine.NoReturnValueException.class) public void EC_21() diff --git a/test/swen90006/machine/PartitioningTests.java b/test/swen90006/machine/PartitioningTests.java index 9dbabcf991ccebdb756d7baa501c8c1e9d636e05..9db1c67260b47eb2481247f4ac944ce1d7da7068 100644 --- a/test/swen90006/machine/PartitioningTests.java +++ b/test/swen90006/machine/PartitioningTests.java @@ -5,7 +5,7 @@ import java.util.ArrayList; import java.nio.charset.Charset; import java.nio.file.Path; import java.nio.file.Files; -import java.nio.file.FileSystems; +import java.nio.file.FileSystems; import org.junit.*; import static org.junit.Assert.*; @@ -24,52 +24,52 @@ public class PartitioningTests { } - //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); - } + // //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"); + // @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")); - } + // //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); - } + // //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(); - } + // //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); - } + // @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(expected = swen90006.machine.NoReturnValueException.class) public void EC_1() @@ -124,7 +124,7 @@ public class PartitioningTests { final List<String> lines = readInstructions("examples/PartitioningTests/EC-7.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 0); + assertEquals(m.execute(lines), 3); } @Test (expected = swen90006.machine.InvalidInstructionException.class) @@ -180,7 +180,7 @@ public class PartitioningTests { final List<String> lines = readInstructions("examples/PartitioningTests/EC-14.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 0); + assertEquals(m.execute(lines), 88); } @Test @@ -191,12 +191,12 @@ public class PartitioningTests assertEquals(m.execute(lines), 0); } - @Test + @Test(expected = swen90006.machine.NoReturnValueException.class) public void EC_16() { final List<String> lines = readInstructions("examples/PartitioningTests/EC-16.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 0); + m.execute(lines); } @Test @@ -207,12 +207,12 @@ public class PartitioningTests assertEquals(m.execute(lines), 0); } - @Test + @Test(expected = swen90006.machine.NoReturnValueException.class) public void EC_18() { final List<String> lines = readInstructions("examples/PartitioningTests/EC-18.s"); Machine m = new Machine(); - assertEquals(m.execute(lines), 1); + m.execute(lines); } @Test @@ -223,13 +223,13 @@ public class PartitioningTests assertEquals(m.execute(lines), 0); } - @Test(expected = swen90006.machine.NoReturnValueException.class) - public void EC_20() - { - final List<String> lines = readInstructions("examples/PartitioningTests/EC-20.s"); - Machine m = new Machine(); - m.execute(lines); - } + // @Test(expected = swen90006.machine.NoReturnValueException.class) + // public void EC_20() + // { + // final List<String> lines = readInstructions("examples/PartitioningTests/EC-20.s"); + // Machine m = new Machine(); + // m.execute(lines); + // } @Test(expected = swen90006.machine.NoReturnValueException.class) public void EC_21()