Skip to content

Instantly share code, notes, and snippets.

@wavejumper
Created April 14, 2018 08:46
Show Gist options
  • Save wavejumper/a9d058b39a228bbf67de2fd96b9f94ee to your computer and use it in GitHub Desktop.
Save wavejumper/a9d058b39a228bbf67de2fd96b9f94ee to your computer and use it in GitHub Desktop.
(ns static.core-test
(:require [clojure.test :refer :all]
[static.core :as s]))
(defmacro with-env [eval-sym & body]
`(let [env# (s/create-env)
~eval-sym (partial s/-eval env#)]
~@body))
(deftest scoping
(with-env eval
(testing "Let binding closing over fn"
(eval
'(let [x (fn [y] y)]
(defn foo "foo" {:a :b} [a b c] {:pre (+ 1 2) :post (+ 1 2)}
(if true "a" (+ 1 2))
;;(+ 1 2 3)
(let [a (if true 1 :a)]
(x b)))))
(let [resp (eval '(foo 1 2 3))]
(is (= 2 (-> resp :output :output :value)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment