about summary refs log tree commit diff stats
path: root/sandbox
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-01 13:51:49 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-01 13:56:21 -0800
commit67d2a9c07dea2f100f526cf6cd0831b544cd73fa (patch)
treea78367a21ac4ab5c1d54a29b8ad9ec69ef7e7e18 /sandbox
parent07a6418389a6c36c0fe9cded6e585fb013ec90e1 (diff)
downloadmu-67d2a9c07dea2f100f526cf6cd0831b544cd73fa.tar.gz
2624
Reorganize further to make edit/008-sandbox-test more self-contained.
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/005-sandbox.mu11
-rw-r--r--sandbox/008-sandbox-test.mu27
2 files changed, 23 insertions, 15 deletions
diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu
index 690ab22c..e79029f6 100644
--- a/sandbox/005-sandbox.mu
+++ b/sandbox/005-sandbox.mu
@@ -18,7 +18,6 @@ after <programming-environment-initialization> [
 container sandbox-data [
   data:address:shared:array:character
   response:address:shared:array:character
-  expected-response:address:shared:array:character
   # coordinates to track clicks
   # constraint: will be 0 for sandboxes at positions before env.render-from
   starting-row-on-screen:number
@@ -223,12 +222,7 @@ recipe save-sandboxes env:address:shared:programming-environment-data [
     data:address:shared:array:character <- get *curr, data:offset
     filename:address:shared:array:character <- to-text idx
     save filename, data
-    {
-      expected-response:address:shared:array:character <- get *curr, expected-response:offset
-      break-unless expected-response
-      filename <- append filename, suffix
-      save filename, expected-response
-    }
+    <end-save-sandbox>
     idx <- add idx, 1
     curr <- get *curr, next-sandbox:offset
     loop
@@ -343,8 +337,7 @@ recipe! restore-sandboxes env:address:shared:programming-environment-data -> env
       filename <- append filename, suffix
       contents <- restore filename
       break-unless contents
-      expected-response:address:address:shared:array:character <- get-address **curr, expected-response:offset
-      *expected-response <- copy contents
+      <end-restore-sandbox>
     }
     +continue
     idx <- add idx, 1
diff --git a/sandbox/008-sandbox-test.mu b/sandbox/008-sandbox-test.mu
index c5695610..b299f704 100644
--- a/sandbox/008-sandbox-test.mu
+++ b/sandbox/008-sandbox-test.mu
@@ -81,6 +81,27 @@ recipe foo [
   ]
 ]
 
+# this requires tracking a couple more things
+container sandbox-data [
+  response-starting-row-on-screen:number
+  expected-response:address:shared:array:character
+]
+
+# include expected response when saving or restoring a sandbox
+before <end-save-sandbox> [
+  {
+    expected-response:address:shared:array:character <- get *curr, expected-response:offset
+    break-unless expected-response
+    filename <- append filename, suffix
+    save filename, expected-response
+  }
+]
+
+before <end-restore-sandbox> [
+  expected-response:address:address:shared:array:character <- get-address **curr, expected-response:offset
+  *expected-response <- copy contents
+]
+
 # clicks on sandbox responses save it as 'expected'
 after <global-touch> [
   # check if it's inside the output of any sandbox
@@ -110,11 +131,6 @@ after <global-touch> [
   }
 ]
 
-# this requires tracking where responses begin for every sandbox
-container sandbox-data [
-  response-starting-row-on-screen:number
-]
-
 recipe find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [
   local-scope
   load-ingredients
@@ -178,7 +194,6 @@ after <render-sandbox-response> [
 ]
 
 before <end-render-sandbox-reset-hidden> [
-  $log sandbox, [resetting response starting row]
   tmp:address:number <- get-address *sandbox, response-starting-row-on-screen:offset
   *tmp <- copy 0
 ]