From 32b8fac2799ac7cec613e84a3eb9c009141b6a3a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 25 Apr 2016 22:27:19 -0700 Subject: 2866 --- html/edit/008-sandbox-test.mu.html | 63 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'html/edit/008-sandbox-test.mu.html') diff --git a/html/edit/008-sandbox-test.mu.html b/html/edit/008-sandbox-test.mu.html index 2f012d7a..69a4fd5c 100644 --- a/html/edit/008-sandbox-test.mu.html +++ b/html/edit/008-sandbox-test.mu.html @@ -39,17 +39,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until 100/app # trace too long assume-screen 40/width, 10/height # basic recipe - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ reply 4 ]] # run it - 2:address:shared:array:character <- new [foo] + 2:address:array:character <- new [foo] assume-console [ press F4 ] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -65,7 +65,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click 5, 21 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # color toggles to green screen-should-contain-in-color 2/green, [ @@ -81,7 +81,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color # cursor should remain unmoved run [ 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] screen-should-contain [ . run (F4) . @@ -102,7 +102,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # result turns red screen-should-contain-in-color 1/red, [ @@ -120,13 +120,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color # this requires tracking a couple more things container sandbox-data [ response-starting-row-on-screen:number - expected-response:address:shared:array:character + expected-response:address: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 + expected-response:address:array:character <- get *curr, expected-response:offset break-unless expected-response filename <- append filename, [.out] save filename, expected-response @@ -134,8 +134,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] before <end-restore-sandbox> [ - expected-response:address:address:shared:array:character <- get-address **curr, expected-response:offset - *expected-response <- copy contents + *curr <- put *curr, expected-response:offset, contents ] # clicks on sandbox responses save it as 'expected' @@ -143,41 +142,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color # check if it's inside the output of any sandbox { sandbox-left-margin:number <- get *current-sandbox, left:offset - click-column:number <- get *t, column:offset + click-column:number <- get t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset - click-row:number <- get *t, row:offset + click-row:number <- get t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose output is being clicked on - sandbox:address:shared:sandbox-data <- find-click-in-sandbox-output env, click-row + sandbox:address:sandbox-data <- find-click-in-sandbox-output env, click-row break-unless sandbox # toggle its expected-response, and save session sandbox <- toggle-expected-response sandbox save-sandboxes env hide-screen screen screen <- render-sandbox-side screen, env, 1/clear - screen <- update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env + screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env # no change in cursor show-screen screen loop +next-event:label } ] -def find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ +def find-click-in-sandbox-output env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:address:shared:sandbox-data <- get *env, sandbox:offset + sandbox:address:sandbox-data <- get *env, sandbox:offset start:number <- get *sandbox, starting-row-on-screen:offset clicked-on-sandboxes?:boolean <- greater-or-equal click-row, start assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset break-unless next-sandbox next-start:number <- get *next-sandbox, starting-row-on-screen:offset found?:boolean <- lesser-than click-row, next-start @@ -193,28 +192,29 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color return sandbox ] -def toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ +def toggle-expected-response sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ local-scope load-ingredients - expected-response:address:address:shared:array:character <- get-address *sandbox, expected-response:offset + expected-response:address:array:character <- get *sandbox, expected-response:offset { # if expected-response is set, reset - break-unless *expected-response - *expected-response <- copy 0 - return sandbox/same-as-ingredient:0 + break-unless expected-response + *sandbox <- put *sandbox, expected-response:offset, 0 + } + { + # if not, set expected response to the current response + break-if expected-response + response:address:array:character <- get *sandbox, response:offset + *sandbox <- put *sandbox, expected-response:offset, response } - # if not, current response is the expected response - response:address:shared:array:character <- get *sandbox, response:offset - *expected-response <- copy response ] # when rendering a sandbox, color it in red/green if expected response exists after <render-sandbox-response> [ { break-unless sandbox-response - response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset - *response-starting-row <- copy row - expected-response:address:shared:array:character <- get *sandbox, expected-response:offset + *sandbox <- put *sandbox, response-starting-row-on-screen:offset, row + expected-response:address:array:character <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey response-is-expected?:boolean <- equal expected-response, sandbox-response { @@ -230,8 +230,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] before <end-render-sandbox-reset-hidden> [ - tmp:address:number <- get-address *sandbox, response-starting-row-on-screen:offset - *tmp <- copy 0 + *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 ] -- cgit 1.4.1-2-gfad0