use of com.rox.emu.processor.mos6502.util.Mos6502Compiler in project emuRox by rossdrew.
the class Mos6502CompilerTest method opCode1JaCoCoCoverage.
@Test
public void opCode1JaCoCoCoverage() {
final Mos6502Compiler compiler = new Mos6502Compiler("\0ADC $10");
try {
compiler.compileProgram();
fail("Exception expected. This should not pass a String switch statement");
} catch (UnknownTokenException e) {
assertTrue(e.getMessage().contains("\0ADC"));
assertNotNull(e);
}
}
use of com.rox.emu.processor.mos6502.util.Mos6502Compiler in project emuRox by rossdrew.
the class Mos6502CompilerTest method testNumericalLabelError.
@Test
public void testNumericalLabelError() {
try {
final Mos6502Compiler compiler = new Mos6502Compiler("MyLabel: SEC BCS 42");
compiler.compileProgram();
fail("Expected compilation to fail, '42' is not a valid label");
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains("BCS"));
assertTrue(e.getMessage().contains("42"));
}
}
use of com.rox.emu.processor.mos6502.util.Mos6502Compiler in project emuRox by rossdrew.
the class Mos6502CompilerTest method testInvalidArgument.
@Test
public void testInvalidArgument() {
try {
final Mos6502Compiler compiler = new Mos6502Compiler("INC $12345");
Program program = compiler.compileProgram();
program.getProgramAsByteArray();
fail("The argument for INC is too long, should throw an error");
} catch (UnknownOpCodeException e) {
assertNotNull(e);
}
}
use of com.rox.emu.processor.mos6502.util.Mos6502Compiler in project emuRox by rossdrew.
the class Mos6502CompilerTest method testInlineCommentRemoval.
@Test
public void testInlineCommentRemoval() {
final Mos6502Compiler compiler = new Mos6502Compiler("SEC ;this should not be parsed\nCLC");
Program program = compiler.compileProgram();
int[] bytes = program.getProgramAsByteArray();
assertEquals(2, bytes.length);
}
use of com.rox.emu.processor.mos6502.util.Mos6502Compiler in project emuRox by rossdrew.
the class Mos6502CompilerTest method testChainedInstruction.
@Test
public void testChainedInstruction() {
final Mos6502Compiler compiler = new Mos6502Compiler("SEC LDA " + IMMEDIATE_VALUE_PREFIX + "47");
final Program program = compiler.compileProgram();
int[] bytes = program.getProgramAsByteArray();
int[] expected = new int[] { OpCode.SEC.getByteValue(), OpCode.LDA_I.getByteValue(), 0x47 };
assertArrayEquals("Expected: " + Arrays.toString(expected) + ", Got: " + Arrays.toString(bytes), expected, bytes);
}
Aggregations