Skip to content

Commit 666e487

Browse files
committed
bump to tools.reader 0.10.0-apha3
add executable comments to cljs.js and add supporting files
1 parent f8b97e0 commit 666e487

File tree

6 files changed

+135
-4
lines changed

6 files changed

+135
-4
lines changed

pom.template.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<dependency>
5151
<groupId>org.clojure</groupId>
5252
<artifactId>tools.reader</artifactId>
53-
<version>0.9.2</version>
53+
<version>0.10.0-alpha3</version>
5454
</dependency>
5555
</dependencies>
5656

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
:test-paths ["src/test/clojure" "src/test/cljs"]
1111
:dependencies [[org.clojure/clojure "1.7.0"]
1212
[org.clojure/data.json "0.2.6"]
13-
[org.clojure/tools.reader "0.9.2"]
13+
[org.clojure/tools.reader "0.10.0-alpha3"]
1414
[org.clojure/google-closure-library "0.0-20150505-021ed5b3"]
1515
[com.google.javascript/closure-compiler "v20150609"]
1616
[org.mozilla/rhino "1.7R5"]]

script/bootstrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CLOSURE_RELEASE="20150609"
77
DJSON_RELEASE="0.2.6"
88
GCLOSURE_LIB_RELEASE="0.0-20150505-021ed5b3"
99
RHINO_RELEASE="1_7R5"
10-
TREADER_RELEASE="0.9.2"
10+
TREADER_RELEASE="0.10.0-alpha3"
1111

1212
# check dependencies
1313
curl -V >/dev/null || { echo "cURL is missing, or not on your system path."; exit 1; }

src/main/cljs/cljs/js.cljs

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,4 +731,127 @@
731731
:*load-macros* (or (:load-macros opts) true)
732732
:*load-fn* (or (:load opts) *load-fn*)
733733
:*eval-fn* (or (:eval opts) *eval-fn*)}
734-
source name opts cb)))
734+
source name opts cb)))
735+
736+
(comment
737+
(ns cljs.js.test
738+
(:require [cljs.js :as cljs]))
739+
740+
(def vm (js/require "vm"))
741+
(def fs (js/require "fs"))
742+
(def st (cljs/empty-state))
743+
744+
(defn node-eval [{:keys [name source]}]
745+
(.runInThisContext vm source (str (munge name) ".js")))
746+
747+
(def libs
748+
{'bootstrap-test.core :cljs
749+
'bootstrap-test.macros :clj})
750+
751+
(defn node-load [{:keys [name macros]} cb]
752+
(if (contains? libs name)
753+
(let [path (str "src/test/" (cljs/ns->relpath name)
754+
"." (cljs.core/name (get libs name)))]
755+
(.readFile fs path "utf-8"
756+
(fn [err src]
757+
(cb (if-not err
758+
{:lang :clj :source src}
759+
(.error js/console err))))))
760+
(cb nil)))
761+
762+
(cljs/eval st '(defn foo [a b] (+ a b))
763+
{:eval cljs/js-eval}
764+
(fn [res]
765+
(println res)))
766+
767+
(cljs/compile st "(defprotocol IFoo (foo [this]))"
768+
(fn [js-source]
769+
(println "Source:")
770+
(println js-source)))
771+
772+
(cljs/eval-str st
773+
"(defn foo [a b] (+ a b))
774+
(defn bar [c d] (+ c d))"
775+
nil
776+
{:eval cljs/js-eval}
777+
(fn [res]
778+
(println res)))
779+
780+
(cljs/eval-str st "1"
781+
nil
782+
{:eval cljs/js-eval
783+
:context :expr}
784+
(fn [res]
785+
(println res)))
786+
787+
(cljs/eval-str st "(def x 1)"
788+
nil
789+
{:eval cljs/js-eval
790+
:context :expr
791+
:def-emits-var true}
792+
(fn [res]
793+
(println res)))
794+
795+
(cljs/eval st '(ns foo.bar)
796+
{:eval cljs/js-eval}
797+
(fn [res]
798+
(println res)))
799+
800+
(cljs/compile st "(defn foo\n[a b]\n(+ a b))" 'cljs.foo
801+
{:verbose true :source-map true}
802+
(fn [js-source]
803+
(println "Source:")
804+
(println js-source)))
805+
806+
(cljs/eval-str st
807+
"(ns foo.bar (:require [bootstrap-test.core]))\n(bootstrap-test.core/foo 3 4)"
808+
'foo.bar
809+
{:verbose true
810+
:source-map true
811+
:eval node-eval
812+
:load node-load}
813+
(fn [ret]
814+
(println ret)))
815+
816+
(cljs/eval-str st
817+
"(ns foo.bar (:require-macros [bootstrap-test.macros :refer [foo]]))\n(foo 4 4)"
818+
'foo.bar
819+
{:verbose true
820+
:source-map true
821+
:eval node-eval
822+
:load node-load}
823+
(fn [{:keys [error] :as res}]
824+
(if error
825+
(do
826+
(println error)
827+
(println (.. error -cause -stack)))
828+
(println res))))
829+
830+
(cljs/eval-str st
831+
"(ns foo.bar)\n(first [1 2 3])"
832+
'foo.bar
833+
{:verbose true
834+
:source-map true
835+
:eval node-eval
836+
:load node-load}
837+
(fn [{:keys [error] :as res}]
838+
(if error
839+
(do
840+
(println error)
841+
(println (.. error -cause -stack)))
842+
(println res))))
843+
844+
(cljs/eval-str st
845+
"(ns foo.bar)\n(map inc [1 2 3])"
846+
'foo.bar
847+
{:verbose true
848+
:source-map true
849+
:eval node-eval
850+
:load node-load}
851+
(fn [{:keys [error] :as res}]
852+
(if error
853+
(do
854+
(println error)
855+
(println (.. error -cause -stack)))
856+
(println res))))
857+
)

src/test/bootstrap_test/core.cljs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(ns bootstrap-test.core)
2+
3+
(defn foo [c d]
4+
(* c d))

src/test/bootstrap_test/macros.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(ns bootstrap-test.macros)
2+
3+
(defmacro foo [a b]
4+
`(* ~a ~b))

0 commit comments

Comments
 (0)