Skip to content

Commit

Permalink
Add host test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
tkers committed Aug 28, 2019
1 parent 5eec522 commit ef059bd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ examples: \
examples/happy-birthday/happy-birthday.gb \
examples/sokoban/sokoban.gb \
examples/goto10/goto10.gb \
examples/synth/synth.gb
examples/synth/synth.gb \
examples/test-suite/test-suite.gb

examples/hello-world-asm/hello.gb: examples/hello-world-asm/hello.fs examples/hello-world-asm/*.fs $(SOURCE_FILES) $(LIB_FILES)
$(GBFORTH) --no-kernel $< $@
Expand All @@ -49,6 +50,7 @@ clean:
-rm -f examples/sokoban/sokoban.gb
-rm -f examples/goto10/goto10.gb
-rm -f examples/synth/synth.gb
-rm -f examples/test-suite/test-suite.gb
-rm -f $(TEST_OBJS)

#
Expand Down
32 changes: 32 additions & 0 deletions examples/test-suite/test-suite.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
title: ANSTESTSUITE
gamecode: ANSF

require ibm-font.fs
require logger.fs
require tester.fs

variable #total
: }T 1 #total +! }T ;

: run-tests
log" Dup"
T{ 1 2 dup -> 1 2 2 }T
T{ -5 dup dup -> -5 -5 -5 }T

log" Swap"
T{ 1 2 3 swap -> 1 3 2 }T
T{ 1 2 3 swap swap -> 1 2 3 }T

;

: main
install-font
init-logger
init-tester
0 #total !
log" Starting tests..."
run-tests
log" --------------------"
#total @ 2 .r space log" Total"
#total @ #errors @ - 2 .r space log" Passed"
#errors @ 2 .r space log" Failed" ;
2 changes: 1 addition & 1 deletion test/gbtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = filename => {
},

get frameSha() {
return getSha(frame);
return frame && getSha(frame);
},

get depth() {
Expand Down
18 changes: 18 additions & 0 deletions test/test-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,21 @@ describe("hello-world-asm", () => {
);
});
});

describe("ans-test-suite", () => {
const gb = require("./gbtest")(
path.resolve(__dirname, "../examples/ans-test-suite/ans-test-suite.gb")
);

test("all tests pass", () => {
gb.steps(10);
gb.run();
gb.steps(100);
gb.saveFrame(
path.resolve(__dirname, "../examples/ans-test-suite/ans-test-suite.png")
);
expect(gb.frameSha).toBe(
"1dded7c5cbaaa4b94377fc76574deffb0869ee65e9b72dfafae0604304fbe365"
);
});
});

0 comments on commit ef059bd

Please sign in to comment.