Search in sources :

Example 21 with Mos6502Compiler

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);
    }
}
Also used : UnknownTokenException(com.rox.emu.UnknownTokenException) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 22 with Mos6502Compiler

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"));
    }
}
Also used : Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 23 with Mos6502Compiler

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);
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) UnknownOpCodeException(com.rox.emu.UnknownOpCodeException) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 24 with Mos6502Compiler

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);
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 25 with Mos6502Compiler

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);
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Aggregations

Mos6502Compiler (com.rox.emu.processor.mos6502.util.Mos6502Compiler)36 Program (com.rox.emu.processor.mos6502.util.Program)32 Test (org.junit.Test)25 Property (com.pholser.junit.quickcheck.Property)10 UnknownOpCodeException (com.rox.emu.UnknownOpCodeException)5 UnknownTokenException (com.rox.emu.UnknownTokenException)3 Memory (com.rox.emu.mem.Memory)2 SimpleMemory (com.rox.emu.mem.SimpleMemory)2