about summary refs log tree commit diff stats
path: root/mu.arc.t
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-29 22:19:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-29 22:19:03 -0700
commitdea74d71561c1d3436d5db59c05ee9230f17c01d (patch)
tree47d86a7c9bf0e9aee84347685094ef6e0be28e4c /mu.arc.t
parent389ed7684a60a5809a640859f80ed354e0ca3039 (diff)
downloadmu-dea74d71561c1d3436d5db59c05ee9230f17c01d.tar.gz
174 - experiment: communicating errors between routines
Who does cleanup? That comes later, with custodians.
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t18
1 files changed, 16 insertions, 2 deletions
diff --git a/mu.arc.t b/mu.arc.t
index 52327ef2..8fbbf7ad 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -519,8 +519,6 @@
 (if (~iso memory* (obj 1 2  2 23 3 nil  4 24 5 t  6 1  7 4))
   (prn "F - 'index-address' returns addresses of indices of arrays"))
 
-; todo: test that out-of-bounds access throws an error
-
 ; Array values know their length. Record lengths are saved in the types table.
 
 (reset)
@@ -1340,6 +1338,22 @@
 ; Eventually we want the right stack-management primitives to build delimited
 ; continuations in mu.
 
+; Routines can throw errors.
+(reset)
+(new-trace "array-bounds-check")
+(add-fns
+  '((main
+      ((1 integer) <- copy (2 literal))
+      ((2 integer) <- copy (23 literal))
+      ((3 integer) <- copy (24 literal))
+      ((4 integer) <- index (1 integer-array) (2 literal)))))
+;? (set dump-trace*)
+(run 'main)
+;? (prn memory*)
+(let last-routine (deq completed-routines*)
+  (if (no rep.last-routine!error)
+    (prn "F - 'index' throws an error if out of bounds")))
+
 ; ---
 
 (reset)