Files
kraken/partial_eval_test.kp
2021-08-17 18:17:42 -04:00

42 lines
2.0 KiB
Plaintext

(with_import "./partial_eval.kp"
(let (
test-case (lambda (code) (let (
_ (println "Code: " code)
[comb_to_mark_map partially_evaled] (partial_eval code)
_ (println "Partially evaled: " partially_evaled)
stripped (strip partially_evaled)
_ (println "Stripped: " stripped)
fully_evaled (eval stripped)
_ (println "Fully evaled: " fully_evaled)
_ (if (combiner? fully_evaled) (println "..and called " (fully_evaled 1337)))
outer_eval (eval code root_env)
_ (println " outer-eval " outer_eval)
_ (if (combiner? outer_eval) (println "..and outer called " (outer_eval 1337)))
_ (println)
) fully_evaled))
simple_add (read-string "(+ 1 2)")
vau_with_add (read-string "(vau (y) (+ 1 2))")
vau_with_add_called (read-string "((vau (y) (+ 1 2)) 4)")
vau_with_passthrough (read-string "((vau (y) y) 4)")
vau_with_no_eval_add (read-string "((vau (y) (+ 13 2 y)) 4)")
vau_with_wrap_add (read-string "((wrap (vau (y) (+ 13 2 y))) (+ 3 4))")
vau_with_add_p (read-string "(vau de (y) (+ (eval y de) (+ 1 2)))")
vau_with_add_p_called (read-string "((vau de (y) ((vau dde (z) (+ 1 (eval z dde))) y)) 17)")
cond_test (read-string "(cond false 1 false 2 (+ 1 2) 3 true 1337)")
cond_vau_test (read-string "(vau de (x) (cond false 1 false 2 x 3 true 42))")
cond_vau_test2 (read-string "(vau de (x) (cond false 1 false 2 3 x true 42))")
_ (test-case simple_add)
_ (test-case vau_with_add)
_ (test-case vau_with_add_called)
_ (test-case vau_with_passthrough)
_ (test-case vau_with_no_eval_add)
_ (test-case vau_with_wrap_add)
_ (test-case vau_with_add_p)
_ (test-case vau_with_add_p_called)
_ (test-case cond_test)
_ (test-case cond_vau_test)
_ (test-case cond_vau_test2)
) nil))