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