Cleanup tests
This commit is contained in:
parent
0fea092675
commit
eeac3a69f8
|
@ -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})")
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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:"));
|
||||||
|
|
Loading…
Reference in New Issue