about summary refs log tree commit diff stats
path: root/edit/009-warnings.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-05 11:50:49 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-05 11:51:10 -0700
commita90faae99043042ec5e2d0de21b7dbe0eba29e3a (patch)
tree2138b6fe60aaf3d3bc47ae05fb955a78135b6eaa /edit/009-warnings.mu
parent9f78ec2d5e2a74ec24cc20cd3b1d60c3bdb9d605 (diff)
downloadmu-a90faae99043042ec5e2d0de21b7dbe0eba29e3a.tar.gz
2156 - split edit.mu into multiple files
Now you can bring up the programming environment by saying:

  $ mu edit

The files under edit aren't yet *layers*, though, they have a few
dependencies that we need to clean up.
Diffstat (limited to 'edit/009-warnings.mu')
-rw-r--r--edit/009-warnings.mu199
1 files changed, 199 insertions, 0 deletions
diff --git a/edit/009-warnings.mu b/edit/009-warnings.mu
new file mode 100644
index 00000000..b20d930b
--- /dev/null
+++ b/edit/009-warnings.mu
@@ -0,0 +1,199 @@
+## handling malformed programs
+
+scenario run-shows-warnings-in-get [
+  $close-trace  # trace too long
+  assume-screen 100/width, 15/height
+  1:address:array:character <- new [ 
+recipe foo [
+  get 123:number, foo:offset
+]]
+  2:address:array:character <- new [foo]
+  3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
+  assume-console [
+    press F4
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .  errors found                                                                   run (F4)           .
+    .                                                  ┊foo                                              .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  get 123:number, foo:offset                      ┊                                                 .
+    .]                                                 ┊                                                 .
+    .unknown element foo in container number           ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+  screen-should-contain-in-color 1/red, [
+    .  errors found                                                                                      .
+    .                                                                                                    .
+    .                                                                                                    .
+    .                                                                                                    .
+    .                                                                                                    .
+    .unknown element foo in container number                                                             .
+    .                                                                                                    .
+  ]
+]
+
+scenario run-shows-missing-type-warnings [
+  $close-trace  # trace too long
+  assume-screen 100/width, 15/height
+  1:address:array:character <- new [ 
+recipe foo [
+  x <- copy 0
+]]
+  2:address:array:character <- new [foo]
+  3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
+  assume-console [
+    press F4
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .  errors found                                                                   run (F4)           .
+    .                                                  ┊foo                                              .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  x <- copy 0                                     ┊                                                 .
+    .]                                                 ┊                                                 .
+    .missing type in 'x <- copy 0'                     ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+]
+
+scenario run-shows-unbalanced-bracket-warnings [
+  $close-trace  # trace too long
+  assume-screen 100/width, 15/height
+  # recipe is incomplete (unbalanced '[')
+  1:address:array:character <- new [ 
+recipe foo «
+  x <- copy 0
+]
+  string-replace 1:address:array:character, 171/«, 91  # '['
+  2:address:array:character <- new [foo]
+  3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
+  assume-console [
+    press F4
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .  errors found                                                                   run (F4)           .
+    .                                                  ┊foo                                              .
+    .recipe foo \\\[                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  x <- copy 0                                     ┊                                                 .
+    .                                                  ┊                                                 .
+    .9: unbalanced '\\\[' for recipe                      ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+]
+
+scenario run-shows-get-on-non-container-warnings [
+  $close-trace  # trace too long
+  assume-screen 100/width, 15/height
+  1:address:array:character <- new [ 
+recipe foo [
+  x:address:point <- new point:type
+  get x:address:point, 1:offset
+]]
+  2:address:array:character <- new [foo]
+  3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
+  assume-console [
+    press F4
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .                                                                                 run (F4)           .
+    .                                                  ┊                                                 .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  x:address:point <- new point:type               ┊                                                x.
+    .  get x:address:point, 1:offset                   ┊foo                                              .
+    .]                                                 ┊foo: first ingredient of 'get' should be a conta↩.
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊iner, but got x:address:point                    .
+    .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊                                                 .
+  ]
+]
+
+scenario run-shows-non-literal-get-argument-warnings [
+  $close-trace  # trace too long
+  assume-screen 100/width, 15/height
+  1:address:array:character <- new [ 
+recipe foo [
+  x:number <- copy 0
+  y:address:point <- new point:type
+  get *y:address:point, x:number
+]]
+  2:address:array:character <- new [foo]
+  3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
+  assume-console [
+    press F4
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .  errors found                                                                   run (F4)           .
+    .                                                  ┊foo                                              .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  x:number <- copy 0                              ┊                                                 .
+    .  y:address:point <- new point:type               ┊                                                 .
+    .  get *y:address:point, x:number                  ┊                                                 .
+    .]                                                 ┊                                                 .
+    .foo: expected ingredient 1 of 'get' to have type ↩┊                                                 .
+    .'offset'; got x:number                            ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+]
+
+scenario run-shows-warnings-everytime [
+  $close-trace  # trace too long
+  # try to run a file with an error
+  assume-screen 100/width, 15/height
+  1:address:array:character <- new [ 
+recipe foo [
+  x:number <- copy y:number
+]]
+  2:address:array:character <- new [foo]
+  3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
+  assume-console [
+    press F4
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .  errors found                                                                   run (F4)           .
+    .                                                  ┊foo                                              .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  x:number <- copy y:number                       ┊                                                 .
+    .]                                                 ┊                                                 .
+    .use before set: y in foo                          ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+  # rerun the file, check for the same error
+  assume-console [
+    press F4
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .  errors found                                                                   run (F4)           .
+    .                                                  ┊foo                                              .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  x:number <- copy y:number                       ┊                                                 .
+    .]                                                 ┊                                                 .
+    .use before set: y in foo                          ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+]