Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace :cljs-splat with :cljs-do, also fixed bug on :cljs-do impl

  • Loading branch information...
commit 52d39ed7c2148b07cd11668232d15f88d9a864d2 1 parent 644f518
@roman roman authored
View
10 src/dalap/leiningen/rules.clj
@@ -19,7 +19,7 @@
(defn cljs-form-only? [form]
(and (list? form)
(or (= (first form) :dalap-cljs-only)
- (= (first form) :dalap-cljs-only-splat))))
+ (= (first form) :dalap-cljs-only-do))))
;; Transformers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -36,11 +36,11 @@
(defn change-to-require-macro [form w_]
(concat [:require-macro] (rest form)))
-(defn replace-with-cljs [form w_]
+(defn replace-with-cljs [form w]
(cond
- (= (first form) :dalap-cljs-only) (w_ (cons 'do (rest form)))
- (= (first form) :dalap-cljs-only-splat) (w_ (second form))
- :else (w_ form)))
+ (= (first form) :dalap-cljs-only) (w (second form))
+ (= (first form) :dalap-cljs-only-do) (w (conj (rest form) 'do))
+ :else (w form)))
;; Constant values ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
View
8 test/fixtures/file.clj
@@ -1,9 +1,13 @@
(ns fixtures.file
(:require [clojure.test :refer [deftest is]]
- #_(:cljs-splat [cljs.only :refer [somefn]]))
+ #_(:cljs [cljs.only :refer [somefn]]))
^:cljs-macro (:require [watchtower.core :refer [watcher]])
^:clj (:import [clojure.lang PersistentVector IFn]))
+
+#_(:cljs-do
+ (.log js/console "hello world"))
+
(defprotocol CustomProtocol
(my-fn [this]))
@@ -19,4 +23,4 @@
(my-fn [this] nil))
(deftest hello-world
- (is (= 1 1)))
+ (is (= 1 1)))
View
12 test/leiningen/test/dalap_test.clj
@@ -78,10 +78,20 @@
{["test/fixtures/file.clj" "test/fixtures/out.cljs"]
[]})
(is (->> (slurp "test/fixtures/file.clj")
- (re-find #":cljs-splat")))
+ (re-find #":cljs")))
(is (->> (slurp "test/fixtures/out.cljs")
(re-find #"\[cljs.only"))))
+
+(deftest test-cljs-do-ignore-macro
+ (run-transformations!
+ {["test/fixtures/file.clj" "test/fixtures/out.cljs"]
+ []})
+ (is (->> (slurp "test/fixtures/file.clj")
+ (re-find #":cljs-do")))
+ (is (->> (slurp "test/fixtures/out.cljs")
+ (re-find #"\(do \(\.log"))))
+
(deftest test-dalap-scope-is-in-configuration-file
(is (thrown?
Exception
Please sign in to comment.
Something went wrong with that request. Please try again.