From 8a92572df505eab170912e082e085301e7fecddd Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 22 Aug 2017 09:50:06 -0700 Subject: 3983 --- html/edit/011-errors.mu.html | 1443 ++++++++++++++++++++++-------------------- 1 file changed, 754 insertions(+), 689 deletions(-) (limited to 'html/edit/011-errors.mu.html') diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index f811408f..742355f5 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -72,634 +72,634 @@ if ('onhashchange' in window) { 9 local-scope 10 load-ingredients 11 recipes:&:editor <- get *env, recipes:offset - 12 in:text <- editor-contents recipes + 12 in:text <- editor-contents recipes 13 resources <- dump resources, [lesson/recipes.mu], in 14 recipe-errors:text <- reload in 15 *env <- put *env, recipe-errors:offset, recipe-errors 16 # if recipe editor has errors, stop 17 { 18 ¦ break-unless recipe-errors - 19 ¦ update-status screen, [errors found ], 1/red + 19 ¦ update-status screen, [errors found ], 1/red 20 ¦ errors-found? <- copy 1/true 21 ¦ return 22 } 23 errors-found? <- copy 0/false 24 ] 25 - 26 after <render-recipe-errors-on-F4> [ - 27 { - 28 ¦ recipe-errors:text <- get *env, recipe-errors:offset - 29 ¦ break-unless recipe-errors - 30 ¦ recipes:&:editor <- get *env, recipes:offset - 31 ¦ left:num <- get *recipes, left:offset - 32 ¦ right:num <- get *recipes, right:offset - 33 ¦ row:num <- get *recipes, bottom:offset - 34 ¦ row, screen <- render-text screen, recipe-errors, left, right, 1/red, row - 35 ¦ # draw dotted line after recipes - 36 ¦ draw-horizontal screen, row, left, right, 9480/horizontal-dotted - 37 ¦ row <- add row, 1 - 38 ¦ clear-screen-from screen, row, left, left, right - 39 } - 40 ] - 41 - 42 container environment [ - 43 error-index:num # index of first sandbox with an error (or -1 if none) - 44 ] - 45 - 46 after <programming-environment-initialization> [ - 47 *result <- put *result, error-index:offset, -1 - 48 ] - 49 - 50 after <run-sandboxes-begin> [ - 51 *env <- put *env, error-index:offset, -1 + 26 after <begin-run-sandboxes-on-F4> [ + 27 old-recipe-errors:text <- get *env, recipe-errors:offset + 28 ] + 29 before <end-run-sandboxes-on-F4> [ + 30 # if there were recipe errors before, check if we can clear them + 31 { + 32 ¦ break-unless old-recipe-errors + 33 ¦ screen <- render-recipes screen, env, render + 34 } + 35 screen <- render-recipe-errors env, screen + 36 ] + 37 + 38 def render-recipe-errors env:&:environment, screen:&:screen -> screen:&:screen [ + 39 local-scope + 40 load-ingredients + 41 recipe-errors:text <- get *env, recipe-errors:offset + 42 return-unless recipe-errors + 43 recipes:&:editor <- get *env, recipes:offset + 44 left:num <- get *recipes, left:offset + 45 right:num <- get *recipes, right:offset + 46 row:num <- get *recipes, bottom:offset + 47 row, screen <- render-text screen, recipe-errors, left, right, 1/red, row + 48 # draw dotted line after recipes + 49 draw-horizontal screen, row, left, right, 9480/horizontal-dotted + 50 row <- add row, 1 + 51 clear-screen-from screen, row, left, left, right 52 ] 53 - 54 before <run-sandboxes-end> [ - 55 { - 56 ¦ error-index:num <- get *env, error-index:offset - 57 ¦ sandboxes-completed-successfully?:bool <- equal error-index, -1 - 58 ¦ break-if sandboxes-completed-successfully? - 59 ¦ errors-found? <- copy 1/true - 60 } - 61 ] - 62 - 63 after <render-sandbox-errors-on-F4> [ - 64 { - 65 ¦ break-if recipe-errors - 66 ¦ error-index:num <- get *env, error-index:offset - 67 ¦ sandboxes-completed-successfully?:bool <- equal error-index, -1 - 68 ¦ break-if sandboxes-completed-successfully? - 69 ¦ error-index-text:text <- to-text error-index - 70 ¦ status:text <- interpolate [errors found (_) ], error-index-text - 71 ¦ update-status screen, status, 1/red + 54 container environment [ + 55 error-index:num # index of first sandbox with an error (or -1 if none) + 56 ] + 57 + 58 after <programming-environment-initialization> [ + 59 *result <- put *result, error-index:offset, -1 + 60 ] + 61 + 62 after <begin-run-sandboxes> [ + 63 *env <- put *env, error-index:offset, -1 + 64 ] + 65 + 66 before <end-run-sandboxes> [ + 67 { + 68 ¦ error-index:num <- get *env, error-index:offset + 69 ¦ sandboxes-completed-successfully?:bool <- equal error-index, -1 + 70 ¦ break-if sandboxes-completed-successfully? + 71 ¦ errors-found? <- copy 1/true 72 } 73 ] 74 - 75 container sandbox [ - 76 errors:text - 77 ] - 78 - 79 def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [ - 80 local-scope - 81 load-ingredients - 82 data:text <- get *sandbox, data:offset - 83 response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool <- run-sandboxed data - 84 *sandbox <- put *sandbox, response:offset, response - 85 *sandbox <- put *sandbox, errors:offset, errors - 86 *sandbox <- put *sandbox, screen:offset, fake-screen - 87 *sandbox <- put *sandbox, trace:offset, trace - 88 { - 89 ¦ break-if errors - 90 ¦ break-if completed? - 91 ¦ errors <- new [took too long! - 92 ] - 93 ¦ *sandbox <- put *sandbox, errors:offset, errors - 94 } - 95 { - 96 ¦ break-unless errors - 97 ¦ error-index:num <- get *env, error-index:offset - 98 ¦ error-not-set?:bool <- equal error-index, -1 - 99 ¦ break-unless error-not-set? -100 ¦ *env <- put *env, error-index:offset, idx -101 } -102 ] -103 -104 # make sure we render any trace -105 after <render-sandbox-trace-done> [ -106 { -107 ¦ sandbox-errors:text <- get *sandbox, errors:offset -108 ¦ break-unless sandbox-errors -109 ¦ *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 # no response -110 ¦ row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row -111 ¦ # don't try to print anything more for this sandbox -112 ¦ jump +render-sandbox-end -113 } -114 ] -115 -116 scenario run-shows-errors-in-get [ -117 local-scope -118 trace-until 100/app # trace too long -119 assume-screen 100/width, 15/height -120 assume-resources [ -121 ¦ [lesson/recipes.mu] <- [ -122 ¦ ¦ |recipe foo [| -123 ¦ ¦ | get 123:num, foo:offset| -124 ¦ ¦ |]| -125 ¦ ] -126 ] -127 env:&:environment <- new-programming-environment resources, screen, [foo] -128 render-all screen, env, render -129 screen-should-contain [ -130 ¦ . run (F4) . -131 ¦ .recipe foo [ ╎foo . -132 ¦ . get 123:num, foo:offset ╎─────────────────────────────────────────────────. -133 ¦ .] ╎ . -134 ¦ . ╎ . -135 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -136 ¦ . ╎ . -137 ] -138 assume-console [ -139 ¦ press F4 + 75 before <end-run-sandboxes-on-F4> [ + 76 { + 77 ¦ break-unless error? + 78 ¦ recipe-errors:text <- get *env, recipe-errors:offset + 79 ¦ break-if recipe-errors + 80 ¦ error-index:num <- get *env, error-index:offset + 81 ¦ sandboxes-completed-successfully?:bool <- equal error-index, -1 + 82 ¦ break-if sandboxes-completed-successfully? + 83 ¦ error-index-text:text <- to-text error-index + 84 ¦ status:text <- interpolate [errors found (_) ], error-index-text + 85 ¦ update-status screen, status, 1/red + 86 } + 87 ] + 88 + 89 container sandbox [ + 90 errors:text + 91 ] + 92 + 93 def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [ + 94 local-scope + 95 load-ingredients + 96 data:text <- get *sandbox, data:offset + 97 response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool <- run-sandboxed data + 98 *sandbox <- put *sandbox, response:offset, response + 99 *sandbox <- put *sandbox, errors:offset, errors +100 *sandbox <- put *sandbox, screen:offset, fake-screen +101 *sandbox <- put *sandbox, trace:offset, trace +102 { +103 ¦ break-if errors +104 ¦ break-if completed? +105 ¦ errors <- new [took too long! +106 ] +107 ¦ *sandbox <- put *sandbox, errors:offset, errors +108 } +109 { +110 ¦ break-unless errors +111 ¦ error-index:num <- get *env, error-index:offset +112 ¦ error-not-set?:bool <- equal error-index, -1 +113 ¦ break-unless error-not-set? +114 ¦ *env <- put *env, error-index:offset, idx +115 } +116 ] +117 +118 # make sure we render any trace +119 after <render-sandbox-trace-done> [ +120 { +121 ¦ sandbox-errors:text <- get *sandbox, errors:offset +122 ¦ break-unless sandbox-errors +123 ¦ *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 # no response +124 ¦ row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row +125 ¦ # don't try to print anything more for this sandbox +126 ¦ jump +render-sandbox-end +127 } +128 ] +129 +130 scenario run-shows-errors-in-get [ +131 local-scope +132 trace-until 100/app # trace too long +133 assume-screen 100/width, 15/height +134 assume-resources [ +135 ¦ [lesson/recipes.mu] <- [ +136 ¦ ¦ |recipe foo [| +137 ¦ ¦ | get 123:num, foo:offset| +138 ¦ ¦ |]| +139 ¦ ] 140 ] -141 run [ -142 ¦ event-loop screen, console, env, resources -143 ] -144 screen-should-contain [ -145 ¦ . errors found run (F4) . -146 ¦ .recipe foo [ ╎foo . -147 ¦ . get 123:num, foo:offset ╎─────────────────────────────────────────────────. -148 ¦ .] ╎ . -149 ¦ .foo: unknown element 'foo' in container 'number' ╎ . -150 ¦ .foo: first ingredient of 'get' should be a contai↩╎ . -151 ¦ .ner, but got '123:num' ╎ . -152 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -153 ¦ . ╎ . +141 env:&:environment <- new-programming-environment resources, screen, [foo] +142 render-all screen, env, render +143 screen-should-contain [ +144 ¦ . run (F4) . +145 ¦ .recipe foo [ ╎foo . +146 ¦ . get 123:num, foo:offset ╎─────────────────────────────────────────────────. +147 ¦ .] ╎ . +148 ¦ . ╎ . +149 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +150 ¦ . ╎ . +151 ] +152 assume-console [ +153 ¦ press F4 154 ] -155 screen-should-contain-in-color 1/red, [ -156 ¦ . errors found . -157 ¦ . . -158 ¦ . . -159 ¦ . . -160 ¦ .foo: unknown element 'foo' in container 'number' . -161 ¦ .foo: first ingredient of 'get' should be a contai . -162 ¦ .ner, but got '123:num' . -163 ¦ . . -164 ] -165 ] -166 -167 scenario run-updates-status-with-first-erroneous-sandbox [ -168 local-scope -169 trace-until 100/app # trace too long -170 assume-screen 100/width, 15/height -171 assume-resources [ -172 ] -173 env:&:environment <- new-programming-environment resources, screen, [] -174 render-all screen, env, render -175 assume-console [ -176 ¦ left-click 3, 80 -177 ¦ # create invalid sandbox 1 -178 ¦ type [get foo, x:offset] -179 ¦ press F4 -180 ¦ # create invalid sandbox 0 -181 ¦ type [get foo, x:offset] -182 ¦ press F4 -183 ] -184 run [ -185 ¦ event-loop screen, console, env, resources +155 run [ +156 ¦ event-loop screen, console, env, resources +157 ] +158 screen-should-contain [ +159 ¦ . errors found run (F4) . +160 ¦ .recipe foo [ ╎foo . +161 ¦ . get 123:num, foo:offset ╎─────────────────────────────────────────────────. +162 ¦ .] ╎ . +163 ¦ .foo: unknown element 'foo' in container 'number' ╎ . +164 ¦ .foo: first ingredient of 'get' should be a contai↩╎ . +165 ¦ .ner, but got '123:num' ╎ . +166 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +167 ¦ . ╎ . +168 ] +169 screen-should-contain-in-color 1/red, [ +170 ¦ . errors found . +171 ¦ . . +172 ¦ . . +173 ¦ . . +174 ¦ .foo: unknown element 'foo' in container 'number' . +175 ¦ .foo: first ingredient of 'get' should be a contai . +176 ¦ .ner, but got '123:num' . +177 ¦ . . +178 ] +179 ] +180 +181 scenario run-updates-status-with-first-erroneous-sandbox [ +182 local-scope +183 trace-until 100/app # trace too long +184 assume-screen 100/width, 15/height +185 assume-resources [ 186 ] -187 # status line shows that error is in first sandbox -188 screen-should-contain [ -189 ¦ . errors found (0) run (F4) . -190 ] -191 ] -192 -193 scenario run-updates-status-with-first-erroneous-sandbox-2 [ -194 local-scope -195 trace-until 100/app # trace too long -196 assume-screen 100/width, 15/height -197 assume-resources [ -198 ] -199 env:&:environment <- new-programming-environment resources, screen, [] -200 render-all screen, env, render -201 assume-console [ -202 ¦ left-click 3, 80 -203 ¦ # create invalid sandbox 2 -204 ¦ type [get foo, x:offset] -205 ¦ press F4 -206 ¦ # create invalid sandbox 1 -207 ¦ type [get foo, x:offset] -208 ¦ press F4 -209 ¦ # create valid sandbox 0 -210 ¦ type [add 2, 2] -211 ¦ press F4 +187 env:&:environment <- new-programming-environment resources, screen, [] +188 render-all screen, env, render +189 assume-console [ +190 ¦ left-click 3, 80 +191 ¦ # create invalid sandbox 1 +192 ¦ type [get foo, x:offset] +193 ¦ press F4 +194 ¦ # create invalid sandbox 0 +195 ¦ type [get foo, x:offset] +196 ¦ press F4 +197 ] +198 run [ +199 ¦ event-loop screen, console, env, resources +200 ] +201 # status line shows that error is in first sandbox +202 screen-should-contain [ +203 ¦ . errors found (0) run (F4) . +204 ] +205 ] +206 +207 scenario run-updates-status-with-first-erroneous-sandbox-2 [ +208 local-scope +209 trace-until 100/app # trace too long +210 assume-screen 100/width, 15/height +211 assume-resources [ 212 ] -213 run [ -214 ¦ event-loop screen, console, env, resources -215 ] -216 # status line shows that error is in second sandbox -217 screen-should-contain [ -218 ¦ . errors found (1) run (F4) . -219 ] -220 ] -221 -222 scenario run-hides-errors-from-past-sandboxes [ -223 local-scope -224 trace-until 100/app # trace too long -225 assume-screen 100/width, 15/height -226 assume-resources [ -227 ] -228 env:&:environment <- new-programming-environment resources, screen, [get foo, x:offset] # invalid -229 render-all screen, env, render -230 assume-console [ -231 ¦ press F4 # generate error -232 ] -233 event-loop screen, console, env, resources -234 assume-console [ -235 ¦ left-click 3, 58 -236 ¦ press ctrl-k -237 ¦ type [add 2, 2] # valid code -238 ¦ press F4 # update sandbox -239 ] -240 run [ -241 ¦ event-loop screen, console, env, resources -242 ] -243 # error should disappear -244 screen-should-contain [ -245 ¦ . run (F4) . -246 ¦ . ╎ . -247 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -248 ¦ . ╎0 edit copy to recipe delete . -249 ¦ . ╎add 2, 2 . -250 ¦ . ╎4 . -251 ¦ . ╎─────────────────────────────────────────────────. -252 ¦ . ╎ . +213 env:&:environment <- new-programming-environment resources, screen, [] +214 render-all screen, env, render +215 assume-console [ +216 ¦ left-click 3, 80 +217 ¦ # create invalid sandbox 2 +218 ¦ type [get foo, x:offset] +219 ¦ press F4 +220 ¦ # create invalid sandbox 1 +221 ¦ type [get foo, x:offset] +222 ¦ press F4 +223 ¦ # create valid sandbox 0 +224 ¦ type [add 2, 2] +225 ¦ press F4 +226 ] +227 run [ +228 ¦ event-loop screen, console, env, resources +229 ] +230 # status line shows that error is in second sandbox +231 screen-should-contain [ +232 ¦ . errors found (1) run (F4) . +233 ] +234 ] +235 +236 scenario run-hides-errors-from-past-sandboxes [ +237 local-scope +238 trace-until 100/app # trace too long +239 assume-screen 100/width, 15/height +240 assume-resources [ +241 ] +242 env:&:environment <- new-programming-environment resources, screen, [get foo, x:offset] # invalid +243 render-all screen, env, render +244 assume-console [ +245 ¦ press F4 # generate error +246 ] +247 event-loop screen, console, env, resources +248 assume-console [ +249 ¦ left-click 3, 58 +250 ¦ press ctrl-k +251 ¦ type [add 2, 2] # valid code +252 ¦ press F4 # update sandbox 253 ] -254 ] -255 -256 scenario run-updates-errors-for-shape-shifting-recipes [ -257 local-scope -258 trace-until 100/app # trace too long -259 assume-screen 100/width, 15/height -260 # define a shape-shifting recipe with an error -261 assume-resources [ -262 ¦ [lesson/recipes.mu] <- [ -263 ¦ ¦ |recipe foo x:_elem -> z:_elem [| -264 ¦ ¦ | local-scope| -265 ¦ ¦ | load-ingredients| -266 ¦ ¦ | y:&:num <- copy 0| -267 ¦ ¦ | z <- add x, y| -268 ¦ ¦ |]| -269 ¦ ] -270 ] -271 env:&:environment <- new-programming-environment resources, screen, [foo 2] -272 render-all screen, env, render -273 assume-console [ -274 ¦ press F4 -275 ] -276 event-loop screen, console, env, resources -277 screen-should-contain [ -278 ¦ . errors found (0) run (F4) . -279 ¦ .recipe foo x:_elem -> z:_elem [ ╎ . -280 ¦ . local-scope ╎─────────────────────────────────────────────────. -281 ¦ . load-ingredients ╎0 edit copy to recipe delete . -282 ¦ . y:&:num <- copy 0 ╎foo 2 . -283 ¦ . z <- add x, y ╎foo_2: 'add' requires number ingredients, but go↩. -284 ¦ .] ╎t 'y' . -285 ¦ . ╎─────────────────────────────────────────────────. -286 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -287 ¦ . ╎ . -288 ] -289 # now rerun everything -290 assume-console [ -291 ¦ press F4 -292 ] -293 run [ -294 ¦ event-loop screen, console, env, resources -295 ] -296 # error should remain unchanged -297 screen-should-contain [ -298 ¦ . errors found (0) run (F4) . -299 ¦ .recipe foo x:_elem -> z:_elem [ ╎ . -300 ¦ . local-scope ╎─────────────────────────────────────────────────. -301 ¦ . load-ingredients ╎0 edit copy to recipe delete . -302 ¦ . y:&:num <- copy 0 ╎foo 2 . -303 ¦ . z <- add x, y ╎foo_3: 'add' requires number ingredients, but go↩. -304 ¦ .] ╎t 'y' . -305 ¦ . ╎─────────────────────────────────────────────────. -306 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -307 ¦ . ╎ . -308 ] -309 ] -310 -311 scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [ -312 local-scope -313 trace-until 100/app # trace too long -314 assume-screen 100/width, 15/height -315 # overload a well-known shape-shifting recipe -316 assume-resources [ -317 ¦ [lesson/recipes.mu] <- [ -318 ¦ ¦ |recipe length l:&:list:_elem -> n:num [| -319 ¦ ¦ |]| -320 ¦ ] -321 ] -322 # call code that uses other variants of it, but not it itself -323 test-sandbox:text <- new [x:&:list:num <- copy 0 -324 to-text x] -325 env:&:environment <- new-programming-environment resources, screen, test-sandbox -326 render-all screen, env, render -327 # run it once -328 assume-console [ -329 ¦ press F4 -330 ] -331 event-loop screen, console, env, resources -332 # no errors anywhere on screen (can't check anything else, since to-text will return an address) -333 screen-should-contain-in-color 1/red, [ -334 ¦ . . -335 ¦ . . -336 ¦ . . -337 ¦ . . -338 ¦ . <- . -339 ¦ . . -340 ¦ . . -341 ¦ . . -342 ¦ . . -343 ¦ . . -344 ¦ . . -345 ¦ . . -346 ¦ . . -347 ¦ . . +254 run [ +255 ¦ event-loop screen, console, env, resources +256 ] +257 # error should disappear +258 screen-should-contain [ +259 ¦ . run (F4) . +260 ¦ . ╎ . +261 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +262 ¦ . ╎0 edit copy to recipe delete . +263 ¦ . ╎add 2, 2 . +264 ¦ . ╎4 . +265 ¦ . ╎─────────────────────────────────────────────────. +266 ¦ . ╎ . +267 ] +268 ] +269 +270 scenario run-updates-errors-for-shape-shifting-recipes [ +271 local-scope +272 trace-until 100/app # trace too long +273 assume-screen 100/width, 15/height +274 # define a shape-shifting recipe with an error +275 assume-resources [ +276 ¦ [lesson/recipes.mu] <- [ +277 ¦ ¦ |recipe foo x:_elem -> z:_elem [| +278 ¦ ¦ | local-scope| +279 ¦ ¦ | load-ingredients| +280 ¦ ¦ | y:&:num <- copy 0| +281 ¦ ¦ | z <- add x, y| +282 ¦ ¦ |]| +283 ¦ ] +284 ] +285 env:&:environment <- new-programming-environment resources, screen, [foo 2] +286 render-all screen, env, render +287 assume-console [ +288 ¦ press F4 +289 ] +290 event-loop screen, console, env, resources +291 screen-should-contain [ +292 ¦ . errors found (0) run (F4) . +293 ¦ .recipe foo x:_elem -> z:_elem [ ╎ . +294 ¦ . local-scope ╎─────────────────────────────────────────────────. +295 ¦ . load-ingredients ╎0 edit copy to recipe delete . +296 ¦ . y:&:num <- copy 0 ╎foo 2 . +297 ¦ . z <- add x, y ╎foo_2: 'add' requires number ingredients, but go↩. +298 ¦ .] ╎t 'y' . +299 ¦ . ╎─────────────────────────────────────────────────. +300 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +301 ¦ . ╎ . +302 ] +303 # now rerun everything +304 assume-console [ +305 ¦ press F4 +306 ] +307 run [ +308 ¦ event-loop screen, console, env, resources +309 ] +310 # error should remain unchanged +311 screen-should-contain [ +312 ¦ . errors found (0) run (F4) . +313 ¦ .recipe foo x:_elem -> z:_elem [ ╎ . +314 ¦ . local-scope ╎─────────────────────────────────────────────────. +315 ¦ . load-ingredients ╎0 edit copy to recipe delete . +316 ¦ . y:&:num <- copy 0 ╎foo 2 . +317 ¦ . z <- add x, y ╎foo_3: 'add' requires number ingredients, but go↩. +318 ¦ .] ╎t 'y' . +319 ¦ . ╎─────────────────────────────────────────────────. +320 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +321 ¦ . ╎ . +322 ] +323 ] +324 +325 scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [ +326 local-scope +327 trace-until 100/app # trace too long +328 assume-screen 100/width, 15/height +329 # overload a well-known shape-shifting recipe +330 assume-resources [ +331 ¦ [lesson/recipes.mu] <- [ +332 ¦ ¦ |recipe length l:&:list:_elem -> n:num [| +333 ¦ ¦ |]| +334 ¦ ] +335 ] +336 # call code that uses other variants of it, but not it itself +337 test-sandbox:text <- new [x:&:list:num <- copy 0 +338 to-text x] +339 env:&:environment <- new-programming-environment resources, screen, test-sandbox +340 render-all screen, env, render +341 # run it once +342 assume-console [ +343 ¦ press F4 +344 ] +345 event-loop screen, console, env, resources +346 # no errors anywhere on screen (can't check anything else, since to-text will return an address) +347 screen-should-contain-in-color 1/red, [ 348 ¦ . . -349 ] -350 # rerun everything -351 assume-console [ -352 ¦ press F4 -353 ] -354 run [ -355 ¦ event-loop screen, console, env, resources -356 ] -357 # still no errors -358 screen-should-contain-in-color 1/red, [ +349 ¦ . . +350 ¦ . . +351 ¦ . . +352 ¦ . <- . +353 ¦ . . +354 ¦ . . +355 ¦ . . +356 ¦ . . +357 ¦ . . +358 ¦ . . 359 ¦ . . 360 ¦ . . 361 ¦ . . 362 ¦ . . -363 ¦ . <- . -364 ¦ . . -365 ¦ . . -366 ¦ . . -367 ¦ . . -368 ¦ . . -369 ¦ . . -370 ¦ . . -371 ¦ . . -372 ¦ . . +363 ] +364 # rerun everything +365 assume-console [ +366 ¦ press F4 +367 ] +368 run [ +369 ¦ event-loop screen, console, env, resources +370 ] +371 # still no errors +372 screen-should-contain-in-color 1/red, [ 373 ¦ . . -374 ] -375 ] -376 -377 scenario run-shows-missing-type-errors [ -378 local-scope -379 trace-until 100/app # trace too long -380 assume-screen 100/width, 15/height -381 assume-resources [ -382 ¦ [lesson/recipes.mu] <- [ -383 ¦ ¦ |recipe foo [| -384 ¦ ¦ | x <- copy 0| -385 ¦ ¦ |]| -386 ¦ ] -387 ] -388 env:&:environment <- new-programming-environment resources, screen, [foo] -389 render-all screen, env, render -390 assume-console [ -391 ¦ press F4 -392 ] -393 run [ -394 ¦ event-loop screen, console, env, resources -395 ] -396 screen-should-contain [ -397 ¦ . errors found run (F4) . -398 ¦ .recipe foo [ ╎foo . -399 ¦ . x <- copy 0 ╎─────────────────────────────────────────────────. -400 ¦ .] ╎ . -401 ¦ .foo: missing type for 'x' in 'x <- copy 0' ╎ . -402 ¦ .foo: can't copy '0' to 'x'; types don't match ╎ . -403 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -404 ¦ . ╎ . -405 ] -406 ] -407 -408 scenario run-shows-unbalanced-bracket-errors [ -409 local-scope -410 trace-until 100/app # trace too long -411 assume-screen 100/width, 15/height -412 # recipe is incomplete (unbalanced '[') -413 assume-resources [ -414 ¦ [lesson/recipes.mu] <- [ -415 ¦ ¦ |recipe foo \\\[| -416 ¦ ¦ | x <- copy 0| -417 ¦ ] -418 ] -419 env:&:environment <- new-programming-environment resources, screen, [foo] -420 render-all screen, env, render -421 assume-console [ -422 ¦ press F4 -423 ] -424 run [ -425 ¦ event-loop screen, console, env, resources -426 ] -427 screen-should-contain [ -428 ¦ . errors found run (F4) . -429 ¦ .recipe foo \\[ ╎foo . -430 ¦ . x <- copy 0 ╎─────────────────────────────────────────────────. -431 ¦ .9: unbalanced '\\[' for recipe ╎ . -432 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -433 ¦ . ╎ . -434 ] -435 ] -436 -437 scenario run-shows-get-on-non-container-errors [ -438 local-scope -439 trace-until 100/app # trace too long -440 assume-screen 100/width, 15/height -441 assume-resources [ -442 ¦ [lesson/recipes.mu] <- [ -443 ¦ ¦ |recipe foo [| -444 ¦ ¦ | local-scope| -445 ¦ ¦ | x:&:point <- new point:type| -446 ¦ ¦ | get x:&:point, 1:offset| -447 ¦ ¦ |]| -448 ¦ ] -449 ] -450 env:&:environment <- new-programming-environment resources, screen, [foo] -451 render-all screen, env, render -452 assume-console [ -453 ¦ press F4 -454 ] -455 run [ -456 ¦ event-loop screen, console, env, resources -457 ] -458 screen-should-contain [ -459 ¦ . errors found run (F4) . -460 ¦ .recipe foo [ ╎foo . -461 ¦ . local-scope ╎─────────────────────────────────────────────────. -462 ¦ . x:&:point <- new point:type ╎ . -463 ¦ . get x:&:point, 1:offset ╎ . -464 ¦ .] ╎ . -465 ¦ .foo: first ingredient of 'get' should be a contai↩╎ . -466 ¦ .ner, but got 'x:&:point' ╎ . -467 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -468 ¦ . ╎ . -469 ] -470 ] -471 -472 scenario run-shows-non-literal-get-argument-errors [ -473 local-scope -474 trace-until 100/app # trace too long -475 assume-screen 100/width, 15/height -476 assume-resources [ -477 ¦ [lesson/recipes.mu] <- [ -478 ¦ ¦ |recipe foo [| -479 ¦ ¦ | local-scope| -480 ¦ ¦ | x:num <- copy 0| -481 ¦ ¦ | y:&:point <- new point:type| -482 ¦ ¦ | get *y:&:point, x:num| -483 ¦ ¦ |]| -484 ¦ ] -485 ] -486 env:&:environment <- new-programming-environment resources, screen, [foo] -487 render-all screen, env, render -488 assume-console [ -489 ¦ press F4 -490 ] -491 run [ -492 ¦ event-loop screen, console, env, resources -493 ] -494 screen-should-contain [ -495 ¦ . errors found run (F4) . -496 ¦ .recipe foo [ ╎foo . -497 ¦ . local-scope ╎─────────────────────────────────────────────────. -498 ¦ . x:num <- copy 0 ╎ . -499 ¦ . y:&:point <- new point:type ╎ . -500 ¦ . get *y:&:point, x:num ╎ . -501 ¦ .] ╎ . -502 ¦ .foo: second ingredient of 'get' should have type ↩╎ . -503 ¦ .'offset', but got 'x:num' ╎ . -504 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -505 ¦ . ╎ . -506 ] -507 ] -508 -509 scenario run-shows-errors-everytime [ -510 local-scope -511 trace-until 100/app # trace too long -512 assume-screen 100/width, 15/height -513 # try to run a file with an error -514 assume-resources [ -515 ¦ [lesson/recipes.mu] <- [ -516 ¦ ¦ |recipe foo [| -517 ¦ ¦ | local-scope| -518 ¦ ¦ | x:num <- copy y:num| -519 ¦ ¦ |]| -520 ¦ ] -521 ] -522 env:&:environment <- new-programming-environment resources, screen, [foo] -523 render-all screen, env, render -524 assume-console [ -525 ¦ press F4 -526 ] -527 event-loop screen, console, env, resources -528 screen-should-contain [ -529 ¦ . errors found run (F4) . -530 ¦ .recipe foo [ ╎foo . -531 ¦ . local-scope ╎─────────────────────────────────────────────────. -532 ¦ . x:num <- copy y:num ╎ . -533 ¦ .] ╎ . -534 ¦ .foo: tried to read ingredient 'y' in 'x:num <- co↩╎ . -535 ¦ .py y:num' but it hasn't been written to yet ╎ . -536 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -537 ¦ . ╎ . -538 ] -539 # rerun the file, check for the same error -540 assume-console [ -541 ¦ press F4 -542 ] -543 run [ -544 ¦ event-loop screen, console, env, resources -545 ] -546 screen-should-contain [ -547 ¦ . errors found run (F4) . -548 ¦ .recipe foo [ ╎foo . -549 ¦ . local-scope ╎─────────────────────────────────────────────────. -550 ¦ . x:num <- copy y:num ╎ . -551 ¦ .] ╎ . -552 ¦ .foo: tried to read ingredient 'y' in 'x:num <- co↩╎ . -553 ¦ .py y:num' but it hasn't been written to yet ╎ . -554 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -555 ¦ . ╎ . +374 ¦ . . +375 ¦ . . +376 ¦ . . +377 ¦ . <- . +378 ¦ . . +379 ¦ . . +380 ¦ . . +381 ¦ . . +382 ¦ . . +383 ¦ . . +384 ¦ . . +385 ¦ . . +386 ¦ . . +387 ¦ . . +388 ] +389 ] +390 +391 scenario run-shows-missing-type-errors [ +392 local-scope +393 trace-until 100/app # trace too long +394 assume-screen 100/width, 15/height +395 assume-resources [ +396 ¦ [lesson/recipes.mu] <- [ +397 ¦ ¦ |recipe foo [| +398 ¦ ¦ | x <- copy 0| +399 ¦ ¦ |]| +400 ¦ ] +401 ] +402 env:&:environment <- new-programming-environment resources, screen, [foo] +403 render-all screen, env, render +404 assume-console [ +405 ¦ press F4 +406 ] +407 run [ +408 ¦ event-loop screen, console, env, resources +409 ] +410 screen-should-contain [ +411 ¦ . errors found run (F4) . +412 ¦ .recipe foo [ ╎foo . +413 ¦ . x <- copy 0 ╎─────────────────────────────────────────────────. +414 ¦ .] ╎ . +415 ¦ .foo: missing type for 'x' in 'x <- copy 0' ╎ . +416 ¦ .foo: can't copy '0' to 'x'; types don't match ╎ . +417 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +418 ¦ . ╎ . +419 ] +420 ] +421 +422 scenario run-shows-unbalanced-bracket-errors [ +423 local-scope +424 trace-until 100/app # trace too long +425 assume-screen 100/width, 15/height +426 # recipe is incomplete (unbalanced '[') +427 assume-resources [ +428 ¦ [lesson/recipes.mu] <- [ +429 ¦ ¦ |recipe foo \\\[| +430 ¦ ¦ | x <- copy 0| +431 ¦ ] +432 ] +433 env:&:environment <- new-programming-environment resources, screen, [foo] +434 render-all screen, env, render +435 assume-console [ +436 ¦ press F4 +437 ] +438 run [ +439 ¦ event-loop screen, console, env, resources +440 ] +441 screen-should-contain [ +442 ¦ . errors found run (F4) . +443 ¦ .recipe foo \\[ ╎foo . +444 ¦ . x <- copy 0 ╎─────────────────────────────────────────────────. +445 ¦ .9: unbalanced '\\[' for recipe ╎ . +446 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +447 ¦ . ╎ . +448 ] +449 ] +450 +451 scenario run-shows-get-on-non-container-errors [ +452 local-scope +453 trace-until 100/app # trace too long +454 assume-screen 100/width, 15/height +455 assume-resources [ +456 ¦ [lesson/recipes.mu] <- [ +457 ¦ ¦ |recipe foo [| +458 ¦ ¦ | local-scope| +459 ¦ ¦ | x:&:point <- new point:type| +460 ¦ ¦ | get x:&:point, 1:offset| +461 ¦ ¦ |]| +462 ¦ ] +463 ] +464 env:&:environment <- new-programming-environment resources, screen, [foo] +465 render-all screen, env, render +466 assume-console [ +467 ¦ press F4 +468 ] +469 run [ +470 ¦ event-loop screen, console, env, resources +471 ] +472 screen-should-contain [ +473 ¦ . errors found run (F4) . +474 ¦ .recipe foo [ ╎foo . +475 ¦ . local-scope ╎─────────────────────────────────────────────────. +476 ¦ . x:&:point <- new point:type ╎ . +477 ¦ . get x:&:point, 1:offset ╎ . +478 ¦ .] ╎ . +479 ¦ .foo: first ingredient of 'get' should be a contai↩╎ . +480 ¦ .ner, but got 'x:&:point' ╎ . +481 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +482 ¦ . ╎ . +483 ] +484 ] +485 +486 scenario run-shows-non-literal-get-argument-errors [ +487 local-scope +488 trace-until 100/app # trace too long +489 assume-screen 100/width, 15/height +490 assume-resources [ +491 ¦ [lesson/recipes.mu] <- [ +492 ¦ ¦ |recipe foo [| +493 ¦ ¦ | local-scope| +494 ¦ ¦ | x:num <- copy 0| +495 ¦ ¦ | y:&:point <- new point:type| +496 ¦ ¦ | get *y:&:point, x:num| +497 ¦ ¦ |]| +498 ¦ ] +499 ] +500 env:&:environment <- new-programming-environment resources, screen, [foo] +501 render-all screen, env, render +502 assume-console [ +503 ¦ press F4 +504 ] +505 run [ +506 ¦ event-loop screen, console, env, resources +507 ] +508 screen-should-contain [ +509 ¦ . errors found run (F4) . +510 ¦ .recipe foo [ ╎foo . +511 ¦ . local-scope ╎─────────────────────────────────────────────────. +512 ¦ . x:num <- copy 0 ╎ . +513 ¦ . y:&:point <- new point:type ╎ . +514 ¦ . get *y:&:point, x:num ╎ . +515 ¦ .] ╎ . +516 ¦ .foo: second ingredient of 'get' should have type ↩╎ . +517 ¦ .'offset', but got 'x:num' ╎ . +518 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +519 ¦ . ╎ . +520 ] +521 ] +522 +523 scenario run-shows-errors-every-time [ +524 local-scope +525 trace-until 100/app # trace too long +526 assume-screen 100/width, 15/height +527 # try to run a file with an error +528 assume-resources [ +529 ¦ [lesson/recipes.mu] <- [ +530 ¦ ¦ |recipe foo [| +531 ¦ ¦ | local-scope| +532 ¦ ¦ | x:num <- copy y:num| +533 ¦ ¦ |]| +534 ¦ ] +535 ] +536 env:&:environment <- new-programming-environment resources, screen, [foo] +537 render-all screen, env, render +538 assume-console [ +539 ¦ press F4 +540 ] +541 event-loop screen, console, env, resources +542 screen-should-contain [ +543 ¦ . errors found run (F4) . +544 ¦ .recipe foo [ ╎foo . +545 ¦ . local-scope ╎─────────────────────────────────────────────────. +546 ¦ . x:num <- copy y:num ╎ . +547 ¦ .] ╎ . +548 ¦ .foo: tried to read ingredient 'y' in 'x:num <- co↩╎ . +549 ¦ .py y:num' but it hasn't been written to yet ╎ . +550 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +551 ¦ . ╎ . +552 ] +553 # rerun the file, check for the same error +554 assume-console [ +555 ¦ press F4 556 ] -557 ] -558 -559 scenario run-instruction-and-print-errors [ -560 local-scope -561 trace-until 100/app # trace too long -562 assume-screen 100/width, 10/height -563 assume-resources [ -564 ] -565 # sandbox editor contains an illegal instruction -566 env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset] -567 render-all screen, env, render -568 assume-console [ -569 ¦ press F4 +557 run [ +558 ¦ event-loop screen, console, env, resources +559 ] +560 screen-should-contain [ +561 ¦ . errors found run (F4) . +562 ¦ .recipe foo [ ╎foo . +563 ¦ . local-scope ╎─────────────────────────────────────────────────. +564 ¦ . x:num <- copy y:num ╎ . +565 ¦ .] ╎ . +566 ¦ .foo: tried to read ingredient 'y' in 'x:num <- co↩╎ . +567 ¦ .py y:num' but it hasn't been written to yet ╎ . +568 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +569 ¦ . ╎ . 570 ] -571 run [ -572 ¦ event-loop screen, console, env, resources -573 ] -574 # check that screen prints error message in red -575 screen-should-contain [ -576 ¦ . errors found (0) run (F4) . -577 ¦ . ╎ . -578 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -579 ¦ . ╎0 edit copy to recipe delete . -580 ¦ . ╎get 1234:num, foo:offset . -581 ¦ . ╎unknown element 'foo' in container 'number' . -582 ¦ . ╎first ingredient of 'get' should be a container,↩. -583 ¦ . ╎ but got '1234:num' . -584 ¦ . ╎─────────────────────────────────────────────────. -585 ¦ . ╎ . -586 ] -587 screen-should-contain-in-color 7/white, [ -588 ¦ . . -589 ¦ . . -590 ¦ . . -591 ¦ . . -592 ¦ . get 1234:num, foo:offset . -593 ¦ . . -594 ¦ . . -595 ¦ . . -596 ] -597 screen-should-contain-in-color 1/red, [ -598 ¦ . errors found (0) . -599 ¦ . . -600 ¦ . . -601 ¦ . . -602 ¦ . . -603 ¦ . unknown element 'foo' in container 'number' . -604 ¦ . first ingredient of 'get' should be a container, . -605 ¦ . but got '1234:num' . -606 ¦ . . -607 ] -608 screen-should-contain-in-color 245/grey, [ -609 ¦ . . -610 ¦ . ╎ . -611 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -612 ¦ . ╎ . -613 ¦ . ╎ . -614 ¦ . ╎ . -615 ¦ . ╎ ↩. -616 ¦ . ╎ . -617 ¦ . ╎─────────────────────────────────────────────────. -618 ¦ . ╎ . -619 ] -620 ] -621 -622 scenario run-instruction-and-print-errors-only-once [ -623 local-scope -624 trace-until 100/app # trace too long -625 assume-screen 100/width, 10/height -626 assume-resources [ -627 ] -628 # sandbox editor contains an illegal instruction -629 env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset] -630 render-all screen, env, render -631 # run the code in the editors multiple times -632 assume-console [ -633 ¦ press F4 +571 ] +572 +573 scenario run-hides-errors [ +574 local-scope +575 trace-until 100/app # trace too long +576 assume-screen 100/width, 15/height +577 # try to run a file with an error +578 assume-resources [ +579 ¦ [lesson/recipes.mu] <- [ +580 ¦ ¦ |recipe foo [| +581 ¦ ¦ | local-scope| +582 ¦ ¦ | x:num <- copy y:num| +583 ¦ ¦ |]| +584 ¦ ] +585 ] +586 env:&:environment <- new-programming-environment resources, screen, [foo] +587 render-all screen, env, render +588 assume-console [ +589 ¦ press F4 +590 ] +591 event-loop screen, console, env, resources +592 screen-should-contain [ +593 ¦ . errors found run (F4) . +594 ¦ .recipe foo [ ╎foo . +595 ¦ . local-scope ╎─────────────────────────────────────────────────. +596 ¦ . x:num <- copy y:num ╎ . +597 ¦ .] ╎ . +598 ¦ .foo: tried to read ingredient 'y' in 'x:num <- co↩╎ . +599 ¦ .py y:num' but it hasn't been written to yet ╎ . +600 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +601 ¦ . ╎ . +602 ] +603 # fix the error, hit F4 +604 assume-console [ +605 ¦ left-click 3, 16 +606 ¦ press ctrl-k +607 ¦ type [0] +608 ¦ press F4 +609 ] +610 event-loop screen, console, env, resources +611 # no error anymore +612 screen-should-contain [ +613 ¦ . run (F4) . +614 ¦ .recipe foo [ ╎ . +615 ¦ . local-scope ╎─────────────────────────────────────────────────. +616 ¦ . x:num <- copy 0 ╎0 edit copy to recipe delete . +617 ¦ .] ╎foo . +618 ¦ . ╎─────────────────────────────────────────────────. +619 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +620 ¦ . ╎ . +621 ] +622 ] +623 +624 scenario run-instruction-and-print-errors [ +625 local-scope +626 trace-until 100/app # trace too long +627 assume-screen 100/width, 10/height +628 assume-resources [ +629 ] +630 # sandbox editor contains an illegal instruction +631 env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset] +632 render-all screen, env, render +633 assume-console [ 634 ¦ press F4 635 ] 636 run [ 637 ¦ event-loop screen, console, env, resources 638 ] -639 # check that screen prints error message just once +639 # check that screen prints error message in red 640 screen-should-contain [ 641 ¦ . errors found (0) run (F4) . 642 ¦ . ╎ . @@ -712,102 +712,167 @@ if ('onhashchange' in window) { 649 ¦ . ╎─────────────────────────────────────────────────. 650 ¦ . ╎ . 651 ] -652 ] -653 -654 scenario sandbox-can-handle-infinite-loop [ -655 local-scope -656 trace-until 100/app # trace too long -657 assume-screen 100/width, 20/height -658 # sandbox editor will trigger an infinite loop -659 assume-resources [ -660 ¦ [lesson/recipes.mu] <- [ -661 ¦ ¦ |recipe foo [| -662 ¦ ¦ | {| -663 ¦ ¦ | loop| -664 ¦ ¦ | }| -665 ¦ ¦ |]| -666 ¦ ] -667 ] -668 env:&:environment <- new-programming-environment resources, screen, [foo] -669 render-all screen, env, render -670 # run the sandbox -671 assume-console [ -672 ¦ press F4 -673 ] -674 run [ -675 ¦ event-loop screen, console, env, resources -676 ] -677 screen-should-contain [ -678 ¦ . errors found (0) run (F4) . -679 ¦ .recipe foo [ ╎ . -680 ¦ . { ╎─────────────────────────────────────────────────. -681 ¦ . loop ╎0 edit copy to recipe delete . -682 ¦ . } ╎foo . -683 ¦ .] ╎took too long! . -684 ¦ . ╎─────────────────────────────────────────────────. -685 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . -686 ¦ . ╎ . -687 ] -688 ] -689 -690 scenario sandbox-with-errors-shows-trace [ -691 local-scope -692 trace-until 100/app # trace too long -693 assume-screen 100/width, 10/height -694 # generate a stash and a error -695 assume-resources [ -696 ¦ [lesson/recipes.mu] <- [ -697 ¦ ¦ |recipe foo [| -698 ¦ ¦ | local-scope| -699 ¦ ¦ | a:num <- next-ingredient| -700 ¦ ¦ | b:num <- next-ingredient| -701 ¦ ¦ | stash [dividing by], b| -702 ¦ ¦ | _, c:num <- divide-with-remainder a, b| -703 ¦ ¦ | reply b| -704 ¦ ¦ |]| -705 ¦ ] -706 ] -707 env:&:environment <- new-programming-environment resources, screen, [foo 4, 0] -708 render-all screen, env, render -709 # run -710 assume-console [ -711 ¦ press F4 -712 ] -713 event-loop screen, console, env, resources -714 # screen prints error message -715 screen-should-contain [ -716 ¦ . errors found (0) run (F4) . -717 ¦ .recipe foo [ ╎ . -718 ¦ . local-scope ╎─────────────────────────────────────────────────. -719 ¦ . a:num <- next-ingredient ╎0 edit copy to recipe delete . -720 ¦ . b:num <- next-ingredient ╎foo 4, 0 . -721 ¦ . stash [dividing by], b ╎foo: divide by zero in '_, c:num <- divide-with-↩. -722 ¦ . _, c:num <- divide-with-remainder a, b ╎remainder a, b' . -723 ¦ . reply b ╎─────────────────────────────────────────────────. -724 ¦ .] ╎ . -725 ¦ . ╎ . -726 ] -727 # click on the call in the sandbox -728 assume-console [ -729 ¦ left-click 4, 55 -730 ] -731 run [ -732 ¦ event-loop screen, console, env, resources -733 ] -734 # screen should expand trace -735 screen-should-contain [ -736 ¦ . errors found (0) run (F4) . -737 ¦ .recipe foo [ ╎ . -738 ¦ . local-scope ╎─────────────────────────────────────────────────. -739 ¦ . a:num <- next-ingredient ╎0 edit copy to recipe delete . -740 ¦ . b:num <- next-ingredient ╎foo 4, 0 . -741 ¦ . stash [dividing by], b ╎dividing by 0 . -742 ¦ . _, c:num <- divide-with-remainder a, b ╎14 instructions run . -743 ¦ . reply b ╎foo: divide by zero in '_, c:num <- divide-with-↩. -744 ¦ .] ╎remainder a, b' . -745 ¦ . ╎─────────────────────────────────────────────────. -746 ] -747 ] +652 screen-should-contain-in-color 7/white, [ +653 ¦ . . +654 ¦ . . +655 ¦ . . +656 ¦ . . +657 ¦ . get 1234:num, foo:offset . +658 ¦ . . +659 ¦ . . +660 ¦ . . +661 ] +662 screen-should-contain-in-color 1/red, [ +663 ¦ . errors found (0) . +664 ¦ . . +665 ¦ . . +666 ¦ . . +667 ¦ . . +668 ¦ . unknown element 'foo' in container 'number' . +669 ¦ . first ingredient of 'get' should be a container, . +670 ¦ . but got '1234:num' . +671 ¦ . . +672 ] +673 screen-should-contain-in-color 245/grey, [ +674 ¦ . . +675 ¦ . ╎ . +676 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +677 ¦ . ╎ . +678 ¦ . ╎ . +679 ¦ . ╎ . +680 ¦ . ╎ ↩. +681 ¦ . ╎ . +682 ¦ . ╎─────────────────────────────────────────────────. +683 ¦ . ╎ . +684 ] +685 ] +686 +687 scenario run-instruction-and-print-errors-only-once [ +688 local-scope +689 trace-until 100/app # trace too long +690 assume-screen 100/width, 10/height +691 assume-resources [ +692 ] +693 # sandbox editor contains an illegal instruction +694 env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset] +695 render-all screen, env, render +696 # run the code in the editors multiple times +697 assume-console [ +698 ¦ press F4 +699 ¦ press F4 +700 ] +701 run [ +702 ¦ event-loop screen, console, env, resources +703 ] +704 # check that screen prints error message just once +705 screen-should-contain [ +706 ¦ . errors found (0) run (F4) . +707 ¦ . ╎ . +708 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +709 ¦ . ╎0 edit copy to recipe delete . +710 ¦ . ╎get 1234:num, foo:offset . +711 ¦ . ╎unknown element 'foo' in container 'number' . +712 ¦ . ╎first ingredient of 'get' should be a container,↩. +713 ¦ . ╎ but got '1234:num' . +714 ¦ . ╎─────────────────────────────────────────────────. +715 ¦ . ╎ . +716 ] +717 ] +718 +719 scenario sandbox-can-handle-infinite-loop [ +720 local-scope +721 trace-until 100/app # trace too long +722 assume-screen 100/width, 20/height +723 # sandbox editor will trigger an infinite loop +724 assume-resources [ +725 ¦ [lesson/recipes.mu] <- [ +726 ¦ ¦ |recipe foo [| +727 ¦ ¦ | {| +728 ¦ ¦ | loop| +729 ¦ ¦ | }| +730 ¦ ¦ |]| +731 ¦ ] +732 ] +733 env:&:environment <- new-programming-environment resources, screen, [foo] +734 render-all screen, env, render +735 # run the sandbox +736 assume-console [ +737 ¦ press F4 +738 ] +739 run [ +740 ¦ event-loop screen, console, env, resources +741 ] +742 screen-should-contain [ +743 ¦ . errors found (0) run (F4) . +744 ¦ .recipe foo [ ╎ . +745 ¦ . { ╎─────────────────────────────────────────────────. +746 ¦ . loop ╎0 edit copy to recipe delete . +747 ¦ . } ╎foo . +748 ¦ .] ╎took too long! . +749 ¦ . ╎─────────────────────────────────────────────────. +750 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . +751 ¦ . ╎ . +752 ] +753 ] +754 +755 scenario sandbox-with-errors-shows-trace [ +756 local-scope +757 trace-until 100/app # trace too long +758 assume-screen 100/width, 10/height +759 # generate a stash and a error +760 assume-resources [ +761 ¦ [lesson/recipes.mu] <- [ +762 ¦ ¦ |recipe foo [| +763 ¦ ¦ | local-scope| +764 ¦ ¦ | a:num <- next-ingredient| +765 ¦ ¦ | b:num <- next-ingredient| +766 ¦ ¦ | stash [dividing by], b| +767 ¦ ¦ | _, c:num <- divide-with-remainder a, b| +768 ¦ ¦ | reply b| +769 ¦ ¦ |]| +770 ¦ ] +771 ] +772 env:&:environment <- new-programming-environment resources, screen, [foo 4, 0] +773 render-all screen, env, render +774 # run +775 assume-console [ +776 ¦ press F4 +777 ] +778 event-loop screen, console, env, resources +779 # screen prints error message +780 screen-should-contain [ +781 ¦ . errors found (0) run (F4) . +782 ¦ .recipe foo [ ╎ . +783 ¦ . local-scope ╎─────────────────────────────────────────────────. +784 ¦ . a:num <- next-ingredient ╎0 edit copy to recipe delete . +785 ¦ . b:num <- next-ingredient ╎foo 4, 0 . +786 ¦ . stash [dividing by], b ╎foo: divide by zero in '_, c:num <- divide-with-↩. +787 ¦ . _, c:num <- divide-with-remainder a, b ╎remainder a, b' . +788 ¦ . reply b ╎─────────────────────────────────────────────────. +789 ¦ .] ╎ . +790 ¦ . ╎ . +791 ] +792 # click on the call in the sandbox +793 assume-console [ +794 ¦ left-click 4, 55 +795 ] +796 run [ +797 ¦ event-loop screen, console, env, resources +798 ] +799 # screen should expand trace +800 screen-should-contain [ +801 ¦ . errors found (0) run (F4) . +802 ¦ .recipe foo [ ╎ . +803 ¦ . local-scope ╎─────────────────────────────────────────────────. +804 ¦ . a:num <- next-ingredient ╎0 edit copy to recipe delete . +805 ¦ . b:num <- next-ingredient ╎foo 4, 0 . +806 ¦ . stash [dividing by], b ╎dividing by 0 . +807 ¦ . _, c:num <- divide-with-remainder a, b ╎14 instructions run . +808 ¦ . reply b ╎foo: divide by zero in '_, c:num <- divide-with-↩. +809 ¦ .] ╎remainder a, b' . +810 ¦ . ╎─────────────────────────────────────────────────. +811 ] +812 ] -- cgit 1.4.1-2-gfad0