All Projects → rhargreaves → zx-spec

rhargreaves / zx-spec

Licence: MIT License
A unit testing framework for Sinclair ZX Spectrum assembly

Programming Languages

assembly
5116 projects
python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to zx-spec

zx-sizif-512
ZX Spectrum CPLD-based clone for rubber case
Stars: ✭ 92 (+187.5%)
Mutual labels:  z80, zx-spectrum
6502.Net
A .Net-based Cross-Assembler for Several 8-Bit Microprocessors
Stars: ✭ 44 (+37.5%)
Mutual labels:  z80, zx-spectrum
doctest
The fastest feature-rich C++11/14/17/20 single-header testing framework
Stars: ✭ 4,434 (+13756.25%)
Mutual labels:  unit-testing, tdd
HiSoft-C
Disassembled code of HiSoft C compiler for ZX Spectrum
Stars: ✭ 20 (-37.5%)
Mutual labels:  z80, zx-spectrum
SimplyVBUnit
The SimplyVBUnit framework provides powerful unit-testing capabilities for VB6.
Stars: ✭ 28 (-12.5%)
Mutual labels:  unit-testing, tdd
channels
ZX Spectrum browser for forums and imageboards
Stars: ✭ 52 (+62.5%)
Mutual labels:  z80, zx-spectrum
utest
Lightweight unit testing framework for C/C++ projects. Suitable for embedded devices.
Stars: ✭ 18 (-43.75%)
Mutual labels:  unit-testing, tdd
Quiz App
A repository reflecting the progress made on the "How to Build iOS Apps with Swift, TDD & Clean Architecture" YouTube series, by Caio & Mike.
Stars: ✭ 230 (+618.75%)
Mutual labels:  unit-testing, tdd
oletus
Minimal ECMAScript Module test runner
Stars: ✭ 43 (+34.38%)
Mutual labels:  unit-testing, tdd
book-fullstack-react-with-typescript
Working through the code samples from Fullstack React with Typescript by Maksim Ivanov and Alex Bespoyasov
Stars: ✭ 52 (+62.5%)
Mutual labels:  unit-testing, tdd
chai-exclude
Exclude keys to compare from a deep equal operation with chai expect or assert.
Stars: ✭ 33 (+3.13%)
Mutual labels:  unit-testing, tdd
zx-spectrum-games
Collection of ZX Spectrum annotated game source code dissasemblies as .skool files
Stars: ✭ 35 (+9.38%)
Mutual labels:  z80, zx-spectrum
jetpac-disassembly
JETPAC: annotated source code disassembly of this classic 8-bit game (1983, ZX Spectrum)
Stars: ✭ 36 (+12.5%)
Mutual labels:  z80, zx-spectrum
apultra
Free open-source compressor for apLib with 5-7% better ratios
Stars: ✭ 84 (+162.5%)
Mutual labels:  z80, zx-spectrum
Alsatian
TypeScript testing framework with test cases
Stars: ✭ 244 (+662.5%)
Mutual labels:  unit-testing, tdd
spectrum128 cpm
zx spectrum 128 emulation on stm32f407 + Grant Searle's CP/M system port ili9341 16 bit display
Stars: ✭ 29 (-9.37%)
Mutual labels:  z80, zx-spectrum
Fluentassertions
A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.7, .NET Core 2.1 and 3.0, as well as .NET Standard 2.0 and 2.1. Supports the unit test frameworks MSTest2, NUnit3, XUnit2, MSpec, and NSpec3.
Stars: ✭ 2,449 (+7553.13%)
Mutual labels:  unit-testing, tdd
Transport Eta
Twitch streamed 🎥playground repo, README speaks to you.
Stars: ✭ 223 (+596.88%)
Mutual labels:  unit-testing, tdd
The-Great-Escape
Classic ZX Spectrum game "The Great Escape" reverse engineered
Stars: ✭ 69 (+115.63%)
Mutual labels:  z80, zx-spectrum
lighthouse-of-doom
A simple text-based adventure game
Stars: ✭ 52 (+62.5%)
Mutual labels:  z80, zx-spectrum

ZX Spec Build Status

A framework for test-driving assembly code for the Sinclair ZX Spectrum 48k.

Usage

The framework has been written with the Pasmo assembler. Simply grab the source in src and include zx-spec.asm to write tests:

