diff options
Diffstat (limited to 'mu.arc')
-rw-r--r-- | mu.arc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mu.arc b/mu.arc index a850363e..8d727a8e 100644 --- a/mu.arc +++ b/mu.arc @@ -5,6 +5,32 @@ (each f (as cons initialization-fns*) (f))) +(mac on-init body + `(enq (fn () ,@body) + initialization-fns*)) + +(on-init + (= traces* nil)) +(def trace (label . args) + (push (list label (apply tostring:prn args)) + traces*)) +(def assert-trace-contains (label string) + (assert (pos (fn ((curr-label curr-msg)) + (and (is label curr-label) + (posmatch string curr-msg))) + traces*) + (tostring + (prn "Couldn't find " (tostring write.string) " in label:") + (each (curr-label curr-msg) traces* + (if (is label curr-label) + (prn " " curr-msg)))))) + +(reset) +(trace "foo" "abc") +(assert-trace-contains "foo" "abc") +(assert-trace-contains "foo" "abd") +(quit) + (mac init-fn (name . body) `(enq (fn () (= (function* ',name) ',body)) initialization-fns*)) |