Skip to content
Snippets Groups Projects
Commit a207f29f authored by Ashwaq Abdullah M Alsaqer's avatar Ashwaq Abdullah M Alsaqer
Browse files

new examples

parent 1d64d19d
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,8 @@
</target>
<target name="partitioning" depends="classes">
<parallel threadCount="1" timeout="5000">
<sequential>
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<classpath>
<pathelement path="classes/"/>
......@@ -25,9 +27,13 @@
<formatter type="plain"/>
<test name="swen90006.machine.PartitioningTests"/>
</junit>
</sequential>
</parallel>
</target>
<target name="boundary" depends="classes">
<parallel threadCount="1" timeout="5000">
<sequential>
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<classpath>
<pathelement path="classes/"/>
......@@ -37,7 +43,8 @@
<formatter type="plain"/>
<test name="swen90006.machine.BoundaryTests"/>
</junit>
</sequential>
</parallel>
</target>
</project>
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -29,6 +29,7 @@
MOV R1 0 ; i = 0;
MOV R0 100
MOV R5 0 ; sum = 0;
;RET R5
SUB R4 R3 R1 ; while(i != N)
JZ R4 6 ; {
......
......@@ -47,7 +47,7 @@ public class BoundaryTests
//Test test opens a file and executes the machine
@Test public void aFileOpenTest()
{
final List<String> lines = readInstructions("examples/array.s");
final List<String> lines = readInstructions("C:\\Users\\ASUS\\git\\SWEN90006-A1-2018\\examples\\array.s");
Machine m = new Machine();
assertEquals(m.execute(lines), 45);
}
......@@ -71,6 +71,29 @@ public class BoundaryTests
assertEquals("Some failure message", expected, actual);
}
@Test(expected = InvalidInstructionException.class)
public void InvalidInstructions() {
final List<String> lines = readInstructions("C:\\Users\\ASUS\\git\\SWEN90006-A1-2018\\examples\\array_copy.s");
Machine m = new Machine();
m.execute(lines);
}
@Test public void MultipuleRuternTest() {
final List<String> lines = readInstructions("C:\\Users\\ASUS\\git\\SWEN90006-A1-2018\\examples\\multiReturn.s");
Machine m = new Machine();
int val = m.execute(lines);
assertEquals(val, 0);
}
@Test public void NotExcuteWrongInstructions() {
final List<String> lines = readInstructions("C:\\Users\\ASUS\\git\\SWEN90006-A1-2018\\examples\\div_test.s");
Machine m = new Machine();
int val = m.execute(lines);
assertEquals(val, 100);
}
//Read in a file containing a program and convert into a list of
//string instructions
private List<String> readInstructions(String file)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment