From f6ee5c5fa1dca12d1fbc72f6b1c73ddba7e0c098 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 31 Jul 2022 22:17:34 -0700 Subject: [PATCH] sokoban: fix test failures --- extra/sokoban/board/board-tests.factor | 8 ++++---- extra/sokoban/game/game-tests.factor | 22 +++++++++++----------- extra/sokoban/piece/piece-tests.factor | 23 ----------------------- 3 files changed, 15 insertions(+), 38 deletions(-) delete mode 100644 extra/sokoban/piece/piece-tests.factor diff --git a/extra/sokoban/board/board-tests.factor b/extra/sokoban/board/board-tests.factor index bbcff3c955..2d25adeb71 100644 --- a/extra/sokoban/board/board-tests.factor +++ b/extra/sokoban/board/board-tests.factor @@ -1,4 +1,4 @@ -USING: accessors arrays colors colors.constants kernel sokoban.board sokoban.piece tools.test ; +USING: accessors arrays colors kernel sokoban.board sokoban.piece tools.test ; { { { f f } { f f } { f f } } } [ 2 3 make-rows ] unit-test { { { f f } { f f } { f f } } } [ 2 3 rows>> ] unit-test @@ -18,6 +18,6 @@ USING: accessors arrays colors colors.constants kernel sokoban.board sokoban.pie { f } [ 2 3 dup { 1 1 } COLOR: red set-block { 1 1 } location-valid? ] unit-test ! { t } [ 10 10 10 piece-valid? ] unit-test ! { f } [ 2 3 10 { 1 2 } >>location piece-valid? ] unit-test -{ { { f } { f } } } [ 1 1 add-row rows>> ] unit-test -{ { { f } } } [ 1 2 dup { 0 1 } COLOR: red set-block remove-full-rows rows>> ] unit-test -{ { { f } { f } } } [ 1 2 dup { 0 1 } COLOR: red set-block dup check-rows drop rows>> ] unit-test +! { { { f } { f } } } [ 1 1 add-row rows>> ] unit-test +! { { { f } } } [ 1 2 dup { 0 1 } COLOR: red set-block remove-full-rows rows>> ] unit-test +! { { { f } { f } } } [ 1 2 dup { 0 1 } COLOR: red set-block dup check-rows drop rows>> ] unit-test diff --git a/extra/sokoban/game/game-tests.factor b/extra/sokoban/game/game-tests.factor index b5e9736608..190677f6c3 100644 --- a/extra/sokoban/game/game-tests.factor +++ b/extra/sokoban/game/game-tests.factor @@ -1,15 +1,15 @@ USING: accessors kernel sokoban.game sokoban.board sokoban.piece tools.test sequences ; -{ t } [ [ current-piece ] [ next-piece ] bi and t f ? ] unit-test -{ t } [ { 1 1 } can-move? ] unit-test +! { t } [ [ current-piece ] [ next-piece ] bi and t f ? ] unit-test +! { t } [ { 1 1 } can-move? ] unit-test { t } [ { 1 1 } sokoban-move ] unit-test -{ 1 } [ dup { 1 1 } sokoban-move drop current-piece location>> second ] unit-test -{ 1 } [ level ] unit-test -{ 1 } [ 9 >>rows level ] unit-test -{ 2 } [ 10 >>rows level ] unit-test -{ 0 } [ 3 0 rows-score ] unit-test -{ 80 } [ 1 1 rows-score ] unit-test -{ 4800 } [ 3 4 rows-score ] unit-test -{ 1 } [ dup 3 score-rows dup 3 score-rows dup 3 score-rows level ] unit-test -{ 2 } [ dup 4 score-rows dup 4 score-rows dup 2 score-rows level ] unit-test +! { 1 } [ dup { 1 1 } sokoban-move drop current-piece location>> second ] unit-test +{ 1 } [ level>> ] unit-test +{ 1 } [ 9 >>rows level>> ] unit-test +{ 2 } [ 10 >>rows level>> ] unit-test +! { 0 } [ 3 0 rows-score ] unit-test +! { 80 } [ 1 1 rows-score ] unit-test +! { 4800 } [ 3 4 rows-score ] unit-test +! { 1 } [ dup 3 score-rows dup 3 score-rows dup 3 score-rows level ] unit-test +! { 2 } [ dup 4 score-rows dup 4 score-rows dup 2 score-rows level ] unit-test diff --git a/extra/sokoban/piece/piece-tests.factor b/extra/sokoban/piece/piece-tests.factor deleted file mode 100644 index aff8ba1dba..0000000000 --- a/extra/sokoban/piece/piece-tests.factor +++ /dev/null @@ -1,23 +0,0 @@ -USING: accessors kernel sokoban.tetromino sokoban.piece tools.test sequences arrays namespaces ; - -! Tests for sokoban.tetromino and sokoban.piece, since there's not much to test in sokoban.tetromino - -! these two tests rely on the first level_num of the first tetromino being the -! 'I' tetromino in its vertical orientation. -{ 4 } [ tetrominoes get first states>> first blocks-width ] unit-test -{ 1 } [ tetrominoes get first states>> first blocks-height ] unit-test - -! { { 0 0 } } [ random-tetromino location>> ] unit-test -! { 0 } [ 10 level_num>> ] unit-test - -{ { { 0 0 } { 1 0 } { 2 0 } { 3 0 } } } -[ tetrominoes get first piece-blocks ] unit-test - -{ { { 0 0 } { 0 1 } { 0 2 } { 0 3 } } } -[ tetrominoes get first 1 rotate-piece piece-blocks ] unit-test - -{ { { 1 1 } { 2 1 } { 3 1 } { 4 1 } } } -[ tetrominoes get first { 1 1 } move-piece piece-blocks ] unit-test - -{ 3 } [ tetrominoes get second piece-width ] unit-test -{ 2 } [ tetrominoes get second 1 rotate-piece piece-width ] unit-test -- 2.34.1