Close

Test Driven Development

A project log for Z80 Computer

Yet another Z80 computer.

james-otsJames Ots 05/23/2017 at 21:270 Comments

I started writing a monitor programme for my Z80 computer last night, and got slightly frustrated by how difficult it was to test that my routines were working properly. So I wrote a Test Driven Development tool.

It's very much a work in progress, but the progress so far can be seen here: https://github.com/jamesots/zat

It's written in TypeScript to work inside Jasmine. Here is a brief example:

it('should work', function() {
    zat.compile(`
    start:
        ld a,0
        halt
        org 20
    newstart:
        ld a,$12
        nop
        nop
    breakhere:
        ld a,$ff
        halt
    `)
    zat.run('newstart', {breakAt:'breakhere'});
    expect(zat.registers.a).toBe(0x12);
});

It can also ompile external files and track and respond to IO and memory requests from JavaScript.

It's useable now, but it needs more work — in particular, I want to track IO automatically so that it is easier to write expectations about IO, and it needs to be packaged properly to use from NPM. I imagine the API will change a fair bit over the next few days (or whenever I get to look at this again.)

Discussions