about summary refs log tree commit diff stats
path: root/mu.arc.t
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-22 18:01:45 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-22 18:01:45 -0800
commit009593c7c6463ec3d4873231da5231fa16d424e2 (patch)
treeb4018a317e09de7b7b7d3c1c1fe48c7376b8af19 /mu.arc.t
parent6275e978b465ad1f550c5b576c6a48dc9c6eaf69 (diff)
downloadmu-009593c7c6463ec3d4873231da5231fa16d424e2.tar.gz
600 - fake keyboard
Use asynchronous channels like 'stdin' for most tests.
Use the synchronous fakes for testing low-level stdin helpers.
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t34
1 files changed, 31 insertions, 3 deletions
diff --git a/mu.arc.t b/mu.arc.t
index a617ec3a..0e8d31a8 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -4087,10 +4087,9 @@
 
 ; fake screen for tests; prints go to a string
 (reset)
-(new-trace "fake-screen-initial")
-(add-code:readfile "chessboard-cursor.mu")
+(new-trace "fake-screen-empty")
 (add-code
-  '((function! main [
+  '((function main [
       (default-space:space-address <- new space:literal 30:literal/capacity)
       (screen:terminal-address <- init-fake-terminal 20:literal 10:literal)
       (5:string-address/raw <- get screen:terminal-address/deref data:offset)
@@ -4112,6 +4111,35 @@
              "                    "))
   (prn "F - fake screen starts out with all spaces"))
 
+; fake keyboard for tests; must initialize keys in advance
+(reset)
+(new-trace "fake-keyboard")
+(add-code
+  '((function main [
+      (default-space:space-address <- new space:literal 30:literal)
+      (s:string-address <- new "foo")
+      (x:keyboard-address <- init-keyboard s:string-address)
+      (1:character-address/raw <- read-key x:keyboard-address)
+     ])))
+(run 'main)
+(when (~is memory*.1 #\f)
+  (prn "F - 'read-key' reads character from provided 'fake keyboard' string"))
+
+; fake keyboard for tests; must initialize keys in advance
+(reset)
+(new-trace "fake-keyboard2")
+(add-code
+  '((function main [
+      (default-space:space-address <- new space:literal 30:literal)
+      (s:string-address <- new "foo")
+      (x:keyboard-address <- init-keyboard s:string-address)
+      (1:character-address/raw <- read-key x:keyboard-address)
+      (1:character-address/raw <- read-key x:keyboard-address)
+     ])))
+(run 'main)
+(when (~is memory*.1 #\o)
+  (prn "F - 'read-key' advances cursor in provided string"))
+
 )  ; section 100
 
 (reset)