Files
kraken/partial_eval_test.kp

61 lines
2.6 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))")
combiner_test (read-string "(combiner? true)")
combiner_test2 (read-string "(combiner? (vau de (x) x))")
combiner_test3 (read-string "(vau de (x) (combiner? x))")
env_test (read-string "(env? true)")
; this doesn't partially eval, but it could with a more percise if the marked values were more percise
env_test2 (read-string "(vau de (x) (env? de))")
env_test3 (read-string "(vau de (x) (env? x))")
env_test4 (read-string "((vau de (x) (env? de)) 1)")
_ (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)
_ (test-case combiner_test)
_ (test-case combiner_test2)
_ (test-case combiner_test3)
_ (test-case env_test)
_ (test-case env_test2)
_ (test-case env_test3)
_ (test-case env_test4)
) nil))