diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-01-21 02:06:53 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-01-21 02:06:53 -0800 |
commit | 79ca54b3d2e74ee7789437fbae9249fb88927f96 (patch) | |
tree | fa42cab47da1979ea31773eabfd003d2fcc973de | |
parent | 5f0ed45e8de50e566228fc637697c2ddca21ffe1 (diff) | |
download | mu-79ca54b3d2e74ee7789437fbae9249fb88927f96.tar.gz |
596
-rw-r--r-- | chessboard-cursor.arc.t | 74 | ||||
-rw-r--r-- | chessboard-cursor.arc.t.3 | 52 |
2 files changed, 48 insertions, 78 deletions
diff --git a/chessboard-cursor.arc.t b/chessboard-cursor.arc.t index 991db2c5..b5eac1e7 100644 --- a/chessboard-cursor.arc.t +++ b/chessboard-cursor.arc.t @@ -44,32 +44,54 @@ (reset) (new-trace "read-move-incomplete") (add-code:readfile "chessboard-cursor.mu") -(add-code - '((function! main [ - (default-space:space-address <- new space:literal 30:literal/capacity) - (stdin:channel-address <- init-channel 1:literal) - (screen:terminal-address <- init-fake-terminal 20:literal 10:literal) - (2:string-address/raw <- get screen:terminal-address/deref data:offset) - (r:integer/routine <- fork-helper read-move:fn nil:literal/globals 2000:literal/limit stdin:channel-address screen:terminal-address) - (c:character <- copy ((#\a literal))) - (x:tagged-value <- save-type c:character) - (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value) - (c:character <- copy ((#\2 literal))) - (x:tagged-value <- save-type c:character) - (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value) - (c:character <- copy ((#\- literal))) - (x:tagged-value <- save-type c:character) - (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value) - (c:character <- copy ((#\a literal))) - (x:tagged-value <- save-type c:character) - (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value) - (sleep until-routine-done:literal r:integer/routine) - ]))) -(run 'main) -(when (ran-to-completion 'read-move) - (prn "F - chessboard hangs until 5 characters are entered")) -(when (~memory-contains-array memory*.2 "a2-a") - (prn "F - chessboard prints keys from keyboard before entire move is read")) +; initialize some variables at specific raw locations +(run-code test-init + (1:channel-address/raw <- init-channel 1:literal) + (2:terminal-address/raw <- init-fake-terminal 20:literal 10:literal) + (3:string-address/raw <- get 2:terminal-address/raw/deref data:offset)) +(wipe completed-routines*) +; the component under test; we'll be running this repeatedly +(let read-move-routine (make-routine 'read-move memory*.1 memory*.2) + (run-code send-first-key + (default-space:space-address <- new space:literal 30:literal/capacity) + (c:character <- copy ((#\a literal))) + (x:tagged-value <- save-type c:character) + (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value)) + (wipe completed-routines*) + ; check that read-move consumes it and then goes to sleep + (enq read-move-routine running-routines*) + (run) + (when (ran-to-completion 'read-move) + (prn "F - chessboard waits after first letter of move")) + (wipe completed-routines*) + ; send in a few more letters + (restart read-move-routine) + (run-code send-more-keys + (default-space:space-address <- new space:literal 30:literal/capacity) + (c:character <- copy ((#\2 literal))) + (x:tagged-value <- save-type c:character) + (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value) + (c:character <- copy ((#\- literal))) + (x:tagged-value <- save-type c:character) + (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value) + (c:character <- copy ((#\a literal))) + (x:tagged-value <- save-type c:character) + (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value)) + ; check that read-move consumes them and then goes to sleep + (when (ran-to-completion 'read-move) + (prn "F - chessboard waits after each subsequent letter of move until the last")) + (wipe completed-routines*) + ; send final key + (restart read-move-routine) + (run-code send-final-key + (default-space:space-address <- new space:literal 30:literal/capacity) + (c:character <- copy ((#\4 literal))) + (x:tagged-value <- save-type c:character) + (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value)) + ; check that read-move consumes it and -- this time -- returns + (when (~ran-to-completion 'read-move) + (prn "F - 'read-move' completes after final letter of move")) +) (reset) (new-trace "read-move-quit") diff --git a/chessboard-cursor.arc.t.3 b/chessboard-cursor.arc.t.3 deleted file mode 100644 index 89b78be8..00000000 --- a/chessboard-cursor.arc.t.3 +++ /dev/null @@ -1,52 +0,0 @@ -(selective-load "mu.arc" section-level) - -(reset) -(add-code:readfile "chessboard-cursor.mu") -; initialize some variables at specific raw locations -(run-code test-init - (1:channel-address/raw <- init-channel 1:literal) - (2:terminal-address/raw <- init-fake-terminal 20:literal 10:literal) - (3:string-address/raw <- get 2:terminal-address/raw/deref data:offset)) -(wipe completed-routines*) -; the component under test; we'll be running this repeatedly -(let read-move-routine (make-routine 'read-move memory*.1 memory*.2) - (run-code send-first-key - (default-space:space-address <- new space:literal 30:literal/capacity) - (c:character <- copy ((#\a literal))) - (x:tagged-value <- save-type c:character) - (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value)) - (wipe completed-routines*) - ; check that read-move consumes it and then goes to sleep - (enq read-move-routine running-routines*) - (run) - (when (ran-to-completion 'read-move) - (prn "F - chessboard waits after first letter of move")) - (wipe completed-routines*) - ; send in a few more letters - (restart read-move-routine) - (run-code send-more-keys - (default-space:space-address <- new space:literal 30:literal/capacity) - (c:character <- copy ((#\2 literal))) - (x:tagged-value <- save-type c:character) - (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value) - (c:character <- copy ((#\- literal))) - (x:tagged-value <- save-type c:character) - (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value) - (c:character <- copy ((#\a literal))) - (x:tagged-value <- save-type c:character) - (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value)) - ; check that read-move consumes them and then goes to sleep - (when (ran-to-completion 'read-move) - (prn "F - chessboard waits after each subsequent letter of move until the last")) - (wipe completed-routines*) - ; send final key - (restart read-move-routine) - (run-code send-final-key - (default-space:space-address <- new space:literal 30:literal/capacity) - (c:character <- copy ((#\4 literal))) - (x:tagged-value <- save-type c:character) - (1:channel-address/raw/deref <- write 1:channel-address/raw x:tagged-value)) - ; check that read-move consumes it and -- this time -- returns - (when (~ran-to-completion 'read-move) - (prn "F - 'read-move' completes after final letter of move")) -) |