about summary refs log tree commit diff stats
path: root/sandbox/008-sandbox-test.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-27 15:27:29 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-27 15:27:29 -0800
commit95425355a01edf284a86d0873e63d88071221ed8 (patch)
treeac293fa0a23a3e51c17faef4de2ebdf36fced6f0 /sandbox/008-sandbox-test.mu
parent5516dd288d705fed42f2c099471b19a76481b18a (diff)
downloadmu-95425355a01edf284a86d0873e63d88071221ed8.tar.gz
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.
Diffstat (limited to 'sandbox/008-sandbox-test.mu')
-rw-r--r--sandbox/008-sandbox-test.mu81
1 files changed, 80 insertions, 1 deletions
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 <global-touch> [