diff --git a/test/swen90006/machine/BoundaryTests.java b/test/swen90006/machine/BoundaryTests.java index 61ce1ca647f325fbf452047408c1e22d9befcb99..9161611aeebcc003b642b559055b619aa787ecd3 100644 --- a/test/swen90006/machine/BoundaryTests.java +++ b/test/swen90006/machine/BoundaryTests.java @@ -12,79 +12,400 @@ 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() + @Test public void BVA1A_pcZero() { + List<String> list = new ArrayList<String>(); + Machine m = new Machine(); + list.add("mov R10 10"); + list.add("mov R14 -1"); + list.add("add R15 R12 R14"); + list.add("jz R15 4"); + list.add("mov R12 1"); + list.add("mov R10 11"); + list.add("jmp -6"); //Setting pc to 0 + list.add("ret R10"); + assertEquals("Valid test for adding two numbers",m.execute(list),10); } - - //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() + +//This test is failing in some way, It should finish early without return a value (null) +//it is return NoReturnValueException + @Test(expected = NoReturnValueException.class) + public void BVA1B_pcMinusOne() { + List<String> list = new ArrayList<String>(); + Machine m = new Machine(); + int instructionsExecuted = m.getCount(); + instructionsExecuted = instructionsExecuted - instructionsExecuted + 1; + String jmpInstruction = "jmp "+instructionsExecuted; + list.add(jmpInstruction);//Successful, its not return value of register 20 + list.add("mov R10 0"); + list.add("mov R12 10"); + list.add("add R20 R10 R12"); + list.add("jmp -20"); + list.add("Ret R20"); + // assertEquals("Should finish early without any value",m.execute(list),null); + m.execute(list); } + - //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 BVA2A_RegisterNumberZeroTest() + { + List<String> list = new ArrayList<String>(); + list.add("mov r0 101"); + list.add("ret r0"); + Machine m = new Machine(); + assertEquals("Lowest number of valid register, r0",m.execute(list),101); + } + + //Register number one less than lowest number + @Test(expected = InvalidInstructionException.class) + public void BVA2B_RegisterNumberMinusOneTest() throws Throwable + { + List<String> list = new ArrayList<String>(); + list.add("mov r-1 101"); + list.add("ret r-1"); + Machine m = new Machine(); + m.execute(list); + } + + @Test public void BVA3A_ZeroMemoryAddressTest() throws Throwable + { + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R20 590"); + list.add("str R10 -5 R20");//Storing at memory address 0 + list.add("ldr R12 r10 -5"); + list.add("ret R12"); + Machine m = new Machine(); + assertEquals("Lowest address number for memory address test",m.execute(list),590); + } +//reading writing from -1 memory address, no operation +@Test public void BVA3B_MinusOneMemoryAddressTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R12 120"); + list.add("mov R20 590"); + list.add("str R10 -6 R20");//Storing at memory address -1 + list.add("ldr R12 r10 -6"); + list.add("ret R12"); //Still reading the old value of 120, not 590 + Machine m = new Machine(); + assertEquals("trying to store and read from memory at address one lower than lowest value",m.execute(list),120); +} - @Test public void anotherTest() - { - List<String> list = new ArrayList<String>(); - list.add("a"); - list.add("b"); +@ Test public void BVA4A_LowestValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov r10 -65535"); + list.add("ret r10"); + Machine m = new Machine(); + assertEquals("testing lowest value (-65535)",m.execute(list),-65535); +} +//trying to store -65536 (one less than lowest value), throw exception +@Test(expected = InvalidInstructionException.class) +public void BVA4B_OneMinusLowestValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov r10 -65536"); + list.add("ret r10"); + Machine m = new Machine(); + m.execute(list); +} - //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(); - } +@Test public void BVA5A_LowestRegisterCapacityValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 65530"); + list.add("mov R12 -32771");//65530*-32771+(-18) = -2147483648 + list.add("mov R14 -18"); + list.add("mul R20 R10 R12"); + list.add("add R24 R14 R20"); + list.add("Ret R24"); + Machine m = new Machine(); + assertEquals("Lowest value a regiser can store test",m.execute(list),-2147483648); +} - //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(expected = java.lang.ArithmeticException.class)//Failed test, + * Commenting it out, as failed test would affect the mutation analysis process + */ +/*public void BVA5B_MinusOneLowestRegisterCapacityValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 65530"); + list.add("mov R12 -32771");//65530*-32771+(-19) = -2147483649 + list.add("mov R14 -19"); + list.add("mul R20 R10 R12"); + list.add("add R24 R14 R20"); + list.add("Ret R24"); + Machine m = new Machine(); + m.execute(list); + // assertEquals("trying to store one less than lowest value of register's capacity",m.execute(list),-2147483649); +}*/ + +@Test public void BVA6A_HighestRegisterCapacityValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 65530"); + list.add("mov R12 32771");//65530*32771+17 = 2147483647 + list.add("mov R14 17"); + list.add("mul R20 R10 R12"); + list.add("add R24 R14 R20"); + list.add("Ret R24"); + Machine m = new Machine(); + assertEquals("trying to store highest value of register's capacity",m.execute(list),2147483647); +} + +/*@Test(expected = java.lang.ArithmeticException.class)//Failed test, +Commenting it out, as failed test would affect the mutation analysis process +@Test public void BVA6B_OnePlusHighestRegisterCapacityValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 65530"); + list.add("mov R12 32771");//65530*32771+17 = 2147483647 + list.add("mov R14 18"); + list.add("mul R20 R10 R12"); + list.add("add R24 R14 R20"); + list.add("Ret R24"); + Machine m = new Machine(); + // assertEquals("trying to store one more than highest value of register's capacity",m.execute(list),2147483648); +}*/ + +@ Test public void BVA7A_HighestValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov r10 65535"); + list.add("ret r10"); + Machine m = new Machine(); + assertEquals("Testing for highest value of Value field",m.execute(list),65535); +} + +//Testing for one more than highest value of Value Field (65535) +@Test(expected = InvalidInstructionException.class) +public void BVA7B_OnePlusHighestValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov r10 65536"); + list.add("ret r10"); + Machine m = new Machine(); + m.execute(list); +} + +@ Test public void BVA8A_HighestMemoryAddressTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R20 590"); + list.add("str R10 65530 R20");//Memory Address would be 65535 + list.add("ldr R12 r10 65530"); + list.add("ret R12"); + Machine m = new Machine(); + assertEquals("Testing for highest memory address value (65535)",m.execute(list),590); +} + +@Test public void BVA8B_OnePlusHighestMemoryTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 6"); + list.add("mov R20 590"); + list.add("str R10 65530 R20");//Memory Address would be 655336 + list.add("ldr R12 r10 65530"); + list.add("ret R12"); //Still returning 0, default value instead of 590 + Machine m = new Machine(); + assertEquals("Testing for one more thanhighest memory address value (65536)",m.execute(list),0); +} + +@Test public void BVA9A_HighestRegisterNumberTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov r31 100"); + list.add("ret r31"); + Machine m = new Machine(); + assertEquals("Test for highest valid register number, r31",m.execute(list),100); +} + +//est for on more than highest valid register number, r32 +@Test(expected = InvalidInstructionException.class) +public void BVA9B_OnePlusHighestRegisterNumberTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov r32 100"); + list.add("ret r32"); + Machine m = new Machine(); + m.execute(list); +} + +@Test public void BVA10A_HighestPCCounterTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("jmp 6"); + list.add("mov r3 100"); + list.add("mov r4 100"); + list.add("mov r5 100"); + list.add("ret r8"); + list.add("mov r6 20"); + list.add("ret r4"); + Machine m = new Machine(); + assertEquals("Testing hightest valid value of pc (6, in this program)", m.execute(list),0); + +} +//Failed Test, its returning NoReturnValueException Exception +//It should terminate early without throwing any exception +//updating assumption that it would throw exception +//so the mutation test would not be affected +@Test(expected = NoReturnValueException.class) +public void BVA10B_OnePlusHighestPCCounterTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("jmp 7"); + list.add("mov r3 100"); + list.add("mov r4 100"); + list.add("mov r5 100"); + list.add("ret r8"); + list.add("mov r6 20"); + list.add("ret r4"); + Machine m = new Machine(); + System.out.println("program lenghtone plus highest is : "+ list.size()); + m.execute(list); +} + +@Test public void BVA11A_CorrectStoreReadMemoryTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R20 590"); + list.add("sTr R10 105 R20"); + list.add("ldr R12 r10 105"); + list.add("ret R12"); + Machine m = new Machine(); + assertEquals("Valid test correcting storing and reading value from memory",m.execute(list),590); +} + +@Test public void BVA12A_CorrectJMPTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("jmp 2"); + list.add("mov R10 20"); + list.add("ret R10"); + Machine m = new Machine(); + assertEquals("Testing for valid jmp instruction",m.execute(list),5); + assertEquals(m.getCount(),3); +} + +@Test public void BVA13A_CorrectJZTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 0"); + list.add("mov R12 121"); + list.add("jz R10 2");//skipped the next instruction, so R12 value stays at 121 + list.add("mov R12 100"); + list.add("Ret R12"); + Machine m = new Machine(); + assertEquals("Testing for valid JZ instruction",m.execute(list),121); + assertEquals(m.getCount(),4); +} + +@Test public void BVA13B_NoTCorrectJZTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 10"); + list.add("mov R12 121"); + list.add("jz R10 2");//skipped the next instruction, so R12 value stays at 121 + list.add("mov R12 100"); + list.add("Ret R12"); + Machine m = new Machine(); + assertEquals("Testing for incorrect JZ instruction",m.execute(list),100); +} + +@Test public void BVA14A_BlankLineTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add(" "); + list.add("ret R10"); + Machine m = new Machine(); + assertEquals("Testing for valid blank instruction",m.execute(list),5); +} + +@Test public void BVA15A_CommentLineTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov r10 45 ;;"); + list.add(";mov r10 54 hello this is comment"); + list.add("ret R10"); + Machine m = new Machine(); + assertEquals("Testing for valid comment line instruction",m.execute(list),45); +} + +//Testing for invalid instruction, which should trow exception +@Test(expected = InvalidInstructionException.class) +public void BVA16A_unrecognizedInstructionTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("sqrt 30"); + list.add("ret r21"); + Machine m = new Machine(); + m.execute(list); +} - //Read in a file containing a program and convert into a list of - //string instructions - private List<String> readInstructions(String file) +@Test public void BVA17A_AddTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R12 10"); + list.add("add R20 R10 R12"); + list.add("Ret R20"); + Machine m = new Machine(); + assertEquals("Testing for valid add instruction",m.execute(list),15); +} + +@Test public void BVA18A_SubtractTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R12 110"); + list.add("sub R20 R12 R10"); + list.add("Ret R20"); + Machine m = new Machine(); + assertEquals("VTesting for valid subract instruction",m.execute(list),105); +} + +@Test public void BVA19A_MultiplyTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 6"); + list.add("mov R12 5"); + list.add("mul R20 R10 R12"); + list.add("Ret R20"); + Machine m = new Machine(); + long value = 4294836225L; + assertEquals("Testing for valid multiply instruction",m.execute(list),30); +} + +@Test public void BVA20A_DivideTest() +{ + Machine m = new Machine(); + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R12 121"); + list.add(" "); + list.add("Div R20 R12 R10"); + list.add("Ret R20"); + assertEquals("Testing for valid divide instruction",m.execute(list),24); + assertEquals( m.getCount(),5); +} +//Testing for no return value, where it should throw exception +@Test(expected = NoReturnValueException.class) +public void BVA21A_noReturnInstructionTest() throws Throwable { - 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; + List<String> list = new ArrayList<String>(); + list.add("mov R10 90"); + list.add("mov R12 30"); + list.add("mul R20 R10 R12"); + list.add(" "); + Machine m = new Machine(); + m.execute(list); } } diff --git a/test/swen90006/machine/PartitioningTests.java b/test/swen90006/machine/PartitioningTests.java index 5494b44f4615351a610fc7b0b649d30b4b2d0a40..bc3db1c9437f04a768d05df6909f784d149039e1 100644 --- a/test/swen90006/machine/PartitioningTests.java +++ b/test/swen90006/machine/PartitioningTests.java @@ -12,79 +12,275 @@ 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() +/*** + * it should finish early without returning a value, but it throwing +NoReturnValueException +updating the assumption that it would return noreturnvalue exception +so it would not affect the mutation analysis proces + */ +@Test(expected = NoReturnValueException.class) + public void EC1pcLessThanZeroTest() + { + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R12 10"); + list.add("add R20 R10 R12"); + list.add("jmp -20"); + list.add("Ret R20"); + Machine m = new Machine(); + m.execute(list); + } +/*** + * it should finish early without returning a value, but it throwing +NoReturnValueException +updating the assumption that it would return noreturnvalue exception +so it would not affect the mutation analysis proces + */ +@Test(expected = NoReturnValueException.class) +public void EC2pcHigherTest() { + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R12 10"); + list.add("add R20 R10 R12"); + list.add("jmp 20");//making pc higher than number of instructions + list.add("Ret R20"); + Machine m = new Machine(); + m.execute(list); } + +@Test(expected = InvalidInstructionException.class) +public void EC3inValidLowRegisterTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("ret r-10"); + Machine m = new Machine(); + m.execute(list); +} + +@Test(expected = InvalidInstructionException.class) +public void EC4inValidHighRegisterTest() throws Throwable + { + List<String> list = new ArrayList<String>(); + list.add("mov r100 120"); + list.add("ret r100"); + Machine m = new Machine(); + m.execute(list); + } - //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() - { - } +@Test public void EC5LowerMemoryAddressTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R20 590"); + list.add("sTr R10 -50 R20"); + list.add("ldr R12 r10 -50"); + list.add("ret R12"); + Machine m = new Machine(); + assertEquals("Tesing for stroing reading from memory lower than range(0)",m.execute(list),0); + } + +@Test public void EC6HigherMemoryAddressTest() + {List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov r12 89"); + list.add("mov R20 590"); + list.add("sTr R10 65532 R20"); + list.add("ldr R12 r10 65532");//would return old value not new one, as new is invalid memory + list.add("ret R12"); + Machine m = new Machine(); + assertEquals("Tesing for stroing reading from memory higher than range (65535)",m.execute(list),89); + } - //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); - } +//Testing for value field's value lower than range (-65535) +@Test(expected = InvalidInstructionException.class) +public void EC7LowValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov r10 -65590"); + list.add("ret r10"); + Machine m = new Machine(); + m.execute(list); +} - @Test public void anotherTest() - { - List<String> list = new ArrayList<String>(); - list.add("a"); - list.add("b"); +@Test(expected = InvalidInstructionException.class) +public void EC8HighValueTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov r10 65590"); + list.add("ret r10"); + Machine m = new Machine(); + m.execute(list); +} - //the assertTrue method is used to check whether something holds. - assertTrue(list.contains("a")); - } +/*** + * Next two tests for higher than and lower than register's capacity + * which should throw arithmeticException, + * which are failing here, so just commenting here as it would affect the + * mutation analysis process + */ +/* @Test(expected = java.lang.ArithmeticException.class)//Failed test +public void EC9HigherThansRegisterCapacityTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 65530"); + list.add("mov R12 65530"); + list.add("mul R20 R10 R12"); + list.add("Ret R20"); + Machine m = new Machine(); + m.execute(list); +} - //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(); - } +@Test(expected = java.lang.ArithmeticException.class)//Failed test +public void EC10LowerThansRegisterCapacityTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 -65530"); + list.add("mov R12 65530"); + list.add("mul R20 R10 R12"); + list.add("Ret R20"); + Machine m = new Machine(); + m.execute(list); + +}*/ - //This test should fail. - //To provide additional feedback when a test fails, an error message - //can be included - @Test public void aFailedTest() +@Test public void EC11LoadToMemoryTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R20 590"); + list.add("sTr R10 105 R20"); + list.add("ldr R12 r10 105"); + list.add("ret R12"); //return the value from the memory + Machine m = new Machine(); + assertEquals("Testing for valid readin/writing to memory",m.execute(list),590); +} + +@Test public void EC12JMPTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("jmp 2"); + list.add("mov R10 20"); + list.add("ret R10"); + Machine m = new Machine(); + assertEquals("Testing from valid JMP instruction",m.execute(list),5); +} + +@Test public void EC13JZTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 0"); + list.add("mov R12 121"); + list.add("jz R10 2");//skipped the next instruction, so R12 value stays at 121 + list.add("mov R12 100"); + list.add("Ret R12"); + Machine m = new Machine(); + assertEquals("Testing from valid JZ instruction",m.execute(list),121); +} + +@Test public void EC14BlankLineTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add(" "); + list.add("ret R10"); + Machine m = new Machine(); + assertEquals("Testing from valid blank line",m.execute(list),5); +} + +@Test public void EC15CommentLineTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov r10 45 ;;"); + list.add(";mov r10 54 hello this is comment"); + list.add("ret R10"); + Machine m = new Machine(); + assertEquals("Testing from comment instruction",m.execute(list),45); +} + +@Test(expected = InvalidInstructionException.class) +public void EC16unrecognizedInstructionTest() throws Throwable +{ + List<String> list = new ArrayList<String>(); + list.add("sqrt 30"); + list.add("ret r21"); + Machine m = new Machine(); + m.execute(list); +} + +@Test public void E17AddTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R12 10"); + list.add("add R20 R10 R12"); + list.add("Ret R20"); + Machine m = new Machine(); + assertEquals("Testing from valid add instruction",m.execute(list),15); +} + +@Test public void EC18SubtractTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R12 110"); + list.add("sub R20 R12 R10"); + list.add("Ret R20"); + Machine m = new Machine(); + assertEquals("Testing from valid subtract instruction",m.execute(list),105); +} + +@Test public void EC19MultiplyTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 6"); + list.add("mov R12 5"); + list.add("mul R20 R10 R12"); + list.add("Ret R20"); + Machine m = new Machine(); + long value = 4294836225L; + assertEquals("Testing from valid multiply instruction",m.execute(list),30); +} + +@Test public void EC20DivideTest() +{ + List<String> list = new ArrayList<String>(); + list.add("mov R10 5"); + list.add("mov R12 121"); + list.add(" "); + list.add("Div R20 R12 R10"); + list.add("Ret R20"); + Machine m = new Machine(); + assertEquals("Testing from valid divide instruction",m.execute(list),24); + } + +/* + loop/ just commenting it out so, it wouldnot affect mutation analysis. + @Test(expected = NoReturnValueException.class) +public void EC21noReturnLoopTest() throws Throwable// array out of bound exception { - //include a message for better feedback - final int expected = 2; - final int actual = 1 + 2; - assertEquals("Some failure message", expected, actual); - } + List<String> list = new ArrayList<String>(); + list.add("mov R10 90"); + list.add("mov R12 30"); + list.add("mul R20 R10 R12"); + list.add("jmp 0");//loop + list.add(" "); + Machine m = new Machine(); + m.execute(list); + }*/ - //Read in a file containing a program and convert into a list of - //string instructions - private List<String> readInstructions(String file) +@Test(expected = NoReturnValueException.class) +public void EC22noReturnInstructionTest() throws Throwable// array out of bound exception { - 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; + List<String> list = new ArrayList<String>(); + list.add("mov R10 90"); + list.add("mov R12 30"); + list.add("mul R20 R10 R12"); + list.add(" "); + Machine m = new Machine(); + m.execute(list); } + }