Open s-daveb opened 8 years ago
I've been working on fully implementing the ADC instruction, and I have this at the top of my unit test, to help me return things to a known state in between tests:
unittest
{
auto cpu = new MOS6502;
auto decoder = cpu._decoder;
auto ram = Console.ram;
ulong cycles_start = 0;
ulong cycles_taken = 0;
Instruction testInstruction;
void initializeCpu(MOS6502 argCpu, ref IMemory refMem) {
cpu.reset();
Console.ram = null;
argCpu._registers.a = 0;
argCpu._status.c = argCpu._status.v = argCpu._status.z = 0;
cpu.powerOn();
assert(cpu._registers.a == 0);
assert(cpu._status.c == 0);
assert(cpu._status.v == 0);
assert(cpu._status.z == 0);
assert(Console.ram !is null);
assert(refMem !is Console.ram);
refMem = Console.ram;
}
// ADC Test Setup
cpu.powerOn();
initializeCpu(cpu, ram);
@bobomb in case we don't get to meet this week, we should try and get some of our ideas down on this issue.
Today at lunch you mentioned you want to generalize the test setup for instructions with zero-page addressing.
I've recently been thinking about something related. I noticed a lot of our unit tests re-use state from prior tests of the same instruction. Maybe we should be calling
cpu.powerOn()
orcpu.reset()
in between tests, or perhaps writing a custom function for each unit test that "resets" the cpu, RAM and console.Topics to Discuss