From 95425355a01edf284a86d0873e63d88071221ed8 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 27 Jan 2016 15:27:29 -0800 Subject: 2608 - fix-up tests in sandbox/ app When I first forked it from the edit/ app, I wasn't sure how to deal with changing the recipe side when the only way the program accesses it is with the untestable 'restore' hack. Now we introduce a little hook into event-loop and pass in any updated recipe side directly. In the process I've cleaned up several minor stylistic inconsistencies between edit/ and sandbox/ apps. --- sandbox/008-sandbox-test.mu | 81 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) (limited to 'sandbox/008-sandbox-test.mu') diff --git a/sandbox/008-sandbox-test.mu b/sandbox/008-sandbox-test.mu index 4e6b2896..a7344ba4 100644 --- a/sandbox/008-sandbox-test.mu +++ b/sandbox/008-sandbox-test.mu @@ -1,6 +1,85 @@ ## clicking on sandbox results to 'fix' them and turn sandboxes into tests -# todo: perform test from edit/ by faking file system +scenario sandbox-click-on-result-toggles-color-to-green [ + trace-until 100/app # trace too long + assume-screen 50/width, 20/height + # basic recipe + 1:address:shared:array:character <- new [ +recipe foo [ + reply 4 +]] + # run it + 2:address:shared:array:character <- new [foo] + assume-console [ + press F4 + ] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 2:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data, 1:address:shared:array:character/test-recipes + screen-should-contain [ + . run (F4) . + . . + .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .0 x. + .foo . + .4 . + .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . . + ] + # click on the '4' in the result + assume-console [ + left-click 5, 21 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data, 1:address:shared:array:character/test-recipes + ] + # color toggles to green + screen-should-contain-in-color 2/green, [ + . . + . . + . . + . . + . . + .4 . + . . + ] + # cursor should remain unmoved + run [ + 4:character/cursor <- copy 9251/␣ + print screen:address:shared:screen, 4:character/cursor + ] + screen-should-contain [ + . run (F4) . + .␣ . + .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .0 x. + .foo . + .4 . + .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . . + ] + # now change the result + 5:address:shared:array:character <- new [ +recipe foo [ + reply 3 +]] + # then rerun + assume-console [ + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data, 5:address:shared:array:character/new-test-recipes + ] + # result turns red + screen-should-contain-in-color 1/red, [ + . . + . . + . . + . . + . . + .3 . + . . + ] +] # clicks on sandbox responses save it as 'expected' after [ -- cgit 1.4.1-2-gfad0