1 (selective-load "mu.arc" section-level)
3 (add-code:readfile "trace.mu")
4 (ero "running tests in trace.arc.t (takes ~10 mins)")
6 (load-system-functions)
9 (new-trace "print-trace")
11 (default-space:space-address <- new space:literal 30:literal/capacity)
12 (x:string-address <- new
14 run: main 0: (((1 integer)) <- ((copy)) ((1 literal)))
15 run: main 0: 1 => ((1 integer))
16 mem: ((1 integer)): 1 <= 1
17 run: main 1: (((2 integer)) <- ((copy)) ((3 literal)))
18 run: main 1: 3 => ((2 integer))
19 mem: ((2 integer)): 2 <= 3
20 run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer)))
21 mem: ((1 integer)) => 1
22 mem: ((2 integer)) => 3
23 run: main 2: 4 => ((3 integer))
24 mem: ((3 integer)): 3 <= 4
25 schedule: done with routine")
26 (s:stream-address <- init-stream x:string-address)
27 (traces:instruction-trace-address-array-address <- parse-traces s:stream-address)
28 (screen:terminal-address <- init-fake-terminal 70:literal 15:literal)
29 (browser-state:space-address <- browser-state traces:instruction-trace-address-array-address 30:literal/screen-height)
30 (print-traces-collapsed browser-state:space-address screen:terminal-address)
31 (1:string-address/raw <- get screen:terminal-address/deref data:offset)
33 (each routine completed-routines*
34 (awhen rep.routine!error
37 (when (~screen-contains memory*.1 70
38 (+ "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
39 "+ main/ 0 : 1 => ((1 integer)) "
40 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
41 "+ main/ 1 : 3 => ((2 integer)) "
42 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
43 "+ main/ 2 : 4 => ((3 integer)) "))
44 (prn "F - print-traces-collapsed works"))
48 (new-trace "print-trace-from-middle-of-screen")
50 (default-space:space-address <- new space:literal 30:literal/capacity)
51 (x:string-address <- new
53 run: main 0: (((1 integer)) <- ((copy)) ((1 literal)))
54 run: main 0: 1 => ((1 integer))
55 mem: ((1 integer)): 1 <= 1
56 run: main 1: (((2 integer)) <- ((copy)) ((3 literal)))
57 run: main 1: 3 => ((2 integer))
58 mem: ((2 integer)): 2 <= 3
59 run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer)))
60 mem: ((1 integer)) => 1
61 mem: ((2 integer)) => 3
62 run: main 2: 4 => ((3 integer))
63 mem: ((3 integer)): 3 <= 4
64 schedule: done with routine")
65 (s:stream-address <- init-stream x:string-address)
66 (traces:instruction-trace-address-array-address <- parse-traces s:stream-address)
67 (1:terminal-address/raw <- init-fake-terminal 70:literal 15:literal)
68 ; position the cursor away from top of screen
69 (cursor-down 1:terminal-address/raw)
70 (cursor-down 1:terminal-address/raw)
71 (browser-state:space-address <- browser-state traces:instruction-trace-address-array-address 30:literal/screen-height)
72 (print-traces-collapsed browser-state:space-address 1:terminal-address/raw traces:instruction-trace-address-array-address)
73 (2:string-address/raw <- get 1:terminal-address/raw/deref data:offset)
75 (each routine completed-routines*
76 (awhen rep.routine!error
78 (when (~screen-contains memory*.2 70
81 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
82 "+ main/ 0 : 1 => ((1 integer)) "
83 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
84 "+ main/ 1 : 3 => ((2 integer)) "
85 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
86 "+ main/ 2 : 4 => ((3 integer)) "))
87 (prn "F - print-traces-collapsed works anywhere on the screen"))
89 (print-character 1:terminal-address/raw ((#\* literal))))
90 (when (~screen-contains memory*.2 70
93 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
94 "+ main/ 0 : 1 => ((1 integer)) "
95 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
96 "+ main/ 1 : 3 => ((2 integer)) "
97 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
98 "+ main/ 2 : 4 => ((3 integer)) "
100 (prn "F - print-traces-collapsed leaves cursor at next line"))
103 (new-trace "process-key-move-up-down")
105 (default-space:space-address <- new space:literal 30:literal/capacity)
106 (x:string-address <- new
108 run: main 0: (((1 integer)) <- ((copy)) ((1 literal)))
109 run: main 0: 1 => ((1 integer))
110 mem: ((1 integer)): 1 <= 1
111 run: main 1: (((2 integer)) <- ((copy)) ((3 literal)))
112 run: main 1: 3 => ((2 integer))
113 mem: ((2 integer)): 2 <= 3
114 run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer)))
115 mem: ((1 integer)) => 1
116 mem: ((2 integer)) => 3
117 run: main 2: 4 => ((3 integer))
118 mem: ((3 integer)): 3 <= 4
119 schedule: done with routine")
120 (s:stream-address <- init-stream x:string-address)
121 (1:instruction-trace-address-array-address/raw <- parse-traces s:stream-address)
122 (2:terminal-address/raw <- init-fake-terminal 70:literal 15:literal)
123 ; position the cursor away from top of screen
124 (cursor-down 2:terminal-address/raw)
125 (cursor-down 2:terminal-address/raw)
126 (3:space-address/raw <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
128 (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
130 ; we have no way yet to test special keys like up-arrow
131 (s:string-address <- new "k")
132 (k:keyboard-address <- init-keyboard s:string-address)
133 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
135 (replace-character 2:terminal-address/raw ((#\* literal)))
136 (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
138 (each routine completed-routines*
139 (awhen rep.routine!error
140 (prn "error - " it)))
141 (when (~screen-contains memory*.4 70
144 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
145 "+ main/ 0 : 1 => ((1 integer)) "
146 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
147 "+ main/ 1 : 3 => ((2 integer)) "
148 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
149 "* main/ 2 : 4 => ((3 integer)) "))
151 (prn "F - process-key can move up the cursor"))
153 (default-space:space-address <- new space:literal 30:literal/capacity)
154 ; reset previous cursor
155 (replace-character 2:terminal-address/raw ((#\+ literal)))
156 ; move cursor up 3 more lines
157 (s:string-address <- new "kkk")
158 (k:keyboard-address <- init-keyboard s:string-address)
159 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
160 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
161 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
162 (replace-character 2:terminal-address/raw ((#\* literal)))
164 ; cursor is now at line 3
165 (when (~screen-contains memory*.4 70
168 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
169 "+ main/ 0 : 1 => ((1 integer)) "
170 "* main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
172 "+ main/ 1 : 3 => ((2 integer)) "
173 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
174 "+ main/ 2 : 4 => ((3 integer)) "))
175 (prn "F - process-key can move up multiple times"))
176 ; try to move cursor up thrice more
178 (default-space:space-address <- new space:literal 30:literal/capacity)
179 (replace-character 2:terminal-address/raw ((#\+ literal)))
180 (s:string-address <- new "kkk")
181 (k:keyboard-address <- init-keyboard s:string-address)
182 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
183 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
184 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
185 (replace-character 2:terminal-address/raw ((#\* literal)))
187 ; cursor doesn't go beyond the first line printed
188 ; stuff on screen before browser-state was initialized is inviolate
189 (when (~screen-contains memory*.4 70
192 "* main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
194 "+ main/ 0 : 1 => ((1 integer)) "
195 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
196 "+ main/ 1 : 3 => ((2 integer)) "
197 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
198 "+ main/ 2 : 4 => ((3 integer)) "))
199 (prn "F - process-key doesn't move above bounds"))
200 ; now move cursor down 4 times
202 (default-space:space-address <- new space:literal 30:literal/capacity)
203 (replace-character 2:terminal-address/raw ((#\+ literal)))
204 (s:string-address <- new "jjjj")
205 (k:keyboard-address <- init-keyboard s:string-address)
206 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
207 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
208 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
209 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
210 (replace-character 2:terminal-address/raw ((#\* literal)))
212 (when (~screen-contains memory*.4 70
215 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
216 "+ main/ 0 : 1 => ((1 integer)) "
217 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
218 "+ main/ 1 : 3 => ((2 integer)) "
219 "* main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
221 "+ main/ 2 : 4 => ((3 integer)) "))
222 (prn "F - process-key can move down multiple times"))
223 ; try to move cursor down 4 more times
225 (default-space:space-address <- new space:literal 30:literal/capacity)
226 (replace-character 2:terminal-address/raw ((#\+ literal)))
227 (s:string-address <- new "jjjj")
228 (k:keyboard-address <- init-keyboard s:string-address)
229 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
230 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
231 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
232 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
233 (replace-character 2:terminal-address/raw ((#\* literal)))
235 (when (~screen-contains memory*.4 70
238 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
239 "+ main/ 0 : 1 => ((1 integer)) "
240 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
241 "+ main/ 1 : 3 => ((2 integer)) "
242 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
243 "+ main/ 2 : 4 => ((3 integer)) "
245 (prn "F - process-key doesn't move below bounds"))
248 (new-trace "process-key-expand")
250 (default-space:space-address <- new space:literal 30:literal/capacity)
251 (x:string-address <- new
253 run: main 0: (((1 integer)) <- ((copy)) ((1 literal)))
254 run: main 0: 1 => ((1 integer))
255 mem: ((1 integer)): 1 <= 1
256 run: main 1: (((2 integer)) <- ((copy)) ((3 literal)))
257 run: main 1: 3 => ((2 integer))
258 mem: ((2 integer)): 2 <= 3
259 run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer)))
260 mem: ((1 integer)) => 1
261 mem: ((2 integer)) => 3
262 run: main 2: 4 => ((3 integer))
263 mem: ((3 integer)): 3 <= 4
264 schedule: done with routine")
265 (s:stream-address <- init-stream x:string-address)
266 (1:instruction-trace-address-array-address/raw <- parse-traces s:stream-address)
267 (2:terminal-address/raw <- init-fake-terminal 70:literal 15:literal)
268 ; position the cursor away from top of screen
269 (cursor-down 2:terminal-address/raw)
270 (cursor-down 2:terminal-address/raw)
271 (3:space-address/raw <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
273 (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
274 (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
276 (each routine completed-routines*
277 (awhen rep.routine!error
278 (prn "error - " it)))
279 (when (~screen-contains memory*.4 70
282 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
283 "+ main/ 0 : 1 => ((1 integer)) "
284 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
285 "+ main/ 1 : 3 => ((2 integer)) "
286 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
287 "+ main/ 2 : 4 => ((3 integer)) "))
288 (prn "F - process-key: before expand"))
290 (default-space:space-address <- new space:literal 30:literal/capacity)
291 ; move cursor to final line and expand
292 (s:string-address <- new "k\n")
293 (k:keyboard-address <- init-keyboard s:string-address)
294 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
295 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
297 ; final line is expanded
298 (when (~screen-contains memory*.4 70
301 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
302 "+ main/ 0 : 1 => ((1 integer)) "
303 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
304 "+ main/ 1 : 3 => ((2 integer)) "
305 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
306 "- main/ 2 : 4 => ((3 integer)) "
307 " mem : ((3 integer)): 3 <= 4 "
308 " schedule : done with routine "))
309 (prn "F - process-key expands the trace index at cursor on <enter>"))
310 ; and cursor should remain on the top-level line
312 (replace-character 2:terminal-address/raw ((#\* literal)))
314 (when (~screen-contains memory*.4 70
317 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
318 "+ main/ 0 : 1 => ((1 integer)) "
319 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
320 "+ main/ 1 : 3 => ((2 integer)) "
321 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
322 "* main/ 2 : 4 => ((3 integer)) "
324 " mem : ((3 integer)): 3 <= 4 "
325 " schedule : done with routine "))
326 (prn "F - process-key positions cursor at start of trace index after expanding"))
329 (new-trace "process-key-expand-nonlast")
331 (default-space:space-address <- new space:literal 30:literal/capacity)
332 (x:string-address <- new
334 run: main 0: (((1 integer)) <- ((copy)) ((1 literal)))
335 run: main 0: 1 => ((1 integer))
336 mem: ((1 integer)): 1 <= 1
337 run: main 1: (((2 integer)) <- ((copy)) ((3 literal)))
338 run: main 1: 3 => ((2 integer))
339 mem: ((2 integer)): 2 <= 3
340 run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer)))
341 mem: ((1 integer)) => 1
342 mem: ((2 integer)) => 3
343 run: main 2: 4 => ((3 integer))
344 mem: ((3 integer)): 3 <= 4
345 schedule: done with routine")
346 (s:stream-address <- init-stream x:string-address)
347 (1:instruction-trace-address-array-address/raw <- parse-traces s:stream-address)
348 (2:terminal-address/raw <- init-fake-terminal 70:literal 15:literal)
349 ; position the cursor away from top of screen
350 (cursor-down 2:terminal-address/raw)
351 (cursor-down 2:terminal-address/raw)
352 (3:space-address/raw <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
354 (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
355 ; expand penultimate line
356 (s:string-address <- new "kk\n")
357 (k:keyboard-address <- init-keyboard s:string-address)
358 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
359 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
360 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
361 (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
363 (each routine completed-routines*
364 (awhen rep.routine!error
365 (prn "error - " it)))
366 (when (~screen-contains memory*.4 70
369 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
370 "+ main/ 0 : 1 => ((1 integer)) "
371 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
372 "+ main/ 1 : 3 => ((2 integer)) "
373 "- main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
374 " mem : ((1 integer)) => 1 "
375 " mem : ((2 integer)) => 3 "
376 "+ main/ 2 : 4 => ((3 integer)) "))
377 (prn "F - process-key: expanding a line continues to print lines after it"))
380 (new-trace "process-key-expanded")
382 (default-space:space-address <- new space:literal 30:literal/capacity)
383 (x:string-address <- new
385 run: main 0: (((1 integer)) <- ((copy)) ((1 literal)))
386 run: main 0: 1 => ((1 integer))
387 mem: ((1 integer)): 1 <= 1
388 mem: ((1 integer)): 1 <= 1
389 run: main 1: (((2 integer)) <- ((copy)) ((3 literal)))
390 run: main 1: 3 => ((2 integer))
391 mem: ((2 integer)): 2 <= 3
392 run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer)))
393 mem: ((1 integer)) => 1
394 mem: ((2 integer)) => 3
395 run: main 2: 4 => ((3 integer))
396 mem: ((3 integer)): 3 <= 4
397 schedule: done with routine")
398 (s:stream-address <- init-stream x:string-address)
399 (1:instruction-trace-address-array-address/raw <- parse-traces s:stream-address)
400 (2:terminal-address/raw <- init-fake-terminal 70:literal 15:literal)
401 ; position the cursor away from top of screen
402 (cursor-down 2:terminal-address/raw)
403 (cursor-down 2:terminal-address/raw)
404 (3:space-address/raw <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
406 (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
407 ; expand penultimate line, then move one line down and draw cursor
408 (s:string-address <- new "kk\nj")
409 (k:keyboard-address <- init-keyboard s:string-address)
410 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
411 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
412 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
413 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
414 (replace-character 2:terminal-address/raw ((#\* literal)))
415 (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
417 (each routine completed-routines*
418 (awhen rep.routine!error
419 (prn "error - " it)))
420 ; cursor should be at next top-level 'run' line
421 (when (~screen-contains memory*.4 70
424 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
425 "+ main/ 0 : 1 => ((1 integer)) "
426 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
427 "+ main/ 1 : 3 => ((2 integer)) "
428 "- main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
429 " mem : ((1 integer)) => 1 "
430 " mem : ((2 integer)) => 3 "
431 "* main/ 2 : 4 => ((3 integer)) "))
432 (prn "F - process-key: navigation moves between top-level trace indices only"))
434 (default-space:space-address <- new space:literal 30:literal/capacity)
435 ; reset previous cursor
436 (replace-character 2:terminal-address/raw ((#\+ literal)))
437 ; move cursor back up one line
438 (s:string-address <- new "k")
439 (k:keyboard-address <- init-keyboard s:string-address)
440 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
442 (replace-character 2:terminal-address/raw ((#\* literal)))
444 (each routine completed-routines*
445 (awhen rep.routine!error
446 (prn "error - " it)))
447 ; cursor should be back at the top of the expanded line
448 (when (~screen-contains memory*.4 70
451 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
452 "+ main/ 0 : 1 => ((1 integer)) "
453 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
454 "+ main/ 1 : 3 => ((2 integer)) "
455 "* main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
456 " mem : ((1 integer)) => 1 "
457 " mem : ((2 integer)) => 3 "
458 "+ main/ 2 : 4 => ((3 integer)) "))
459 (prn "F - process-key: navigation moves between top-level indices only - 2"))
461 (default-space:space-address <- new space:literal 30:literal/capacity)
462 ; reset previous cursor
463 (replace-character 2:terminal-address/raw ((#\+ literal)))
465 (s:string-address <- new "\n")
466 (k:keyboard-address <- init-keyboard s:string-address)
467 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
469 (each routine completed-routines*
470 (awhen rep.routine!error
471 (prn "error - " it)))
472 ; expanded trace should now be collapsed
473 (when (~screen-contains memory*.4 70
476 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
477 "+ main/ 0 : 1 => ((1 integer)) "
478 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
479 "+ main/ 1 : 3 => ((2 integer)) "
480 "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
481 "+ main/ 2 : 4 => ((3 integer)) "
484 (prn "F - process-key: process-key collapses trace indices correctly after moving around"))
486 (default-space:space-address <- new space:literal 30:literal/capacity)
487 ; move up a few lines, expand, then move down and expand again
488 (s:string-address <- new "kkk\njjj\n")
489 (k:keyboard-address <- init-keyboard s:string-address)
490 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
491 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
492 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
493 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
494 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
495 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
496 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
497 ;? (replace-character 2:terminal-address/raw ((#\* literal))) ;? 1
498 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
500 (each routine completed-routines*
501 (awhen rep.routine!error
502 (prn "error - " it)))
503 ; first expand should have no effect
504 (when (~screen-contains memory*.4 70
507 "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) "
508 "+ main/ 0 : 1 => ((1 integer)) "
509 "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) "
510 "+ main/ 1 : 3 => ((2 integer)) "
511 "- main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) "
512 " mem : ((1 integer)) => 1 "
513 " mem : ((2 integer)) => 3 "
514 "+ main/ 2 : 4 => ((3 integer)) "))
515 (prn "F - process-key: process-key collapses the previously expanded trace index when expanding elsewhere"))
517 ;; manage screen height
520 (new-trace "trace-paginate")
522 (default-space:space-address <- new space:literal 30:literal/capacity)
523 (x:string-address <- new
539 (s:stream-address <- init-stream x:string-address)
540 (traces:instruction-trace-address-array-address <- parse-traces s:stream-address)
541 (2:terminal-address/raw <- init-fake-terminal 17:literal 15:literal)
542 (3:space-address/raw/browser-state <- browser-state traces:instruction-trace-address-array-address 3:literal/screen-height)
543 (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw)
544 (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
546 (each routine completed-routines*
547 (awhen rep.routine!error
548 (prn "error - " it)))
549 ; screen shows a subset of collapsed trace lines
550 (when (~screen-contains memory*.4 17
551 (+ "+ main/ 0 : a b c"
553 "+ main/ 2 : g hi "))
554 (prn "F - print-traces-collapsed can show just one 'page' of a larger trace"))
558 (default-space:space-address <- new space:literal 30:literal/capacity)
559 (s:string-address <- new "kkk\n")
560 (k:keyboard-address <- init-keyboard s:string-address)
561 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
562 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
563 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
564 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
566 (each routine completed-routines*
567 (awhen rep.routine!error
568 (prn "error - " it)))
569 ; screen shows just first trace line fully expanded
570 (when (~screen-contains memory*.4 17
571 (+ "- main/ 0 : a b c"
575 (prn "F - expanding doesn't print past end of page"))
577 (replace-character 2:terminal-address/raw ((#\* literal)))
579 ; screen shows part of the second trace line expanded
580 (when (~screen-contains memory*.4 17
581 (+ "* main/ 0 : a b c"
585 (prn "F - cursor at right place after expand"))
587 ; expand line below without first collapsing previously expanded line
589 (default-space:space-address <- new space:literal 30:literal/capacity)
590 ; reset previous cursor
591 (replace-character 2:terminal-address/raw ((#\- literal)))
592 (s:string-address <- new "j\n")
593 (k:keyboard-address <- init-keyboard s:string-address)
594 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
595 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
597 (each routine completed-routines*
598 (awhen rep.routine!error
599 (prn "error - " it)))
600 ; screen shows part of the second trace line expanded
601 (when (~screen-contains memory*.4 17
602 (+ "+ main/ 0 : a b c"
607 (prn "F - expanding below expanded line respects screen/page height"))
609 (replace-character 2:terminal-address/raw ((#\* literal)))
611 ; screen shows part of the second trace line expanded
612 (when (~screen-contains memory*.4 17
613 (+ "+ main/ 0 : a b c"
618 (prn "F - cursor at right place after expand below"))
620 ; expand line *above* without first collapsing previously expanded line
622 (default-space:space-address <- new space:literal 30:literal/capacity)
623 ; reset previous cursor
624 (replace-character 2:terminal-address/raw ((#\- literal)))
625 (s:string-address <- new "k\n")
626 (k:keyboard-address <- init-keyboard s:string-address)
627 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
628 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
630 (each routine completed-routines*
631 (awhen rep.routine!error
632 (prn "error - " it)))
633 ; screen again shows first trace line expanded
634 (when (~screen-contains memory*.4 17
635 (+ "- main/ 0 : a b c"
639 (prn "F - expanding above expanded line respects screen/page height"))
642 ; collapse everything and hit page-down
643 ; again, we can't yet check for special keys like 'page-down so we'll use
644 ; upper-case J and K for moving a page down or up, respectively.
646 (default-space:space-address <- new space:literal 30:literal/capacity)
647 (s:string-address <- new "\nJ")
648 (k:keyboard-address <- init-keyboard s:string-address)
649 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
650 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
652 (each routine completed-routines*
653 (awhen rep.routine!error
654 (prn "error - " it)))
655 ; screen shows second page of traces
656 (when (~screen-contains memory*.4 17
661 (prn "F - 'page-down' skips to next page after this one"))
664 ; move cursor down, then page-down
666 (default-space:space-address <- new space:literal 30:literal/capacity)
667 (s:string-address <- new "jJ")
668 (k:keyboard-address <- init-keyboard s:string-address)
669 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
670 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
672 (each routine completed-routines*
673 (awhen rep.routine!error
674 (prn "error - " it)))
675 ; page-down behaves the same regardless of where the cursor was
676 (when (~screen-contains memory*.4 17
680 (prn "F - 'page-down' skips to same place regardless of cursor position"))
682 ; try to page-down past end of trace
684 (default-space:space-address <- new space:literal 30:literal/capacity)
685 (s:string-address <- new "J")
686 (k:keyboard-address <- init-keyboard s:string-address)
687 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
689 (each routine completed-routines*
690 (awhen rep.routine!error
691 (prn "error - " it)))
693 (when (~screen-contains memory*.4 17
697 (prn "F - 'page-down' skips to same place regardless of cursor position"))
701 (default-space:space-address <- new space:literal 30:literal/capacity)
702 (s:string-address <- new "K")
703 (k:keyboard-address <- init-keyboard s:string-address)
704 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
706 (each routine completed-routines*
707 (awhen rep.routine!error
708 (prn "error - " it)))
709 ; precisely undoes previous page-down
710 (when (~screen-contains memory*.4 17
715 (prn "F - 'page-up' on partial page behaves as if page was full"))
717 ;; back to page 1, expand a line
719 (default-space:space-address <- new space:literal 30:literal/capacity)
720 (s:string-address <- new "Kkk\n")
721 (k:keyboard-address <- init-keyboard s:string-address)
722 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
723 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
724 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
725 ;? (print-character 2:terminal-address/raw ((#\* literal))) ;? 1
726 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
728 (each routine completed-routines*
729 (awhen rep.routine!error
730 (prn "error - " it)))
731 ; now we have an expanded line
732 (when (~screen-contains memory*.4 17
733 (+ "+ main/ 0 : a b c"
738 (prn "F - intermediate state after expanding a line"))
742 (default-space:space-address <- new space:literal 30:literal/capacity)
743 (s:string-address <- new "J")
744 (k:keyboard-address <- init-keyboard s:string-address)
745 ;? ($start-tracing) ;? 1
746 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
748 (each routine completed-routines*
749 (awhen rep.routine!error
750 (prn "error - " it)))
751 ; no lines skipped, page with just inner traces
752 (when (~screen-contains memory*.4 17
758 (prn "F - page down continues existing expanded line"))
762 (default-space:space-address <- new space:literal 30:literal/capacity)
763 (s:string-address <- new "J")
764 (k:keyboard-address <- init-keyboard s:string-address)
765 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
767 (each routine completed-routines*
768 (awhen rep.routine!error
769 (prn "error - " it)))
770 ; page with partial inner trace and more collapsed
771 (when (~screen-contains memory*.4 17
777 (prn "F - page down shows collapsed lines after continued expanded line at top of page"))
780 ; page-up through an expanded line
782 (default-space:space-address <- new space:literal 30:literal/capacity)
783 (s:string-address <- new "K")
784 (k:keyboard-address <- init-keyboard s:string-address)
785 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
787 (each routine completed-routines*
788 (awhen rep.routine!error
789 (prn "error - " it)))
790 (when (~screen-contains memory*.4 17
796 (prn "F - page up understands expanded lines"))
799 ; skip ones starting at top of trace for now
801 ; + run: main 0: a b c
803 ; + run: main 1: d e f <- top of page
809 ; + run: main 2: g hi
810 ; + run: main 3: j <- bottom of page
817 (default-space:space-address <- new space:literal 30:literal/capacity)
818 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
819 ;? ($print first-index-on-page:integer/space:1) ;? 1
820 ;? ($print (("\n" literal))) ;? 1
821 (first-index-on-page:integer/space:1 <- copy 1:literal)
822 ;? ($print first-index-on-page:integer/space:1) ;? 1
823 ;? ($print (("\n" literal))) ;? 1
824 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
825 (last-index-on-page:integer/space:1 <- copy 3:literal)
826 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
827 (expanded-index:integer/space:1 <- copy -1:literal)
828 (expanded-children:integer/space:1 <- copy -1:literal)
829 (s:string-address <- new "K")
830 (k:keyboard-address <- init-keyboard s:string-address)
831 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
833 (each routine completed-routines*
834 (awhen rep.routine!error
835 (prn "error - " it)))
836 (when (~screen-contains memory*.4 17
837 (+ "+ main/ 0 : a b c"
839 "+ main/ 2 : g hi "))
840 (prn "F - page-up 2"))
843 ; + run: main 0: a b c
845 ; - run: main 1: d e f <- top of page
847 ; mem: 1 b <- bottom of page
851 ; + run: main 2: g hi
859 (default-space:space-address <- new space:literal 30:literal/capacity)
860 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
861 (first-index-on-page:integer/space:1 <- copy 1:literal)
862 (first-subindex-on-page:integer/space:1 <- copy -1:literal)
863 (last-index-on-page:integer/space:1 <- copy 1:literal)
864 (last-subindex-on-page:integer/space:1 <- copy 1:literal)
865 (expanded-index:integer/space:1 <- copy 1:literal)
866 (expanded-children:integer/space:1 <- copy 5:literal)
867 (to-top 0:space-address/browser-state 2:terminal-address/raw)
868 (print-page 0:space-address/browser-state 2:terminal-address/raw)
870 (each routine completed-routines*
871 (awhen rep.routine!error
872 (prn "error - " it)))
873 (when (~screen-contains memory*.4 17
874 (+ "- main/ 1 : d e f"
879 (prn "F - page-up 3: initial print-page state"))
881 (default-space:space-address <- new space:literal 30:literal/capacity)
882 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
883 (first-index-on-page:integer/space:1 <- copy 0:literal)
884 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
885 (last-index-on-page:integer/space:1 <- copy 1:literal)
886 (last-subindex-on-page:integer/space:1 <- copy 0:literal)
887 (expanded-index:integer/space:1 <- copy 1:literal)
888 (expanded-children:integer/space:1 <- copy 5:literal)
889 (to-top 0:space-address/browser-state 2:terminal-address/raw)
890 (print-page 0:space-address/browser-state 2:terminal-address/raw)
892 (each routine completed-routines*
893 (awhen rep.routine!error
894 (prn "error - " it)))
895 (when (~screen-contains memory*.4 17
896 (+ "+ main/ 0 : a b c"
901 (prn "F - page-up 3: expected post page-up state"))
904 (default-space:space-address <- new space:literal 30:literal/capacity)
905 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
906 (first-index-on-page:integer/space:1 <- copy 1:literal)
907 (first-subindex-on-page:integer/space:1 <- copy -1:literal)
908 (last-index-on-page:integer/space:1 <- copy 1:literal)
909 (last-subindex-on-page:integer/space:1 <- copy 1:literal)
910 (expanded-index:integer/space:1 <- copy 1:literal)
911 (expanded-children:integer/space:1 <- copy 5:literal)
912 (s:string-address <- new "K")
913 (k:keyboard-address <- init-keyboard s:string-address)
914 ;? ($start-tracing) ;? 1
915 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
917 (each routine completed-routines*
918 (awhen rep.routine!error
919 (prn "error - " it)))
920 (when (~screen-contains memory*.4 17
921 (+ "+ main/ 0 : a b c"
926 (prn "F - page-up 3"))
930 ; + run: main 0: a b c
932 ; - run: main 1: d e f
935 ; mem: 1 c <- top of page
937 ; mem: 1 e <- bottom of page
938 ; + run: main 2: g hi
946 (default-space:space-address <- new space:literal 30:literal/capacity)
947 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
948 (first-index-on-page:integer/space:1 <- copy 1:literal)
949 (first-subindex-on-page:integer/space:1 <- copy 2:literal)
950 (last-index-on-page:integer/space:1 <- copy 1:literal)
951 (last-subindex-on-page:integer/space:1 <- copy 4:literal)
952 (expanded-index:integer/space:1 <- copy 1:literal)
953 (expanded-children:integer/space:1 <- copy 5:literal)
954 (s:string-address <- new "K")
955 (k:keyboard-address <- init-keyboard s:string-address)
956 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
958 (each routine completed-routines*
959 (awhen rep.routine!error
960 (prn "error - " it)))
961 (when (~screen-contains memory*.4 17
962 (+ "- main/ 1 : d e f"
967 (prn "F - page-up 4"))
970 ; + run: main 0: a b c
972 ; - run: main 1: d e f
973 ; mem: 1 a <- top of page
975 ; mem: 1 c <- bottom of page
978 ; + run: main 2: g hi
986 (default-space:space-address <- new space:literal 30:literal/capacity)
987 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
988 (first-index-on-page:integer/space:1 <- copy 1:literal)
989 (first-subindex-on-page:integer/space:1 <- copy 0:literal)
990 (last-index-on-page:integer/space:1 <- copy 1:literal)
991 (last-subindex-on-page:integer/space:1 <- copy 2:literal)
992 (expanded-index:integer/space:1 <- copy 1:literal)
993 (expanded-children:integer/space:1 <- copy 5:literal)
994 ;? ($print cursor-row:integer/space:1) ;? 1
995 (to-top 0:space-address/browser-state 2:terminal-address/raw)
996 ;? ($print cursor-row:integer/space:1) ;? 1
997 (print-page 0:space-address/browser-state 2:terminal-address/raw)
999 (each routine completed-routines*
1000 (awhen rep.routine!error
1001 (prn "error - " it)))
1002 (when (~screen-contains memory*.4 17
1008 (prn "F - page-up 5: initial print-page state"))
1010 (default-space:space-address <- new space:literal 30:literal/capacity)
1011 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1012 (first-index-on-page:integer/space:1 <- copy 1:literal)
1013 (first-subindex-on-page:integer/space:1 <- copy 0:literal)
1014 (last-index-on-page:integer/space:1 <- copy 1:literal)
1015 (last-subindex-on-page:integer/space:1 <- copy 2:literal)
1016 (expanded-index:integer/space:1 <- copy 1:literal)
1017 (expanded-children:integer/space:1 <- copy 5:literal)
1018 (s:string-address <- new "K")
1019 (k:keyboard-address <- init-keyboard s:string-address)
1020 ;? ($dump-browser-state 3:space-address/raw/browser-state) ;? 1
1021 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1023 (each routine completed-routines*
1024 (awhen rep.routine!error
1025 (prn "error - " it)))
1026 (when (~screen-contains memory*.4 17
1027 (+ "+ main/ 0 : a b c"
1032 (prn "F - page-up 5"))
1034 ; page-up scenario 6
1035 ; + run: main 0: a b c
1037 ; - run: main 1: d e f
1039 ; mem: 1 b <- top of page
1041 ; mem: 1 d <- bottom of page
1043 ; + run: main 2: g hi
1051 (default-space:space-address <- new space:literal 30:literal/capacity)
1052 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1053 (first-index-on-page:integer/space:1 <- copy 1:literal)
1054 (first-subindex-on-page:integer/space:1 <- copy 1:literal)
1055 (last-index-on-page:integer/space:1 <- copy 1:literal)
1056 (last-subindex-on-page:integer/space:1 <- copy 3:literal)
1057 (expanded-index:integer/space:1 <- copy 1:literal)
1058 (expanded-children:integer/space:1 <- copy 5:literal)
1059 (s:string-address <- new "K")
1060 (k:keyboard-address <- init-keyboard s:string-address)
1061 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1063 (each routine completed-routines*
1064 (awhen rep.routine!error
1065 (prn "error - " it)))
1066 (when (~screen-contains memory*.4 17
1067 (+ "+ main/ 0 : a b c"
1072 (prn "F - page-up 6"))
1074 ; page-up scenario 7
1075 ; + run: main 0: a b c
1077 ; + run: main 1: d e f <- top of page
1083 ; + run: main 2: g hi
1084 ; - run: main 3: j <- bottom of page
1091 (default-space:space-address <- new space:literal 30:literal/capacity)
1092 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1093 (first-index-on-page:integer/space:1 <- copy 1:literal)
1094 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1095 (last-index-on-page:integer/space:1 <- copy 3:literal)
1096 (last-subindex-on-page:integer/space:1 <- copy -1:literal)
1097 (expanded-index:integer/space:1 <- copy 3:literal)
1098 (expanded-children:integer/space:1 <- copy 1:literal)
1099 (s:string-address <- new "K")
1100 (k:keyboard-address <- init-keyboard s:string-address)
1101 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1103 (each routine completed-routines*
1104 (awhen rep.routine!error
1105 (prn "error - " it)))
1106 (when (~screen-contains memory*.4 17
1107 (+ "+ main/ 0 : a b c"
1111 (prn "F - page-up 7 - expanded index starts below bottom"))
1114 ; page-up scenario 8
1115 ; + run: main 0: a b c
1117 ; + run: main 1: d e f <- top of page
1123 ; + run: main 2: g hi
1124 ; + run: main 3: j <- bottom of page
1131 (default-space:space-address <- new space:literal 30:literal/capacity)
1132 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1133 (first-index-on-page:integer/space:1 <- copy 1:literal)
1134 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1135 (last-index-on-page:integer/space:1 <- copy 3:literal)
1136 (last-subindex-on-page:integer/space:1 <- copy -1:literal)
1137 (expanded-index:integer/space:1 <- copy 4:literal)
1138 (expanded-children:integer/space:1 <- copy 0:literal)
1139 (s:string-address <- new "K")
1140 (k:keyboard-address <- init-keyboard s:string-address)
1141 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1143 (each routine completed-routines*
1144 (awhen rep.routine!error
1145 (prn "error - " it)))
1146 (when (~screen-contains memory*.4 17
1147 (+ "+ main/ 0 : a b c"
1151 (prn "F - page-up 8 - expanded index starts below top - 2"))
1153 ; page-up scenario 9
1154 ; - run: main 0: a b c
1156 ; + run: main 1: d e f
1162 ; + run: main 2: g hi
1163 ; + run: main 3: j <- top of page
1166 ; + run: main 5: l <- bottom of page
1170 (default-space:space-address <- new space:literal 30:literal/capacity)
1171 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1172 (first-index-on-page:integer/space:1 <- copy 3:literal)
1173 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1174 (last-index-on-page:integer/space:1 <- copy 5:literal)
1175 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1176 (expanded-index:integer/space:1 <- copy 0:literal)
1177 (expanded-children:integer/space:1 <- copy 1:literal)
1178 (s:string-address <- new "K")
1179 (k:keyboard-address <- init-keyboard s:string-address)
1180 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1182 (each routine completed-routines*
1183 (awhen rep.routine!error
1184 (prn "error - " it)))
1185 (when (~screen-contains memory*.4 17
1190 (prn "F - page-up 9 - expanded index overlaps target page"))
1192 ; page-up scenario 10
1193 ; - run: main 0: a b c
1195 ; + run: main 1: d e f
1201 ; + run: main 2: g hi <- top of page
1204 ; + run: main 4: k <- bottom of page
1209 (default-space:space-address <- new space:literal 30:literal/capacity)
1210 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1211 (first-index-on-page:integer/space:1 <- copy 2:literal)
1212 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1213 (last-index-on-page:integer/space:1 <- copy 4:literal)
1214 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1215 (expanded-index:integer/space:1 <- copy 0:literal)
1216 (expanded-children:integer/space:1 <- copy 1:literal)
1217 (to-top 0:space-address/browser-state 2:terminal-address/raw)
1218 ;? ($start-tracing) ;? 2
1219 (print-page 0:space-address/browser-state 2:terminal-address/raw)
1221 (each routine completed-routines*
1222 (awhen rep.routine!error
1223 (prn "error - " it)))
1224 (when (~screen-contains memory*.4 17
1225 (+ "+ main/ 2 : g hi "
1230 (prn "F - page-up 10: initial print-page state"))
1233 (default-space:space-address <- new space:literal 30:literal/capacity)
1234 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1235 (first-index-on-page:integer/space:1 <- copy 2:literal)
1236 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1237 (last-index-on-page:integer/space:1 <- copy 4:literal)
1238 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1239 (expanded-index:integer/space:1 <- copy 0:literal)
1240 (expanded-children:integer/space:1 <- copy 1:literal)
1241 (s:string-address <- new "K")
1242 (k:keyboard-address <- init-keyboard s:string-address)
1243 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1245 (each routine completed-routines*
1246 (awhen rep.routine!error
1247 (prn "error - " it)))
1248 (when (~screen-contains memory*.4 17
1249 (+ "- main/ 0 : a b c"
1254 (prn "F - page-up 10 - expanded index overlaps target page - 2"))
1258 (new-trace "trace-paginate2")
1259 ; page-up scenario 11
1260 ; + run: main 0: a b c
1262 ; + run: main 1: d e f
1263 ; - run: main 2: g hi
1265 ; + run: main 3: j <- top of page
1268 ; + run: main 5: l <- bottom of page
1272 (default-space:space-address <- new space:literal 30:literal/capacity)
1273 (x:string-address <- new
1285 (s:stream-address <- init-stream x:string-address)
1286 (traces:instruction-trace-address-array-address <- parse-traces s:stream-address)
1287 (2:terminal-address/raw <- init-fake-terminal 17:literal 15:literal)
1288 (3:space-address/raw/browser-state <- browser-state traces:instruction-trace-address-array-address 3:literal/screen-height)
1289 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1290 (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
1291 (first-index-on-page:integer/space:1 <- copy 3:literal)
1292 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1293 (last-index-on-page:integer/space:1 <- copy 5:literal)
1294 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1295 (expanded-index:integer/space:1 <- copy 2:literal)
1296 (expanded-children:integer/space:1 <- copy 1:literal)
1297 (s:string-address <- new "K")
1298 (k:keyboard-address <- init-keyboard s:string-address)
1299 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1301 (each routine completed-routines*
1302 (awhen rep.routine!error
1303 (prn "error - " it)))
1304 (when (~screen-contains memory*.4 17
1305 (+ "+ main/ 1 : d e f"
1310 (prn "F - page-up 11 - expanded index overlaps target page - 3"))
1312 ; page-up scenario 12
1313 ; + run: main 0: a b c
1315 ; + run: main 1: d e f
1316 ; - run: main 2: g hi
1320 ; + run: main 4: k <- top of page
1322 ; + run: main 6: m <- bottom of page
1325 (default-space:space-address <- new space:literal 30:literal/capacity)
1326 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1327 (first-index-on-page:integer/space:1 <- copy 4:literal)
1328 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1329 (last-index-on-page:integer/space:1 <- copy 6:literal)
1330 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1331 (expanded-index:integer/space:1 <- copy 2:literal)
1332 (expanded-children:integer/space:1 <- copy 1:literal)
1333 (s:string-address <- new "K")
1334 (k:keyboard-address <- init-keyboard s:string-address)
1335 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1337 (each routine completed-routines*
1338 (awhen rep.routine!error
1339 (prn "error - " it)))
1340 (when (~screen-contains memory*.4 17
1341 (+ "- main/ 2 : g hi "
1345 (prn "F - page-up 12 - expanded index overlaps target page - 4"))
1347 ; page-up scenario 13
1348 ; + run: main 0: a b c
1350 ; + run: main 1: d e f
1351 ; - run: main 2: g hi
1357 ; + run: main 6: m <- top of page
1358 ; + run: main 7: n <- bottom of page
1360 (default-space:space-address <- new space:literal 30:literal/capacity)
1361 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1362 (first-index-on-page:integer/space:1 <- copy 6:literal)
1363 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1364 (last-index-on-page:integer/space:1 <- copy 7:literal)
1365 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1366 (expanded-index:integer/space:1 <- copy 2:literal)
1367 (expanded-children:integer/space:1 <- copy 1:literal)
1368 (s:string-address <- new "K")
1369 (k:keyboard-address <- init-keyboard s:string-address)
1370 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1372 (each routine completed-routines*
1373 (awhen rep.routine!error
1374 (prn "error - " it)))
1375 (when (~screen-contains memory*.4 17
1380 (prn "F - page-up 13 - expanded index far above target page"))
1383 (default-space:space-address <- new space:literal 30:literal/capacity)
1384 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1385 (s:string-address <- new "kk\n")
1386 (k:keyboard-address <- init-keyboard s:string-address)
1387 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1388 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1389 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1391 (each routine completed-routines*
1392 (awhen rep.routine!error
1393 (prn "error - " it)))
1394 (when (~screen-contains memory*.4 17
1399 (prn "F - process-key expands a trace index on any page"))
1401 (replace-character 2:terminal-address/raw ((#\* literal)))
1403 (when (~screen-contains memory*.4 17
1408 (prn "F - process-key resets the cursor after expand"))
1412 (default-space:space-address <- new space:literal 30:literal/capacity)
1413 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1414 ; reset previous cursor
1415 (replace-character 2:terminal-address/raw ((#\- literal)))
1416 (s:string-address <- new "j\n")
1417 (k:keyboard-address <- init-keyboard s:string-address)
1418 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1419 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1421 (each routine completed-routines*
1422 (awhen rep.routine!error
1423 (prn "error - " it)))
1424 (when (~screen-contains memory*.4 17
1429 (prn "F - process-key expands a trace index on any page when there's an expanded trace index above it on the same page"))
1432 ; + run: main 0: a b c
1434 ; + run: main 1: d e f
1435 ; - run: main 2: g hi
1436 ; mem: 2 a <- top of page
1439 ; + run: main 4: k <- bottom of page
1444 (default-space:space-address <- new space:literal 30:literal/capacity)
1445 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1446 (first-index-on-page:integer/space:1 <- copy 2:literal)
1447 (first-subindex-on-page:integer/space:1 <- copy 0:literal)
1448 (last-index-on-page:integer/space:1 <- copy 4:literal)
1449 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1450 (expanded-index:integer/space:1 <- copy 2:literal)
1451 (expanded-children:integer/space:1 <- copy 1:literal)
1452 (to-top 0:space-address/browser-state 2:terminal-address/raw)
1453 (print-page 0:space-address/browser-state 2:terminal-address/raw)
1454 (s:string-address <- new "kk\n")
1455 (k:keyboard-address <- init-keyboard s:string-address)
1456 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1457 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1458 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1459 ;? (replace-character 2:terminal-address/raw ((#\* literal))) ;? 2
1461 (each routine completed-routines*
1462 (awhen rep.routine!error
1463 (prn "error - " it)))
1464 (when (~screen-contains memory*.4 17
1465 ;? (+ " mem : 2 a " ; after print-page
1469 (+ "+ main/ 2 : g hi "
1473 ;? (+ "- main/ 3 : j " ; alternative interpretation in case the above isn't intuitive
1475 ;? (+ "- main/ 4 : k "
1477 (prn "F - process-key expands trace index on a page that starts with a partial expanded trace"))
1480 (new-trace "trace-paginate3")
1482 ; + run: main 0: a b c
1484 ; + run: main 1: d e f
1486 ; mem: 1 b <- top of page
1488 ; + run: main 2: g hi <- bottom of page
1494 (default-space:space-address <- new space:literal 30:literal/capacity)
1495 (x:string-address <- new
1507 (s:stream-address <- init-stream x:string-address)
1508 (traces:instruction-trace-address-array-address <- parse-traces s:stream-address)
1509 (2:terminal-address/raw <- init-fake-terminal 17:literal 15:literal)
1510 (3:space-address/raw/browser-state <- browser-state traces:instruction-trace-address-array-address 3:literal/screen-height)
1511 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1512 (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
1513 (first-index-on-page:integer/space:1 <- copy 1:literal)
1514 (first-subindex-on-page:integer/space:1 <- copy 1:literal)
1515 (last-index-on-page:integer/space:1 <- copy 3:literal)
1516 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1517 (expanded-index:integer/space:1 <- copy 1:literal)
1518 (expanded-children:integer/space:1 <- copy 3:literal)
1519 (to-top 0:space-address/browser-state 2:terminal-address/raw)
1520 (print-page 0:space-address/browser-state 2:terminal-address/raw)
1521 ;? (replace-character 2:terminal-address/raw ((#\* literal))) ;? 1
1522 (s:string-address <- new "k\n")
1523 (k:keyboard-address <- init-keyboard s:string-address)
1524 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1525 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1527 (each routine completed-routines*
1528 (awhen rep.routine!error
1529 (prn "error - " it)))
1530 (when (~screen-contains memory*.4 17
1531 ;? (+ " mem : 1 b " ; after print-page
1533 ;? "+ main/ 2 : g hi "
1536 (+ "+ main/ 1 : d e f"
1541 (prn "F - process-key expands trace index on a page that starts with a partial expanded trace - 2"))
1544 ; + run: main 0: a b c
1546 ; + run: main 1: d e f
1547 ; mem: 1 a <- top of page
1549 ; mem: 1 c <- bottom of page
1550 ; + run: main 2: g hi
1556 (default-space:space-address <- new space:literal 30:literal/capacity)
1557 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1558 (first-index-on-page:integer/space:1 <- copy 1:literal)
1559 (first-subindex-on-page:integer/space:1 <- copy 0:literal)
1560 (last-index-on-page:integer/space:1 <- copy 1:literal)
1561 (last-subindex-on-page:integer/space:1 <- copy 2:literal)
1562 (expanded-index:integer/space:1 <- copy 1:literal)
1563 (expanded-children:integer/space:1 <- copy 3:literal)
1564 (to-top 0:space-address/browser-state 2:terminal-address/raw)
1565 (print-page 0:space-address/browser-state 2:terminal-address/raw)
1566 (s:string-address <- new "k\n")
1567 (k:keyboard-address <- init-keyboard s:string-address)
1568 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1569 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1570 ;? (replace-character 2:terminal-address/raw ((#\* literal))) ;? 1
1572 (each routine completed-routines*
1573 (awhen rep.routine!error
1574 (prn "error - " it)))
1575 (when (~screen-contains memory*.4 17
1576 ;? (+ " mem : 1 a " ; after print-page
1580 (+ "+ main/ 1 : d e f"
1583 (prn "F - process-key expands trace index on a page with only subindex lines"))
1586 (default-space:space-address <- new space:literal 30:literal/capacity)
1587 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1589 (first-index-on-page:integer/space:1 <- copy 0:literal)
1590 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1591 (last-index-on-page:integer/space:1 <- copy 2:literal)
1592 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1593 (expanded-index:integer/space:1 <- copy -1:literal)
1594 (expanded-children:integer/space:1 <- copy -1:literal)
1595 (to-top 0:space-address/browser-state 2:terminal-address/raw)
1596 (print-page 0:space-address/browser-state 2:terminal-address/raw)
1597 ;? (replace-character 2:terminal-address/raw ((#\* literal))) ;? 1
1598 (s:string-address <- new "Jjj\n")
1599 (k:keyboard-address <- init-keyboard s:string-address)
1600 ;? ($print (("test: first subindex " literal))) ;? 1
1601 ;? ($print first-subindex-on-page:integer/space:1) ;? 1
1602 ;? ($print (("\n" literal))) ;? 1
1603 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1604 ;? ($print (("test: first subindex 2 " literal))) ;? 1
1605 ;? ($print first-subindex-on-page:integer/space:1) ;? 1
1606 ;? ($print (("\n" literal))) ;? 1
1607 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1608 ;? ($print (("test: first subindex 3 " literal))) ;? 1
1609 ;? ($print first-subindex-on-page:integer/space:1) ;? 1
1610 ;? ($print (("\n" literal))) ;? 1
1611 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1612 ;? ($print (("test: first subindex 4 " literal))) ;? 1
1613 ;? ($print first-subindex-on-page:integer/space:1) ;? 1
1614 ;? ($print (("\n" literal))) ;? 1
1615 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1617 (each routine completed-routines*
1618 (awhen rep.routine!error
1619 (prn "error - " it)))
1620 (when (~screen-contains memory*.4 17
1626 (prn "F - process-key expands final index of trace at bottom of page"))
1629 (default-space:space-address <- new space:literal 30:literal/capacity)
1630 (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
1632 (first-index-on-page:integer/space:1 <- copy 0:literal)
1633 (first-subindex-on-page:integer/space:1 <- copy -2:literal)
1634 (last-index-on-page:integer/space:1 <- copy 2:literal)
1635 (last-subindex-on-page:integer/space:1 <- copy -2:literal)
1636 (expanded-index:integer/space:1 <- copy -1:literal)
1637 (expanded-children:integer/space:1 <- copy -1:literal)
1638 (to-top 0:space-address/browser-state 2:terminal-address/raw)
1639 (print-page 0:space-address/browser-state 2:terminal-address/raw)
1640 ;? (replace-character 2:terminal-address/raw ((#\* literal))) ;? 1
1641 (s:string-address <- new "kk\nJjj")
1642 (k:keyboard-address <- init-keyboard s:string-address)
1643 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1644 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1645 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1646 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1647 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1648 (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
1649 (5:integer-address/raw <- get-address 2:terminal-address/raw/deref cursor-row:offset)
1651 (each routine completed-routines*
1652 (awhen rep.routine!error
1653 (prn "error - " it)))
1654 ;? (prn (memory* memory*.5)) ;? 1
1655 (when (~is 3 (memory* memory*.5))
1656 (prn "F - key movement stays within screen bounds, even when no next trace on page"))
1659 ;? (print-times) ;? 3