include src/zx-spec.asm

spec_init
    
    describe 'ld a,n'
        it 'sets A register to value'
            ld a,5
            assert_a_equal 5

spec_end

Names and Groupings

You can optionally name a set of asserts using the it macro. This groups the asserts into a single test. In addition to it, you can use the describe macro to group one or more tests. Nested describe or it macros are not permitted.

Verbose Output

By default test descriptions are not output for tests that pass. You can output test descriptions even for passing tests by defining zxspec_config_verbose_output as non-zero either on the command-line of Pasmo (--equ zxspec_config_verbose_output), or in code before you call spec_init:

    zxspec_config_verbose_output    equ    $FF

This can be used to generate a form of living documentation for your project.

Hexadecimals

By default, expected and actual values are displayed as decimals. You can switch to hexadecimal by defining zxspec_config_display_numbers_as_hex as non-zero either on the command-line of Pasmo (--equ zxspec_config_display_numbers_as_hex), or in code before you call spec_init:

    zxspec_config_display_numbers_as_hex    equ    $FF

See test/test-hex.asm for example usage. Note that assert_bytes_equal always displays expected/actual bytes as a comma-seperated list of hexadecimal pairs, regardless of this setting.

Assertions

See test/test-passes.asm for examples.

You can immediately pass or fail a test by using:

  • assert_pass
  • assert_fail

Registers

These assertions will preserve register values.

8-bit

  • assert_a_equal
  • assert_a_not_equal
  • assert_b_equal
  • assert_b_not_equal
  • assert_c_equal
  • assert_c_not_equal
  • assert_d_equal
  • assert_d_not_equal
  • assert_e_equal
  • assert_e_not_equal
  • assert_h_equal
  • assert_h_not_equal
  • assert_l_equal
  • assert_l_not_equal
  • assert_a_is_zero
  • assert_a_is_not_zero

16-bit

  • assert_bc_equal
  • assert_bc_not_equal
  • assert_de_equal
  • assert_de_not_equal
  • assert_hl_equal
  • assert_hl_not_equal
  • assert_ix_equal
  • assert_ix_not_equal
IY

Asserting on the IY register value is not currently supported. The IY register is used by Spectrum ROM routines as a index to system variables and is not generally recommended to be used in custom routines due to the added complexity of ensuring its use does not interfere with normal operation.

Flags

  • assert_z_set
  • assert_z_reset
  • assert_carry_set
  • assert_carry_reset
  • assert_s_set
  • assert_s_reset
  • assert_p_v_set
  • assert_p_v_reset

Memory

Be warned that these assertions will not preserve register values.

Single-Byte

  • assert_byte_equal
  • assert_byte_not_equal

Double-Byte Word

  • assert_word_equal
  • assert_word_not_equal

Strings

  • assert_str_equal
  • assert_str_not_equal

Multiple Bytes

  • assert_bytes_equal
  • assert_bytes_not_equal

Dependencies

  • Python 2.7 (for running ZX Spec tests)

  • Docker (for running Pasmo)

  • Fuse Emulator

    Linux

    $ sudo apt-get install fuse-emulator-common spectrum-roms

    macOS

    $ brew install homebrew/games/fuse-emulator

    You can also run Fuse with Docker by setting the FUSE environment variable accordingly:

    $ export "FUSE=docker run -v /tmp/.X11-unix:/tmp/.X11-unix --privileged -e DISPLAY=unix$DISPLAY -it rhargreaves/fuse-emulator"

Tests

ZX Spec can be tested by running:

$ make test

Two sets of automated tests will run. One set results in all tests passing, and the other set results in all tests failing. The results are sent to an emulated ZX Printer (rather than sent to the display) which is then output by the emulator to a text file. This file is then validated to ensure the framework is working correctly.

Unfortunately, the speed of the ZX Printer is also emulated resulting in the tests taking a few minutes to complete. I don't currently know of a way to speed this up!

Demos

You can run a couple of example demos:

When all tests pass...

$ make demo-green

When all tests fail...

$ make demo-red

When there's a mixture...

$ make demo-mix

Example Kata

I had a go at completing part of the Checkout Kata using this framework.

Credits

  • This project was inspired by 64spec - a Commodore 64 Testing Framework
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].