From 5d6d9110314f68ad8d43bfab1e2b50886c1cde9f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 14 May 2015 12:39:12 -0700 Subject: 1372 - new chessboard test no longer hanging Still failing, though. --- chessboard.mu | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'chessboard.mu') diff --git a/chessboard.mu b/chessboard.mu index 101078b8..dd0d388f 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -27,8 +27,10 @@ recipe main [ scenario print-board-and-read-move [ assume-screen 30:literal/width, 12:literal/height + # initialize keyboard to type in a move, then quit assume-keyboard [a2-a4 -] # newline is important +q +] run [ screen:address, keyboard:address <- chessboard screen:address, keyboard:address ] @@ -38,9 +40,9 @@ scenario print-board-and-read-move [ .7 | p p p p p p p p . .6 | . .5 | . - .4 | . + .4 | P . .3 | . - .2 | P P P P P P P P . + .2 | P P P P P P P . .1 | R N B Q K B N R . . +---------------- . . a b c d e f g h . @@ -50,13 +52,13 @@ scenario print-board-and-read-move [ ] recipe chessboard [ -#? $start-tracing [schedule] #? 1 +#? $start-tracing [schedule] #? 2 #? $start-tracing #? 1 default-space:address:array:location <- new location:type, 30:literal screen:address <- next-ingredient keyboard:address <- next-ingredient - $print [screen: ], screen:address, [, keyboard: ], keyboard:address, [ -] +#? $print [screen: ], screen:address, [, keyboard: ], keyboard:address, [ +#? ] #? 1 board:address:array:address:array:character <- initial-position # hook up stdin stdin:address:channel <- init-channel 10:literal/capacity @@ -68,31 +70,31 @@ recipe chessboard [ msg:address:array:character <- new [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves. ] print-string screen:address, msg:address:array:character - $print [aaa -] +#? $print [aaa +#? ] #? 1 cursor-to-next-line screen:address print-board screen:address, board:address:array:address:array:character cursor-to-next-line screen:address msg:address:array:character <- new [Type in your move as -. For example: 'a2-a4'. Then press . ] print-string screen:address, msg:address:array:character - $print [bbb -] +#? $print [bbb +#? ] #? 1 cursor-to-next-line screen:address msg:address:array:character <- new [Hit 'q' to exit. ] print-string screen:address, msg:address:array:character - $print [ccc -] +#? $print [ccc +#? ] #? 1 { cursor-to-next-line screen:address msg:address:array:character <- new [move: ] print-string screen:address, msg:address:array:character - $print [ddd -] +#? $print [ddd +#? ] #? 1 m:address:move, quit:boolean, error:boolean <- read-move buffered-stdin:address:channel, screen:address - $print [eee -] +#? $print [eee +#? ] #? 1 break-if quit:boolean, +quit:offset buffered-stdin:address:channel <- clear-channel buffered-stdin:address:channel # cleanup after error. todo: test this? loop-if error:boolean @@ -297,6 +299,11 @@ recipe read-file [ break-unless q-pressed?:boolean reply 0:literal/dummy, 1:literal/quit, 0:literal/error } + { + empty-fake-keyboard?:boolean <- equal c:character, 0:literal/eof + break-unless empty-fake-keyboard?:boolean + reply 0:literal/dummy, 1:literal/quit, 0:literal/error + } { newline?:boolean <- equal c:character, 10:literal/newline break-unless newline?:boolean -- cgit 1.4.1-2-gfad0