about summary refs log tree commit diff stats
path: root/sandbox/005-sandbox.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-28 19:48:56 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-28 19:48:56 -0700
commit6f65d5918f4b73de56e6cb6362c7cbc7dbbe5945 (patch)
treedec4043f2d62f5dd02156d369e20af247881e2ac /sandbox/005-sandbox.mu
parent1627d836b46440f57d766b154ec488fa2e5a1e06 (diff)
downloadmu-6f65d5918f4b73de56e6cb6362c7cbc7dbbe5945.tar.gz
3429 - standardize Mu scenarios
A long-standing problem has been that I couldn't spread code across
'run' blocks because they were separate scopes, so I've ended up making
them effectively comments. Running code inside a 'run' block is
identical in every way to simply running the code directly. The 'run'
block is merely a visual aid to separate setup from the component under
test.

In the process I've also standardized all Mu scenarios to always run in
a local scope, and only use (raw) numeric addresses for values they want
to check later.
Diffstat (limited to 'sandbox/005-sandbox.mu')
-rw-r--r--sandbox/005-sandbox.mu112
1 files changed, 56 insertions, 56 deletions
diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu
index 4d6e2bdc..c83e9f9c 100644
--- a/sandbox/005-sandbox.mu
+++ b/sandbox/005-sandbox.mu
@@ -29,17 +29,17 @@ container sandbox [
 ]
 
 scenario run-and-show-results [
+  local-scope
   trace-until 100/app  # trace too long
   assume-screen 50/width, 15/height
   # sandbox editor contains an instruction without storing outputs
-  1:text <- new [divide-with-remainder 11, 3]
-  2:&:environment <- new-programming-environment screen:&:screen, 1:text
+  env:&:environment <- new-programming-environment screen:&:screen, [divide-with-remainder 11, 3]
   # run the code in the editors
   assume-console [
     press F4
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
+    event-loop screen:&:screen, console:&:console, env
   ]
   # check that screen prints the results
   screen-should-contain [
@@ -82,7 +82,7 @@ scenario run-and-show-results [
     press F4
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
+    event-loop screen:&:screen, console:&:console, env
   ]
   # check that screen prints both sandboxes
   screen-should-contain [
@@ -501,23 +501,23 @@ def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num,
 ]
 
 scenario run-updates-results [
+  local-scope
   trace-until 100/app  # trace too long
   assume-screen 50/width, 12/height
   # define a recipe (no indent for the 'add' line below so column numbers are more obvious)
-  1:text <- new [ 
-def foo [
+  recipes:text <- new [ 
+recipe foo [
 local-scope
 z:num <- add 2, 2
-return z
+reply z
 ]]
   # sandbox editor contains an instruction without storing outputs
-  2:text <- new [foo]
-  3:&:environment <- new-programming-environment screen:&:screen, 2:text
+  env:&:environment <- new-programming-environment screen:&:screen, [foo]
   # run the code in the editors
   assume-console [
     press F4
   ]
-  event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/recipes
+  event-loop screen:&:screen, console:&:console, env, recipes
   screen-should-contain [
     .                               run (F4)           .
     .                                                  .
@@ -529,7 +529,7 @@ return z
     .                                                  .
   ]
   # make a change (incrementing one of the args to 'add'), then rerun
-  1:text <- new [ 
+  recipes:text <- new [ 
 def foo [
 local-scope
 z:num <- add 2, 3
@@ -539,7 +539,7 @@ return z
     press F4
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/recipes
+    event-loop screen:&:screen, console:&:console, env, recipes
   ]
   # check that screen updates the result on the right
   screen-should-contain [
@@ -555,17 +555,17 @@ return z
 ]
 
 scenario run-instruction-manages-screen-per-sandbox [
+  local-scope
   trace-until 100/app  # trace too long
   assume-screen 50/width, 20/height
   # editor contains an instruction
-  1:text <- new [print-integer screen, 4]
-  2:&:environment <- new-programming-environment screen:&:screen, 1:text
+  env:&:environment <- new-programming-environment screen:&:screen, [print-integer screen, 4]
   # run the code in the editor
   assume-console [
     press F4
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
+    event-loop screen:&:screen, console:&:console, env
   ]
   # check that it prints a little toy screen
   screen-should-contain [
@@ -605,37 +605,37 @@ def editor-contents editor:&:editor -> result:text [
 ]
 
 scenario editor-provides-edited-contents [
+  local-scope
   assume-screen 10/width, 5/height
-  1:text <- new [abc]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
+  e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right
   assume-console [
     left-click 1, 2
     type [def]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:text <- editor-contents 2:&:editor
-    4:@:char <- copy *3:text
+    editor-event-loop screen:&:screen, console:&:console, e
+    s:text <- editor-contents e
+    1:@:char/raw <- copy *s
   ]
   memory-should-contain [
-    4:array:character <- [abdefc]
+    1:array:character <- [abdefc]
   ]
 ]
 
 # scrolling through sandboxes
 
 scenario scrolling-down-past-bottom-of-sandbox-editor [
+  local-scope
   trace-until 100/app  # trace too long
   assume-screen 50/width, 20/height
   # initialize
-  1:text <- new [add 2, 2]
-  2:&:environment <- new-programming-environment screen:&:screen, 1:text
-  render-all screen, 2:&:environment, render
+  env:&:environment <- new-programming-environment screen:&:screen, [add 2, 2]
+  render-all screen, env, render
   assume-console [
     # create a sandbox
     press F4
   ]
-  event-loop screen:&:screen, console:&:console, 2:&:environment
+  event-loop screen:&:screen, console:&:console, env
   screen-should-contain [
     .                               run (F4)           .
     .                                                  .
@@ -651,9 +651,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [
     press page-down
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
-    3:char/cursor <- copy 9251/␣
-    print screen:&:screen, 3:char/cursor
+    event-loop screen:&:screen, console:&:console, env
+    cursor:char <- copy 9251/␣
+    print screen:&:screen, cursor
   ]
   # sandbox editor hidden; first sandbox displayed
   # cursor moves to first sandbox
@@ -671,9 +671,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [
     press page-up
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
-    3:char/cursor <- copy 9251/␣
-    print screen:&:screen, 3:char/cursor
+    event-loop screen:&:screen, console:&:console, env
+    cursor:char <- copy 9251/␣
+    print screen:&:screen, cursor
   ]
   # sandbox editor displays again
   screen-should-contain [
@@ -761,12 +761,12 @@ def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [
 ]
 
 scenario scrolling-through-multiple-sandboxes [
+  local-scope
   trace-until 100/app  # trace too long
   assume-screen 50/width, 20/height
   # initialize environment
-  1:text <- new []
-  2:&:environment <- new-programming-environment screen:&:screen, 1:text
-  render-all screen, 2:&:environment, render
+  env:&:environment <- new-programming-environment screen:&:screen, []
+  render-all screen, env, render
   # create 2 sandboxes
   assume-console [
     press ctrl-n
@@ -775,9 +775,9 @@ scenario scrolling-through-multiple-sandboxes [
     type [add 1, 1]
     press F4
   ]
-  event-loop screen:&:screen, console:&:console, 2:&:environment
-  3:char/cursor <- copy 9251/␣
-  print screen:&:screen, 3:char/cursor
+  event-loop screen:&:screen, console:&:console, env
+  cursor:char <- copy 9251/␣
+  print screen:&:screen, cursor
   screen-should-contain [
     .                               run (F4)           .
     .␣                                                 .
@@ -797,9 +797,9 @@ scenario scrolling-through-multiple-sandboxes [
     press page-down
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
-    3:char/cursor <- copy 9251/␣
-    print screen:&:screen, 3:char/cursor
+    event-loop screen:&:screen, console:&:console, env
+    cursor:char <- copy 9251/␣
+    print screen:&:screen, cursor
   ]
   # sandbox editor hidden; first sandbox displayed
   # cursor moves to first sandbox
@@ -821,7 +821,7 @@ scenario scrolling-through-multiple-sandboxes [
     press page-down
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
+    event-loop screen:&:screen, console:&:console, env
   ]
   # just second sandbox displayed
   screen-should-contain [
@@ -838,7 +838,7 @@ scenario scrolling-through-multiple-sandboxes [
     press page-down
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
+    event-loop screen:&:screen, console:&:console, env
   ]
   # no change
   screen-should-contain [
@@ -855,7 +855,7 @@ scenario scrolling-through-multiple-sandboxes [
     press page-up
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
+    event-loop screen:&:screen, console:&:console, env
   ]
   # back to displaying both sandboxes without editor
   screen-should-contain [
@@ -876,9 +876,9 @@ scenario scrolling-through-multiple-sandboxes [
     press page-up
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
-    3:char/cursor <- copy 9251/␣
-    print screen:&:screen, 3:char/cursor
+    event-loop screen:&:screen, console:&:console, env
+    cursor:char <- copy 9251/␣
+    print screen:&:screen, cursor
   ]
   # back to displaying both sandboxes as well as editor
   screen-should-contain [
@@ -900,9 +900,9 @@ scenario scrolling-through-multiple-sandboxes [
     press page-up
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
-    3:char/cursor <- copy 9251/␣
-    print screen:&:screen, 3:char/cursor
+    event-loop screen:&:screen, console:&:console, env
+    cursor:char <- copy 9251/␣
+    print screen:&:screen, cursor
   ]
   # no change
   screen-should-contain [
@@ -922,19 +922,19 @@ scenario scrolling-through-multiple-sandboxes [
 ]
 
 scenario scrolling-manages-sandbox-index-correctly [
+  local-scope
   trace-until 100/app  # trace too long
   assume-screen 50/width, 20/height
   # initialize environment
-  1:text <- new []
-  2:&:environment <- new-programming-environment screen:&:screen, 1:text
-  render-all screen, 2:&:environment, render
+  env:&:environment <- new-programming-environment screen:&:screen, []
+  render-all screen, env, render
   # create a sandbox
   assume-console [
     press ctrl-n
     type [add 1, 1]
     press F4
   ]
-  event-loop screen:&:screen, console:&:console, 2:&:environment
+  event-loop screen:&:screen, console:&:console, env
   screen-should-contain [
     .                               run (F4)           .
     .                                                  .
@@ -950,7 +950,7 @@ scenario scrolling-manages-sandbox-index-correctly [
     press page-down
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
+    event-loop screen:&:screen, console:&:console, env
   ]
   # sandbox editor hidden; first sandbox displayed
   # cursor moves to first sandbox
@@ -968,7 +968,7 @@ scenario scrolling-manages-sandbox-index-correctly [
     press page-up
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
+    event-loop screen:&:screen, console:&:console, env
   ]
   # back to displaying both sandboxes as well as editor
   screen-should-contain [
@@ -986,7 +986,7 @@ scenario scrolling-manages-sandbox-index-correctly [
     press page-down
   ]
   run [
-    event-loop screen:&:screen, console:&:console, 2:&:environment
+    event-loop screen:&:screen, console:&:console, env
   ]
   # sandbox editor hidden; first sandbox displayed
   # cursor moves to first sandbox