Skip to content

Unit testing framework #28

Description

@s-daveb

@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() or cpu.reset() in between tests, or perhaps writing a custom function for each unit test that "resets" the cpu, RAM and console.

Topics to Discuss

  • Unit test granularity
    • Should we write one unit test per instruction, or should we split it up to one unit test per "instruction-addressingMode"?
  • Unit test Initialization
    • Even if we split the unit tests up into numerous smaller tests, we still need to reset the status register in between test cases, otherwise we won't know if the C or V flag was toggled by the first test case, etc.
  • What do we want to generalize?
    • Should we have an initialization function for each unit test?
    • We will probably have one test initialization function for each type of addressing mode
    • I would really really like for the assert messages to print out the variables it's comparing, or at least the incorrect value the unit test is detecting.
  • Implementation questions
    • Could we use mixins (similar to C++ templates or C Macros), in order to generate the initialization routines?
      • Template Mixins are also an option: "It is useful for injecting parameterized ‘boilerplate’ code, as well as for creating templated nested functions, which is not possible with template instantiations."
    • Or should we create a separate dlang module?
      • I'd prefer to use a pre-existing unit testing framework, but I think we might need something 6502-specific.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions