 (ns cljs.compiler-tests
   (:use clojure.test)
-  (:require [cljs.analyzer :as a])
-  (:require [cljs.compiler :as c])
-  (:require [cljs.env :as e])
-  (:require [cljs.util :as util]
-            [cljs.compiler :as comp])
-  (:import (java.io File)))
+  (:require [cljs.analyzer :as ana]
+            [cljs.compiler :as comp]
+            [cljs.env :as env]
+            [cljs.util :as util])
+  (:import [java.io File]))
 
-(def ns-env (assoc-in (a/empty-env) [:ns :name] 'cljs.user))
+(def aenv (assoc-in (ana/empty-env) [:ns :name] 'cljs.user))
+(def cenv (env/default-compiler-env))
 
 (deftest should-recompile
   (let [src (File. "test/hello.cljs")


(deftest test-js-negative-infinity
  (= (with-out-str
       (c/emit
         (a/analyze (assoc ns-env :context :expr) 'js/-Infinity)))
     "-Infinity"))

        opt {:optimize-constants true}
        optmod {:optimize-constants true :elide-asserts false}]
    (with-redefs [util/*clojurescript-version* {:major 0 :minor 0 :qualifier 42}]
      (env/with-compiler-env (env/default-compiler-env)
        (.setLastModified dst (- (.lastModified src) 100))
        (is (comp/requires-compilation? src dst opt))
        (comp/compile-file src dst opt)
        (is (not (comp/requires-compilation? src dst opt)))
        (is (comp/requires-compilation? src dst optmod))
        (comp/compile-file src dst optmod)
        (is (not (comp/requires-compilation? src dst optmod)))))))

(deftest fn-scope-munge
  (is (= (comp/munge
           (get-in
             (ana/analyze aenv
               '(defn foo []
                  (fn bar [])))
             [:init :name]))
         'cljs$user$foo))
  (is (= (comp/munge
           (get-in
             (ana/analyze aenv
               '(defn foo []
                  (fn bar [])))
             [:init :children 0 :children 0 :name]))
          'cljs$user$foo_$_bar))
  (is (= (comp/munge
           (get-in
             (ana/analyze aenv
               '(fn []
                  (fn console [])))
             [:children 0 :children 0 :name]))
