diff options
-rw-r--r-- | chessboard.mu | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/chessboard.mu b/chessboard.mu index a5ba2627..11d2c9d3 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -204,6 +204,13 @@ recipe read-file [ break-unless q-pressed?:boolean reply 0:literal/dummy, 1:literal/quit, 0:literal/error } + { + newline?:boolean <- equal c:character, 13:literal/newline + break-unless newline?:boolean + error-message:address:array:character <- new [that's not enough] + print-string screen:address, error-message:address:array:character + reply 0:literal/dummy, 0:literal/quit, 1:literal/error + } file:integer <- subtract c:character, 97:literal # 'a' #? $print file:integer, [ #? 1 #? ] #? 1 @@ -245,6 +252,13 @@ recipe read-rank [ break-unless q-pressed?:boolean reply 0:literal/dummy, 1:literal/quit, 0:literal/error } + { + newline?:boolean <- equal c:character, 13:literal/newline + break-unless newline?:boolean + error-message:address:array:character <- new [that's not enough] + print-string screen:address, error-message:address:array:character + reply 0:literal/dummy, 0:literal/quit, 1:literal/error + } rank:integer <- subtract c:character, 49:literal # '1' #? $print rank:integer, [ #? 1 #? ] #? 1 @@ -450,6 +464,28 @@ F read-move-file: routine failed to pause after coming up (before any keys were ] ] +scenario read-move-empty [ + assume-screen 20:literal/width, 2:literal/height + run [ + 1:address:channel <- init-channel 2:literal + 2:integer/routine <- start-running read-move:recipe, 1:address:channel, screen:address + # 'read-move' is waiting for input + wait-for-routine 2:integer + 3:integer <- routine-state 2:integer/id + 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + assert 4:boolean/waiting?, [ +F read-move-file: routine failed to pause after coming up (before any keys were pressed)] + 1:address:channel <- write 1:address:channel, 13:literal/newline + 1:address:channel <- write 1:address:channel, 97:literal # 'a' + restart 2:integer/routine + wait-for-routine 2:integer + ] + screen-should-contain [ + .that's not enough . + . . + ] +] + recipe make-move [ default-space:address:array:location <- new location:type, 30:literal b:address:array:address:array:character <- next-ingredient |