- Major overhaul of the Simulator control class (where 'main' lives).
- Removed the CommandParser class entirely, as the weird dependency between Simulator and CommandParser never made me comfortable. - Added a Command inner class to Simulator that handles some of the command line tokenizing.
This commit is contained in:
1 parent
5c7a98df86
commit
a3e57274a2
11 files changed
+364
-122
No files matched your search
@@ -0,0 +1,64 @@
|
||||
package com.loomcom.symon;
|
||||
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class CommandTest {
|
||||
|
||||
@Test
|
||||
public void testCommandShouldParseCorrectNumberOfArguments() {
|
||||
Simulator.Command c;
|
||||
|
||||
c = new Simulator.Command("foo");
|
||||
assertEquals("foo", c.getCommand());
|
||||
assertEquals(0, c.numArgs());
|
||||
|
||||
c = new Simulator.Command("foo bar");
|
||||
assertEquals("foo", c.getCommand());
|
||||
assertEquals(1, c.numArgs());
|
||||
assertEquals("bar", c.getArgs()[0]);
|
||||
|
||||
c = new Simulator.Command("foo bar baz quux 0 100");
|
||||
assertEquals("foo", c.getCommand());
|
||||
assertEquals(5, c.numArgs());
|
||||
assertEquals("bar", c.getArgs()[0]);
|
||||
assertEquals("baz", c.getArgs()[1]);
|
||||
assertEquals("quux", c.getArgs()[2]);
|
||||
assertEquals("0", c.getArgs()[3]);
|
||||
assertEquals("100", c.getArgs()[4]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommandShouldIgnoreWhitespaceBetweenTokens() {
|
||||
Simulator.Command c;
|
||||
|
||||
c = new Simulator.Command("foo bar baz");
|
||||
assertEquals("foo", c.getCommand());
|
||||
assertEquals(2, c.numArgs());
|
||||
assertEquals("bar", c.getArgs()[0]);
|
||||
assertEquals("baz", c.getArgs()[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommandShouldIgnoreWhitespaceBeforeCommand() {
|
||||
Simulator.Command c;
|
||||
|
||||
c = new Simulator.Command(" foo bar baz");
|
||||
assertEquals("foo", c.getCommand());
|
||||
assertEquals(2, c.numArgs());
|
||||
assertEquals("bar", c.getArgs()[0]);
|
||||
assertEquals("baz", c.getArgs()[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommandShouldIgnoreWhitespaceAfterCommand() {
|
||||
Simulator.Command c;
|
||||
|
||||
c = new Simulator.Command("foo bar baz ");
|
||||
assertEquals("foo", c.getCommand());
|
||||
assertEquals(2, c.numArgs());
|
||||
assertEquals("bar", c.getArgs()[0]);
|
||||
assertEquals("baz", c.getArgs()[1]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class CpuAbsoluteXModeTest extends TestCase {
|
||||
0xa9, 0xff, // LDA #$ff
|
||||
0x3d, 0x05, 0x1a, // AND $1a05,X
|
||||
0xa9, 0x01, // LDA #$01
|
||||
0x3d, 0xd2, 0x1a); // AND $1ad2,X
|
||||
0x3d, 0xd2, 0x19); // AND $19d2,X
|
||||
cpu.step();
|
||||
assertEquals(0x00, cpu.getAccumulator());
|
||||
assertTrue(cpu.getZeroFlag());
|
||||
|
||||
@@ -115,7 +115,7 @@ public class CpuAbsoluteYModeTest extends TestCase {
|
||||
0xa9, 0xff, // LDA #$ff
|
||||
0x39, 0x05, 0x1a, // AND $1a05,Y
|
||||
0xa9, 0x01, // LDA #$01
|
||||
0x39, 0xd2, 0x1a); // AND $1ad2,Y
|
||||
0x39, 0xd2, 0x19); // AND $19d2,Y
|
||||
cpu.step();
|
||||
assertEquals(0x00, cpu.getAccumulator());
|
||||
assertTrue(cpu.getZeroFlag());
|
||||
|
||||
@@ -74,7 +74,7 @@ public class CpuImpliedModeTest extends TestCase {
|
||||
cpu.setOverflowFlag();
|
||||
assertEquals(0x20|Cpu.P_CARRY|Cpu.P_OVERFLOW,
|
||||
cpu.getProcessorStatus());
|
||||
assertEquals(0xff, cpu.stackPeek());
|
||||
assertEquals(0x00, cpu.stackPeek());
|
||||
assertFalse(cpu.getBreakFlag());
|
||||
assertEquals(0x0200, cpu.getProgramCounter());
|
||||
assertEquals(0xff, cpu.getStackPointer());
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.loomcom.symon;
|
||||
|
||||
import com.loomcom.symon.devices.Memory;
|
||||
import com.loomcom.symon.exceptions.MemoryAccessException;
|
||||
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -115,7 +115,7 @@ public class CpuIndirectXModeTest extends TestCase {
|
||||
0xa9, 0xff, // LDA #$ff
|
||||
0x3d, 0x05, 0x1a, // AND $1a05,X
|
||||
0xa9, 0x01, // LDA #$01
|
||||
0x3d, 0xd2, 0x1a); // AND $1ad2,X
|
||||
0x3d, 0xd2, 0x19); // AND $19d2,X
|
||||
cpu.step();
|
||||
assertEquals(0x00, cpu.getAccumulator());
|
||||
assertTrue(cpu.getZeroFlag());
|
||||
|
||||
@@ -70,7 +70,7 @@ public class CpuTest extends TestCase {
|
||||
|
||||
public void testStackPush() throws MemoryAccessException {
|
||||
assertEquals(0xff, cpu.getStackPointer());
|
||||
assertEquals(0xff, bus.read(0x1ff));
|
||||
assertEquals(0x00, bus.read(0x1ff));
|
||||
|
||||
cpu.stackPush(0x06);
|
||||
assertEquals(0xfe, cpu.getStackPointer());
|
||||
@@ -179,7 +179,7 @@ public class CpuTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testStackPeekDoesNotAlterStackPointer() throws MemoryAccessException {
|
||||
assertEquals(0xff, cpu.stackPeek());
|
||||
assertEquals(0x00, cpu.stackPeek());
|
||||
assertEquals(0xff, cpu.getStackPointer());
|
||||
|
||||
cpu.stackPush(0x01);
|
||||
|
||||
Reference in new issue
Block a user