## clicking on sandbox results to 'fix' them and turn sandboxes into tests scenario sandbox-click-on-result-toggles-color-to-green [ local-scope trace-until 100/app # trace too long assume-screen 100/width, 20/height # basic recipe assume-resources [ [lesson/recipes.mu] <- [ |recipe foo [| | reply 4| |]| ] ] env:&:environment <- new-programming-environment resources, screen, [foo] render-all screen, env, render # run it assume-console [ press F4 ] event-loop screen, console, env, resources screen-should-contain [ . run (F4) . .recipe foo [ ┊ . . reply 4 ┊─────────────────────────────────────────────────. .] ┊0 edit copy to recipe delete . . ┊foo . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 . . ┊─────────────────────────────────────────────────. . ┊ . ] # click on the '4' in the result $clear-trace assume-console [ left-click 5, 51 ] run [ event-loop screen, console, env, resources ] # color toggles to green screen-should-contain-in-color 2/green, [ . . . . . . . . . . . 4 . . . . . ] # don't render entire sandbox side check-trace-count-for-label-lesser-than 250, [print-character] # say 5 sandbox lines # cursor should remain unmoved run [ cursor:char <- copy 9251/␣ print screen, cursor ] screen-should-contain [ . run (F4) . .␣ecipe foo [ ┊ . . reply 4 ┊─────────────────────────────────────────────────. .] ┊0 edit copy to recipe delete . . ┊foo . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 . . ┊─────────────────────────────────────────────────. . ┊ . ] # now change the result # then rerun assume-console [ left-click 2, 11 # cursor to end of line press backspace type [3] press F4 ] run [ event-loop screen, console, env, resources ] # result turns red screen-should-contain-in-color 1/red, [ . . . . . . . . . . . 3 . . . . . ] ] # this requires tracking a couple more things container sandbox [ response-starting-row-on-screen:num expected-response:text ] # include expected response when saving or restoring a sandbox before [ { expected-response:text <- get *sandbox, expected-response:offset break-unless expected-response filename <- append filename, [.out] resources <- dump resources, filename, expected-response } ] before [ { filename <- append filename, [.out] contents <- slurp resources, filename break-unless contents *curr <- put *curr, expected-response:offset, contents } ] # clicks on sandbox responses save it as 'expected' after [ # check if it's inside the output of any sandbox { sandbox-left-margin:num <- get *current-sandbox, left:offset click-column:num <- get t, column:offset on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? first-sandbox:&:sandbox <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset clic