News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_duncan_bayne

Test driven development on an Amstrad CPC

Started by duncan_bayne, 07:20, 06 July 13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

duncan_bayne

Hi Folks,

I'm trying to develop a (simple, Scheme-like) Lisp for the Amstrad CPC.  I'm hoping to develop it test-first, and my efforts are working so far.

See:
Running tests on an Amstrad CPC on Vimeo

All the source is up at duncan-bayne/zlisp · GitHub if you want to take a look at how I'm doing test driven development on this system. 

Elevator pitch: I have two different build targets.  One provides |REPL to run the Lisp environment (or at least, it will when I'm finished).  The other provides |TESTS to run the automated tests.

If you have any questions, please feel free to ask :)  This has been something of a learning experience for me, trying to follow modern development practices to develop software for an 8-bit micro.

Yours,
Duncan



Octoate

Great idea to bring TDD to CPC development. I will have a look at it for sure :)!
--

duncan_bayne

#2
Quote from: Octoate on 15:35, 07 July 13
Great idea to bring TDD to CPC development. I will have a look at it for sure :) !

Thanks :)

The rough approach I'm taking is to have two separate targets in the Makefile.  The default is the usual release build, and then there's another that compiles the tests including a main.c that runs them all.  Then, fire up the emulator and run |TESTS.  Here's an example test, checking that my changes to the SDCC heap size worked:

#include "lisp_tests.h"

void _test_heap_size();

void _test_heap_size()
{
  /* SDCC defaults to a 1kB heap size; check we have > 30kB to play with */
  void *block = malloc(30720);
  assert(block != NULL);
  free(block);
}

void run_lisp_tests()
{
  RUN_TEST(_test_heap_size);
}


RUN_TEST is a macro defined elsewhere:

#define RUN_TEST(a) printf("%s:%d ... ", __FILE__, __LINE__); a(); printf("OK\r\n");

It works well so far but I'm concerned about running out of resources with a complex program and a large test suite.

Powered by SMFPacks Menu Editor Mod