about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-12 11:29:02 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-12 11:29:02 -0700
commitbb63c4191f03aa8b7acdc8aa5a9269f84007d942 (patch)
tree4e47f9313b508ee2e3b8f28aff7b28ff5c3da12b
parent1bd5f2f5f1a3df0bf5d0907d08c70eda9e120e1f (diff)
downloadmu-bb63c4191f03aa8b7acdc8aa5a9269f84007d942.tar.gz
139
-rw-r--r--mu.arc.t15
1 files changed, 14 insertions, 1 deletions
diff --git a/mu.arc.t b/mu.arc.t
index 1f1329be..a4eab61a 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -641,13 +641,26 @@
 (add-fns
   '((test1
       ((1 type) <- copy (integer-address literal))
-      ((2 integer-address) <- copy (34 literal))
+      ((2 integer-address) <- copy (34 literal))  ; pointer to nowhere
       ((3 integer-address) (4 boolean) <- maybe-coerce (1 tagged-value) (integer-address literal)))))
 (run 'test1)
 ;? (prn memory*)
 (if (or (~is memory*.3 34) (~is memory*.4 t))
   (prn "F - 'maybe-coerce' copies value only if type tag matches"))
 
+(reset)
+(new-trace "tagged-value-2")
+;? (set dump-trace*)
+(add-fns
+  '((test1
+      ((1 type) <- copy (integer-address literal))
+      ((2 integer-address) <- copy (34 literal))  ; pointer to nowhere
+      ((3 integer-address) (4 boolean) <- maybe-coerce (1 tagged-value) (boolean-address literal)))))
+(run 'test1)
+(prn memory*)
+(if (or (~is memory*.3 0) (~is memory*.4 nil))
+  (prn "F - 'maybe-coerce' doesn't copy value when type tag doesn't match"))
+
 ; Just like the table of types is centralized, functions are conceptualized as
 ; a centralized table of operations just like the 'primitives' we've seen so
 ; far. If you create a function you can call it like any other op.