Skip to content

Commit

Permalink
Merge branch 'master' into rhino-eval
Browse files Browse the repository at this point in the history
  • Loading branch information
brentonashworth committed Sep 28, 2011
2 parents 545aad2 + 3359fdb commit 9f8c8fd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions script/test
@@ -1,3 +1,4 @@
rm -rf out
mkdir -p out

#bin/cljsc test > out/core-test.js
Expand Down
13 changes: 10 additions & 3 deletions src/clj/cljs/compiler.clj
Expand Up @@ -1117,6 +1117,14 @@
parent-file (java.io.File. ^String (to-path (cons target parents)))]
(java.io.File. parent-file ^String (rename-to-js (last relative-path)))))

(defn cljs-files-in
"Return a sequence of all .cljs files in the given directory."
[dir]
(filter #(let [name (.getName ^java.io.File %)]
(and (.endsWith name ".cljs")
(not= \. (first name))))
(file-seq dir)))

(defn compile-root
"Looks recursively in src-dir for .cljs files and compiles them to
.js files. If target-dir is provided, output will go into this
Expand All @@ -1126,9 +1134,8 @@
([src-dir]
(compile-root src-dir "out"))
([src-dir target-dir]
(let [src-dir-file (io/file src-dir)
cljs-files (filter #(.endsWith (.getName ^java.io.File %) ".cljs") (file-seq src-dir-file))]
(loop [cljs-files cljs-files
(let [src-dir-file (io/file src-dir)]
(loop [cljs-files (cljs-files-in src-dir-file)
output-files []]
(if (seq cljs-files)
(let [cljs-file (first cljs-files)
Expand Down
6 changes: 3 additions & 3 deletions src/clj/cljs/core.clj
Expand Up @@ -115,12 +115,12 @@
(defmacro max
([x] x)
([x y] (list 'js* "((~{} > ~{}) ? ~{} : ~{})" x y x y))
([x y & more] `(max (max x y) ~@more)))
([x y & more] `(max (max ~x ~y) ~@more)))

(defmacro min
([x] x)
([x y] (list 'js* "((~{} < ~{}) ? ~{} : ~{})" x y x y))
([x y & more] `(min (min x y) ~@more)))
([x y & more] `(min (min ~x ~y) ~@more)))

(defmacro mod [num div]
(list 'js* "(~{} % ~{})" num div))
Expand All @@ -142,7 +142,7 @@

(defmacro bit-and-not
([x y] (list 'js* "(~{} & ~~{})" x y))
([x y & more] `(bit-and-not (bit-and-not x y) ~@more)))
([x y & more] `(bit-and-not (bit-and-not ~x ~y) ~@more)))

(defmacro bit-clear [x n]
(list 'js* "(~{} & ~(1 << ~{}))" x n))
Expand Down
4 changes: 3 additions & 1 deletion test/cljs/cljs/core_test.cljs
Expand Up @@ -290,8 +290,10 @@
(assert ((complement number?) :foo))
(assert (= [1 [2 3] [1 2 3]] ((juxt first rest seq) [1 2 3])))
(assert (= 5 (max 1 2 3 4 5)))
(assert (= 5 (max 5 4 3 2 1)))
(assert (= 5.5 (max 1 2 3 4 5 5.5)))
(assert (= 1 (min 5 4 3 2 1)))
(assert (= 1 (min 1 2 3 4 5)))
(assert (= 0.5 (min 5 4 3 0.5 2 1)))
(let [x (array 1 2 3)]
(set! (.foo x) :hello)
Expand Down Expand Up @@ -725,4 +727,4 @@
(assert (= (assoc fred :wife :ethel) {:firstname "Fred" :lastname "Mertz" :wife :ethel}))
(assert (= (dissoc ethel :husband) {:firstname "Ethel" :lastname "Mertz"}))

:ok)
:ok)

0 comments on commit 9f8c8fd

Please sign in to comment.