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-08-21 00:57:57 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-08-21 00:57:57 -0700
commit689a480e1e0f7aca0f406bfad90a52dcef01d878 (patch)
tree16056e3425356b0831059e2e35c2e1e084265ef2 /mu.arc.t
parent0c57bf0a1bfababf3f4b661c500f9ef7aae56776 (diff)
downloadmu-689a480e1e0f7aca0f406bfad90a52dcef01d878.tar.gz
61 - 'get' for array access
get _ 0 => retrieves array length
get _ n => retrieves index n-1
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t20
1 files changed, 20 insertions, 0 deletions
diff --git a/mu.arc.t b/mu.arc.t
index a7003c6e..a385164a 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -90,6 +90,9 @@
   (prn "F - 'arg' with index can access function call arguments out of order"))
 ;? (quit)
 
+; todo: test that too few args throws an error
+; how should errors be handled? will be unclear until we support concurrency and routine trees.
+
 (reset)
 (add-fns
   '((test1
@@ -346,6 +349,23 @@
 (reset)
 (add-fns
   '((main
+      ((1 integer) <- literal 2)
+      ((2 integer) <- literal 23)
+      ((3 boolean) <- literal nil)
+      ((4 integer) <- literal 24)
+      ((5 boolean) <- literal t)
+      ((6 integer) <- get (1 integer-boolean-pair-array) (0 offset))
+      ((7 integer-boolean-pair) <- get (1 integer-boolean-pair-array) (1 offset)))))
+(run function*!main)
+;? (prn memory*)
+(if (~iso memory* (obj 1 2  2 23 3 nil  4 24 5 t  6 2  7 23 8 nil))
+  (prn "F - 'get' accesses fields of arrays"))
+
+; todo: test that out-of-bounds access throws an error
+
+(reset)
+(add-fns
+  '((main
       ((1 integer) <- literal 34)
       ((2 boolean) <- literal nil)
       ((4 boolean) <- literal t)