about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-11 17:46:46 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-11 17:46:46 -0800
commit693c270dd464c7b1f93d32a6247b57e57f7ad487 (patch)
tree8b2ca8bce93cd044265a0593325db913b8271dea
parentb52a2cb5d82097bd91346a6520a746c93b7eb3a2 (diff)
downloadmu-693c270dd464c7b1f93d32a6247b57e57f7ad487.tar.gz
745 - first test of expand functionality
Expanding trace items, of course, doesn't work on anything but the last
item. But we've now caught automatic tests up to the state of
development.

These tests are hugely expensive. Previous .t files run in ~30s. Already
the trace browser tests clock in at 2 minutes. And we're just getting
started. Time to explore reimplementing the mu VM in C.
-rw-r--r--trace.arc.t72
1 files changed, 72 insertions, 0 deletions
diff --git a/trace.arc.t b/trace.arc.t
index dbf2277f..bf81f3f9 100644
--- a/trace.arc.t
+++ b/trace.arc.t
@@ -255,3 +255,75 @@ schedule:  done with routine")
   (prn "F - process-key doesn't move below bounds"))
 
 (reset)
+(new-trace "process-key-expand")
+(add-code:readfile "trace.mu")
+(add-code
+  '((function! main [
+      (default-space:space-address <- new space:literal 30:literal/capacity)
+      (x:string-address <- new
+"schedule: main
+run: main 0: (((1 integer)) <- ((copy)) ((1 literal)))
+run: main 0: 1 => ((1 integer))
+mem: ((1 integer)): 1 <= 1
+run: main 1: (((2 integer)) <- ((copy)) ((3 literal)))
+run: main 1: 3 => ((2 integer))
+mem: ((2 integer)): 2 <= 3
+run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer)))
+mem: ((1 integer)) => 1
+mem: ((2 integer)) => 3
+run: main 2: 4 => ((3 integer))
+mem: ((3 integer)): 3 <= 4
+schedule:  done with routine")
+      (s:stream-address <- init-stream x:string-address)
+      (1:instruction-trace-address-array-address/raw <- parse-traces s:stream-address)
+      (len:integer <- length 1:instruction-trace-address-array-address/raw/deref)
+      (2:terminal-address/raw <- init-fake-terminal 70:literal 15:literal)
+      ; position the cursor away from top of screen
+      (cursor-down 2:terminal-address/raw)
+      (cursor-down 2:terminal-address/raw)
+      (3:space-address/raw <- screen-state)
+      ; draw trace
+      (print-traces-collapsed 3:space-address/raw/screen-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
+      (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
+    ])))
+(run 'main)
+(each routine completed-routines*
+  (awhen rep.routine!error
+    (prn "error - " it)))
+(when (~memory-contains-array memory*.4
+         (+ "                                                                      "
+            "                                                                      "
+            "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal)))                 "
+            "+ main/ 0 : 1 => ((1 integer))                                        "
+            "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal)))                 "
+            "+ main/ 1 : 3 => ((2 integer))                                        "
+            "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer)))    "
+            "+ main/ 2 : 4 => ((3 integer))                                        "))
+  (prn "F - process-key: before expand"))
+(run-code main2
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  ; move cursor to final line and expand
+  (s:string-address <- new "k\n")
+  (k:keyboard-address <- init-keyboard s:string-address)
+  (process-key 3:space-address/raw/screen-state k:keyboard-address 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
+  (process-key 3:space-address/raw/screen-state k:keyboard-address 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
+  )
+; final line is expanded
+(when (~memory-contains-array memory*.4
+         (+ "                                                                      "
+            "                                                                      "
+            "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal)))                 "
+            "+ main/ 0 : 1 => ((1 integer))                                        "
+            "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal)))                 "
+            "+ main/ 1 : 3 => ((2 integer))                                        "
+            "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer)))    "
+            "- main/ 2 : 4 => ((3 integer))                                        "
+            "   mem : ((1 integer)): 1 <= 1                                        "
+            "   mem : ((2 integer)): 2 <= 3                                        "
+            "   mem : ((1 integer)) => 1                                           "
+            "   mem : ((2 integer)) => 3                                           "
+            "   mem : ((3 integer)): 3 <= 4                                        "
+            "   schedule :  done with routine                                      "))
+  (prn "F - process-key expands current trace segment on <enter>"))
+
+(reset)