about summary refs log tree commit diff stats
path: root/chessboard.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-14 12:39:12 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-14 12:39:12 -0700
commit5d6d9110314f68ad8d43bfab1e2b50886c1cde9f (patch)
treef7cedd9d0631feaf69a37cb1a873fea716d4205a /chessboard.mu
parent85da949ef338205566cda37f63b523933aa020bf (diff)
downloadmu-5d6d9110314f68ad8d43bfab1e2b50886c1cde9f.tar.gz
1372 - new chessboard test no longer hanging
Still failing, though.
Diffstat (limited to 'chessboard.mu')
-rw-r--r--chessboard.mu39
1 files changed, 23 insertions, 16 deletions
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 <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.
 ]
     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
@@ -298,6 +300,11 @@ recipe read-file [
     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
     error-message:address:array:character <- new [that's not enough]