about summary refs log tree commit diff stats
path: root/lambda-to-mu.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-07-23 14:17:35 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-07-23 14:20:26 -0700
commita62cf4c3e3233e86aa46c0067871269fe7066765 (patch)
treec7475df0f9e1708c46bb39a2da7b783f326e1bd0 /lambda-to-mu.mu
parente7b152ceb2a360e9f8f4faa7068c70bfc7d3f0ac (diff)
downloadmu-a62cf4c3e3233e86aa46c0067871269fe7066765.tar.gz
3140
Manual tests for parse errors because scenarios can't handle assertion
failures yet.
Diffstat (limited to 'lambda-to-mu.mu')
-rw-r--r--lambda-to-mu.mu34
1 files changed, 30 insertions, 4 deletions
diff --git a/lambda-to-mu.mu b/lambda-to-mu.mu
index dea68868..47870be0 100644
--- a/lambda-to-mu.mu
+++ b/lambda-to-mu.mu
@@ -188,8 +188,9 @@ def parse in:address:stream -> out:address:cell, in:address:stream [
     out <- new cell:type  # start out with nil
     # read in first element of pair
     {
-      done?:boolean <- end-of-stream? in
-      break-if done?
+      end?:boolean <- end-of-stream? in
+      not-end?:boolean <- not end?
+      assert not-end?, [unbalanced '(' in expression]
       c <- peek in
       close-paren?:boolean <- equal c, 41/close-paren
       break-if close-paren?
@@ -199,8 +200,9 @@ def parse in:address:stream -> out:address:cell, in:address:stream [
     # read in any remaining elements
     curr:address:cell <- copy out
     {
-      done?:boolean <- end-of-stream? in
-      break-if done?
+      end?:boolean <- end-of-stream? in
+      not-end?:boolean <- not end?
+      assert not-end?, [unbalanced '(' in expression]
       c <- peek in
       close-paren?:boolean <- equal c, 41/close-paren
       break-if close-paren?
@@ -296,3 +298,27 @@ scenario parse-list-of-more-than-two-atoms [
     40:array:character <- [ghi]  # result.rest.rest
   ]
 ]
+
+# todo: uncomment these tests after we figure out how to continue tests after
+# assertion failures
+#? scenario parse-error [
+#?   local-scope
+#?   s:address:array:character <- new [(]
+#? #?   hide-errors
+#?   x:address:cell <- parse s
+#? #?   show-errors
+#?   trace-should-contain [
+#?     error: unbalanced '(' in expression
+#?   ]
+#? ]
+#? 
+#? scenario parse-error-after-element [
+#?   local-scope
+#?   s:address:array:character <- new [(abc]
+#? #?   hide-errors
+#?   x:address:cell <- parse s
+#? #?   show-errors
+#?   trace-should-contain [
+#?     error: unbalanced '(' in expression
+#?   ]
+#? ]