Cleanup tests

This commit is contained in:
Felipe Lima 2017-03-07 22:25:59 -08:00
parent 0fea092675
commit eeac3a69f8
4 changed files with 11 additions and 34 deletions

View File

@ -70,7 +70,6 @@ class CPU(val memory: Memory) : Display.Callbacks {
while (true) { while (true) {
setRandomByte() setRandomByte()
executeNextInstruction() executeNextInstruction()
if (PC == 0 || !isRunning) { if (PC == 0 || !isRunning) {
break break
} }
@ -111,7 +110,6 @@ class CPU(val memory: Memory) : Display.Callbacks {
} else { } else {
val candidate = Opcodes.MAP.entries val candidate = Opcodes.MAP.entries
.first { it.value.any { opcode -> opcode == instruction } } .first { it.value.any { opcode -> opcode == instruction } }
throw Exception( throw Exception(
"Address $${PC.toHexString()} - unknown opcode 0x${instruction.toHexString()} " + "Address $${PC.toHexString()} - unknown opcode 0x${instruction.toHexString()} " +
"(instruction ${candidate.key.name})") "(instruction ${candidate.key.name})")

View File

@ -1,10 +1,9 @@
package android.emu6502; package android.emu6502;
import android.emu6502.instructions.Symbols;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.junit.Before; import android.emu6502.instructions.Symbols;
import org.junit.Test; import org.junit.Test;
import java.util.List; import java.util.List;
@ -15,12 +14,7 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
public class AssemblerTest { public class AssemblerTest {
private final Assembler assembler = new Assembler(new Memory(mock(Display.class)), new Symbols());
private Assembler assembler;
@Before public void setUp() {
assembler = new Assembler(new Memory(mock(Display.class)), new Symbols());
}
@Test public void testSimple() { @Test public void testSimple() {
List<String> lines = ImmutableList.of( List<String> lines = ImmutableList.of(

View File

@ -1,10 +1,9 @@
package android.emu6502; package android.emu6502;
import android.emu6502.instructions.Symbols;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.junit.Before; import android.emu6502.instructions.Symbols;
import org.junit.Test; import org.junit.Test;
import java.util.List; import java.util.List;
@ -14,16 +13,9 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
public class CPUTest { public class CPUTest {
private final Memory memory = new Memory(mock(Display.class));
private CPU cpu; private final Assembler assembler = new Assembler(memory, new Symbols());
private Assembler assembler; private final CPU cpu = new CPU(memory);
@Before public void setUp() {
Memory memory = new Memory(mock(Display.class));
assembler = new Assembler(memory, new Symbols());
cpu = new CPU(memory);
}
@Test public void testSimple() { @Test public void testSimple() {
List<String> lines = ImmutableList.of( List<String> lines = ImmutableList.of(

View File

@ -2,7 +2,6 @@ package android.emu6502;
import android.emu6502.instructions.Symbols; import android.emu6502.instructions.Symbols;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.util.Collections; import java.util.Collections;
@ -12,15 +11,9 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
public class LabelsTest { public class LabelsTest {
private final Symbols symbols = new Symbols();
private Labels labels; private final Assembler assembler = new Assembler(new Memory(mock(Display.class)), symbols);
private Assembler assembler; private final Labels labels = new Labels(assembler, symbols);
@Before public void setUp() {
Symbols symbols = new Symbols();
assembler = new Assembler(new Memory(mock(Display.class)), symbols);
labels = new Labels(assembler, symbols);
}
@Test public void testAddLabel() { @Test public void testAddLabel() {
labels.indexLines(Collections.singletonList("test:")); labels.indexLines(Collections.singletonList("test:"));