117 lines
6.3 KiB
Plaintext
117 lines
6.3 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)
|
|
fully_evaled_called (if (combiner? fully_evaled) (fully_evaled 1337))
|
|
_ (if (combiner? fully_evaled) (println "..and called " fully_evaled_called))
|
|
|
|
outer_eval (eval code root_env)
|
|
_ (println " outer-eval " outer_eval)
|
|
outer_called (if (combiner? outer_eval) (outer_eval 1337))
|
|
_ (if (combiner? outer_eval) (println "..and outer called " outer_called))
|
|
_ (cond (or (combiner? fully_evaled) (combiner? outer_eval))
|
|
(if (!= fully_evaled_called outer_called) (error (str "called versions unequal for " code " are " fully_evaled_called " vs " outer_called)))
|
|
(!= fully_evaled outer_eval) (error (str "partial-eval versions unequal for " code " are " fully_evaled " vs " outer_eval))
|
|
true nil)
|
|
_ (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)))")
|
|
;; No longer works with our more aggressive partial-evaling of vaus with incomplete environments
|
|
;; BUT DOES CUZ I ROLLED THAT BACK
|
|
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)")
|
|
|
|
; let1 test
|
|
|
|
; ((wrap (vau root_env (quote) ((wrap (vau (let1) ;HERE;)) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de))))) (vau (x) x))
|
|
|
|
;let1_test (read-string "((wrap (vau root_env (quote) ((wrap (vau (let1) (let1 a 12 (+ a 1)))) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de))))) (vau (x) x))")
|
|
let1_test (read-string "((wrap (vau (let1) (let1 a 12 (+ a 1)))) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de)))")
|
|
let2_test (read-string "((wrap (vau (let1) (let1 a 12 (vau (x) (+ a 1))))) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de)))")
|
|
let3_test (read-string "((wrap (vau (let1) (let1 a 12 (wrap (vau (x) (+ x a 1)))))) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de)))")
|
|
let4_test (read-string "((wrap (vau (let1) (let1 a 12 (wrap (vau (x) (let1 y (+ a 1) (+ y x a))))))) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de)))")
|
|
let5_test (read-string "((wrap (vau (let1) (let1 a 12 (wrap (vau (x) (let1 y (+ x a 1) (+ y x a))))))) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de)))")
|
|
|
|
lambda1_test (read-string "((wrap (vau (let1)
|
|
(let1 lambda (vau se (p b) (wrap (eval (array vau p b) se)))
|
|
(lambda (x) x)
|
|
))) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de)))")
|
|
lambda2_test (read-string "((wrap (vau (let1)
|
|
(let1 lambda (vau se (p b) (wrap (eval (array vau p b) se)))
|
|
(let1 a 12
|
|
(lambda (x) (+ a x)))
|
|
))) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de)))")
|
|
lambda3_test (read-string "((wrap (vau (let1)
|
|
(let1 lambda (vau se (p b) (wrap (eval (array vau p b) se)))
|
|
(let1 a 12
|
|
(lambda (x) (let1 b (+ a x)
|
|
(+ a x b))))
|
|
))) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de)))")
|
|
|
|
|
|
|
|
;big_test1 [[vau ['*ARGV*] (read-string (slurp "./prelude.kp"))] ["" "-C" "1339"]]
|
|
;big_test1 [[vau ['*ARGV*] (read-string (slurp "./prelude.kp"))] ["" "-C" "(let (a 17) (vau (x) a))"]]
|
|
big_test1 [[vau ['*ARGV*] (read-string (slurp "./prelude.kp"))] ["" "-C" "(let (a 17) a)"]]
|
|
;big_test1 [[vau ['*ARGV*] (read-string (slurp "./prelude.kp"))] []]
|
|
|
|
_ (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)
|
|
|
|
_ (test-case let1_test)
|
|
_ (test-case let2_test)
|
|
_ (test-case let3_test)
|
|
_ (test-case let4_test)
|
|
_ (test-case let5_test)
|
|
|
|
_ (test-case lambda1_test)
|
|
_ (test-case lambda2_test)
|
|
_ (test-case lambda3_test)
|
|
|
|
;_ (println "THE BIG SHOW")
|
|
;_ (println big_test1)
|
|
;_ (test-case big_test1)
|
|
) nil))
|