Skip to content

Commit

Permalink
Add first instruction test
Browse files Browse the repository at this point in the history
  • Loading branch information
fraya committed May 13, 2024
1 parent 942dce2 commit d65a85f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions sources/brainfuck.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ define inline method program-forth
interpreter.program-pointer := interpreter.program-pointer + 1
end;


////////////////////////////////////////////////////////////////////////
//
// Execute methods
Expand Down
1 change: 1 addition & 0 deletions sources/library.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ define module brainfuck-impl
// Memory instructions

export
interpreter-memory,
<memory-instruction>,
instruction-amount,
<memory-data-instruction>,
Expand Down
34 changes: 31 additions & 3 deletions tests/brainfuck-test-suite.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ define test test-memory ()
assert-equal(0, memory.memory-item);
end;

///////////////////////////////////////////////////////////////////////////////
//
// Test instructions
//
//////////////////////////////////////////////////////////////////////////////

define test memory-data-increment-test ()
let bf = run(read-program("+"));
expect-equal(1, bf.program-pointer);
expect-equal(1, bf.interpreter-memory.memory-item);
end test;

define suite instruction-test-suite ()
test memory-data-increment-test;
end suite;

//////////////////////////////////////////////////////////////////////////////
//
// Read a program
Expand All @@ -27,7 +43,7 @@ end;

//////////////////////////////////////////////////////////////////////////////
//
// Reset to zero tests
// Optimization tests
//
//////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -57,11 +73,23 @@ define test test-precalculate-jumps ()
assert-equal(make(<jump-forward>, address: 5), optimized.first);
end;

define suite brainfuck-test-suite ()
test test-parse-instructions;
define suite optimization-test-suite ()
test test-reset-to-zero;
test test-group-instructions;
test test-precalculate-jumps;
end suite;

//////////////////////////////////////////////////////////////////////////////
//
// All tests
//
//////////////////////////////////////////////////////////////////////////////


define suite brainfuck-test-suite ()
test test-parse-instructions;
suite instruction-test-suite;
suite optimization-test-suite;
end;

// Use `_build/bin/dylan-brainfuck-test-suite --help` to see options.
Expand Down

0 comments on commit d65a85f

Please sign in to comment.