Skip to content

Instantly share code, notes, and snippets.

@shaunlebron
Created December 15, 2018 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaunlebron/d08cb06e162be725b0a5e75e586621f9 to your computer and use it in GitHub Desktop.
Save shaunlebron/d08cb06e162be725b0a5e75e586621f9 to your computer and use it in GitHub Desktop.
parindent on clojurescript core
diff --git a/benchmark/cljs/benchmark_runner.cljs b/benchmark/cljs/benchmark_runner.cljs
index a4ea583c..4407b571 100644
--- a/benchmark/cljs/benchmark_runner.cljs
+++ b/benchmark/cljs/benchmark_runner.cljs
@@ -1,8 +1,8 @@
(ns cljs.benchmark-runner
(:refer-clojure :exclude [println])
(:require [cljs.reader :as reader]
- [clojure.core.reducers :as r]
- [clojure.string :as string]))
+ [clojure.core.reducers :as r]
+ [clojure.string :as string]))
(def println print)
@@ -111,11 +111,11 @@
(println ";;; transients")
(print "transient vector, conj! 1000000 items")
(time
- (let [v (transient [])]
- (loop [i 0 v v]
- (if (> i 1000000)
- (persistent! v)
- (recur (inc i) (conj! v i))))))
+ (let [v (transient [])]
+ (loop [i 0 v v]
+ (if (> i 1000000)
+ (persistent! v)
+ (recur (inc i) (conj! v i))))))
(println ";;; vector equality")
(simple-benchmark
@@ -323,9 +323,9 @@
(defn ints-seq
([n] (ints-seq 0 n))
([i n]
- (when (< i n)
- (lazy-seq
- (cons i (ints-seq (inc i) n))))))
+ (when (< i n)
+ (lazy-seq
+ (cons i (ints-seq (inc i) n))))))
(def r (ints-seq 1000000))
(println ";;; lazy-seq")
(println ";;; first run")
diff --git a/samples/dom/src/dom/test.cljs b/samples/dom/src/dom/test.cljs
index a23fb078..856cb0b3 100644
--- a/samples/dom/src/dom/test.cljs
+++ b/samples/dom/src/dom/test.cljs
@@ -1,6 +1,6 @@
(ns dom.test
(:require [clojure.browser.event :as event]
- [clojure.browser.dom :as dom]))
+ [clojure.browser.dom :as dom]))
(defn log [& args]
(.log js/console (apply pr-str args)))
diff --git a/samples/hello/src/hello/core.cljs b/samples/hello/src/hello/core.cljs
index 67a479f3..e4178ebb 100644
--- a/samples/hello/src/hello/core.cljs
+++ b/samples/hello/src/hello/core.cljs
@@ -1,6 +1,6 @@
(ns hello.core
(:require [hello.foo.bar :as bar]
- [cljs.reader :as reader]))
+ [cljs.reader :as reader]))
(defn ^{:export greet} greet [n]
(str "Hello " n))
diff --git a/samples/nodehello.cljs b/samples/nodehello.cljs
index 629c670c..85aac6f1 100644
--- a/samples/nodehello.cljs
+++ b/samples/nodehello.cljs
@@ -8,13 +8,13 @@
(set! *main-cli-fn* -main)
(comment
-; Compile this using a command line like:
+ ; Compile this using a command line like:
-CLOJURESCRIPT_HOME=".../clojurescript/" \
+ CLOJURESCRIPT_HOME=".../clojurescript/" \
bin/cljsc samples/nodehello.cljs {:target :nodejs} \
> out/nodehello.js
-; Then run using:
-nodejs out/nodehello.js
+ ; Then run using:
+ nodejs out/nodehello.js
-)
+ )
diff --git a/samples/repl/src/repl/test.cljs b/samples/repl/src/repl/test.cljs
index 0853715f..87aea9d5 100644
--- a/samples/repl/src/repl/test.cljs
+++ b/samples/repl/src/repl/test.cljs
@@ -8,8 +8,8 @@
(ns repl.test
(:require [clojure.browser.repl :as repl]
- ;[clojure.reflect :as reflect]
- ))
+ ;[clojure.reflect :as reflect]
+ ))
(defonce conn
(repl/connect "http://localhost:9000/repl"))
diff --git a/samples/string-requires-npm-deps/src/foo/core.cljs b/samples/string-requires-npm-deps/src/foo/core.cljs
index 43cd8328..675afe4d 100644
--- a/samples/string-requires-npm-deps/src/foo/core.cljs
+++ b/samples/string-requires-npm-deps/src/foo/core.cljs
@@ -1,7 +1,7 @@
(ns foo.core
(:require [react :refer [createElement]]
- ["react-dom/server" :as rds :refer [renderToString]]
- "create-react-class"))
+ ["react-dom/server" :as rds :refer [renderToString]]
+ "create-react-class"))
(enable-console-print!)
diff --git a/samples/twitterbuzz/src/twitterbuzz/anneal.cljs b/samples/twitterbuzz/src/twitterbuzz/anneal.cljs
index b1d3a318..8e137c26 100644
--- a/samples/twitterbuzz/src/twitterbuzz/anneal.cljs
+++ b/samples/twitterbuzz/src/twitterbuzz/anneal.cljs
@@ -57,10 +57,10 @@
(comment
-(take 10 (take-nth 100
- (anneal #(abs (- % 42))
- (linear-cooling 1000)
- (fn [s _] (+ s (- (random) 0.5)))
- standard-prob
- 55)))
-)
+ (take 10 (take-nth 100
+ (anneal #(abs (- % 42))
+ (linear-cooling 1000)
+ (fn [s _] (+ s (- (random) 0.5)))
+ standard-prob
+ 55)))
+ )
diff --git a/samples/twitterbuzz/src/twitterbuzz/core.cljs b/samples/twitterbuzz/src/twitterbuzz/core.cljs
index 2f29aedc..05d27dfc 100644
--- a/samples/twitterbuzz/src/twitterbuzz/core.cljs
+++ b/samples/twitterbuzz/src/twitterbuzz/core.cljs
@@ -8,13 +8,13 @@
(ns twitterbuzz.core
(:require [twitterbuzz.dom-helpers :as dom]
- [clojure.string :as string]
- [goog.string :as gstring]
- [goog.net.Jsonp :as jsonp]
- [goog.Timer :as timer]
- [goog.events :as events]
- [goog.events.EventType :as event-type]
- [goog.dom.classes :as classes]))
+ [clojure.string :as string]
+ [goog.string :as gstring]
+ [goog.net.Jsonp :as jsonp]
+ [goog.Timer :as timer]
+ [goog.events :as events]
+ [goog.events.EventType :as event-type]
+ [goog.dom.classes :as classes]))
(def results-per-page 100)
(def max-missing-query 20)
@@ -59,10 +59,10 @@
"For the given event, call every listener for that event, passing the
message."
([event]
- (send-event event nil))
+ (send-event event nil))
([event message]
- (doseq [f (-> @state :listeners event)]
- (f message))))
+ (doseq [f (-> @state :listeners event)]
+ (f message))))
(defn parse-mentions
"Given a map representing a single tweet, return all mentions that
@@ -94,8 +94,8 @@
node (get acc user {:mentions {}})]
(-> (assoc acc user
(assoc node :last-tweet (:text tweet)
- :image-url (:profile_image_url tweet)
- :username (:from_user tweet)))
+ :image-url (:profile_image_url tweet)
+ :username (:from_user tweet)))
(add-mentions user mentions))))
graph
(map #(select-keys % [:text :from_user :profile_image_url]) tweet-maps)))
@@ -265,11 +265,11 @@
"Add markup to tweet text to activate links."
[s]
(let [markup-f (fn [s] (let [w (string/trim s)]
- (cond (gstring/startsWith w "http://")
- (link w w)
- (gstring/startsWith w "@")
- (link (str "http://twitter.com/#!/" (re-find #"\w+" w)) w)
- :else s)))]
+ (cond (gstring/startsWith w "http://")
+ (link w w)
+ (gstring/startsWith w "@")
+ (link (str "http://twitter.com/#!/" (re-find #"\w+" w)) w)
+ :else s)))]
(string/join " " (map markup-f (string/split s #"[ ]")))))
(comment
diff --git a/samples/twitterbuzz/src/twitterbuzz/dom-helpers.cljs b/samples/twitterbuzz/src/twitterbuzz/dom-helpers.cljs
index 21d28564..048aa1f8 100644
--- a/samples/twitterbuzz/src/twitterbuzz/dom-helpers.cljs
+++ b/samples/twitterbuzz/src/twitterbuzz/dom-helpers.cljs
@@ -8,7 +8,7 @@
(ns twitterbuzz.dom-helpers
(:require [clojure.string :as string]
- [goog.dom :as dom]))
+ [goog.dom :as dom]))
(defn get-element
"Return the element with the passed id."
diff --git a/samples/twitterbuzz/src/twitterbuzz/layout.cljs b/samples/twitterbuzz/src/twitterbuzz/layout.cljs
index 3e8f4d2c..371e1384 100644
--- a/samples/twitterbuzz/src/twitterbuzz/layout.cljs
+++ b/samples/twitterbuzz/src/twitterbuzz/layout.cljs
@@ -8,8 +8,8 @@
(ns twitterbuzz.layout
(:require [twitterbuzz.anneal :as ann]
- [twitterbuzz.radial :as rad]
- [goog.math :as math]))
+ [twitterbuzz.radial :as rad]
+ [goog.math :as math]))
(defn random-loc []
{:x (ann/random) :y (ann/random)})
@@ -45,8 +45,8 @@
[mentions-data]
(let [mentions #(rad/get-mentions mentions-data %)
weights (rad/weights
- (into (set (roots mentions-data)) (mapcat mentions (keys mentions-data)))
- mentions)]
+ (into (set (roots mentions-data)) (mapcat mentions (keys mentions-data)))
+ mentions)]
{:mentions mentions-data
:locs (-> (rad/layout (roots mentions-data) weights mentions)
(rad/polar->cartesian 3))}))
@@ -86,15 +86,15 @@
:mentions mentions}))
(comment
-(def test-data {})
+ (def test-data {})
-(def init (init-state test-data))
+ (def init (init-state test-data))
-(map (fn [x] {:best-score (:best-score x) :t (:t x)})
- (take 10 (take-nth 100
- (ann/anneal score
- (ann/linear-cooling 1000)
- permute-move
- ann/standard-prob
- init))))
+ (map (fn [x] {:best-score (:best-score x) :t (:t x)})
+ (take 10 (take-nth 100
+ (ann/anneal score
+ (ann/linear-cooling 1000)
+ permute-move
+ ann/standard-prob
+ init))))
)
diff --git a/samples/twitterbuzz/src/twitterbuzz/leaderboard.cljs b/samples/twitterbuzz/src/twitterbuzz/leaderboard.cljs
index a60247b7..aef545e6 100644
--- a/samples/twitterbuzz/src/twitterbuzz/leaderboard.cljs
+++ b/samples/twitterbuzz/src/twitterbuzz/leaderboard.cljs
@@ -8,7 +8,7 @@
(ns twitterbuzz.leaderboard
(:require [twitterbuzz.core :as buzz]
- [twitterbuzz.dom-helpers :as dom]))
+ [twitterbuzz.dom-helpers :as dom]))
(defn leaderboard-element
"Create a leaderboard element from a user map."
diff --git a/samples/twitterbuzz/src/twitterbuzz/radial.cljs b/samples/twitterbuzz/src/twitterbuzz/radial.cljs
index 238ae707..68bb290d 100644
--- a/samples/twitterbuzz/src/twitterbuzz/radial.cljs
+++ b/samples/twitterbuzz/src/twitterbuzz/radial.cljs
@@ -8,7 +8,7 @@
(ns twitterbuzz.radial
(:require [clojure.set :as set]
- [goog.math :as math]))
+ [goog.math :as math]))
(defn get-mentions
"Returns the set of mentions for k in mentions-data"
@@ -42,9 +42,9 @@
using child-fn to get the set of children for a node."
[nodes child-fn]
(reduce
- (fn [m n] (assoc m n (weight n child-fn)))
- {}
- nodes))
+ (fn [m n] (assoc m n (weight n child-fn)))
+ {}
+ nodes))
(defn layout
"Returns a map of node => :radius, :slice, :angle.
@@ -52,27 +52,27 @@
weight-fn: one arg fn of node returning weight
child-fn: one arg fn of node returning set of nodes"
([nodes weight-fn child-fn]
- (layout nodes weight-fn child-fn 1 0 360 #{}))
+ (layout nodes weight-fn child-fn 1 0 360 #{}))
([nodes weight-fn child-fn radius a1 a2 seen]
- (let [slice (- a2 a1)
- total-weight (reduce + (map #(or (weight-fn %)
- (throw (str "No weight for " %))) nodes))
- seen (into seen nodes)]
- (loop [m {}
- c1 a1
- [node & more] (seq nodes)]
- (if node
- (let [s (* slice (/ (weight-fn node) total-weight))
- c2 (+ c1 s)]
- (recur
- (merge
+ (let [slice (- a2 a1)
+ total-weight (reduce + (map #(or (weight-fn %)
+ (throw (str "No weight for " %))) nodes))
+ seen (into seen nodes)]
+ (loop [m {}
+ c1 a1
+ [node & more] (seq nodes)]
+ (if node
+ (let [s (* slice (/ (weight-fn node) total-weight))
+ c2 (+ c1 s)]
+ (recur
+ (merge
m
{node {:radius radius :slice s :angle (/ (+ c1 c2) 2)}}
(when-let [children (seq (remove seen (child-fn node)))]
(layout children weight-fn child-fn (inc radius) c1 c2 seen)))
- c2
- more))
- m)))))
+ c2
+ more))
+ m)))))
(defn polar->cartesian
"Convert polar coordinates (from layout) into
@@ -80,12 +80,12 @@
square will display max-rings rings."
[polar-map max-rings]
(reduce
- (fn [m [k {:keys [radius angle]}]]
- (let [r (/ radius (+ 0.5 max-rings) 2)]
- (assoc m k {:x (+ 0.5 (math/angleDx angle r))
- :y (+ 0.5 (math/angleDy angle r))})))
- {}
- polar-map))
+ (fn [m [k {:keys [radius angle]}]]
+ (let [r (/ radius (+ 0.5 max-rings) 2)]
+ (assoc m k {:x (+ 0.5 (math/angleDx angle r))
+ :y (+ 0.5 (math/angleDy angle r))})))
+ {}
+ polar-map))
diff --git a/samples/twitterbuzz/src/twitterbuzz/showgraph.cljs b/samples/twitterbuzz/src/twitterbuzz/showgraph.cljs
index 9a03d2bc..d742ac6d 100644
--- a/samples/twitterbuzz/src/twitterbuzz/showgraph.cljs
+++ b/samples/twitterbuzz/src/twitterbuzz/showgraph.cljs
@@ -8,17 +8,17 @@
(ns twitterbuzz.showgraph
(:require [twitterbuzz.core :as buzz]
- [twitterbuzz.layout :as layout]
- [twitterbuzz.dom-helpers :as dom]
- [twitterbuzz.timeline :as timeline]
- [goog.events :as events]
- [goog.style :as style]
- [goog.math.Coordinate :as Coordinate]
- [goog.ui.HoverCard :as HoverCard]
- [goog.graphics.Font :as Font]
- [goog.graphics.Stroke :as Stroke]
- [goog.graphics.SolidFill :as SolidFill]
- [goog.graphics :as graphics]))
+ [twitterbuzz.layout :as layout]
+ [twitterbuzz.dom-helpers :as dom]
+ [twitterbuzz.timeline :as timeline]
+ [goog.events :as events]
+ [goog.style :as style]
+ [goog.math.Coordinate :as Coordinate]
+ [goog.ui.HoverCard :as HoverCard]
+ [goog.graphics.Font :as Font]
+ [goog.graphics.Stroke :as Stroke]
+ [goog.graphics.SolidFill :as SolidFill]
+ [goog.graphics :as graphics]))
; Drawing configuration
(def avatar-size 32) ; used for both x and y dimensions of avatars
@@ -62,9 +62,9 @@
(fn [event]
(hide-tooltip event)
(.setPosition avatar-hover
- (goog.ui/Tooltip.CursorTooltipPosition.
- (Coordinate/sum (goog.math/Coordinate. px py)
- canvas-offset)))
+ (goog.ui/Tooltip.CursorTooltipPosition.
+ (Coordinate/sum (goog.math/Coordinate. px py)
+ canvas-offset)))
(dom/remove-children :avatar-hover-body)
(dom/append (dom/get-element :avatar-hover-body)
(timeline/timeline-element tweet))
@@ -84,8 +84,8 @@
(let [x2 (unit-to-pixel ux2 (.-width canvas-size))
y2 (unit-to-pixel uy2 (.-height canvas-size))]
(.drawPath g
- (-> (. g (createPath)) (.moveTo x1 y1) (.lineTo x2 y2))
- edge-stroke nil))))
+ (-> (. g (createPath)) (.moveTo x1 y1) (.lineTo x2 y2))
+ edge-stroke nil))))
; Draw avatar nodes
(doseq [[username {:keys [x y] :as foo}] locs]
@@ -105,7 +105,7 @@
text)]
(when text
(.drawTextOnLine g text 5 20 (.-width canvas-size) 20
- "left" font nil fill)))))
+ "left" font nil fill)))))
(def graph-data (atom nil))
diff --git a/samples/twitterbuzz/src/twitterbuzz/timeline.cljs b/samples/twitterbuzz/src/twitterbuzz/timeline.cljs
index 07fc447f..ce218059 100644
--- a/samples/twitterbuzz/src/twitterbuzz/timeline.cljs
+++ b/samples/twitterbuzz/src/twitterbuzz/timeline.cljs
@@ -8,7 +8,7 @@
(ns twitterbuzz.timeline
(:require [twitterbuzz.core :as buzz]
- [twitterbuzz.dom-helpers :as dom]))
+ [twitterbuzz.dom-helpers :as dom]))
(defn timeline-element
"Return a timeline dom element for the given tweet."
diff --git a/src/main/cljs/cljs/core.cljs b/src/main/cljs/cljs/core.cljs
index 0a53d9d7..d2209ba1 100644
--- a/src/main/cljs/cljs/core.cljs
+++ b/src/main/cljs/cljs/core.cljs
@@ -8,11 +8,11 @@
(ns cljs.core
(:require goog.math.Long
- goog.math.Integer
- [goog.string :as gstring]
- [goog.object :as gobject]
- [goog.array :as garray]
- [goog.Uri])
+ goog.math.Integer
+ [goog.string :as gstring]
+ [goog.object :as gobject]
+ [goog.array :as garray]
+ [goog.Uri])
(:import [goog.string StringBuffer]))
;; next line is auto-generated by the build-script - Do not edit!
@@ -73,9 +73,9 @@
*exec-tap-fn*
[f]
(and
- (exists? js/setTimeout)
- (js/setTimeout f 0)
- true))
+ (exists? js/setTimeout)
+ (js/setTimeout f 0)
+ true))
(defonce
^{:doc "Each runtime environment provides a different way to print error output.
@@ -282,9 +282,9 @@
[p x]
(let [x (if (nil? x) nil x)]
(cond
- (unchecked-get p (goog/typeOf x)) true
- (unchecked-get p "_") true
- :else false)))
+ (unchecked-get p (goog/typeOf x)) true
+ (unchecked-get p "_") true
+ :else false)))
(set! *unchecked-if* false)
(defn is_proto_
@@ -313,9 +313,9 @@
ty (if (and ty (.-cljs$lang$type ty))
(.-cljs$lang$ctorStr ty)
(goog/typeOf obj))]
- (js/Error.
- (.join (array "No protocol method " proto
- " defined for type " ty ": " obj) ""))))
+ (js/Error.
+ (.join (array "No protocol method " proto
+ " defined for type " ty ": " obj) ""))))
(defn type->str [ty]
(if-let [s (.-cljs$lang$ctorStr ty)]
@@ -413,15 +413,15 @@
way to allocate multi-dimensional arrays in JavaScript; as such, this function
will run in polynomial time when called with 3 or more arguments."
([size]
- (js/Array. size))
+ (js/Array. size))
([type size]
- (make-array size))
+ (make-array size))
([type size & more-sizes]
- (let [dims more-sizes
- dimarray (make-array size)]
- (dotimes [i (alength dimarray)]
- (aset dimarray i (apply make-array nil dims)))
- dimarray)))
+ (let [dims more-sizes
+ dimarray (make-array size)]
+ (dotimes [i (alength dimarray)]
+ (aset dimarray i (apply make-array nil dims)))
+ dimarray)))
(defn aclone
"Returns a javascript array, cloned from the passed in array"
@@ -496,17 +496,17 @@
(defn aget
"Returns the value at the index/indices. Works on JavaScript arrays."
([array idx]
- (cljs.core/aget array idx))
+ (cljs.core/aget array idx))
([array idx & idxs]
- (apply aget (aget array idx) idxs)))
+ (apply aget (aget array idx) idxs)))
(defn aset
"Sets the value at the index/indices. Works on JavaScript arrays.
Returns val."
([array idx val]
- (cljs.core/aset array idx val))
+ (cljs.core/aset array idx val))
([array idx idx2 & idxv]
- (apply aset (aget array idx) idx2 idxv)))
+ (apply aset (aget array idx) idx2 idxv)))
(defn ^number alength
"Returns the length of the array. Works on arrays of all types."
@@ -519,9 +519,9 @@
"Returns an array with components set to the values in aseq. Optional type
argument accepted for compatibility with Clojure."
([aseq]
- (into-array nil aseq))
+ (into-array nil aseq))
([type aseq]
- (reduce (fn [a x] (.push a x) a) (array) aseq)))
+ (reduce (fn [a x] (.push a x) a) (array) aseq)))
(defn js-invoke
"Invoke JavaScript object method via string. Needed when the
@@ -565,12 +565,12 @@
(defprotocol ICloneable
"Protocol for cloning a value."
(^clj -clone [value]
- "Creates a clone of value."))
+ "Creates a clone of value."))
(defprotocol ICounted
"Protocol for adding the ability to count a collection in constant time."
(^number -count [coll]
- "Calculates the count of coll in constant time. Used by cljs.core/count."))
+ "Calculates the count of coll in constant time. Used by cljs.core/count."))
(defprotocol IEmptyableCollection
"Protocol for creating an empty collection."
@@ -581,7 +581,7 @@
(defprotocol ICollection
"Protocol for adding to a collection."
(^clj -conj [coll o]
- "Returns a new collection of coll with o added to it. The new item
+ "Returns a new collection of coll with o added to it. The new item
should be added to the most efficient place, e.g.
(conj [1 2 3 4] 5) => [1 2 3 4 5]
(conj '(2 3 4 5) 1) => '(1 2 3 4 5)"))
@@ -603,7 +603,7 @@
(-first [coll]
"Returns the first item in the collection coll. Used by cljs.core/first.")
(^clj -rest [coll]
- "Returns a new collection of coll without the first item. It should
+ "Returns a new collection of coll without the first item. It should
always return a seq, e.g.
(rest []) => ()
(rest nil) => ()"))
@@ -611,7 +611,7 @@
(defprotocol INext
"Protocol for accessing the next items of a collection."
(^clj-or-nil -next [coll]
- "Returns a new collection of coll without the first item. In contrast to
+ "Returns a new collection of coll without the first item. In contrast to
rest, it should return nil if there are no more items, e.g.
(next []) => nil
(next nil) => nil"))
@@ -625,10 +625,10 @@
(defprotocol IAssociative
"Protocol for adding associativity to collections."
(^boolean -contains-key? [coll k]
- "Returns true if k is a key in coll.")
+ "Returns true if k is a key in coll.")
#_(-entry-at [coll k])
(^clj -assoc [coll k v]
- "Returns a new collection of coll with a mapping from key k to
+ "Returns a new collection of coll with a mapping from key k to
value v added to it."))
(defprotocol IFind
@@ -639,7 +639,7 @@
"Protocol for adding mapping functionality to collections."
#_(-assoc-ex [coll k v])
(^clj -dissoc [coll k]
- "Returns a new collection of coll without the mapping for key k."))
+ "Returns a new collection of coll without the mapping for key k."))
(defprotocol IMapEntry
"Protocol for examining a map entry."
@@ -651,7 +651,7 @@
(defprotocol ISet
"Protocol for adding set functionality to a collection."
(^clj -disjoin [coll v]
- "Returns a new collection of coll that does not contain v."))
+ "Returns a new collection of coll that does not contain v."))
(defprotocol IStack
"Protocol for collections to provide access to their items as stacks. The top
@@ -660,13 +660,13 @@
(-peek [coll]
"Returns the item from the top of the stack. Is used by cljs.core/peek.")
(^clj -pop [coll]
- "Returns a new stack without the item on top of the stack. Is used
+ "Returns a new stack without the item on top of the stack. Is used
by cljs.core/pop."))
(defprotocol IVector
"Protocol for adding vector functionality to collections."
(^clj -assoc-n [coll n val]
- "Returns a new vector with value val added at position n."))
+ "Returns a new vector with value val added at position n."))
(defprotocol IDeref
"Protocol for adding dereference functionality to a reference."
@@ -679,12 +679,12 @@
(defprotocol IMeta
"Protocol for accessing the metadata of an object."
(^clj-or-nil -meta [o]
- "Returns the metadata of object o."))
+ "Returns the metadata of object o."))
(defprotocol IWithMeta
"Protocol for adding metadata to an object."
(^clj -with-meta [o meta]
- "Returns a new object with value of o and metadata meta added to it."))
+ "Returns a new object with value of o and metadata meta added to it."))
(defprotocol IReduce
"Protocol for seq types that can reduce themselves.
@@ -704,7 +704,7 @@
(defprotocol IEquiv
"Protocol for adding value comparison functionality to a type."
(^boolean -equiv [o other]
- "Returns true if o and other are equal, false otherwise."))
+ "Returns true if o and other are equal, false otherwise."))
(defprotocol IHash
"Protocol for adding hashing functionality to a type."
@@ -714,7 +714,7 @@
(defprotocol ISeqable
"Protocol for adding the ability to a type to be transformed into a sequence."
(^clj-or-nil -seq [o]
- "Returns a seq of o, or nil if o is empty."))
+ "Returns a seq of o, or nil if o is empty."))
(defprotocol ISequential
"Marker interface indicating a persistent collection of sequential items")
@@ -728,15 +728,15 @@
(defprotocol IReversible
"Protocol for reversing a seq."
(^clj -rseq [coll]
- "Returns a seq of the items in coll in reversed order."))
+ "Returns a seq of the items in coll in reversed order."))
(defprotocol ISorted
"Protocol for a collection which can represent their items
in a sorted manner. "
(^clj -sorted-seq [coll ascending?]
- "Returns a sorted seq from coll in either ascending or descending order.")
+ "Returns a sorted seq from coll in either ascending or descending order.")
(^clj -sorted-seq-from [coll k ascending?]
- "Returns a sorted seq from coll in either ascending or descending order.
+ "Returns a sorted seq from coll in either ascending or descending order.
If ascending is true, the result should contain all items which are > or >=
than k. If ascending is false, the result should contain all items which
are < or <= than k, e.g.
@@ -766,7 +766,7 @@
"Protocol for types which can have a deferred realization. Currently only
implemented by Delay and LazySeq."
(^boolean -realized? [x]
- "Returns true if a value for x has been produced, false otherwise."))
+ "Returns true if a value for x has been produced, false otherwise."))
(defprotocol IWatchable
"Protocol for types that can be watched. Currently only implemented by Atom."
@@ -781,42 +781,42 @@
(defprotocol IEditableCollection
"Protocol for collections which can transformed to transients."
(^clj -as-transient [coll]
- "Returns a new, transient version of the collection, in constant time."))
+ "Returns a new, transient version of the collection, in constant time."))
(defprotocol ITransientCollection
"Protocol for adding basic functionality to transient collections."
(^clj -conj! [tcoll val]
- "Adds value val to tcoll and returns tcoll.")
+ "Adds value val to tcoll and returns tcoll.")
(^clj -persistent! [tcoll]
- "Creates a persistent data structure from tcoll and returns it."))
+ "Creates a persistent data structure from tcoll and returns it."))
(defprotocol ITransientAssociative
"Protocol for adding associativity to transient collections."
(^clj -assoc! [tcoll key val]
- "Returns a new transient collection of tcoll with a mapping from key to
+ "Returns a new transient collection of tcoll with a mapping from key to
val added to it."))
(defprotocol ITransientMap
"Protocol for adding mapping functionality to transient collections."
(^clj -dissoc! [tcoll key]
- "Returns a new transient collection of tcoll without the mapping for key."))
+ "Returns a new transient collection of tcoll without the mapping for key."))
(defprotocol ITransientVector
"Protocol for adding vector functionality to transient collections."
(^clj -assoc-n! [tcoll n val]
- "Returns tcoll with value val added at position n.")
+ "Returns tcoll with value val added at position n.")
(^clj -pop! [tcoll]
- "Returns tcoll with the last item removed from it."))
+ "Returns tcoll with the last item removed from it."))
(defprotocol ITransientSet
"Protocol for adding set functionality to a transient collection."
(^clj -disjoin! [tcoll v]
- "Returns tcoll without v."))
+ "Returns tcoll without v."))
(defprotocol IComparable
"Protocol for values that can be compared."
(^number -compare [x y]
- "Returns a negative number, zero, or a positive number when x is logically
+ "Returns a negative number, zero, or a positive number when x is logically
'less than', 'equal to', or 'greater than' y."))
(defprotocol IChunk
@@ -839,9 +839,9 @@
(defprotocol INamed
"Protocol for adding a name."
(^string -name [x]
- "Returns the name String of x.")
+ "Returns the name String of x.")
( ^{:tag #{string clj-nil}}-namespace [x]
- "Returns the namespace String of x."))
+ "Returns the namespace String of x."))
(defprotocol IAtom
"Marker protocol indicating an atom.")
@@ -1045,15 +1045,15 @@
(defn- compare-symbols [a b]
(cond
- (identical? (.-str a) (.-str b)) 0
- (and (not (.-ns a)) (.-ns b)) -1
- (.-ns a) (if-not (.-ns b)
- 1
- (let [nsc (garray/defaultCompare (.-ns a) (.-ns b))]
- (if (== 0 nsc)
- (garray/defaultCompare (.-name a) (.-name b))
- nsc)))
- :default (garray/defaultCompare (.-name a) (.-name b))))
+ (identical? (.-str a) (.-str b)) 0
+ (and (not (.-ns a)) (.-ns b)) -1
+ (.-ns a) (if-not (.-ns b)
+ 1
+ (let [nsc (garray/defaultCompare (.-ns a) (.-ns b))]
+ (if (== 0 nsc)
+ (garray/defaultCompare (.-name a) (.-name b))
+ nsc)))
+ :default (garray/defaultCompare (.-name a) (.-name b))))
(declare get)
@@ -1265,16 +1265,16 @@
comparison."
([x] true)
([x y]
- (if (nil? x)
- (nil? y)
- (or (identical? x y)
- ^boolean (-equiv x y))))
+ (if (nil? x)
+ (nil? y)
+ (or (identical? x y)
+ ^boolean (-equiv x y))))
([x y & more]
- (if (= x y)
- (if (next more)
- (recur y (first more) (next more))
- (= y (first more)))
- false)))
+ (if (= x y)
+ (if (next more)
+ (recur y (first more) (next more))
+ (= y (first more)))
+ false)))
;; EXPERIMENTAL: subject to change
(deftype ES6Iterator [^:mutable s]
@@ -1455,65 +1455,65 @@
"Accepts any collection which satisfies the ICount and IIndexed protocols and
reduces them without incurring seq initialization"
([cicoll f]
- (let [cnt (-count cicoll)]
- (if (zero? cnt)
- (f)
- (loop [val (-nth cicoll 0), n 1]
- (if (< n cnt)
- (let [nval (f val (-nth cicoll n))]
- (if (reduced? nval)
- @nval
- (recur nval (inc n))))
- val)))))
- ([cicoll f val]
- (let [cnt (-count cicoll)]
- (loop [val val, n 0]
- (if (< n cnt)
- (let [nval (f val (-nth cicoll n))]
- (if (reduced? nval)
- @nval
- (recur nval (inc n))))
- val))))
- ([cicoll f val idx]
- (let [cnt (-count cicoll)]
- (loop [val val, n idx]
+ (let [cnt (-count cicoll)]
+ (if (zero? cnt)
+ (f)
+ (loop [val (-nth cicoll 0), n 1]
(if (< n cnt)
(let [nval (f val (-nth cicoll n))]
(if (reduced? nval)
@nval
(recur nval (inc n))))
val)))))
+ ([cicoll f val]
+ (let [cnt (-count cicoll)]
+ (loop [val val, n 0]
+ (if (< n cnt)
+ (let [nval (f val (-nth cicoll n))]
+ (if (reduced? nval)
+ @nval
+ (recur nval (inc n))))
+ val))))
+ ([cicoll f val idx]
+ (let [cnt (-count cicoll)]
+ (loop [val val, n idx]
+ (if (< n cnt)
+ (let [nval (f val (-nth cicoll n))]
+ (if (reduced? nval)
+ @nval
+ (recur nval (inc n))))
+ val)))))
(defn- array-reduce
([arr f]
- (let [cnt (alength arr)]
- (if (zero? (alength arr))
- (f)
- (loop [val (aget arr 0), n 1]
- (if (< n cnt)
- (let [nval (f val (aget arr n))]
- (if (reduced? nval)
- @nval
- (recur nval (inc n))))
- val)))))
- ([arr f val]
- (let [cnt (alength arr)]
- (loop [val val, n 0]
- (if (< n cnt)
- (let [nval (f val (aget arr n))]
- (if (reduced? nval)
- @nval
- (recur nval (inc n))))
- val))))
- ([arr f val idx]
- (let [cnt (alength arr)]
- (loop [val val, n idx]
+ (let [cnt (alength arr)]
+ (if (zero? (alength arr))
+ (f)
+ (loop [val (aget arr 0), n 1]
(if (< n cnt)
(let [nval (f val (aget arr n))]
(if (reduced? nval)
@nval
(recur nval (inc n))))
val)))))
+ ([arr f val]
+ (let [cnt (alength arr)]
+ (loop [val val, n 0]
+ (if (< n cnt)
+ (let [nval (f val (aget arr n))]
+ (if (reduced? nval)
+ @nval
+ (recur nval (inc n))))
+ val))))
+ ([arr f val idx]
+ (let [cnt (alength arr)]
+ (loop [val val, n idx]
+ (if (< n cnt)
+ (let [nval (f val (aget arr n))]
+ (if (reduced? nval)
+ @nval
+ (recur nval (inc n))))
+ val)))))
(declare hash-coll cons drop count nth RSeq List)
@@ -1547,17 +1547,17 @@ reduces them without incurring seq initialization"
(-lastIndexOf coll x (count coll)))
([coll x start]
(let [len (count coll)]
- (if (zero? len)
- -1
- (loop [idx (cond
- (pos? start) (min (dec len) start)
- (neg? start) (+ len start)
- :else start)]
- (if (>= idx 0)
- (if (= (nth coll idx) x)
- idx
- (recur (dec idx)))
- -1))))))
+ (if (zero? len)
+ -1
+ (loop [idx (cond
+ (pos? start) (min (dec len) start)
+ (neg? start) (+ len start)
+ :else start)]
+ (if (>= idx 0)
+ (if (= (nth coll idx) x)
+ idx
+ (recur (dec idx)))
+ -1))))))
(deftype IndexedSeqIterator [arr ^:mutable i]
Object
@@ -1571,7 +1571,7 @@ reduces them without incurring seq initialization"
(deftype IndexedSeq [arr i meta]
Object
(toString [coll]
- (pr-str* coll))
+ (pr-str* coll))
(equiv [this other]
(-equiv this other))
(indexOf [coll x]
@@ -1661,17 +1661,17 @@ reduces them without incurring seq initialization"
(defn prim-seq
"Create seq from a primitive JavaScript Array-like."
([prim]
- (prim-seq prim 0))
+ (prim-seq prim 0))
([prim i]
- (when (< i (alength prim))
- (IndexedSeq. prim i nil))))
+ (when (< i (alength prim))
+ (IndexedSeq. prim i nil))))
(defn array-seq
"Create a seq from a JavaScript array."
([array]
- (prim-seq array 0))
+ (prim-seq array 0))
([array i]
- (prim-seq array i)))
+ (prim-seq array i)))
(declare with-meta seq-reduce)
@@ -1784,13 +1784,13 @@ reduces them without incurring seq initialization"
([] [])
([coll] coll)
([coll x]
- (if-not (nil? coll)
- (-conj coll x)
- (list x)))
+ (if-not (nil? coll)
+ (-conj coll x)
+ (list x)))
([coll x & xs]
- (if xs
- (recur (conj coll x) (first xs) (next xs))
- (conj coll x))))
+ (if xs
+ (recur (conj coll x) (first xs) (next xs))
+ (conj coll x))))
(defn empty
"Returns an empty collection of the same category as coll, or nil"
@@ -1834,23 +1834,23 @@ reduces them without incurring seq initialization"
(defn- linear-traversal-nth
([coll n]
- (cond
- (nil? coll) (throw (js/Error. "Index out of bounds"))
- (zero? n) (if (seq coll)
- (first coll)
- (throw (js/Error. "Index out of bounds")))
- (indexed? coll) (-nth coll n)
- (seq coll) (recur (next coll) (dec n))
- :else (throw (js/Error. "Index out of bounds"))))
+ (cond
+ (nil? coll) (throw (js/Error. "Index out of bounds"))
+ (zero? n) (if (seq coll)
+ (first coll)
+ (throw (js/Error. "Index out of bounds")))
+ (indexed? coll) (-nth coll n)
+ (seq coll) (recur (next coll) (dec n))
+ :else (throw (js/Error. "Index out of bounds"))))
([coll n not-found]
- (cond
- (nil? coll) not-found
- (zero? n) (if (seq coll)
- (first coll)
- not-found)
- (indexed? coll) (-nth coll n not-found)
- (seq coll) (recur (next coll) (dec n) not-found)
- :else not-found)))
+ (cond
+ (nil? coll) not-found
+ (zero? n) (if (seq coll)
+ (first coll)
+ not-found)
+ (indexed? coll) (-nth coll n not-found)
+ (seq coll) (recur (next coll) (dec n) not-found)
+ :else not-found)))
(defn nth
"Returns the value at the index. get returns nil if index out of
@@ -1858,121 +1858,121 @@ reduces them without incurring seq initialization"
also works for strings, arrays, regex Matchers and Lists, and,
in O(n) time, for sequences."
([coll n]
- (cond
- (not (number? n))
- (throw (js/Error. "Index argument to nth must be a number"))
+ (cond
+ (not (number? n))
+ (throw (js/Error. "Index argument to nth must be a number"))
- (nil? coll)
- coll
+ (nil? coll)
+ coll
- (implements? IIndexed coll)
- (-nth coll n)
+ (implements? IIndexed coll)
+ (-nth coll n)
- (array? coll)
- (if (and (< -1 n (.-length coll)))
- (aget coll (int n))
- (throw (js/Error. "Index out of bounds")))
+ (array? coll)
+ (if (and (< -1 n (.-length coll)))
+ (aget coll (int n))
+ (throw (js/Error. "Index out of bounds")))
- (string? coll)
- (if (and (< -1 n (.-length coll)))
- (.charAt coll (int n))
- (throw (js/Error. "Index out of bounds")))
+ (string? coll)
+ (if (and (< -1 n (.-length coll)))
+ (.charAt coll (int n))
+ (throw (js/Error. "Index out of bounds")))
- (or (implements? ISeq coll)
- (implements? ISequential coll))
- (if (neg? n)
- (throw (js/Error. "Index out of bounds"))
- (linear-traversal-nth coll n))
+ (or (implements? ISeq coll)
+ (implements? ISequential coll))
+ (if (neg? n)
+ (throw (js/Error. "Index out of bounds"))
+ (linear-traversal-nth coll n))
- (native-satisfies? IIndexed coll)
- (-nth coll n)
+ (native-satisfies? IIndexed coll)
+ (-nth coll n)
- :else
- (throw (js/Error. (str "nth not supported on this type "
- (type->str (type coll)))))))
+ :else
+ (throw (js/Error. (str "nth not supported on this type "
+ (type->str (type coll)))))))
([coll n not-found]
- (cond
- (not (number? n))
- (throw (js/Error. "Index argument to nth must be a number."))
+ (cond
+ (not (number? n))
+ (throw (js/Error. "Index argument to nth must be a number."))
- (nil? coll)
- not-found
+ (nil? coll)
+ not-found
- (implements? IIndexed coll)
- (-nth coll n not-found)
+ (implements? IIndexed coll)
+ (-nth coll n not-found)
- (array? coll)
- (if (and (< -1 n (.-length coll)))
- (aget coll (int n))
- not-found)
+ (array? coll)
+ (if (and (< -1 n (.-length coll)))
+ (aget coll (int n))
+ not-found)
- (string? coll)
- (if (and (< -1 n (.-length coll)))
- (.charAt coll (int n))
- not-found)
+ (string? coll)
+ (if (and (< -1 n (.-length coll)))
+ (.charAt coll (int n))
+ not-found)
- (or (implements? ISeq coll)
- (implements? ISequential coll))
- (if (neg? n)
- not-found
- (linear-traversal-nth coll n not-found))
+ (or (implements? ISeq coll)
+ (implements? ISequential coll))
+ (if (neg? n)
+ not-found
+ (linear-traversal-nth coll n not-found))
- (native-satisfies? IIndexed coll)
- (-nth coll n not-found)
+ (native-satisfies? IIndexed coll)
+ (-nth coll n not-found)
- :else
- (throw (js/Error. (str "nth not supported on this type "
- (type->str (type coll))))))))
+ :else
+ (throw (js/Error. (str "nth not supported on this type "
+ (type->str (type coll))))))))
(defn nthrest
"Returns the nth rest of coll, coll when n is 0."
[coll n]
- (loop [n n xs coll]
- (if-let [xs (and (pos? n) (seq xs))]
- (recur (dec n) (rest xs))
- xs)))
+ (loop [n n xs coll]
+ (if-let [xs (and (pos? n) (seq xs))]
+ (recur (dec n) (rest xs))
+ xs)))
(defn get
"Returns the value mapped to key, not-found or nil if key not present."
([o k]
- (when-not (nil? o)
- (cond
- (implements? ILookup o)
- (-lookup o k)
+ (when-not (nil? o)
+ (cond
+ (implements? ILookup o)
+ (-lookup o k)
- (array? o)
- (when (and (some? k) (< k (.-length o)))
- (aget o (int k)))
+ (array? o)
+ (when (and (some? k) (< k (.-length o)))
+ (aget o (int k)))
- (string? o)
- (when (and (some? k) (< k (.-length o)))
- (.charAt o (int k)))
+ (string? o)
+ (when (and (some? k) (< k (.-length o)))
+ (.charAt o (int k)))
- (native-satisfies? ILookup o)
- (-lookup o k)
+ (native-satisfies? ILookup o)
+ (-lookup o k)
- :else nil)))
+ :else nil)))
([o k not-found]
- (if-not (nil? o)
- (cond
- (implements? ILookup o)
- (-lookup o k not-found)
+ (if-not (nil? o)
+ (cond
+ (implements? ILookup o)
+ (-lookup o k not-found)
- (array? o)
- (if (and (some? k) (< -1 k (.-length o)))
- (aget o (int k))
- not-found)
+ (array? o)
+ (if (and (some? k) (< -1 k (.-length o)))
+ (aget o (int k))
+ not-found)
- (string? o)
- (if (and (some? k) (< -1 k (.-length o)))
- (.charAt o (int k))
- not-found)
+ (string? o)
+ (if (and (some? k) (< -1 k (.-length o)))
+ (.charAt o (int k))
+ not-found)
- (native-satisfies? ILookup o)
- (-lookup o k not-found)
+ (native-satisfies? ILookup o)
+ (-lookup o k not-found)
- :else not-found)
- not-found)))
+ :else not-found)
+ not-found)))
(declare PersistentHashMap PersistentArrayMap MapEntry)
@@ -1982,28 +1982,28 @@ reduces them without incurring seq initialization"
val(s). When applied to a vector, returns a new vector that
contains val at index."
([coll k v]
- (if-not (nil? coll)
- (-assoc coll k v)
- (array-map k v)))
+ (if-not (nil? coll)
+ (-assoc coll k v)
+ (array-map k v)))
([coll k v & kvs]
- (let [ret (assoc coll k v)]
- (if kvs
- (recur ret (first kvs) (second kvs) (nnext kvs))
- ret))))
+ (let [ret (assoc coll k v)]
+ (if kvs
+ (recur ret (first kvs) (second kvs) (nnext kvs))
+ ret))))
(defn dissoc
"dissoc[iate]. Returns a new map of the same (hashed/sorted) type,
that does not contain a mapping for key(s)."
([coll] coll)
([coll k]
- (when-not (nil? coll)
- (-dissoc coll k)))
+ (when-not (nil? coll)
+ (-dissoc coll k)))
([coll k & ks]
- (when-not (nil? coll)
- (let [ret (dissoc coll k)]
- (if ks
- (recur ret (first ks) (next ks))
- ret)))))
+ (when-not (nil? coll)
+ (let [ret (dissoc coll k)]
+ (if ks
+ (recur ret (first ks) (next ks))
+ ret)))))
(defn fn?
"Return true if f is a JavaScript function or satisfies the Fn protocol."
@@ -2099,14 +2099,14 @@ reduces them without incurring seq initialization"
does not contain key(s)."
([coll] coll)
([coll k]
- (when-not (nil? coll)
- (-disjoin coll k)))
+ (when-not (nil? coll)
+ (-disjoin coll k)))
([coll k & ks]
- (when-not (nil? coll)
- (let [ret (disj coll k)]
- (if ks
- (recur ret (first ks) (next ks))
- ret)))))
+ (when-not (nil? coll)
+ (let [ret (disj coll k)]
+ (if ks
+ (recur ret (first ks) (next ks))
+ ret)))))
(defn empty?
"Returns true if coll has no items - same as (not (seq coll)).
@@ -2129,11 +2129,11 @@ reduces them without incurring seq initialization"
(satisfies? ISet x)))
(defn associative?
- "Returns true if coll implements IAssociative"
+ "Returns true if coll implements IAssociative"
[x] (satisfies? IAssociative x))
(defn ifind?
- "Returns true if coll implements IFind"
+ "Returns true if coll implements IFind"
[x] (satisfies? IFind x))
(defn sequential?
@@ -2175,9 +2175,9 @@ reduces them without incurring seq initialization"
"Create JavaSript object from an even number arguments representing
interleaved keys and values."
([]
- (cljs.core/js-obj))
+ (cljs.core/js-obj))
([& keyvals]
- (apply gobject/create keyvals)))
+ (apply gobject/create keyvals)))
(defn js-keys
"Return the JavaScript keys for an object."
@@ -2192,19 +2192,19 @@ reduces them without incurring seq initialization"
(defn- array-copy
([from i to j len]
- (loop [i i j j len len]
- (if (zero? len)
- to
- (do (aset to j (aget from i))
- (recur (inc i) (inc j) (dec len)))))))
+ (loop [i i j j len len]
+ (if (zero? len)
+ to
+ (do (aset to j (aget from i))
+ (recur (inc i) (inc j) (dec len)))))))
(defn- array-copy-downward
([from i to j len]
- (loop [i (+ i (dec len)) j (+ j (dec len)) len len]
- (if (zero? len)
- to
- (do (aset to j (aget from i))
- (recur (dec i) (dec j) (dec len)))))))
+ (loop [i (+ i (dec len)) j (+ j (dec len)) len len]
+ (if (zero? len)
+ to
+ (do (aset to j (aget from i))
+ (recur (dec i) (dec j) (dec len)))))))
;;;;;;;;;;;;;;;; preds ;;;;;;;;;;;;;;;;;;
@@ -2238,10 +2238,10 @@ reduces them without incurring seq initialization"
"Return true if the seq function is supported for s"
[s]
(or
- (nil? s)
- (satisfies? ISeqable s)
- (array? s)
- (string? s)))
+ (nil? s)
+ (satisfies? ISeqable s)
+ (array? s)
+ (string? s)))
(defn boolean
"Coerce to boolean"
@@ -2359,7 +2359,7 @@ reduces them without incurring seq initialization"
([x] true)
([x y] (not (= x y)))
([x y & more]
- (if (not (= x y))
+ (if (not (= x y))
(loop [s #{x y} xs more]
(let [x (first xs)
etc (next xs)]
@@ -2379,40 +2379,40 @@ reduces them without incurring seq initialization"
of the same type and special-cases nil to be less than any other object."
[x y]
(cond
- (identical? x y) 0
+ (identical? x y) 0
- (nil? x) -1
+ (nil? x) -1
- (nil? y) 1
+ (nil? y) 1
- (number? x) (if (number? y)
- (garray/defaultCompare x y)
- (throw (js/Error. (str "Cannot compare " x " to " y))))
+ (number? x) (if (number? y)
+ (garray/defaultCompare x y)
+ (throw (js/Error. (str "Cannot compare " x " to " y))))
- (satisfies? IComparable x)
- (-compare x y)
+ (satisfies? IComparable x)
+ (-compare x y)
- :else
- (if (and (or (string? x) (array? x) (true? x) (false? x))
- (identical? (type x) (type y)))
- (garray/defaultCompare x y)
- (throw (js/Error. (str "Cannot compare " x " to " y))))))
+ :else
+ (if (and (or (string? x) (array? x) (true? x) (false? x))
+ (identical? (type x) (type y)))
+ (garray/defaultCompare x y)
+ (throw (js/Error. (str "Cannot compare " x " to " y))))))
(defn ^:private compare-indexed
"Compare indexed collection."
([xs ys]
- (let [xl (count xs)
- yl (count ys)]
- (cond
- (< xl yl) -1
- (> xl yl) 1
- (== xl 0) 0
- :else (compare-indexed xs ys xl 0))))
+ (let [xl (count xs)
+ yl (count ys)]
+ (cond
+ (< xl yl) -1
+ (> xl yl) 1
+ (== xl 0) 0
+ :else (compare-indexed xs ys xl 0))))
([xs ys len n]
- (let [d (compare (nth xs n) (nth ys n))]
- (if (and (zero? d) (< (+ n 1) len))
- (recur xs ys len (inc n))
- d))))
+ (let [d (compare (nth xs n) (nth ys n))]
+ (if (and (zero? d) (< (+ n 1) len))
+ (recur xs ys len (inc n))
+ d))))
(defn ^:private fn->comparator
"Given a fn that might be boolean valued or a comparator,
@@ -2452,22 +2452,22 @@ reduces them without incurring seq initialization"
([keyfn coll]
(sort-by keyfn compare coll))
([keyfn comp coll]
- (sort (fn [x y] ((fn->comparator comp) (keyfn x) (keyfn y))) coll)))
+ (sort (fn [x y] ((fn->comparator comp) (keyfn x) (keyfn y))) coll)))
; simple reduce based on seqs, used as default
(defn- seq-reduce
([f coll]
- (if-let [s (seq coll)]
- (reduce f (first s) (next s))
- (f)))
+ (if-let [s (seq coll)]
+ (reduce f (first s) (next s))
+ (f)))
([f val coll]
- (loop [val val, coll (seq coll)]
- (if coll
- (let [nval (f val (first coll))]
- (if (reduced? nval)
- @nval
- (recur nval (next coll))))
- val))))
+ (loop [val val, coll (seq coll)]
+ (if coll
+ (let [nval (f val (first coll))]
+ (if (reduced? nval)
+ @nval
+ (recur nval (next coll))))
+ val))))
(declare vec)
@@ -2512,43 +2512,43 @@ reduces them without incurring seq initialization"
applying f to that result and the 2nd item, etc. If coll contains no
items, returns val and f is not called."
([f coll]
- (cond
- (implements? IReduce coll)
- (-reduce coll f)
+ (cond
+ (implements? IReduce coll)
+ (-reduce coll f)
- (array? coll)
- (array-reduce coll f)
+ (array? coll)
+ (array-reduce coll f)
- (string? coll)
- (array-reduce coll f)
+ (string? coll)
+ (array-reduce coll f)
- (native-satisfies? IReduce coll)
- (-reduce coll f)
+ (native-satisfies? IReduce coll)
+ (-reduce coll f)
- (iterable? coll)
- (iter-reduce coll f)
+ (iterable? coll)
+ (iter-reduce coll f)
- :else
- (seq-reduce f coll)))
+ :else
+ (seq-reduce f coll)))
([f val coll]
- (cond
- (implements? IReduce coll)
- (-reduce coll f val)
+ (cond
+ (implements? IReduce coll)
+ (-reduce coll f val)
- (array? coll)
- (array-reduce coll f val)
+ (array? coll)
+ (array-reduce coll f val)
- (string? coll)
- (array-reduce coll f val)
+ (string? coll)
+ (array-reduce coll f val)
- (native-satisfies? IReduce coll)
- (-reduce coll f val)
+ (native-satisfies? IReduce coll)
+ (-reduce coll f val)
- (iterable? coll)
- (iter-reduce coll f val)
+ (iterable? coll)
+ (iter-reduce coll f val)
- :else
- (seq-reduce f val coll))))
+ :else
+ (seq-reduce f val coll))))
(defn reduce-kv
"Reduces an associative collection. f should be a function of 3
@@ -2558,9 +2558,9 @@ reduces them without incurring seq initialization"
and f is not called. Note that reduce-kv is supported on vectors,
where the keys will be the ordinals."
([f init coll]
- (if-not (nil? coll)
- (-kv-reduce coll f init)
- init)))
+ (if-not (nil? coll)
+ (-kv-reduce coll f init)
+ init)))
(defn identity
"Returns its argument."
@@ -2572,10 +2572,10 @@ reduces them without incurring seq initialization"
identity) on the result argument."
([f] (completing f identity))
([f cf]
- (fn
- ([] (f))
- ([x] (cf x))
- ([x y] (f x y)))))
+ (fn
+ ([] (f))
+ ([x] (cf x))
+ ([x y] (f x y)))))
(defn transduce
"reduce with a transformation of f (xf). If init is not
@@ -2588,9 +2588,9 @@ reduces them without incurring seq initialization"
certain transforms may inject or skip items."
([xform f coll] (transduce xform f (f) coll))
([xform f init coll]
- (let [f (xform f)
- ret (reduce f init coll)]
- (f ret))))
+ (let [f (xform f)
+ ret (reduce f init coll)]
+ (f ret))))
;;; Math - variadic forms will not work until the following implemented:
;;; first, next, reduce
@@ -2601,7 +2601,7 @@ reduces them without incurring seq initialization"
([x] x)
([x y] (cljs.core/+ x y))
([x y & more]
- (reduce + (cljs.core/+ x y) more)))
+ (reduce + (cljs.core/+ x y) more)))
(defn ^number -
"If no ys are supplied, returns the negation of x, else subtracts
@@ -2632,11 +2632,11 @@ reduces them without incurring seq initialization"
([x] true)
([x y] (cljs.core/< x y))
([x y & more]
- (if (cljs.core/< x y)
- (if (next more)
- (recur y (first more) (next more))
- (cljs.core/< y (first more)))
- false)))
+ (if (cljs.core/< x y)
+ (if (next more)
+ (recur y (first more) (next more))
+ (cljs.core/< y (first more)))
+ false)))
(defn ^boolean <=
"Returns non-nil if nums are in monotonically non-decreasing order,
@@ -2848,25 +2848,25 @@ reduces them without incurring seq initialization"
"Bitwise exclusive or"
([x y] (cljs.core/bit-xor x y))
([x y & more]
- (reduce bit-xor (cljs.core/bit-xor x y) more)))
+ (reduce bit-xor (cljs.core/bit-xor x y) more)))
(defn bit-and
"Bitwise and"
([x y] (cljs.core/bit-and x y))
([x y & more]
- (reduce bit-and (cljs.core/bit-and x y) more)))
+ (reduce bit-and (cljs.core/bit-and x y) more)))
(defn bit-or
"Bitwise or"
([x y] (cljs.core/bit-or x y))
([x y & more]
- (reduce bit-or (cljs.core/bit-or x y) more)))
+ (reduce bit-or (cljs.core/bit-or x y) more)))
(defn bit-and-not
"Bitwise and with complement"
([x y] (cljs.core/bit-and-not x y))
([x y & more]
- (reduce bit-and-not (cljs.core/bit-and-not x y) more)))
+ (reduce bit-and-not (cljs.core/bit-and-not x y) more)))
(defn bit-clear
"Clear bit at index n"
@@ -2962,10 +2962,10 @@ reduces them without incurring seq initialization"
""
(.join #js [x] "")))
([x & ys]
- (loop [sb (StringBuffer. (str x)) more ys]
- (if more
- (recur (. sb (append (str (first more)))) (next more))
- (.toString sb)))))
+ (loop [sb (StringBuffer. (str x)) more ys]
+ (if more
+ (recur (. sb (append (str (first more)))) (next more))
+ (.toString sb)))))
(defn subs
"Returns the substring of s beginning at start inclusive, and ending
@@ -3006,7 +3006,7 @@ reduces them without incurring seq initialization"
(if s
(let [e (first s)]
(recur (js-mod (+ h (bit-xor (hash (key e)) (hash (val e))))
- 4503599627370496)
+ 4503599627370496)
(next s)))
h)))
@@ -3289,15 +3289,15 @@ reduces them without incurring seq initialization"
(defn- compare-keywords [a b]
(cond
- (identical? (.-fqn a) (.-fqn b)) 0
- (and (not (.-ns a)) (.-ns b)) -1
- (.-ns a) (if-not (.-ns b)
- 1
- (let [nsc (garray/defaultCompare (.-ns a) (.-ns b))]
- (if (== 0 nsc)
- (garray/defaultCompare (.-name a) (.-name b))
- nsc)))
- :default (garray/defaultCompare (.-name a) (.-name b))))
+ (identical? (.-fqn a) (.-fqn b)) 0
+ (and (not (.-ns a)) (.-ns b)) -1
+ (.-ns a) (if-not (.-ns b)
+ 1
+ (let [nsc (garray/defaultCompare (.-ns a) (.-ns b))]
+ (if (== 0 nsc)
+ (garray/defaultCompare (.-name a) (.-name b))
+ nsc)))
+ :default (garray/defaultCompare (.-name a) (.-name b))))
(deftype Keyword [ns name fqn ^:mutable _hash]
Object
@@ -3535,11 +3535,11 @@ reduces them without incurring seq initialization"
(defn array-chunk
([arr]
- (ArrayChunk. arr 0 (alength arr)))
+ (ArrayChunk. arr 0 (alength arr)))
([arr off]
- (ArrayChunk. arr off (alength arr)))
+ (ArrayChunk. arr off (alength arr)))
([arr off end]
- (ArrayChunk. arr off end)))
+ (ArrayChunk. arr off end)))
(deftype ChunkedCons [chunk more meta ^:mutable __hash]
Object
@@ -3652,100 +3652,100 @@ reduces them without incurring seq initialization"
"Returns a (potentially-ragged) 2-dimensional array
containing the contents of coll."
[coll]
- (let [ret (make-array (count coll))]
- (loop [i 0 xs (seq coll)]
- (when-not (nil? xs)
- (aset ret i (to-array (first xs)))
- (recur (inc i) (next xs))))
- ret))
+ (let [ret (make-array (count coll))]
+ (loop [i 0 xs (seq coll)]
+ (when-not (nil? xs)
+ (aset ret i (to-array (first xs)))
+ (recur (inc i) (next xs))))
+ ret))
(defn int-array
"Creates an array of ints. Does not coerce array, provided for compatibility
with Clojure."
([size-or-seq]
- (if (number? size-or-seq)
- (int-array size-or-seq nil)
- (into-array size-or-seq)))
+ (if (number? size-or-seq)
+ (int-array size-or-seq nil)
+ (into-array size-or-seq)))
([size init-val-or-seq]
- (let [a (make-array size)]
- (if (seq? init-val-or-seq)
- (let [s (seq init-val-or-seq)]
- (loop [i 0 s s]
- (if (and s (< i size))
- (do
- (aset a i (first s))
- (recur (inc i) (next s)))
- a)))
- (do
- (dotimes [i size]
- (aset a i init-val-or-seq))
- a)))))
+ (let [a (make-array size)]
+ (if (seq? init-val-or-seq)
+ (let [s (seq init-val-or-seq)]
+ (loop [i 0 s s]
+ (if (and s (< i size))
+ (do
+ (aset a i (first s))
+ (recur (inc i) (next s)))
+ a)))
+ (do
+ (dotimes [i size]
+ (aset a i init-val-or-seq))
+ a)))))
(defn long-array
"Creates an array of longs. Does not coerce array, provided for compatibility
with Clojure."
([size-or-seq]
- (if (number? size-or-seq)
- (long-array size-or-seq nil)
- (into-array size-or-seq)))
+ (if (number? size-or-seq)
+ (long-array size-or-seq nil)
+ (into-array size-or-seq)))
([size init-val-or-seq]
- (let [a (make-array size)]
- (if (seq? init-val-or-seq)
- (let [s (seq init-val-or-seq)]
- (loop [i 0 s s]
- (if (and s (< i size))
- (do
- (aset a i (first s))
- (recur (inc i) (next s)))
- a)))
- (do
- (dotimes [i size]
- (aset a i init-val-or-seq))
- a)))))
+ (let [a (make-array size)]
+ (if (seq? init-val-or-seq)
+ (let [s (seq init-val-or-seq)]
+ (loop [i 0 s s]
+ (if (and s (< i size))
+ (do
+ (aset a i (first s))
+ (recur (inc i) (next s)))
+ a)))
+ (do
+ (dotimes [i size]
+ (aset a i init-val-or-seq))
+ a)))))
(defn double-array
"Creates an array of doubles. Does not coerce array, provided for compatibility
with Clojure."
([size-or-seq]
- (if (number? size-or-seq)
- (double-array size-or-seq nil)
- (into-array size-or-seq)))
+ (if (number? size-or-seq)
+ (double-array size-or-seq nil)
+ (into-array size-or-seq)))
([size init-val-or-seq]
- (let [a (make-array size)]
- (if (seq? init-val-or-seq)
- (let [s (seq init-val-or-seq)]
- (loop [i 0 s s]
- (if (and s (< i size))
- (do
- (aset a i (first s))
- (recur (inc i) (next s)))
- a)))
- (do
- (dotimes [i size]
- (aset a i init-val-or-seq))
- a)))))
+ (let [a (make-array size)]
+ (if (seq? init-val-or-seq)
+ (let [s (seq init-val-or-seq)]
+ (loop [i 0 s s]
+ (if (and s (< i size))
+ (do
+ (aset a i (first s))
+ (recur (inc i) (next s)))
+ a)))
+ (do
+ (dotimes [i size]
+ (aset a i init-val-or-seq))
+ a)))))
(defn object-array
"Creates an array of objects. Does not coerce array, provided for compatibility
with Clojure."
([size-or-seq]
- (if (number? size-or-seq)
- (object-array size-or-seq nil)
- (into-array size-or-seq)))
+ (if (number? size-or-seq)
+ (object-array size-or-seq nil)
+ (into-array size-or-seq)))
([size init-val-or-seq]
- (let [a (make-array size)]
- (if (seq? init-val-or-seq)
- (let [s (seq init-val-or-seq)]
- (loop [i 0 s s]
- (if (and s (< i size))
- (do
- (aset a i (first s))
- (recur (inc i) (next s)))
- a)))
- (do
- (dotimes [i size]
- (aset a i init-val-or-seq))
- a)))))
+ (let [a (make-array size)]
+ (if (seq? init-val-or-seq)
+ (let [s (seq init-val-or-seq)]
+ (loop [i 0 s s]
+ (if (and s (< i size))
+ (do
+ (aset a i (first s))
+ (recur (inc i) (next s)))
+ a)))
+ (do
+ (dotimes [i size]
+ (aset a i init-val-or-seq))
+ a)))))
(defn bounded-count
"If coll is counted? returns its count, else will count at most the first n
@@ -3773,25 +3773,25 @@ reduces them without incurring seq initialization"
([] (lazy-seq nil))
([x] (lazy-seq x))
([x y]
- (lazy-seq
- (let [s (seq x)]
- (if s
- (if (chunked-seq? s)
- (chunk-cons (chunk-first s) (concat (chunk-rest s) y))
- (cons (first s) (concat (rest s) y)))
- y))))
+ (lazy-seq
+ (let [s (seq x)]
+ (if s
+ (if (chunked-seq? s)
+ (chunk-cons (chunk-first s) (concat (chunk-rest s) y))
+ (cons (first s) (concat (rest s) y)))
+ y))))
([x y & zs]
- (let [cat (fn cat [xys zs]
- (lazy-seq
- (let [xys (seq xys)]
- (if xys
- (if (chunked-seq? xys)
- (chunk-cons (chunk-first xys)
- (cat (chunk-rest xys) zs))
- (cons (first xys) (cat (rest xys) zs)))
- (when zs
- (cat (first zs) (next zs)))))))]
- (cat (concat x y) zs))))
+ (let [cat (fn cat [xys zs]
+ (lazy-seq
+ (let [xys (seq xys)]
+ (if xys
+ (if (chunked-seq? xys)
+ (chunk-cons (chunk-first xys)
+ (cat (chunk-rest xys) zs))
+ (cons (first xys) (cat (rest xys) zs)))
+ (when zs
+ (cat (first zs) (next zs)))))))]
+ (cat (concat x y) zs))))
(defn list*
"Creates a new list containing the items prepended to the rest, the
@@ -3801,7 +3801,7 @@ reduces them without incurring seq initialization"
([a b args] (cons a (cons b args)))
([a b c args] (cons a (cons b (cons c args))))
([a b c d & more]
- (cons a (cons b (cons c (cons d (spread more)))))))
+ (cons a (cons b (cons c (cons d (spread more)))))))
;;; Transients
@@ -3824,34 +3824,34 @@ reduces them without incurring seq initialization"
([] (transient []))
([tcoll] tcoll)
([tcoll val]
- (-conj! tcoll val))
+ (-conj! tcoll val))
([tcoll val & vals]
- (let [ntcoll (-conj! tcoll val)]
- (if vals
- (recur ntcoll (first vals) (next vals))
- ntcoll))))
+ (let [ntcoll (-conj! tcoll val)]
+ (if vals
+ (recur ntcoll (first vals) (next vals))
+ ntcoll))))
(defn assoc!
"When applied to a transient map, adds mapping of key(s) to
val(s). When applied to a transient vector, sets the val at index.
Note - index must be <= (count vector). Returns coll."
([tcoll key val]
- (-assoc! tcoll key val))
+ (-assoc! tcoll key val))
([tcoll key val & kvs]
- (let [ntcoll (-assoc! tcoll key val)]
- (if kvs
- (recur ntcoll (first kvs) (second kvs) (nnext kvs))
- ntcoll))))
+ (let [ntcoll (-assoc! tcoll key val)]
+ (if kvs
+ (recur ntcoll (first kvs) (second kvs) (nnext kvs))
+ ntcoll))))
(defn dissoc!
"Returns a transient map that doesn't contain a mapping for key(s)."
([tcoll key]
- (-dissoc! tcoll key))
+ (-dissoc! tcoll key))
([tcoll key & ks]
- (let [ntcoll (-dissoc! tcoll key)]
- (if ks
- (recur ntcoll (first ks) (next ks))
- ntcoll))))
+ (let [ntcoll (-dissoc! tcoll key)]
+ (if ks
+ (recur ntcoll (first ks) (next ks))
+ ntcoll))))
(defn pop!
"Removes the last item from a transient vector. If
@@ -3863,12 +3863,12 @@ reduces them without incurring seq initialization"
"disj[oin]. Returns a transient set of the same (hashed/sorted) type, that
does not contain key(s)."
([tcoll val]
- (-disjoin! tcoll val))
+ (-disjoin! tcoll val))
([tcoll val & vals]
- (let [ntcoll (-disjoin! tcoll val)]
- (if vals
- (recur ntcoll (first vals) (next vals))
- ntcoll))))
+ (let [ntcoll (-disjoin! tcoll val)]
+ (if vals
+ (recur ntcoll (first vals) (next vals))
+ ntcoll))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; apply ;;;;;;;;;;;;;;;;
@@ -3963,7 +3963,7 @@ reduces them without incurring seq initialization"
(set! *unchecked-if* false)
(defn vary-meta
- "Returns an object of the same type and value as obj, with
+ "Returns an object of the same type and value as obj, with
(apply f (meta obj) args) as its metadata."
([obj f]
(with-meta obj (f (meta obj))))
@@ -4195,9 +4195,9 @@ reduces them without incurring seq initialization"
remaining items in other colls are ignored. The transform should accept
number-of-colls arguments"
([coll]
- (if (seq? coll)
- coll
- (or (seq coll) ())))
+ (if (seq? coll)
+ coll
+ (or (seq coll) ())))
([xform coll]
(or (chunkIteratorSeq
(.create TransformerIterator xform (iter coll)))
@@ -4212,9 +4212,9 @@ reduces them without incurring seq initialization"
false."
[pred coll]
(cond
- (nil? (seq coll)) true
- (pred (first coll)) (recur pred (next coll))
- :else false))
+ (nil? (seq coll)) true
+ (pred (first coll)) (recur pred (next coll))
+ :else false))
(defn not-every?
"Returns false if (pred x) is logical true for every x in
@@ -4237,7 +4237,7 @@ reduces them without incurring seq initialization"
(defn even?
"Returns true if n is even, throws an exception if n is not an integer"
- [n] (if (integer? n)
+ [n] (if (integer? n)
(zero? (bit-and n 1))
(throw (js/Error. (str "Argument must be an integer: " n)))))
@@ -4267,26 +4267,26 @@ reduces them without incurring seq initialization"
([] identity)
([f] f)
([f g]
- (fn
- ([] (f (g)))
- ([x] (f (g x)))
- ([x y] (f (g x y)))
- ([x y z] (f (g x y z)))
- ([x y z & args] (f (apply g x y z args)))))
+ (fn
+ ([] (f (g)))
+ ([x] (f (g x)))
+ ([x y] (f (g x y)))
+ ([x y z] (f (g x y z)))
+ ([x y z & args] (f (apply g x y z args)))))
([f g h]
- (fn
- ([] (f (g (h))))
- ([x] (f (g (h x))))
- ([x y] (f (g (h x y))))
- ([x y z] (f (g (h x y z))))
- ([x y z & args] (f (g (apply h x y z args))))))
+ (fn
+ ([] (f (g (h))))
+ ([x] (f (g (h x))))
+ ([x y] (f (g (h x y))))
+ ([x y z] (f (g (h x y z))))
+ ([x y z & args] (f (g (apply h x y z args))))))
([f1 f2 f3 & fs]
- (let [fs (reverse (list* f1 f2 f3 fs))]
- (fn [& args]
- (loop [ret (apply (first fs) args) fs (next fs)]
- (if fs
- (recur ((first fs) ret) (next fs))
- ret))))))
+ (let [fs (reverse (list* f1 f2 f3 fs))]
+ (fn [& args]
+ (loop [ret (apply (first fs) args) fs (next fs)]
+ (if fs
+ (recur ((first fs) ret) (next fs))
+ ret))))))
(defn partial
"Takes a function f and fewer than the normal arguments to f, and
@@ -4349,26 +4349,26 @@ reduces them without incurring seq initialization"
accept 2 arguments, index and item. Returns a stateful transducer when
no collection is provided."
([f]
- (fn [rf]
- (let [i (volatile! -1)]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (rf result (f (vswap! i inc) input)))))))
+ (fn [rf]
+ (let [i (volatile! -1)]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (rf result (f (vswap! i inc) input)))))))
([f coll]
- (letfn [(mapi [idx coll]
- (lazy-seq
- (when-let [s (seq coll)]
- (if (chunked-seq? s)
- (let [c (chunk-first s)
- size (count c)
- b (chunk-buffer size)]
- (dotimes [i size]
- (chunk-append b (f (+ idx i) (-nth c i))))
- (chunk-cons (chunk b) (mapi (+ idx size) (chunk-rest s))))
- (cons (f idx (first s)) (mapi (inc idx) (rest s)))))))]
- (mapi 0 coll))))
+ (letfn [(mapi [idx coll]
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (if (chunked-seq? s)
+ (let [c (chunk-first s)
+ size (count c)
+ b (chunk-buffer size)]
+ (dotimes [i size]
+ (chunk-append b (f (+ idx i) (-nth c i))))
+ (chunk-cons (chunk b) (mapi (+ idx size) (chunk-rest s))))
+ (cons (f idx (first s)) (mapi (inc idx) (rest s)))))))]
+ (mapi 0 coll))))
(defn keep
"Returns a lazy sequence of the non-nil results of (f item). Note,
@@ -4380,26 +4380,26 @@ reduces them without incurring seq initialization"
([] (rf))
([result] (rf result))
([result input]
- (let [v (f input)]
- (if (nil? v)
- result
- (rf result v)))))))
+ (let [v (f input)]
+ (if (nil? v)
+ result
+ (rf result v)))))))
([f coll]
(lazy-seq
- (when-let [s (seq coll)]
- (if (chunked-seq? s)
- (let [c (chunk-first s)
- size (count c)
- b (chunk-buffer size)]
- (dotimes [i size]
- (let [x (f (-nth c i))]
- (when-not (nil? x)
- (chunk-append b x))))
- (chunk-cons (chunk b) (keep f (chunk-rest s))))
- (let [x (f (first s))]
- (if (nil? x)
- (keep f (rest s))
- (cons x (keep f (rest s))))))))))
+ (when-let [s (seq coll)]
+ (if (chunked-seq? s)
+ (let [c (chunk-first s)
+ size (count c)
+ b (chunk-buffer size)]
+ (dotimes [i size]
+ (let [x (f (-nth c i))]
+ (when-not (nil? x)
+ (chunk-append b x))))
+ (chunk-cons (chunk b) (keep f (chunk-rest s))))
+ (let [x (f (first s))]
+ (if (nil? x)
+ (keep f (rest s))
+ (cons x (keep f (rest s))))))))))
;; =============================================================================
;; Atom
@@ -4581,29 +4581,29 @@ reduces them without incurring seq initialization"
([] (rf))
([result] (rf result))
([result input]
- (let [i (vswap! ia inc)
- v (f i input)]
- (if (nil? v)
- result
- (rf result v))))))))
+ (let [i (vswap! ia inc)
+ v (f i input)]
+ (if (nil? v)
+ result
+ (rf result v))))))))
([f coll]
- (letfn [(keepi [idx coll]
- (lazy-seq
- (when-let [s (seq coll)]
- (if (chunked-seq? s)
- (let [c (chunk-first s)
- size (count c)
- b (chunk-buffer size)]
- (dotimes [i size]
- (let [x (f (+ idx i) (-nth c i))]
- (when-not (nil? x)
- (chunk-append b x))))
- (chunk-cons (chunk b) (keepi (+ idx size) (chunk-rest s))))
- (let [x (f idx (first s))]
- (if (nil? x)
- (keepi (inc idx) (rest s))
- (cons x (keepi (inc idx) (rest s)))))))))]
- (keepi 0 coll))))
+ (letfn [(keepi [idx coll]
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (if (chunked-seq? s)
+ (let [c (chunk-first s)
+ size (count c)
+ b (chunk-buffer size)]
+ (dotimes [i size]
+ (let [x (f (+ idx i) (-nth c i))]
+ (when-not (nil? x)
+ (chunk-append b x))))
+ (chunk-cons (chunk b) (keepi (+ idx size) (chunk-rest s))))
+ (let [x (f idx (first s))]
+ (if (nil? x)
+ (keepi (inc idx) (rest s))
+ (cons x (keepi (inc idx) (rest s)))))))))]
+ (keepi 0 coll))))
(defn every-pred
"Takes a set of predicates and returns a function f that returns true if all of its
@@ -4611,38 +4611,38 @@ reduces them without incurring seq initialization"
false. Note that f is short-circuiting in that it will stop execution on the first
argument that triggers a logical false result against the original predicates."
([p]
- (fn ep1
- ([] true)
- ([x] (boolean (p x)))
- ([x y] (boolean (and (p x) (p y))))
- ([x y z] (boolean (and (p x) (p y) (p z))))
- ([x y z & args] (boolean (and (ep1 x y z)
- (every? p args))))))
+ (fn ep1
+ ([] true)
+ ([x] (boolean (p x)))
+ ([x y] (boolean (and (p x) (p y))))
+ ([x y z] (boolean (and (p x) (p y) (p z))))
+ ([x y z & args] (boolean (and (ep1 x y z)
+ (every? p args))))))
([p1 p2]
- (fn ep2
- ([] true)
- ([x] (boolean (and (p1 x) (p2 x))))
- ([x y] (boolean (and (p1 x) (p1 y) (p2 x) (p2 y))))
- ([x y z] (boolean (and (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z))))
- ([x y z & args] (boolean (and (ep2 x y z)
- (every? #(and (p1 %) (p2 %)) args))))))
+ (fn ep2
+ ([] true)
+ ([x] (boolean (and (p1 x) (p2 x))))
+ ([x y] (boolean (and (p1 x) (p1 y) (p2 x) (p2 y))))
+ ([x y z] (boolean (and (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z))))
+ ([x y z & args] (boolean (and (ep2 x y z)
+ (every? #(and (p1 %) (p2 %)) args))))))
([p1 p2 p3]
- (fn ep3
- ([] true)
- ([x] (boolean (and (p1 x) (p2 x) (p3 x))))
- ([x y] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y))))
- ([x y z] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z))))
- ([x y z & args] (boolean (and (ep3 x y z)
- (every? #(and (p1 %) (p2 %) (p3 %)) args))))))
+ (fn ep3
+ ([] true)
+ ([x] (boolean (and (p1 x) (p2 x) (p3 x))))
+ ([x y] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y))))
+ ([x y z] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z))))
+ ([x y z & args] (boolean (and (ep3 x y z)
+ (every? #(and (p1 %) (p2 %) (p3 %)) args))))))
([p1 p2 p3 & ps]
- (let [ps (list* p1 p2 p3 ps)]
- (fn epn
- ([] true)
- ([x] (every? #(% x) ps))
- ([x y] (every? #(and (% x) (% y)) ps))
- ([x y z] (every? #(and (% x) (% y) (% z)) ps))
- ([x y z & args] (boolean (and (epn x y z)
- (every? #(every? % args) ps))))))))
+ (let [ps (list* p1 p2 p3 ps)]
+ (fn epn
+ ([] true)
+ ([x] (every? #(% x) ps))
+ ([x y] (every? #(and (% x) (% y)) ps))
+ ([x y z] (every? #(and (% x) (% y) (% z)) ps))
+ ([x y z & args] (boolean (and (epn x y z)
+ (every? #(every? % args) ps))))))))
(defn some-fn
"Takes a set of predicates and returns a function f that returns the first logical true value
@@ -4650,38 +4650,38 @@ reduces them without incurring seq initialization"
logical false. Note that f is short-circuiting in that it will stop execution on the first
argument that triggers a logical true result against the original predicates."
([p]
- (fn sp1
- ([] nil)
- ([x] (p x))
- ([x y] (or (p x) (p y)))
- ([x y z] (or (p x) (p y) (p z)))
- ([x y z & args] (or (sp1 x y z)
- (some p args)))))
+ (fn sp1
+ ([] nil)
+ ([x] (p x))
+ ([x y] (or (p x) (p y)))
+ ([x y z] (or (p x) (p y) (p z)))
+ ([x y z & args] (or (sp1 x y z)
+ (some p args)))))
([p1 p2]
- (fn sp2
- ([] nil)
- ([x] (or (p1 x) (p2 x)))
- ([x y] (or (p1 x) (p1 y) (p2 x) (p2 y)))
- ([x y z] (or (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z)))
- ([x y z & args] (or (sp2 x y z)
- (some #(or (p1 %) (p2 %)) args)))))
+ (fn sp2
+ ([] nil)
+ ([x] (or (p1 x) (p2 x)))
+ ([x y] (or (p1 x) (p1 y) (p2 x) (p2 y)))
+ ([x y z] (or (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z)))
+ ([x y z & args] (or (sp2 x y z)
+ (some #(or (p1 %) (p2 %)) args)))))
([p1 p2 p3]
- (fn sp3
- ([] nil)
- ([x] (or (p1 x) (p2 x) (p3 x)))
- ([x y] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y)))
- ([x y z] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z)))
- ([x y z & args] (or (sp3 x y z)
- (some #(or (p1 %) (p2 %) (p3 %)) args)))))
+ (fn sp3
+ ([] nil)
+ ([x] (or (p1 x) (p2 x) (p3 x)))
+ ([x y] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y)))
+ ([x y z] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z)))
+ ([x y z & args] (or (sp3 x y z)
+ (some #(or (p1 %) (p2 %) (p3 %)) args)))))
([p1 p2 p3 & ps]
- (let [ps (list* p1 p2 p3 ps)]
- (fn spn
- ([] nil)
- ([x] (some #(% x) ps))
- ([x y] (some #(or (% x) (% y)) ps))
- ([x y z] (some #(or (% x) (% y) (% z)) ps))
- ([x y z & args] (or (spn x y z)
- (some #(some % args) ps)))))))
+ (let [ps (list* p1 p2 p3 ps)]
+ (fn spn
+ ([] nil)
+ ([x] (some #(% x) ps))
+ ([x y] (some #(or (% x) (% y)) ps))
+ ([x y z] (some #(or (% x) (% y) (% z)) ps))
+ ([x y z & args] (or (spn x y z)
+ (some #(some % args) ps)))))))
(defn map
"Returns a lazy sequence consisting of the result of applying f to
@@ -4691,40 +4691,40 @@ reduces them without incurring seq initialization"
f should accept number-of-colls arguments. Returns a transducer when
no collection is provided."
([f]
- (fn [rf]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (rf result (f input)))
- ([result input & inputs]
- (rf result (apply f input inputs))))))
+ (fn [rf]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (rf result (f input)))
+ ([result input & inputs]
+ (rf result (apply f input inputs))))))
([f coll]
(lazy-seq
- (when-let [s (seq coll)]
- (if (chunked-seq? s)
- (let [c (chunk-first s)
- size (count c)
- b (chunk-buffer size)]
- (dotimes [i size]
- (chunk-append b (f (-nth c i))))
- (chunk-cons (chunk b) (map f (chunk-rest s))))
- (cons (f (first s)) (map f (rest s)))))))
+ (when-let [s (seq coll)]
+ (if (chunked-seq? s)
+ (let [c (chunk-first s)
+ size (count c)
+ b (chunk-buffer size)]
+ (dotimes [i size]
+ (chunk-append b (f (-nth c i))))
+ (chunk-cons (chunk b) (map f (chunk-rest s))))
+ (cons (f (first s)) (map f (rest s)))))))
([f c1 c2]
(lazy-seq
- (let [s1 (seq c1) s2 (seq c2)]
- (when (and s1 s2)
- (cons (f (first s1) (first s2))
- (map f (rest s1) (rest s2)))))))
+ (let [s1 (seq c1) s2 (seq c2)]
+ (when (and s1 s2)
+ (cons (f (first s1) (first s2))
+ (map f (rest s1) (rest s2)))))))
([f c1 c2 c3]
(lazy-seq
- (let [s1 (seq c1) s2 (seq c2) s3 (seq c3)]
- (when (and s1 s2 s3)
- (cons (f (first s1) (first s2) (first s3))
- (map f (rest s1) (rest s2) (rest s3)))))))
+ (let [s1 (seq c1) s2 (seq c2) s3 (seq c3)]
+ (when (and s1 s2 s3)
+ (cons (f (first s1) (first s2) (first s3))
+ (map f (rest s1) (rest s2) (rest s3)))))))
([f c1 c2 c3 & colls]
(let [step (fn step [cs]
- (lazy-seq
+ (lazy-seq
(let [ss (map seq cs)]
(when (every? identity ss)
(cons (map first ss) (step (map rest ss)))))))]
@@ -4736,51 +4736,51 @@ reduces them without incurring seq initialization"
no collection is provided."
([n]
{:pre [(number? n)]}
- (fn [rf]
- (let [na (volatile! n)]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (let [n @na
- nn (vswap! na dec)
- result (if (pos? n)
- (rf result input)
- result)]
- (if (not (pos? nn))
- (ensure-reduced result)
- result)))))))
+ (fn [rf]
+ (let [na (volatile! n)]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (let [n @na
+ nn (vswap! na dec)
+ result (if (pos? n)
+ (rf result input)
+ result)]
+ (if (not (pos? nn))
+ (ensure-reduced result)
+ result)))))))
([n coll]
{:pre [(number? n)]}
- (lazy-seq
- (when (pos? n)
- (when-let [s (seq coll)]
- (cons (first s) (take (dec n) (rest s))))))))
+ (lazy-seq
+ (when (pos? n)
+ (when-let [s (seq coll)]
+ (cons (first s) (take (dec n) (rest s))))))))
(defn drop
"Returns a lazy sequence of all but the first n items in coll.
Returns a stateful transducer when no collection is provided."
([n]
{:pre [(number? n)]}
- (fn [rf]
- (let [na (volatile! n)]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (let [n @na]
- (vswap! na dec)
- (if (pos? n)
- result
- (rf result input))))))))
+ (fn [rf]
+ (let [na (volatile! n)]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (let [n @na]
+ (vswap! na dec)
+ (if (pos? n)
+ result
+ (rf result input))))))))
([n coll]
{:pre [(number? n)]}
- (let [step (fn [n coll]
- (let [s (seq coll)]
- (if (and (pos? n) s)
- (recur (dec n) (rest s))
- s)))]
- (lazy-seq (step n coll)))))
+ (let [step (fn [n coll]
+ (let [s (seq coll)]
+ (if (and (pos? n) s)
+ (recur (dec n) (rest s))
+ s)))]
+ (lazy-seq (step n coll)))))
(defn drop-last
"Return a lazy sequence of all but the last n (default 1) items in coll"
@@ -4801,25 +4801,25 @@ reduces them without incurring seq initialization"
first item for which (pred item) returns logical false. Returns a
stateful transducer when no collection is provided."
([pred]
- (fn [rf]
- (let [da (volatile! true)]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (let [drop? @da]
- (if (and drop? (pred input))
- result
- (do
- (vreset! da nil)
- (rf result input)))))))))
+ (fn [rf]
+ (let [da (volatile! true)]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (let [drop? @da]
+ (if (and drop? (pred input))
+ result
+ (do
+ (vreset! da nil)
+ (rf result input)))))))))
([pred coll]
- (let [step (fn [pred coll]
- (let [s (seq coll)]
- (if (and s (pred (first s)))
- (recur pred (rest s))
- s)))]
- (lazy-seq (step pred coll)))))
+ (let [step (fn [pred coll]
+ (let [s (seq coll)]
+ (if (and s (pred (first s)))
+ (recur pred (rest s))
+ s)))]
+ (lazy-seq (step pred coll)))))
(deftype Cycle [meta all prev ^:mutable current ^:mutable _next]
Object
@@ -5080,35 +5080,35 @@ reduces them without incurring seq initialization"
([] ())
([c1] (lazy-seq c1))
([c1 c2]
- (lazy-seq
- (let [s1 (seq c1) s2 (seq c2)]
- (when (and s1 s2)
- (cons (first s1) (cons (first s2)
- (interleave (rest s1) (rest s2))))))))
+ (lazy-seq
+ (let [s1 (seq c1) s2 (seq c2)]
+ (when (and s1 s2)
+ (cons (first s1) (cons (first s2)
+ (interleave (rest s1) (rest s2))))))))
([c1 c2 & colls]
- (lazy-seq
- (let [ss (map seq (conj colls c2 c1))]
- (when (every? identity ss)
- (concat (map first ss) (apply interleave (map rest ss))))))))
+ (lazy-seq
+ (let [ss (map seq (conj colls c2 c1))]
+ (when (every? identity ss)
+ (concat (map first ss) (apply interleave (map rest ss))))))))
(defn interpose
"Returns a lazy seq of the elements of coll separated by sep.
Returns a stateful transducer when no collection is provided."
([sep]
- (fn [rf]
- (let [started (volatile! false)]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (if @started
- (let [sepr (rf result sep)]
- (if (reduced? sepr)
- sepr
- (rf sepr input)))
- (do
- (vreset! started true)
- (rf result input))))))))
+ (fn [rf]
+ (let [started (volatile! false)]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (if @started
+ (let [sepr (rf result sep)]
+ (if (reduced? sepr)
+ sepr
+ (rf sepr input)))
+ (do
+ (vreset! started true)
+ (rf result input))))))))
([sep coll] (drop 1 (interleave (repeat sep) coll))))
@@ -5135,36 +5135,36 @@ reduces them without incurring seq initialization"
:static true}
([f] (comp (map f) cat))
([f & colls]
- (apply concat (apply map f colls))))
+ (apply concat (apply map f colls))))
(defn filter
"Returns a lazy sequence of the items in coll for which
(pred item) returns logical true. pred must be free of side-effects.
Returns a transducer when no collection is provided."
([pred]
- (fn [rf]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (if (pred input)
- (rf result input)
- result)))))
+ (fn [rf]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (if (pred input)
+ (rf result input)
+ result)))))
([pred coll]
(lazy-seq
- (when-let [s (seq coll)]
- (if (chunked-seq? s)
- (let [c (chunk-first s)
- size (count c)
- b (chunk-buffer size)]
- (dotimes [i size]
- (when (pred (-nth c i))
- (chunk-append b (-nth c i))))
- (chunk-cons (chunk b) (filter pred (chunk-rest s))))
- (let [f (first s) r (rest s)]
- (if (pred f)
- (cons f (filter pred r))
- (filter pred r))))))))
+ (when-let [s (seq coll)]
+ (if (chunked-seq? s)
+ (let [c (chunk-first s)
+ size (count c)
+ b (chunk-buffer size)]
+ (dotimes [i size]
+ (when (pred (-nth c i))
+ (chunk-append b (-nth c i))))
+ (chunk-cons (chunk b) (filter pred (chunk-rest s))))
+ (let [f (first s) r (rest s)]
+ (if (pred f)
+ (cons f (filter pred r))
+ (filter pred r))))))))
(defn remove
"Returns a lazy sequence of the items in coll for which
@@ -5172,7 +5172,7 @@ reduces them without incurring seq initialization"
Returns a transducer when no collection is provided."
([pred] (filter (complement pred)))
([pred coll]
- (filter (complement pred) coll)))
+ (filter (complement pred) coll)))
(defn tree-seq
"Returns a lazy sequence of the nodes in a tree, via a depth-first walk.
@@ -5181,13 +5181,13 @@ reduces them without incurring seq initialization"
arg that returns a sequence of the children. Will only be called on
nodes for which branch? returns true. Root is the root node of the
tree."
- [branch? children root]
- (let [walk (fn walk [node]
- (lazy-seq
+ [branch? children root]
+ (let [walk (fn walk [node]
+ (lazy-seq
(cons node
- (when (branch? node)
- (mapcat walk (children node))))))]
- (walk root)))
+ (when (branch? node)
+ (mapcat walk (children node))))))]
+ (walk root)))
(defn flatten
"Takes any nested combination of sequential things (lists, vectors,
@@ -5203,15 +5203,15 @@ reduces them without incurring seq initialization"
([] [])
([to] to)
([to from]
- (if-not (nil? to)
- (if (implements? IEditableCollection to)
- (-with-meta (persistent! (reduce -conj! (transient to) from)) (meta to))
- (reduce -conj to from))
- (reduce conj () from)))
- ([to xform from]
+ (if-not (nil? to)
(if (implements? IEditableCollection to)
- (-with-meta (persistent! (transduce xform conj! (transient to) from)) (meta to))
- (transduce xform conj to from))))
+ (-with-meta (persistent! (reduce -conj! (transient to) from)) (meta to))
+ (reduce -conj to from))
+ (reduce conj () from)))
+ ([to xform from]
+ (if (implements? IEditableCollection to)
+ (-with-meta (persistent! (transduce xform conj! (transient to) from)) (meta to))
+ (transduce xform conj to from))))
(defn mapv
"Returns a vector consisting of the result of applying f to the
@@ -5220,14 +5220,14 @@ reduces them without incurring seq initialization"
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments."
([f coll]
- (-> (reduce (fn [v o] (conj! v (f o))) (transient []) coll)
- persistent!))
+ (-> (reduce (fn [v o] (conj! v (f o))) (transient []) coll)
+ persistent!))
([f c1 c2]
- (into [] (map f c1 c2)))
+ (into [] (map f c1 c2)))
([f c1 c2 c3]
- (into [] (map f c1 c2 c3)))
+ (into [] (map f c1 c2 c3)))
([f c1 c2 c3 & colls]
- (into [] (apply map f c1 c2 c3 colls))))
+ (into [] (apply map f c1 c2 c3 colls))))
(defn filterv
"Returns a vector of the items in coll for which
@@ -5245,20 +5245,20 @@ reduces them without incurring seq initialization"
necessary to complete last partition up to n items. In case there are
not enough padding elements, return a partition with less than n items."
([n coll]
- (partition n n coll))
+ (partition n n coll))
([n step coll]
- (lazy-seq
- (when-let [s (seq coll)]
- (let [p (take n s)]
- (when (== n (count p))
- (cons p (partition n step (drop step s))))))))
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (let [p (take n s)]
+ (when (== n (count p))
+ (cons p (partition n step (drop step s))))))))
([n step pad coll]
- (lazy-seq
- (when-let [s (seq coll)]
- (let [p (take n s)]
- (if (== n (count p))
- (cons p (partition n step pad (drop step s)))
- (list (take n (concat p pad)))))))))
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (let [p (take n s)]
+ (if (== n (count p))
+ (cons p (partition n step pad (drop step s)))
+ (list (take n (concat p pad)))))))))
(defn get-in
"Returns the value in a nested associative structure,
@@ -5267,17 +5267,17 @@ reduces them without incurring seq initialization"
{:added "1.2"
:static true}
([m ks]
- (reduce get m ks))
+ (reduce get m ks))
([m ks not-found]
- (loop [sentinel lookup-sentinel
- m m
- ks (seq ks)]
- (if-not (nil? ks)
- (let [m (get m (first ks) sentinel)]
- (if (identical? sentinel m)
- not-found
- (recur sentinel m (next ks))))
- m))))
+ (loop [sentinel lookup-sentinel
+ m m
+ ks (seq ks)]
+ (if-not (nil? ks)
+ (let [m (get m (first ks) sentinel)]
+ (if (identical? sentinel m)
+ not-found
+ (recur sentinel m (next ks))))
+ m))))
(defn assoc-in
"Associates a value in a nested associative structure, where ks is a
@@ -5419,16 +5419,16 @@ reduces them without incurring seq initialization"
(defn- pop-tail [pv level node]
(let [subidx (bit-and (bit-shift-right-zero-fill (- (.-cnt pv) 2) level) 0x01f)]
(cond
- (> level 5) (let [new-child (pop-tail pv (- level 5) (pv-aget node subidx))]
- (if (and (nil? new-child) (zero? subidx))
- nil
- (let [ret (pv-clone-node node)]
- (pv-aset ret subidx new-child)
- ret)))
- (zero? subidx) nil
- :else (let [ret (pv-clone-node node)]
- (pv-aset ret subidx nil)
- ret))))
+ (> level 5) (let [new-child (pop-tail pv (- level 5) (pv-aget node subidx))]
+ (if (and (nil? new-child) (zero? subidx))
+ nil
+ (let [ret (pv-clone-node node)]
+ (pv-aset ret subidx new-child)
+ ret)))
+ (zero? subidx) nil
+ :else (let [ret (pv-clone-node node)]
+ (pv-aset ret subidx nil)
+ ret))))
(deftype RangedIterator [^:mutable i ^:mutable base ^:mutable arr v start end]
Object
@@ -5504,9 +5504,9 @@ reduces them without incurring seq initialization"
(-nth coll (dec cnt))))
(-pop [coll]
(cond
- (zero? cnt) (throw (js/Error. "Can't pop empty vector"))
- (== 1 cnt) (-with-meta (.-EMPTY PersistentVector) meta)
- (< 1 (- cnt (tail-off coll)))
+ (zero? cnt) (throw (js/Error. "Can't pop empty vector"))
+ (== 1 cnt) (-with-meta (.-EMPTY PersistentVector) meta)
+ (< 1 (- cnt (tail-off coll)))
(PersistentVector. meta (dec cnt) shift root (.slice tail 0 -1) nil)
:else (let [new-tail (unchecked-array-for coll (- cnt 2))
nr (pop-tail coll shift root)
@@ -5529,9 +5529,9 @@ reduces them without incurring seq initialization"
new-shift (if root-overflow? (+ shift 5) shift)
new-root (if root-overflow?
(let [n-r (pv-fresh-node nil)]
- (pv-aset n-r 0 root)
- (pv-aset n-r 1 (new-path nil shift (VectorNode. nil tail)))
- n-r)
+ (pv-aset n-r 0 root)
+ (pv-aset n-r 1 (new-path nil shift (VectorNode. nil tail)))
+ n-r)
(push-tail coll shift root (VectorNode. nil tail)))]
(PersistentVector. meta (inc cnt) new-shift new-root (array o) nil))))
@@ -5602,14 +5602,14 @@ reduces them without incurring seq initialization"
IVector
(-assoc-n [coll n val]
(cond
- (and (<= 0 n) (< n cnt))
- (if (<= (tail-off coll) n)
- (let [new-tail (aclone tail)]
- (aset new-tail (bit-and n 0x01f) val)
- (PersistentVector. meta cnt shift root new-tail nil))
- (PersistentVector. meta cnt shift (do-assoc coll shift root n val) tail nil))
- (== n cnt) (-conj coll val)
- :else (throw (js/Error. (str "Index " n " out of bounds [0," cnt "]")))))
+ (and (<= 0 n) (< n cnt))
+ (if (<= (tail-off coll) n)
+ (let [new-tail (aclone tail)]
+ (aset new-tail (bit-and n 0x01f) val)
+ (PersistentVector. meta cnt shift root new-tail nil))
+ (PersistentVector. meta cnt shift (do-assoc coll shift root n val) tail nil))
+ (== n cnt) (-conj coll val)
+ :else (throw (js/Error. (str "Index " n " out of bounds [0," cnt "]")))))
IReduce
(-reduce [v f]
@@ -5809,7 +5809,7 @@ reduces them without incurring seq initialization"
([vec i off] (ChunkedSeq. vec (array-for vec i) i off nil nil))
([vec node i off] (ChunkedSeq. vec node i off nil nil))
([vec node i off meta]
- (ChunkedSeq. vec node i off meta nil)))
+ (ChunkedSeq. vec node i off meta nil)))
(declare build-subvec)
@@ -5868,7 +5868,7 @@ reduces them without incurring seq initialization"
(when-not (== i end)
(cons (-nth v i)
(lazy-seq
- (subvec-seq (inc i))))))]
+ (subvec-seq (inc i))))))]
(subvec-seq start)))
IReversible
@@ -6005,7 +6005,7 @@ reduces them without incurring seq initialization"
subidx (bit-and (bit-shift-right-zero-fill (- (.-cnt tv) 2) level) 0x01f)]
(cond
(> level 5) (let [new-child (tv-pop-tail
- tv (- level 5) (pv-aget node subidx))]
+ tv (- level 5) (pv-aget node subidx))]
(if (and (nil? new-child) (zero? subidx))
nil
(do (pv-aset node subidx new-child)
@@ -6101,8 +6101,8 @@ reduces them without incurring seq initialization"
(== n cnt) (-conj! tcoll val)
:else
(throw
- (js/Error.
- (str "Index " n " out of bounds for TransientVector of length" cnt))))
+ (js/Error.
+ (str "Index " n " out of bounds for TransientVector of length" cnt))))
(throw (js/Error. "assoc! after persistent!"))))
(-pop! [tcoll]
@@ -6356,9 +6356,9 @@ reduces them without incurring seq initialization"
(let [a (hash a)
b (hash b)]
(cond
- (< a b) -1
- (> a b) 1
- :else 0)))
+ (< a b) -1
+ (> a b) 1
+ :else 0)))
(defn- obj-map->hash-map [m k v]
(let [ks (.-keys m)
@@ -7130,12 +7130,12 @@ reduces them without incurring seq initialization"
(defn- clone-and-set
([arr i a]
- (doto (aclone arr)
- (aset i a)))
+ (doto (aclone arr)
+ (aset i a)))
([arr i a j b]
- (doto (aclone arr)
- (aset i a)
- (aset j b))))
+ (doto (aclone arr)
+ (aset i a)
+ (aset j b))))
(defn- remove-pair [arr i]
(let [new-arr (make-array (- (alength arr) 2))]
@@ -7151,14 +7151,14 @@ reduces them without incurring seq initialization"
(defn- edit-and-set
([inode edit i a]
- (let [editable (.ensure-editable inode edit)]
- (aset (.-arr editable) i a)
- editable))
+ (let [editable (.ensure-editable inode edit)]
+ (aset (.-arr editable) i a)
+ editable))
([inode edit i a j b]
- (let [editable (.ensure-editable inode edit)]
- (aset (.-arr editable) i a)
- (aset (.-arr editable) j b)
- editable)))
+ (let [editable (.ensure-editable inode edit)]
+ (aset (.-arr editable) i a)
+ (aset (.-arr editable) j b)
+ editable)))
(defn- inode-kv-reduce [arr f init]
(let [len (alength arr)]
@@ -7178,7 +7178,7 @@ reduces them without incurring seq initialization"
(declare ArrayNode)
- (deftype NodeIterator [arr ^:mutable i ^:mutable next-entry ^:mutable next-iter]
+(deftype NodeIterator [arr ^:mutable i ^:mutable next-entry ^:mutable next-iter]
Object
(advance [this]
(let [len (alength arr)]
@@ -7548,8 +7548,8 @@ reduces them without incurring seq initialization"
(recur (inc i) init)))
init))))
- IIterable
- (-iterator [coll]
+ IIterable
+ (-iterator [coll]
(ArrayNodeIterator. arr 0 nil)))
(defn- hash-collision-node-find-index [arr cnt key]
@@ -7665,21 +7665,21 @@ reduces them without incurring seq initialization"
(defn- create-node
([shift key1 val1 key2hash key2 val2]
- (let [key1hash (hash key1)]
- (if (== key1hash key2hash)
- (HashCollisionNode. nil key1hash 2 (array key1 val1 key2 val2))
- (let [added-leaf? (Box. false)]
- (-> (.-EMPTY BitmapIndexedNode)
- (.inode-assoc shift key1hash key1 val1 added-leaf?)
- (.inode-assoc shift key2hash key2 val2 added-leaf?))))))
+ (let [key1hash (hash key1)]
+ (if (== key1hash key2hash)
+ (HashCollisionNode. nil key1hash 2 (array key1 val1 key2 val2))
+ (let [added-leaf? (Box. false)]
+ (-> (.-EMPTY BitmapIndexedNode)
+ (.inode-assoc shift key1hash key1 val1 added-leaf?)
+ (.inode-assoc shift key2hash key2 val2 added-leaf?))))))
([edit shift key1 val1 key2hash key2 val2]
- (let [key1hash (hash key1)]
- (if (== key1hash key2hash)
- (HashCollisionNode. nil key1hash 2 (array key1 val1 key2 val2))
- (let [added-leaf? (Box. false)]
- (-> (.-EMPTY BitmapIndexedNode)
- (.inode-assoc! edit shift key1hash key1 val1 added-leaf?)
- (.inode-assoc! edit shift key2hash key2 val2 added-leaf?)))))))
+ (let [key1hash (hash key1)]
+ (if (== key1hash key2hash)
+ (HashCollisionNode. nil key1hash 2 (array key1 val1 key2 val2))
+ (let [added-leaf? (Box. false)]
+ (-> (.-EMPTY BitmapIndexedNode)
+ (.inode-assoc! edit shift key1hash key1 val1 added-leaf?)
+ (.inode-assoc! edit shift key2hash key2 val2 added-leaf?)))))))
(deftype NodeSeq [meta nodes i s ^:mutable __hash]
Object
@@ -7747,20 +7747,20 @@ reduces them without incurring seq initialization"
(defn- create-inode-seq
([nodes]
- (create-inode-seq nodes 0 nil))
+ (create-inode-seq nodes 0 nil))
([nodes i s]
- (if (nil? s)
- (let [len (alength nodes)]
- (loop [j i]
- (if (< j len)
- (if-not (nil? (aget nodes j))
- (NodeSeq. nil nodes j nil nil)
- (if-let [node (aget nodes (inc j))]
- (if-let [node-seq (.inode-seq node)]
- (NodeSeq. nil nodes (+ j 2) node-seq nil)
- (recur (+ j 2)))
- (recur (+ j 2)))))))
- (NodeSeq. nil nodes i s nil))))
+ (if (nil? s)
+ (let [len (alength nodes)]
+ (loop [j i]
+ (if (< j len)
+ (if-not (nil? (aget nodes j))
+ (NodeSeq. nil nodes j nil nil)
+ (if-let [node (aget nodes (inc j))]
+ (if-let [node-seq (.inode-seq node)]
+ (NodeSeq. nil nodes (+ j 2) node-seq nil)
+ (recur (+ j 2)))
+ (recur (+ j 2)))))))
+ (NodeSeq. nil nodes i s nil))))
(deftype ArrayNodeSeq [meta nodes i s ^:mutable __hash]
Object
@@ -7821,16 +7821,16 @@ reduces them without incurring seq initialization"
(defn- create-array-node-seq
([nodes] (create-array-node-seq nodes 0 nil))
([nodes i s]
- (if (nil? s)
- (let [len (alength nodes)]
- (loop [j i]
- (if (< j len)
- (if-let [nj (aget nodes j)]
- (if-let [ns (.inode-seq nj)]
- (ArrayNodeSeq. nil nodes (inc j) ns nil)
- (recur (inc j)))
- (recur (inc j))))))
- (ArrayNodeSeq. nil nodes i s nil))))
+ (if (nil? s)
+ (let [len (alength nodes)]
+ (loop [j i]
+ (if (< j len)
+ (if-let [nj (aget nodes j)]
+ (if-let [ns (.inode-seq nj)]
+ (ArrayNodeSeq. nil nodes (inc j) ns nil)
+ (recur (inc j)))
+ (recur (inc j))))))
+ (ArrayNodeSeq. nil nodes i s nil))))
(deftype HashMapIter [nil-val root-iter ^:mutable seen]
Object
@@ -8227,9 +8227,9 @@ reduces them without incurring seq initialization"
(cond
(instance? RedNode (.-left ins))
(RedNode. (.-key ins) (.-val ins)
- (.blacken (.-left ins))
- (BlackNode. key val (.-right ins) right nil)
- nil)
+ (.blacken (.-left ins))
+ (BlackNode. key val (.-right ins) right nil)
+ nil)
(instance? RedNode (.-right ins))
(RedNode. (.. ins -right -key) (.. ins -right -val)
@@ -8908,20 +8908,20 @@ reduces them without incurring seq initialization"
"keyval => key val
Returns a new sorted map with supplied mappings."
([& keyvals]
- (loop [in (seq keyvals) out (.-EMPTY PersistentTreeMap)]
- (if in
- (recur (nnext in) (assoc out (first in) (second in)))
- out))))
+ (loop [in (seq keyvals) out (.-EMPTY PersistentTreeMap)]
+ (if in
+ (recur (nnext in) (assoc out (first in) (second in)))
+ out))))
(defn sorted-map-by
"keyval => key val
Returns a new sorted map with supplied mappings, using the supplied comparator."
([comparator & keyvals]
- (loop [in (seq keyvals)
- out (PersistentTreeMap. (fn->comparator comparator) nil 0 nil 0)]
- (if in
- (recur (nnext in) (assoc out (first in) (second in)))
- out))))
+ (loop [in (seq keyvals)
+ out (PersistentTreeMap. (fn->comparator comparator) nil 0 nil 0)]
+ (if in
+ (recur (nnext in) (assoc out (first in) (second in)))
+ out))))
(deftype KeySeq [^not-native mseq _meta]
Object
@@ -9108,16 +9108,16 @@ reduces them without incurring seq initialization"
(defn select-keys
"Returns a map containing only those entries in map whose key is in keys"
[map keyseq]
- (loop [ret {} keys (seq keyseq)]
- (if keys
- (let [key (first keys)
- entry (get map key ::not-found)]
- (recur
- (if (not= entry ::not-found)
- (assoc ret key entry)
- ret)
- (next keys)))
- (-with-meta ret (meta map)))))
+ (loop [ret {} keys (seq keyseq)]
+ (if keys
+ (let [key (first keys)
+ entry (get map key ::not-found)]
+ (recur
+ (if (not= entry ::not-found)
+ (assoc ret key entry)
+ ret)
+ (next keys)))
+ (-with-meta ret (meta map)))))
;;; PersistentHashSet
@@ -9179,15 +9179,15 @@ reduces them without incurring seq initialization"
IEquiv
(-equiv [coll other]
(and
- (set? other)
- (== (count coll) (count other))
- ^boolean
- (try
- (reduce-kv
- #(or (contains? other %2) (reduced false))
- true hash-map)
- (catch js/Error ex
- false))))
+ (set? other)
+ (== (count coll) (count other))
+ ^boolean
+ (try
+ (reduce-kv
+ #(or (contains? other %2) (reduced false))
+ true hash-map)
+ (catch js/Error ex
+ false))))
IHash
(-hash [coll] (caching-hash coll hash-unordered-coll __hash))
@@ -9232,11 +9232,11 @@ reduces them without incurring seq initialization"
(if (< i len)
(recur (inc i) (-assoc! out (aget items i) nil))
(PersistentHashSet. nil (-persistent! out) nil))))
- (loop [i 0
- out (transient (.-EMPTY PersistentHashSet))]
- (if (< i len)
- (recur (inc i) (-conj! out (aget items i)))
- (-persistent! out)))))))
+ (loop [i 0
+ out (transient (.-EMPTY PersistentHashSet))]
+ (if (< i len)
+ (recur (inc i) (-conj! out (aget items i)))
+ (-persistent! out)))))))
(set! (.-createWithCheck PersistentHashSet)
(fn [items]
@@ -9336,15 +9336,15 @@ reduces them without incurring seq initialization"
IEquiv
(-equiv [coll other]
(and
- (set? other)
- (== (count coll) (count other))
- ^boolean
- (try
- (reduce-kv
- #(or (contains? other %2) (reduced false))
- true tree-map)
- (catch js/Error ex
- false))))
+ (set? other)
+ (== (count coll) (count other))
+ ^boolean
+ (try
+ (reduce-kv
+ #(or (contains? other %2) (reduced false))
+ true tree-map)
+ (catch js/Error ex
+ false))))
IHash
(-hash [coll] (caching-hash coll hash-unordered-coll __hash))
@@ -9444,41 +9444,41 @@ reduces them without incurring seq initialization"
corresponding val in smap. Returns a transducer when no collection
is provided."
([smap]
- (map #(if-let [e (find smap %)] (val e) %)))
+ (map #(if-let [e (find smap %)] (val e) %)))
([smap coll]
- (if (vector? coll)
- (let [n (count coll)]
- (reduce (fn [v i]
- (if-let [e (find smap (nth v i))]
- (assoc v i (second e))
- v))
- coll (take n (iterate inc 0))))
- (map #(if-let [e (find smap %)] (second e) %) coll))))
+ (if (vector? coll)
+ (let [n (count coll)]
+ (reduce (fn [v i]
+ (if-let [e (find smap (nth v i))]
+ (assoc v i (second e))
+ v))
+ coll (take n (iterate inc 0))))
+ (map #(if-let [e (find smap %)] (second e) %) coll))))
(defn distinct
"Returns a lazy sequence of the elements of coll with duplicates removed.
Returns a stateful transducer when no collection is provided."
([]
- (fn [rf]
- (let [seen (volatile! #{})]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (if (contains? @seen input)
- result
- (do (vswap! seen conj input)
- (rf result input))))))))
+ (fn [rf]
+ (let [seen (volatile! #{})]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (if (contains? @seen input)
+ result
+ (do (vswap! seen conj input)
+ (rf result input))))))))
([coll]
- (let [step (fn step [xs seen]
- (lazy-seq
- ((fn [[f :as xs] seen]
- (when-let [s (seq xs)]
- (if (contains? seen f)
- (recur (rest s) seen)
- (cons f (step (rest s) (conj seen f))))))
- xs seen)))]
- (step coll #{}))))
+ (let [step (fn step [xs seen]
+ (lazy-seq
+ ((fn [[f :as xs] seen]
+ (when-let [s (seq xs)]
+ (if (contains? seen f)
+ (recur (rest s) seen)
+ (cons f (step (rest s) (conj seen f))))))
+ xs seen)))]
+ (step coll #{}))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn butlast
@@ -9501,14 +9501,14 @@ reduces them without incurring seq initialization"
(defn zipmap
"Returns a map with the keys mapped to the corresponding vals."
[keys vals]
- (loop [map (transient {})
- ks (seq keys)
- vs (seq vals)]
- (if (and ks vs)
- (recur (assoc! map (first ks) (first vs))
- (next ks)
- (next vs))
- (persistent! map))))
+ (loop [map (transient {})
+ ks (seq keys)
+ vs (seq vals)]
+ (if (and ks vs)
+ (recur (assoc! map (first ks) (first vs))
+ (next ks)
+ (next vs))
+ (persistent! map))))
(defn max-key
"Returns the x for which (k x), a number, is greatest.
@@ -9526,7 +9526,7 @@ reduces them without incurring seq initialization"
([k x] x)
([k x y] (if (< (k x) (k y)) x y))
([k x y & more]
- (reduce #(min-key k %1 %2) (min-key k x y) more)))
+ (reduce #(min-key k %1 %2) (min-key k x y) more)))
(deftype ArrayList [^:mutable arr]
Object
@@ -9549,45 +9549,45 @@ reduces them without incurring seq initialization"
(fn
([] (rf))
([result]
- (let [result (if (.isEmpty a)
- result
- (let [v (vec (.toArray a))]
- ;;clear first!
- (.clear a)
- (unreduced (rf result v))))]
- (rf result)))
+ (let [result (if (.isEmpty a)
+ result
+ (let [v (vec (.toArray a))]
+ ;;clear first!
+ (.clear a)
+ (unreduced (rf result v))))]
+ (rf result)))
([result input]
- (.add a input)
- (if (== n (.size a))
- (let [v (vec (.toArray a))]
- (.clear a)
- (rf result v))
- result))))))
+ (.add a input)
+ (if (== n (.size a))
+ (let [v (vec (.toArray a))]
+ (.clear a)
+ (rf result v))
+ result))))))
([n coll]
- (partition-all n n coll))
+ (partition-all n n coll))
([n step coll]
- (lazy-seq
- (when-let [s (seq coll)]
- (cons (take n s) (partition-all n step (drop step s)))))))
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (cons (take n s) (partition-all n step (drop step s)))))))
(defn take-while
"Returns a lazy sequence of successive items from coll while
(pred item) returns logical true. pred must be free of side-effects.
Returns a transducer when no collection is provided."
([pred]
- (fn [rf]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (if (pred input)
- (rf result input)
- (reduced result))))))
+ (fn [rf]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (if (pred input)
+ (rf result input)
+ (reduced result))))))
([pred coll]
- (lazy-seq
- (when-let [s (seq coll)]
- (when (pred (first s))
- (cons (first s) (take-while pred (rest s))))))))
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (when (pred (first s))
+ (cons (first s) (take-while pred (rest s))))))))
(defn mk-bound-fn
[sc test key]
@@ -9600,30 +9600,30 @@ reduces them without incurring seq initialization"
>=. Returns a seq of those entries with keys ek for
which (test (.. sc comparator (compare ek key)) 0) is true"
([sc test key]
- (let [include (mk-bound-fn sc test key)]
- (if (#{> >=} test)
- (when-let [[e :as s] (-sorted-seq-from sc key true)]
- (if (include e) s (next s)))
- (take-while include (-sorted-seq sc true)))))
+ (let [include (mk-bound-fn sc test key)]
+ (if (#{> >=} test)
+ (when-let [[e :as s] (-sorted-seq-from sc key true)]
+ (if (include e) s (next s)))
+ (take-while include (-sorted-seq sc true)))))
([sc start-test start-key end-test end-key]
- (when-let [[e :as s] (-sorted-seq-from sc start-key true)]
- (take-while (mk-bound-fn sc end-test end-key)
- (if ((mk-bound-fn sc start-test start-key) e) s (next s))))))
+ (when-let [[e :as s] (-sorted-seq-from sc start-key true)]
+ (take-while (mk-bound-fn sc end-test end-key)
+ (if ((mk-bound-fn sc start-test start-key) e) s (next s))))))
(defn rsubseq
"sc must be a sorted collection, test(s) one of <, <=, > or
>=. Returns a reverse seq of those entries with keys ek for
which (test (.. sc comparator (compare ek key)) 0) is true"
([sc test key]
- (let [include (mk-bound-fn sc test key)]
- (if (#{< <=} test)
- (when-let [[e :as s] (-sorted-seq-from sc key false)]
- (if (include e) s (next s)))
- (take-while include (-sorted-seq sc false)))))
+ (let [include (mk-bound-fn sc test key)]
+ (if (#{< <=} test)
+ (when-let [[e :as s] (-sorted-seq-from sc key false)]
+ (if (include e) s (next s)))
+ (take-while include (-sorted-seq sc false)))))
([sc start-test start-key end-test end-key]
- (when-let [[e :as s] (-sorted-seq-from sc end-key false)]
- (take-while (mk-bound-fn sc start-test start-key)
- (if ((mk-bound-fn sc end-test end-key) e) s (next s))))))
+ (when-let [[e :as s] (-sorted-seq-from sc end-key false)]
+ (take-while (mk-bound-fn sc start-test start-key)
+ (if ((mk-bound-fn sc end-test end-key) e) s (next s))))))
(deftype RangeChunk [start step count]
ICounted
@@ -9802,21 +9802,21 @@ reduces them without incurring seq initialization"
transducer when no collection is provided."
([n]
{:pre [(number? n)]}
- (fn [rf]
- (let [ia (volatile! -1)]
- (fn
- ([] (rf))
- ([result] (rf result))
- ([result input]
- (let [i (vswap! ia inc)]
- (if (zero? (rem i n))
- (rf result input)
- result)))))))
+ (fn [rf]
+ (let [ia (volatile! -1)]
+ (fn
+ ([] (rf))
+ ([result] (rf result))
+ ([result input]
+ (let [i (vswap! ia inc)]
+ (if (zero? (rem i n))
+ (rf result input)
+ result)))))))
([n coll]
{:pre [(number? n)]}
- (lazy-seq
- (when-let [s (seq coll)]
- (cons (first s) (take-nth n (drop n s)))))))
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (cons (first s) (take-nth n (drop n s)))))))
(defn split-with
"Returns a vector of [(take-while pred coll) (drop-while pred coll)]"
@@ -9828,50 +9828,50 @@ reduces them without incurring seq initialization"
new value. Returns a lazy seq of partitions. Returns a stateful
transducer when no collection is provided."
([f]
- (fn [rf]
- (let [a (array-list)
- pa (volatile! ::none)]
- (fn
- ([] (rf))
- ([result]
- (let [result (if (.isEmpty a)
- result
- (let [v (vec (.toArray a))]
- ;;clear first!
- (.clear a)
- (unreduced (rf result v))))]
- (rf result)))
- ([result input]
- (let [pval @pa
- val (f input)]
- (vreset! pa val)
- (if (or (keyword-identical? pval ::none)
- (= val pval))
- (do
- (.add a input)
- result)
- (let [v (vec (.toArray a))]
- (.clear a)
- (let [ret (rf result v)]
- (when-not (reduced? ret)
- (.add a input))
- ret)))))))))
+ (fn [rf]
+ (let [a (array-list)
+ pa (volatile! ::none)]
+ (fn
+ ([] (rf))
+ ([result]
+ (let [result (if (.isEmpty a)
+ result
+ (let [v (vec (.toArray a))]
+ ;;clear first!
+ (.clear a)
+ (unreduced (rf result v))))]
+ (rf result)))
+ ([result input]
+ (let [pval @pa
+ val (f input)]
+ (vreset! pa val)
+ (if (or (keyword-identical? pval ::none)
+ (= val pval))
+ (do
+ (.add a input)
+ result)
+ (let [v (vec (.toArray a))]
+ (.clear a)
+ (let [ret (rf result v)]
+ (when-not (reduced? ret)
+ (.add a input))
+ ret)))))))))
([f coll]
- (lazy-seq
- (when-let [s (seq coll)]
- (let [fst (first s)
- fv (f fst)
- run (cons fst (take-while #(= fv (f %)) (next s)))]
- (cons run (partition-by f (lazy-seq (drop (count run) s)))))))))
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (let [fst (first s)
+ fv (f fst)
+ run (cons fst (take-while #(= fv (f %)) (next s)))]
+ (cons run (partition-by f (lazy-seq (drop (count run) s)))))))))
(defn frequencies
"Returns a map from distinct items in coll to the number of times
they appear."
[coll]
(persistent!
- (reduce (fn [counts x]
- (assoc! counts x (inc (get counts x 0))))
- (transient {}) coll)))
+ (reduce (fn [counts x]
+ (assoc! counts x (inc (get counts x 0))))
+ (transient {}) coll)))
(defn reductions
"Returns a lazy seq of the intermediate values of the reduction (as
@@ -9896,34 +9896,34 @@ reduces them without incurring seq initialization"
args (left-to-right).
((juxt a b c) x) => [(a x) (b x) (c x)]"
([f]
- (fn
- ([] (vector (f)))
- ([x] (vector (f x)))
- ([x y] (vector (f x y)))
- ([x y z] (vector (f x y z)))
- ([x y z & args] (vector (apply f x y z args)))))
+ (fn
+ ([] (vector (f)))
+ ([x] (vector (f x)))
+ ([x y] (vector (f x y)))
+ ([x y z] (vector (f x y z)))
+ ([x y z & args] (vector (apply f x y z args)))))
([f g]
- (fn
- ([] (vector (f) (g)))
- ([x] (vector (f x) (g x)))
- ([x y] (vector (f x y) (g x y)))
- ([x y z] (vector (f x y z) (g x y z)))
- ([x y z & args] (vector (apply f x y z args) (apply g x y z args)))))
+ (fn
+ ([] (vector (f) (g)))
+ ([x] (vector (f x) (g x)))
+ ([x y] (vector (f x y) (g x y)))
+ ([x y z] (vector (f x y z) (g x y z)))
+ ([x y z & args] (vector (apply f x y z args) (apply g x y z args)))))
([f g h]
- (fn
- ([] (vector (f) (g) (h)))
- ([x] (vector (f x) (g x) (h x)))
- ([x y] (vector (f x y) (g x y) (h x y)))
- ([x y z] (vector (f x y z) (g x y z) (h x y z)))
- ([x y z & args] (vector (apply f x y z args) (apply g x y z args) (apply h x y z args)))))
+ (fn
+ ([] (vector (f) (g) (h)))
+ ([x] (vector (f x) (g x) (h x)))
+ ([x y] (vector (f x y) (g x y) (h x y)))
+ ([x y z] (vector (f x y z) (g x y z) (h x y z)))
+ ([x y z & args] (vector (apply f x y z args) (apply g x y z args) (apply h x y z args)))))
([f g h & fs]
- (let [fs (list* f g h fs)]
- (fn
- ([] (reduce #(conj %1 (%2)) [] fs))
- ([x] (reduce #(conj %1 (%2 x)) [] fs))
- ([x y] (reduce #(conj %1 (%2 x y)) [] fs))
- ([x y z] (reduce #(conj %1 (%2 x y z)) [] fs))
- ([x y z & args] (reduce #(conj %1 (apply %2 x y z args)) [] fs))))))
+ (let [fs (list* f g h fs)]
+ (fn
+ ([] (reduce #(conj %1 (%2)) [] fs))
+ ([x] (reduce #(conj %1 (%2 x)) [] fs))
+ ([x y] (reduce #(conj %1 (%2 x y)) [] fs))
+ ([x y z] (reduce #(conj %1 (%2 x y z)) [] fs))
+ ([x y z & args] (reduce #(conj %1 (apply %2 x y z args)) [] fs))))))
(defn dorun
"When lazy sequences are produced via functions that have side
@@ -9993,10 +9993,10 @@ reduces them without incurring seq initialization"
(vec matches))]
(cons match-vals
(lazy-seq
- (let [post-idx (+ (.-index matches)
- (max 1 (.-length match-str)))]
- (when (<= post-idx (.-length s))
- (re-seq* re (subs s post-idx)))))))))
+ (let [post-idx (+ (.-index matches)
+ (max 1 (.-length match-str)))]
+ (when (<= post-idx (.-length s))
+ (re-seq* re (subs s post-idx)))))))))
(defn re-seq
"Returns a lazy sequence of successive matches of re in s."
@@ -10238,7 +10238,7 @@ reduces them without incurring seq initialization"
(pr-with-opts objs (pr-opts)))
(def ^{:doc
- "Prints the object(s) using string-print.
+ "Prints the object(s) using string-print.
print and println produce output for human consumption."}
print
(fn cljs-core-print [& objs]
@@ -10529,9 +10529,9 @@ reduces them without incurring seq initialization"
prefix is not supplied, the prefix is 'G__'."
([] (gensym "G__"))
([prefix-string]
- (when (nil? gensym_counter)
- (set! gensym_counter (atom 0)))
- (symbol (str prefix-string (swap! gensym_counter inc)))))
+ (when (nil? gensym_counter)
+ (set! gensym_counter (atom 0)))
+ (symbol (str prefix-string (swap! gensym_counter inc)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Delay ;;;;;;;;;;;;;;;;;;;;
@@ -10586,7 +10586,7 @@ reduces them without incurring seq initialization"
([] (rf))
([result] (rf result))
([result input]
- (reduce rf1 result input)))))
+ (reduce rf1 result input)))))
(defn halt-when
"Returns a transducer that ends transduction when pred returns true
@@ -10600,17 +10600,17 @@ reduces them without incurring seq initialization"
{:added "1.9"}
([pred] (halt-when pred nil))
([pred retf]
- (fn [rf]
- (fn
- ([] (rf))
- ([result]
- (if (and (map? result) (contains? result ::halt))
- (::halt result)
- (rf result)))
- ([result input]
- (if (pred input)
- (reduced {::halt (if retf (retf (rf result) input) input)})
- (rf result input)))))))
+ (fn [rf]
+ (fn
+ ([] (rf))
+ ([result]
+ (if (and (map? result) (contains? result ::halt))
+ (::halt result)
+ (rf result)))
+ ([result input]
+ (if (pred input)
+ (reduced {::halt (if retf (retf (rf result) input) input)})
+ (rf result input)))))))
(defn dedupe
"Returns a lazy sequence removing consecutive duplicates in coll.
@@ -10622,11 +10622,11 @@ reduces them without incurring seq initialization"
([] (rf))
([result] (rf result))
([result input]
- (let [prior @pa]
- (vreset! pa input)
- (if (= prior input)
- result
- (rf result input))))))))
+ (let [prior @pa]
+ (vreset! pa input)
+ (if (= prior input)
+ result
+ (rf result input))))))))
([coll] (sequence (dedupe) coll)))
(declare rand)
@@ -10635,9 +10635,9 @@ reduces them without incurring seq initialization"
"Returns items from coll with random probability of prob (0.0 -
1.0). Returns a transducer when no collection is provided."
([prob]
- (filter (fn [_] (< (rand) prob))))
+ (filter (fn [_] (< (rand) prob))))
([prob coll]
- (filter (fn [_] (< (rand) prob)) coll)))
+ (filter (fn [_] (< (rand) prob)) coll)))
(deftype Eduction [xform coll]
Object
@@ -10741,33 +10741,33 @@ reduces them without incurring seq initialization"
strings to keywords."
([x] (js->clj x :keywordize-keys false))
([x & opts]
- (let [{:keys [keywordize-keys]} opts
- keyfn (if keywordize-keys keyword str)
- f (fn thisfn [x]
- (cond
- (satisfies? IEncodeClojure x)
- (-js->clj x (apply array-map opts))
+ (let [{:keys [keywordize-keys]} opts
+ keyfn (if keywordize-keys keyword str)
+ f (fn thisfn [x]
+ (cond
+ (satisfies? IEncodeClojure x)
+ (-js->clj x (apply array-map opts))
- (seq? x)
- (doall (map thisfn x))
+ (seq? x)
+ (doall (map thisfn x))
- (map-entry? x)
- (MapEntry. (thisfn (key x)) (thisfn (val x)) nil)
+ (map-entry? x)
+ (MapEntry. (thisfn (key x)) (thisfn (val x)) nil)
- (coll? x)
- (into (empty x) (map thisfn) x)
+ (coll? x)
+ (into (empty x) (map thisfn) x)
- (array? x)
- (persistent!
+ (array? x)
+ (persistent!
(reduce #(conj! %1 (thisfn %2))
(transient []) x))
- (identical? (type x) js/Object)
- (persistent!
+ (identical? (type x) js/Object)
+ (persistent!
(reduce (fn [r k] (assoc! r (keyfn k) (thisfn (gobject/get x k))))
(transient {}) (js-keys x)))
- :else x))]
- (f x))))
+ :else x))]
+ (f x))))
(defn memoize
"Returns a memoized version of a referentially transparent function. The
@@ -10793,12 +10793,12 @@ reduces them without incurring seq initialization"
final value, you must wrap it in some data structure and unpack it
after trampoline returns."
([f]
- (let [ret (f)]
- (if (fn? ret)
- (recur ret)
- ret)))
+ (let [ret (f)]
+ (if (fn? ret)
+ (recur ret)
+ ret)))
([f & args]
- (trampoline #(apply f args))))
+ (trampoline #(apply f args))))
(defn rand
"Returns a random floating point number between 0 (inclusive) and
@@ -10854,17 +10854,17 @@ reduces them without incurring seq initialization"
hierarchy"
([child parent] (isa? @(get-global-hierarchy) child parent))
([h child parent]
- (or (= child parent)
- ;; (and (class? parent) (class? child)
- ;; (. ^Class parent isAssignableFrom child))
- (contains? ((:ancestors h) child) parent)
- ;;(and (class? child) (some #(contains? ((:ancestors h) %) parent) (supers child)))
- (and (vector? parent) (vector? child)
- (== (count parent) (count child))
- (loop [ret true i 0]
- (if (or (not ret) (== i (count parent)))
- ret
- (recur (isa? h (child i) (parent i)) (inc i))))))))
+ (or (= child parent)
+ ;; (and (class? parent) (class? child)
+ ;; (. ^Class parent isAssignableFrom child))
+ (contains? ((:ancestors h) child) parent)
+ ;;(and (class? child) (some #(contains? ((:ancestors h) %) parent) (supers child)))
+ (and (vector? parent) (vector? child)
+ (== (count parent) (count child))
+ (loop [ret true i 0]
+ (if (or (not ret) (== i (count parent)))
+ ret
+ (recur (isa? h (child i) (parent i)) (inc i))))))))
(defn parents
"Returns the immediate parents of tag, either via a JavaScript type
@@ -10915,36 +10915,36 @@ reduces them without incurring seq initialization"
(reduce conj (get targets k #{}) (cons target (targets target)))))
m (cons source (sources source))))]
(or
- (when-not (contains? (tp tag) parent)
- (when (contains? (ta tag) parent)
- (throw (js/Error. (str tag "already has" parent "as ancestor"))))
- (when (contains? (ta parent) tag)
- (throw (js/Error. (str "Cyclic derivation:" parent "has" tag "as ancestor"))))
- {:parents (assoc (:parents h) tag (conj (get tp tag #{}) parent))
- :ancestors (tf (:ancestors h) tag td parent ta)
- :descendants (tf (:descendants h) parent ta tag td)})
- h))))
+ (when-not (contains? (tp tag) parent)
+ (when (contains? (ta tag) parent)
+ (throw (js/Error. (str tag "already has" parent "as ancestor"))))
+ (when (contains? (ta parent) tag)
+ (throw (js/Error. (str "Cyclic derivation:" parent "has" tag "as ancestor"))))
+ {:parents (assoc (:parents h) tag (conj (get tp tag #{}) parent))
+ :ancestors (tf (:ancestors h) tag td parent ta)
+ :descendants (tf (:descendants h) parent ta tag td)})
+ h))))
(defn underive
"Removes a parent/child relationship between parent and
tag. h must be a hierarchy obtained from make-hierarchy, if not
supplied defaults to, and modifies, the global hierarchy."
([tag parent]
- (swap-global-hierarchy! underive tag parent)
- nil)
+ (swap-global-hierarchy! underive tag parent)
+ nil)
([h tag parent]
- (let [parentMap (:parents h)
- childsParents (if (parentMap tag)
- (disj (parentMap tag) parent) #{})
- newParents (if (not-empty childsParents)
+ (let [parentMap (:parents h)
+ childsParents (if (parentMap tag)
+ (disj (parentMap tag) parent) #{})
+ newParents (if (not-empty childsParents)
(assoc parentMap tag childsParents)
(dissoc parentMap tag))
- deriv-seq (flatten (map #(cons (first %) (interpose (first %) (second %)))
- (seq newParents)))]
- (if (contains? (parentMap tag) parent)
- (reduce #(apply derive %1 %2) (make-hierarchy)
- (partition 2 deriv-seq))
- h))))
+ deriv-seq (flatten (map #(cons (first %) (interpose (first %) (second %)))
+ (seq newParents)))]
+ (if (contains? (parentMap tag) parent)
+ (reduce #(apply derive %1 %2) (make-hierarchy)
+ (partition 2 deriv-seq))
+ h))))
(defn- reset-cache
[method-cache method-table cached-hierarchy hierarchy]
@@ -10955,19 +10955,19 @@ reduces them without incurring seq initialization"
[x y prefer-table]
(let [xprefs (@prefer-table x)]
(or
- (when (and xprefs (xprefs y))
- true)
- (loop [ps (parents y)]
- (when (pos? (count ps))
- (when (prefers* x (first ps) prefer-table)
- true)
- (recur (rest ps))))
- (loop [ps (parents x)]
- (when (pos? (count ps))
- (when (prefers* (first ps) y prefer-table)
- true)
- (recur (rest ps))))
- false)))
+ (when (and xprefs (xprefs y))
+ true)
+ (loop [ps (parents y)]
+ (when (pos? (count ps))
+ (when (prefers* x (first ps) prefer-table)
+ true)
+ (recur (rest ps))))
+ (loop [ps (parents x)]
+ (when (pos? (count ps))
+ (when (prefers* (first ps) y prefer-table)
+ true)
+ (recur (rest ps))))
+ false)))
(defn- dominates
[x y prefer-table hierarchy]
@@ -11180,7 +11180,7 @@ reduces them without incurring seq initialization"
(-prefer-method [mf dispatch-val-x dispatch-val-y]
(when (prefers* dispatch-val-x dispatch-val-y prefer-table)
(throw (js/Error. (str "Preference conflict in multimethod '" name "': " dispatch-val-y
- " is already preferred to " dispatch-val-x))))
+ " is already preferred to " dispatch-val-x))))
(swap! prefer-table
(fn [old]
(assoc old dispatch-val-x
@@ -11202,13 +11202,13 @@ reduces them without incurring seq initialization"
(defn remove-all-methods
"Removes all of the methods of multimethod."
- [multifn]
- (-reset multifn))
+ [multifn]
+ (-reset multifn))
(defn remove-method
"Removes the method of multimethod associated with dispatch-value."
- [multifn dispatch-val]
- (-remove-method multifn dispatch-val))
+ [multifn dispatch-val]
+ (-remove-method multifn dispatch-val))
(defn prefer-method
"Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y
@@ -11333,7 +11333,7 @@ reduces them without incurring seq initialization"
map of additional data."
([msg data] (ex-info msg data nil))
([msg data cause]
- (ExceptionInfo. msg data cause)))
+ (ExceptionInfo. msg data cause)))
(defn ex-data
"Returns exception data (a map) if ex is an ExceptionInfo.
@@ -11509,10 +11509,10 @@ reduces them without incurring seq initialization"
(defn demunge [name]
((if (symbol? name) symbol str)
- (let [name' (str name)]
- (if (identical? name' "_DOT__DOT_")
- ".."
- (demunge-str name')))))
+ (let [name' (str name)]
+ (if (identical? name' "_DOT__DOT_")
+ ".."
+ (demunge-str name')))))
(defonce ^{:jsdoc ["@type {*}"] :private true}
tapset nil)
@@ -11660,10 +11660,10 @@ reduces them without incurring seq initialization"
(if-not (nil? the-ns)
the-ns
(let [ns-obj (find-ns-obj ns)]
- (when-not (nil? ns-obj)
- (let [new-ns (create-ns ns ns-obj)]
- (swap! NS_CACHE assoc ns new-ns)
- new-ns))))))
+ (when-not (nil? ns-obj)
+ (let [new-ns (create-ns ns ns-obj)]
+ (swap! NS_CACHE assoc ns new-ns)
+ new-ns))))))
(defn ns-name
"Returns the name of the namespace, a Namespace object.
diff --git a/src/main/cljs/cljs/js.clj b/src/main/cljs/cljs/js.clj
index 1c4a51a6..133dd261 100644
--- a/src/main/cljs/cljs/js.clj
+++ b/src/main/cljs/cljs/js.clj
@@ -8,9 +8,9 @@
(ns cljs.js
(:require [cljs.env :as env]
- [cljs.env.macros :as menv]
- [cljs.analyzer :as ana]
- [clojure.java.io :as io]))
+ [cljs.env.macros :as menv]
+ [cljs.analyzer :as ana]
+ [clojure.java.io :as io]))
(defmacro with-state
[state & body]
diff --git a/src/main/cljs/cljs/js.cljs b/src/main/cljs/cljs/js.cljs
index 899215bd..19b7c5ea 100644
--- a/src/main/cljs/cljs/js.cljs
+++ b/src/main/cljs/cljs/js.cljs
@@ -9,18 +9,18 @@
(ns cljs.js
(:refer-clojure :exclude [require eval])
(:require-macros [cljs.js :refer [dump-core]]
- [cljs.env.macros :as env])
+ [cljs.env.macros :as env])
(:require [clojure.string :as string]
- [clojure.walk :as walk]
- [cljs.env :as env]
- [cljs.spec.alpha]
- [cljs.analyzer :as ana]
- [cljs.compiler :as comp]
- [cljs.tools.reader :as r]
- [cljs.tools.reader.reader-types :as rt]
- [cljs.tagged-literals :as tags]
- [goog.crypt.base64 :as base64]
- [cljs.source-map :as sm])
+ [clojure.walk :as walk]
+ [cljs.env :as env]
+ [cljs.spec.alpha]
+ [cljs.analyzer :as ana]
+ [cljs.compiler :as comp]
+ [cljs.tools.reader :as r]
+ [cljs.tools.reader.reader-types :as rt]
+ [cljs.tagged-literals :as tags]
+ [goog.crypt.base64 :as base64]
+ [cljs.source-map :as sm])
(:import [goog.string StringBuffer]))
(js/goog.require "cljs.core$macros")
@@ -156,33 +156,33 @@
(defn- append-source-map
[state name source sb sm-data {:keys [output-dir asset-path source-map-timestamp] :as opts}]
- (let [t (.valueOf (js/Date.))
- mn (if name
- (munge (str name))
- (str "cljs-" t))
- smn (cond-> mn
- name (string/replace "." "/"))
- ts (.valueOf (js/Date.))
- out (or output-dir asset-path)
- src (cond-> (str smn ".cljs")
- (true? source-map-timestamp) (str "?rel=" ts)
- out (prefix (str out "/")))
- file (cond-> (str smn ".js")
- (true? source-map-timestamp) (str "?rel=" ts)
- out (prefix (str out "/")))
- json (sm/encode {src (:source-map sm-data)}
- {:lines (+ (:gen-line sm-data) 3)
- :file file :sources-content [source]})]
- (when (:verbose opts) (debug-prn json))
- (swap! state assoc-in
- [:source-maps (symbol mn)] (sm/invert-reverse-map (:source-map sm-data)))
- (.append sb
- (str "\n//# sourceURL=" file
- "\n//# sourceMappingURL=data:application/json;base64,"
- (-> (js/encodeURIComponent json)
- (string/replace #"%([0-9A-F]{2})" (fn [[_ match]]
- (.fromCharCode js/String (str "0x" match))))
- (base64/encodeString))))))
+ (let [t (.valueOf (js/Date.))
+ mn (if name
+ (munge (str name))
+ (str "cljs-" t))
+ smn (cond-> mn
+ name (string/replace "." "/"))
+ ts (.valueOf (js/Date.))
+ out (or output-dir asset-path)
+ src (cond-> (str smn ".cljs")
+ (true? source-map-timestamp) (str "?rel=" ts)
+ out (prefix (str out "/")))
+ file (cond-> (str smn ".js")
+ (true? source-map-timestamp) (str "?rel=" ts)
+ out (prefix (str out "/")))
+ json (sm/encode {src (:source-map sm-data)}
+ {:lines (+ (:gen-line sm-data) 3)
+ :file file :sources-content [source]})]
+ (when (:verbose opts) (debug-prn json))
+ (swap! state assoc-in
+ [:source-maps (symbol mn)] (sm/invert-reverse-map (:source-map sm-data)))
+ (.append sb
+ (str "\n//# sourceURL=" file
+ "\n//# sourceMappingURL=data:application/json;base64,"
+ (-> (js/encodeURIComponent json)
+ (string/replace #"%([0-9A-F]{2})" (fn [[_ match]]
+ (.fromCharCode js/String (str "0x" match))))
+ (base64/encodeString))))))
(defn- alias-map
[compiler cljs-ns]
@@ -267,9 +267,9 @@
(defn require
([name cb]
- (require name nil cb))
+ (require name nil cb))
([name opts cb]
- (require nil name opts cb))
+ (require nil name opts cb))
([bound-vars name opts cb]
(require bound-vars name nil opts cb))
([bound-vars name reload opts cb]
@@ -292,60 +292,60 @@
(let [env (:*env* bound-vars)]
(try
((:*load-fn* bound-vars)
- {:name name
- :macros (:macros-ns opts)
- :path (ns->relpath name)}
- (fn [resource]
- (assert (or (map? resource) (nil? resource))
- "*load-fn* may only return a map or nil")
- (if resource
- (let [{:keys [lang source cache source-map file]} resource]
- (condp keyword-identical? lang
- :clj (do
- (pre-file-side-effects (:*compiler* bound-vars) aname file opts)
- (eval-str* bound-vars source name (assoc opts :cljs-file file)
- (fn [res]
- (post-file-side-effects file opts)
- (if (:error res)
- (cb res)
- (do
- (swap! *loaded* conj aname)
- (cb {:value true}))))))
- :js (process-macros-deps bound-vars cache opts
- (fn [res]
- (if (:error res)
- (cb res)
- (process-libs-deps bound-vars cache opts
- (fn [res]
- (if (:error res)
- (cb res)
- (let [res (try
- ((:*eval-fn* bound-vars) resource)
- (when cache
- (load-analysis-cache!
- (:*compiler* bound-vars) aname cache)
- (ana/register-specs cache))
- (when source-map
- (load-source-map!
- (:*compiler* bound-vars) aname source-map))
- (catch :default cause
- (wrap-error
- (ana/error env
- (str "Could not require " name) cause))))]
- (if (:error res)
- (cb res)
- (do
- (swap! *loaded* conj aname)
- (cb {:value true}))))))))))
- (cb (wrap-error
- (ana/error env
- (str "Invalid :lang specified " lang ", only :clj or :js allowed"))))))
- (cb (wrap-error
- (ana/error env
- (ana/error-message (if (:macros-ns opts)
- :undeclared-macros-ns
- :undeclared-ns)
- {:ns-sym name :js-provide (cljs.core/name name)})))))))
+ {:name name
+ :macros (:macros-ns opts)
+ :path (ns->relpath name)}
+ (fn [resource]
+ (assert (or (map? resource) (nil? resource))
+ "*load-fn* may only return a map or nil")
+ (if resource
+ (let [{:keys [lang source cache source-map file]} resource]
+ (condp keyword-identical? lang
+ :clj (do
+ (pre-file-side-effects (:*compiler* bound-vars) aname file opts)
+ (eval-str* bound-vars source name (assoc opts :cljs-file file)
+ (fn [res]
+ (post-file-side-effects file opts)
+ (if (:error res)
+ (cb res)
+ (do
+ (swap! *loaded* conj aname)
+ (cb {:value true}))))))
+ :js (process-macros-deps bound-vars cache opts
+ (fn [res]
+ (if (:error res)
+ (cb res)
+ (process-libs-deps bound-vars cache opts
+ (fn [res]
+ (if (:error res)
+ (cb res)
+ (let [res (try
+ ((:*eval-fn* bound-vars) resource)
+ (when cache
+ (load-analysis-cache!
+ (:*compiler* bound-vars) aname cache)
+ (ana/register-specs cache))
+ (when source-map
+ (load-source-map!
+ (:*compiler* bound-vars) aname source-map))
+ (catch :default cause
+ (wrap-error
+ (ana/error env
+ (str "Could not require " name) cause))))]
+ (if (:error res)
+ (cb res)
+ (do
+ (swap! *loaded* conj aname)
+ (cb {:value true}))))))))))
+ (cb (wrap-error
+ (ana/error env
+ (str "Invalid :lang specified " lang ", only :clj or :js allowed"))))))
+ (cb (wrap-error
+ (ana/error env
+ (ana/error-message (if (:macros-ns opts)
+ :undeclared-macros-ns
+ :undeclared-ns)
+ {:ns-sym name :js-provide (cljs.core/name name)})))))))
(catch :default cause
(cb (wrap-error
(ana/error env
@@ -565,7 +565,7 @@
(defn- ns-side-effects
([bound-vars ana-env ast opts cb]
- (ns-side-effects false bound-vars ana-env ast opts cb))
+ (ns-side-effects false bound-vars ana-env ast opts cb))
([load bound-vars ana-env {:keys [op] :as ast} opts cb]
(when (:verbose opts)
(debug-prn "Namespace side effects for" (:name ast)))
@@ -677,49 +677,49 @@
bound-vars (cond-> (merge bound-vars {:*cljs-ns* the-ns})
(:source-map opts) (assoc :*sm-data* (sm-data)))]
(trampoline
- (fn analyze-loop [last-ast ns]
- (binding [env/*compiler* (:*compiler* bound-vars)
- ana/*cljs-ns* ns
- ana/*checked-arrays* (:checked-arrays opts)
- ana/*cljs-static-fns* (:static-fns opts)
- ana/*fn-invoke-direct* (and (:static-fns opts) (:fn-invoke-direct opts))
- *ns* (create-ns ns)
- ana/*passes* (:*passes* bound-vars)
- r/*alias-map* (alias-map @(:*compiler* bound-vars) ns)
- r/*data-readers* (:*data-readers* bound-vars)
- r/resolve-symbol resolve-symbol
- comp/*source-map-data* (:*sm-data* bound-vars)
- ana/*cljs-file* (:cljs-file opts)]
- (let [res (try
- {:value (read eof rdr)}
- (catch :default cause
- (wrap-error
- (ana/error aenv
- (str "Could not analyze " name) cause))))]
- (if (:error res)
- (cb res)
- (let [form (:value res)]
- (if-not (identical? eof form)
- (let [aenv (cond-> (assoc aenv :ns (ana/get-namespace ana/*cljs-ns*))
- (:context opts) (assoc :context (:context opts))
- (:def-emits-var opts) (assoc :def-emits-var true))
- res (try
- {:value (ana/analyze aenv form nil opts)}
- (catch :default cause
- (wrap-error
- (ana/error aenv
- (str "Could not analyze " name) cause))))]
- (if (:error res)
- (cb res)
- (let [ast (:value res)]
- (if (#{:ns :ns*} (:op ast))
- ((trampoline-safe ns-side-effects) bound-vars aenv ast opts
+ (fn analyze-loop [last-ast ns]
+ (binding [env/*compiler* (:*compiler* bound-vars)
+ ana/*cljs-ns* ns
+ ana/*checked-arrays* (:checked-arrays opts)
+ ana/*cljs-static-fns* (:static-fns opts)
+ ana/*fn-invoke-direct* (and (:static-fns opts) (:fn-invoke-direct opts))
+ *ns* (create-ns ns)
+ ana/*passes* (:*passes* bound-vars)
+ r/*alias-map* (alias-map @(:*compiler* bound-vars) ns)
+ r/*data-readers* (:*data-readers* bound-vars)
+ r/resolve-symbol resolve-symbol
+ comp/*source-map-data* (:*sm-data* bound-vars)
+ ana/*cljs-file* (:cljs-file opts)]
+ (let [res (try
+ {:value (read eof rdr)}
+ (catch :default cause
+ (wrap-error
+ (ana/error aenv
+ (str "Could not analyze " name) cause))))]
+ (if (:error res)
+ (cb res)
+ (let [form (:value res)]
+ (if-not (identical? eof form)
+ (let [aenv (cond-> (assoc aenv :ns (ana/get-namespace ana/*cljs-ns*))
+ (:context opts) (assoc :context (:context opts))
+ (:def-emits-var opts) (assoc :def-emits-var true))
+ res (try
+ {:value (ana/analyze aenv form nil opts)}
+ (catch :default cause
+ (wrap-error
+ (ana/error aenv
+ (str "Could not analyze " name) cause))))]
+ (if (:error res)
+ (cb res)
+ (let [ast (:value res)]
+ (if (#{:ns :ns*} (:op ast))
+ ((trampoline-safe ns-side-effects) bound-vars aenv ast opts
(fn [res]
(if (:error res)
(cb res)
(trampoline analyze-loop ast (:name ast)))))
- #(analyze-loop ast ns)))))
- (cb {:value last-ast}))))))) nil the-ns)))
+ #(analyze-loop ast ns)))))
+ (cb {:value last-ast}))))))) nil the-ns)))
(defn analyze-str
"Analyze ClojureScript source. The compiler state will be populated with
@@ -908,46 +908,46 @@
bound-vars (cond-> (merge bound-vars {:*cljs-ns* the-ns})
(:source-map opts) (assoc :*sm-data* (sm-data)))]
(trampoline
- (fn compile-loop [ns]
- (binding [env/*compiler* (:*compiler* bound-vars)
- *eval-fn* (:*eval-fn* bound-vars)
- ana/*cljs-ns* ns
- ana/*checked-arrays* (:checked-arrays opts)
- ana/*cljs-static-fns* (:static-fns opts)
- ana/*fn-invoke-direct* (and (:static-fns opts) (:fn-invoke-direct opts))
- *ns* (create-ns ns)
- r/*alias-map* (alias-map @(:*compiler* bound-vars) ns)
- r/*data-readers* (:*data-readers* bound-vars)
- r/resolve-symbol resolve-symbol
- comp/*source-map-data* (:*sm-data* bound-vars)]
- (let [res (try
- {:value (read eof rdr)}
- (catch :default cause
- (wrap-error
- (ana/error aenv
- (str "Could not compile " name) cause))))]
- (if (:error res)
- (cb res)
- (let [form (:value res)]
- (if-not (identical? eof form)
- (let [aenv (cond-> (assoc aenv :ns (ana/get-namespace ana/*cljs-ns*))
- (:context opts) (assoc :context (:context opts))
- (:def-emits-var opts) (assoc :def-emits-var true))
- res (try
- {:value (ana/analyze aenv form nil opts)}
- (catch :default cause
- (wrap-error
- (ana/error aenv
- (str "Could not compile " name) cause))))]
- (if (:error res)
- (cb res)
- (let [ast (:value res)
- [node-deps ast] (if (keyword-identical? (:target opts) :nodejs)
- (let [{node-libs true libs-to-load false} (group-by ana/node-module-dep? (:deps ast))]
- [node-libs (assoc ast :deps libs-to-load)])
- [nil ast])]
- (if (#{:ns :ns*} (:op ast))
- ((trampoline-safe ns-side-effects) bound-vars aenv ast opts
+ (fn compile-loop [ns]
+ (binding [env/*compiler* (:*compiler* bound-vars)
+ *eval-fn* (:*eval-fn* bound-vars)
+ ana/*cljs-ns* ns
+ ana/*checked-arrays* (:checked-arrays opts)
+ ana/*cljs-static-fns* (:static-fns opts)
+ ana/*fn-invoke-direct* (and (:static-fns opts) (:fn-invoke-direct opts))
+ *ns* (create-ns ns)
+ r/*alias-map* (alias-map @(:*compiler* bound-vars) ns)
+ r/*data-readers* (:*data-readers* bound-vars)
+ r/resolve-symbol resolve-symbol
+ comp/*source-map-data* (:*sm-data* bound-vars)]
+ (let [res (try
+ {:value (read eof rdr)}
+ (catch :default cause
+ (wrap-error
+ (ana/error aenv
+ (str "Could not compile " name) cause))))]
+ (if (:error res)
+ (cb res)
+ (let [form (:value res)]
+ (if-not (identical? eof form)
+ (let [aenv (cond-> (assoc aenv :ns (ana/get-namespace ana/*cljs-ns*))
+ (:context opts) (assoc :context (:context opts))
+ (:def-emits-var opts) (assoc :def-emits-var true))
+ res (try
+ {:value (ana/analyze aenv form nil opts)}
+ (catch :default cause
+ (wrap-error
+ (ana/error aenv
+ (str "Could not compile " name) cause))))]
+ (if (:error res)
+ (cb res)
+ (let [ast (:value res)
+ [node-deps ast] (if (keyword-identical? (:target opts) :nodejs)
+ (let [{node-libs true libs-to-load false} (group-by ana/node-module-dep? (:deps ast))]
+ [node-libs (assoc ast :deps libs-to-load)])
+ [nil ast])]
+ (if (#{:ns :ns*} (:op ast))
+ ((trampoline-safe ns-side-effects) bound-vars aenv ast opts
(fn [res]
(if (:error res)
(cb res)
@@ -956,14 +956,14 @@
(when-not (nil? node-deps)
(node-side-effects bound-vars sb node-deps ns-name (:def-emits-var opts)))
(trampoline compile-loop (:name ast))))))
- (do
- (.append sb (with-out-str (comp/emit ast)))
- #(compile-loop ns))))))
- (do
- (when (:source-map opts)
- (append-source-map env/*compiler*
- name source sb @comp/*source-map-data* opts))
- (cb {:value (.toString sb)})))))))) the-ns)))
+ (do
+ (.append sb (with-out-str (comp/emit ast)))
+ #(compile-loop ns))))))
+ (do
+ (when (:source-map opts)
+ (append-source-map env/*compiler*
+ name source sb @comp/*source-map-data* opts))
+ (cb {:value (.toString sb)})))))))) the-ns)))
(defn compile-str
"Compile ClojureScript source into JavaScript. The parameters:
@@ -1043,92 +1043,92 @@
(when (:verbose opts) (debug-prn "Evaluating" name))
(clear-fns!)
(trampoline
- (fn compile-loop [ns]
- (binding [env/*compiler* (:*compiler* bound-vars)
- *eval-fn* (:*eval-fn* bound-vars)
- ana/*cljs-ns* ns
- ana/*checked-arrays* (:checked-arrays opts)
- ana/*cljs-static-fns* (:static-fns opts)
- ana/*fn-invoke-direct* (and (:static-fns opts) (:fn-invoke-direct opts))
- *ns* (create-ns ns)
- r/*alias-map* (alias-map @(:*compiler* bound-vars) ns)
- r/*data-readers* (:*data-readers* bound-vars)
- r/resolve-symbol resolve-symbol
- comp/*source-map-data* (:*sm-data* bound-vars)
- ana/*cljs-file* (:cljs-file opts)]
- (let [res (try
- {:value (read eof rdr)}
- (catch :default cause
- (wrap-error
- (ana/error aenv
- (str "Could not eval " name) cause))))]
- (if (:error res)
- (cb res)
- (let [form (:value res)]
- (if-not (identical? eof form)
- (let [aenv (cond-> (assoc aenv :ns (ana/get-namespace ns))
- (:context opts) (assoc :context (:context opts))
- (:def-emits-var opts) (assoc :def-emits-var true))
- res (try
- {:value (ana/analyze aenv form nil opts)}
- (catch :default cause
- (wrap-error
- (ana/error aenv
- (str "Could not eval " name) cause))))]
- (if (:error res)
- (cb res)
- (let [ast (:value res)
- ns' ana/*cljs-ns*
- [node-deps ast] (if (keyword-identical? (:target opts) :nodejs)
- (let [{node-libs true libs-to-load false} (group-by ana/node-module-dep? (:deps ast))]
- [node-libs (assoc ast :deps libs-to-load)])
- [nil ast])]
- (if (#{:ns :ns*} (:op ast))
- (do
- (.append sb
- (with-out-str (comp/emitln (str "goog.provide(\"" (comp/munge (:name ast)) "\");"))))
- ((trampoline-safe ns-side-effects) true bound-vars aenv ast opts
- (fn [res]
- (if (:error res)
- (cb res)
- (let [ns-name (:name ast)]
- (when-not (nil? node-deps)
- (node-side-effects bound-vars sb node-deps ns-name (:def-emits-var opts)))
- (global-exports-side-effects bound-vars sb
- (filter ana/dep-has-global-exports? (:deps ast))
- ns-name
- (:def-emits-var opts))
- (trampoline compile-loop ns'))))))
- (do
- (env/with-compiler-env (assoc @(:*compiler* bound-vars) :options opts)
- (.append sb (with-out-str (comp/emit ast))))
- #(compile-loop ns'))))))
- (do
- (when (:source-map opts)
- (append-source-map env/*compiler*
- aname source sb @comp/*source-map-data* opts))
- (when (symbol? aname)
- (ana/dump-specs aname))
- (let [js-source (.toString sb)
- evalm {:lang :clj
- :name name
- :path (ns->relpath name)
- :source js-source
- :cache (get-in @env/*compiler* [::ana/namespaces aname])}
- complete (fn [res]
- (if (:error res)
- (cb res)
- (do
- (when (:verbose opts)
- (debug-prn js-source))
- (let [res (try
- {:ns ns :value (*eval-fn* evalm)}
- (catch :default cause
- (wrap-error (ana/error aenv "ERROR" cause))))]
- (cb res)))))]
- (if-let [f (:cache-source opts)]
- ((trampoline-safe f) evalm complete)
- (complete {:value nil}))))))))))
+ (fn compile-loop [ns]
+ (binding [env/*compiler* (:*compiler* bound-vars)
+ *eval-fn* (:*eval-fn* bound-vars)
+ ana/*cljs-ns* ns
+ ana/*checked-arrays* (:checked-arrays opts)
+ ana/*cljs-static-fns* (:static-fns opts)
+ ana/*fn-invoke-direct* (and (:static-fns opts) (:fn-invoke-direct opts))
+ *ns* (create-ns ns)
+ r/*alias-map* (alias-map @(:*compiler* bound-vars) ns)
+ r/*data-readers* (:*data-readers* bound-vars)
+ r/resolve-symbol resolve-symbol
+ comp/*source-map-data* (:*sm-data* bound-vars)
+ ana/*cljs-file* (:cljs-file opts)]
+ (let [res (try
+ {:value (read eof rdr)}
+ (catch :default cause
+ (wrap-error
+ (ana/error aenv
+ (str "Could not eval " name) cause))))]
+ (if (:error res)
+ (cb res)
+ (let [form (:value res)]
+ (if-not (identical? eof form)
+ (let [aenv (cond-> (assoc aenv :ns (ana/get-namespace ns))
+ (:context opts) (assoc :context (:context opts))
+ (:def-emits-var opts) (assoc :def-emits-var true))
+ res (try
+ {:value (ana/analyze aenv form nil opts)}
+ (catch :default cause
+ (wrap-error
+ (ana/error aenv
+ (str "Could not eval " name) cause))))]
+ (if (:error res)
+ (cb res)
+ (let [ast (:value res)
+ ns' ana/*cljs-ns*
+ [node-deps ast] (if (keyword-identical? (:target opts) :nodejs)
+ (let [{node-libs true libs-to-load false} (group-by ana/node-module-dep? (:deps ast))]
+ [node-libs (assoc ast :deps libs-to-load)])
+ [nil ast])]
+ (if (#{:ns :ns*} (:op ast))
+ (do
+ (.append sb
+ (with-out-str (comp/emitln (str "goog.provide(\"" (comp/munge (:name ast)) "\");"))))
+ ((trampoline-safe ns-side-effects) true bound-vars aenv ast opts
+ (fn [res]
+ (if (:error res)
+ (cb res)
+ (let [ns-name (:name ast)]
+ (when-not (nil? node-deps)
+ (node-side-effects bound-vars sb node-deps ns-name (:def-emits-var opts)))
+ (global-exports-side-effects bound-vars sb
+ (filter ana/dep-has-global-exports? (:deps ast))
+ ns-name
+ (:def-emits-var opts))
+ (trampoline compile-loop ns'))))))
+ (do
+ (env/with-compiler-env (assoc @(:*compiler* bound-vars) :options opts)
+ (.append sb (with-out-str (comp/emit ast))))
+ #(compile-loop ns'))))))
+ (do
+ (when (:source-map opts)
+ (append-source-map env/*compiler*
+ aname source sb @comp/*source-map-data* opts))
+ (when (symbol? aname)
+ (ana/dump-specs aname))
+ (let [js-source (.toString sb)
+ evalm {:lang :clj
+ :name name
+ :path (ns->relpath name)
+ :source js-source
+ :cache (get-in @env/*compiler* [::ana/namespaces aname])}
+ complete (fn [res]
+ (if (:error res)
+ (cb res)
+ (do
+ (when (:verbose opts)
+ (debug-prn js-source))
+ (let [res (try
+ {:ns ns :value (*eval-fn* evalm)}
+ (catch :default cause
+ (wrap-error (ana/error aenv "ERROR" cause))))]
+ (cb res)))))]
+ (if-let [f (:cache-source opts)]
+ ((trampoline-safe f) evalm complete)
+ (complete {:value nil}))))))))))
(:*cljs-ns* bound-vars))))
(defn eval-str
diff --git a/src/main/cljs/cljs/loader.cljs b/src/main/cljs/cljs/loader.cljs
index 249f0e85..b8867bba 100644
--- a/src/main/cljs/cljs/loader.cljs
+++ b/src/main/cljs/cljs/loader.cljs
@@ -9,7 +9,7 @@
(ns cljs.loader
(:require [goog.object :as gobj])
(:import [goog.module ModuleLoader]
- [goog.module ModuleManager]))
+ [goog.module ModuleManager]))
(def module-infos MODULE_INFOS) ;; set by compiler
(def module-uris
@@ -60,7 +60,7 @@
"Load a module. module-name should be a keyword matching a :modules module
definition."
([module-name]
- (load module-name nil))
+ (load module-name nil))
([module-name cb]
(assert (contains? module-infos module-name)
(str "Module " module-name " does not exist"))
diff --git a/src/main/cljs/cljs/main.clj b/src/main/cljs/cljs/main.clj
index de17bb33..592177aa 100644
--- a/src/main/cljs/cljs/main.clj
+++ b/src/main/cljs/cljs/main.clj
@@ -8,7 +8,7 @@
(ns cljs.main
(:require [cljs.repl.browser :as browser]
- [cljs.cli :as cli])
+ [cljs.cli :as cli])
(:gen-class))
(defn- get-js-opt [args]
@@ -36,7 +36,7 @@
(let [pred (complement #{"-re" "--repl-env"})
[pre post] ((juxt #(take-while pred %)
#(drop-while pred %))
- args)]
+ args)]
(if (= pre args)
[nil pre]
(let [[js-opt post'] (normalize* (nnext post))]
@@ -54,7 +54,7 @@
pred (complement #{"-re" "--repl-env"})
[pre post] ((juxt #(take-while pred %)
#(drop-while pred %))
- args)
+ args)
[js-args args] ((juxt #(take 2 %) #(drop 2 %)) post)
repl-opt (get-js-opt js-args)]
(try
diff --git a/src/main/cljs/cljs/nodejscli.cljs b/src/main/cljs/cljs/nodejscli.cljs
index 256a4fa9..3215bd39 100644
--- a/src/main/cljs/cljs/nodejscli.cljs
+++ b/src/main/cljs/cljs/nodejscli.cljs
@@ -11,7 +11,7 @@
; is called with the script's command-line arguments.
(ns cljs.nodejscli
(:require [cljs.nodejs :as nodejs]
- [goog.object :as gobj]))
+ [goog.object :as gobj]))
;; need to set goog.global if COMPILED
(when ^boolean js/COMPILED
diff --git a/src/main/cljs/cljs/pprint.cljs b/src/main/cljs/cljs/pprint.cljs
index fb349a1f..c72086df 100644
--- a/src/main/cljs/cljs/pprint.cljs
+++ b/src/main/cljs/cljs/pprint.cljs
@@ -9,13 +9,13 @@
(ns cljs.pprint
(:refer-clojure :exclude [deftype print println pr prn float?])
(:require-macros
- [cljs.pprint :as m :refer [with-pretty-writer getf setf deftype
- pprint-logical-block print-length-loop
- defdirectives formatter-out]])
+ [cljs.pprint :as m :refer [with-pretty-writer getf setf deftype
+ pprint-logical-block print-length-loop
+ defdirectives formatter-out]])
(:require
- [cljs.core :refer [IWriter IDeref]]
- [clojure.string :as string]
- [goog.string :as gstring])
+ [cljs.core :refer [IWriter IDeref]]
+ [clojure.string :as string]
+ [goog.string :as gstring])
(:import [goog.string StringBuffer]))
;;======================================================================
@@ -196,8 +196,8 @@ beginning of aseq"
(-write
;;-write isn't multi-arity, so need different way to do this
#_([this ^chars cbuf ^Number off ^Number len]
- (let [writer (get-field this :base)]
- (-write writer cbuf off len)))
+ (let [writer (get-field this :base)]
+ (-write writer cbuf off len)))
[this x]
(condp = (type x)
js/String
@@ -366,7 +366,7 @@ beginning of aseq"
(let [nl (first buffer)
lb (:logical-block nl)
section (seq (take-while #(let [nl-lb (:logical-block %)]
- (not (and (nl-t? %) (or (= nl-lb lb) (ancestor? nl-lb lb)))))
+ (not (and (nl-t? %) (or (= nl-lb lb) (ancestor? nl-lb lb)))))
(next buffer)))]
section))
@@ -613,66 +613,66 @@ beginning of aseq"
;; *print-length*, *print-level*, *print-namespace-maps* and *print-dup* are defined in cljs.core
(def ^:dynamic
- ^{:doc "Bind to true if you want write to use pretty printing"}
- *print-pretty* true)
+ ^{:doc "Bind to true if you want write to use pretty printing"}
+ *print-pretty* true)
(defonce ^:dynamic
- ^{:doc "The pretty print dispatch function. Use with-pprint-dispatch or
+ ^{:doc "The pretty print dispatch function. Use with-pprint-dispatch or
set-pprint-dispatch to modify."
- :added "1.2"}
- *print-pprint-dispatch* nil)
+ :added "1.2"}
+ *print-pprint-dispatch* nil)
(def ^:dynamic
- ^{:doc "Pretty printing will try to avoid anything going beyond this column.
+ ^{:doc "Pretty printing will try to avoid anything going beyond this column.
Set it to nil to have pprint let the line be arbitrarily long. This will ignore all
non-mandatory newlines.",
- :added "1.2"}
- *print-right-margin* 72)
+ :added "1.2"}
+ *print-right-margin* 72)
(def ^:dynamic
- ^{:doc "The column at which to enter miser style. Depending on the dispatch table,
+ ^{:doc "The column at which to enter miser style. Depending on the dispatch table,
miser style add newlines in more places to try to keep lines short allowing for further
levels of nesting.",
- :added "1.2"}
- *print-miser-width* 40)
+ :added "1.2"}
+ *print-miser-width* 40)
;;; TODO implement output limiting
(def ^:dynamic
-^{:private true,
- :doc "Maximum number of lines to print in a pretty print instance (N.B. This is not yet used)"}
-*print-lines* nil)
+ ^{:private true,
+ :doc "Maximum number of lines to print in a pretty print instance (N.B. This is not yet used)"}
+ *print-lines* nil)
;;; TODO: implement circle and shared
(def ^:dynamic
-^{:private true,
- :doc "Mark circular structures (N.B. This is not yet used)"}
-*print-circle* nil)
+ ^{:private true,
+ :doc "Mark circular structures (N.B. This is not yet used)"}
+ *print-circle* nil)
;;; TODO: should we just use *print-dup* here?
(def ^:dynamic
-^{:private true,
- :doc "Mark repeated structures rather than repeat them (N.B. This is not yet used)"}
-*print-shared* nil)
+ ^{:private true,
+ :doc "Mark repeated structures rather than repeat them (N.B. This is not yet used)"}
+ *print-shared* nil)
(def ^:dynamic
-^{:doc "Don't print namespaces with symbols. This is particularly useful when
+ ^{:doc "Don't print namespaces with symbols. This is particularly useful when
pretty printing the results of macro expansions"
- :added "1.2"}
-*print-suppress-namespaces* nil)
+ :added "1.2"}
+ *print-suppress-namespaces* nil)
;;; TODO: support print-base and print-radix in cl-format
;;; TODO: support print-base and print-radix in rationals
(def ^:dynamic
-^{:doc "Print a radix specifier in front of integers and rationals. If *print-base* is 2, 8,
+ ^{:doc "Print a radix specifier in front of integers and rationals. If *print-base* is 2, 8,
or 16, then the radix specifier used is #b, #o, or #x, respectively. Otherwise the
radix specifier is in the form #XXr where XX is the decimal value of *print-base* "
- :added "1.2"}
-*print-radix* nil)
+ :added "1.2"}
+ *print-radix* nil)
(def ^:dynamic
-^{:doc "The base to use for printing integers and rationals."
- :added "1.2"}
-*print-base* 10)
+ ^{:doc "The base to use for printing integers and rationals."
+ :added "1.2"}
+ *print-base* 10)
;;======================================================================
;; Internal variables that keep track of where we are in the
@@ -790,8 +790,8 @@ The following keyword arguments can be passed with values:
cljs.pprint/*print-suppress-namespaces* (:suppress-namespaces options cljs.pprint/*print-suppress-namespaces*)]
;;TODO enable printing base
#_[bindings (if (or (not (= *print-base* 10)) *print-radix*)
- {#'pr pr-with-base}
- {})]
+ {#'pr pr-with-base}
+ {})]
(binding []
(let [sb (StringBuffer.)
optval (if (contains? options :stream)
@@ -1080,8 +1080,8 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
(reverse
(first
(consume #(if (pos? %)
- [(rem % base) (quot % base)]
- [nil nil])
+ [(rem % base) (quot % base)]
+ [nil nil])
val))))
;; TODO: xlated-val does not seem to be used here.
@@ -1444,10 +1444,10 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
;; Every formatted floating point number should include at
;; least one decimal digit and a decimal point.
w (if w (max 2 w)
- ;;NB: if w doesn't exist, it won't ever be used because d will
- ;; satisfy the cond below. cljs gives a compilation warning if
- ;; we don't provide a value here.
- 0)
+ ;;NB: if w doesn't exist, it won't ever be used because d will
+ ;; satisfy the cond below. cljs gives a compilation warning if
+ ;; we don't provide a value here.
+ 0)
round-pos (cond
;; If d was given, that forces the rounding
;; position, regardless of any width that may
@@ -1924,7 +1924,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
(-write
;;no multi-arity, not sure of importance
#_([^chars cbuf ^Integer off ^Integer len]
- (.write writer cbuf off len))
+ (.write writer cbuf off len))
[this x]
(condp = (type x)
js/String
@@ -1945,7 +1945,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
(-write
;;no multi-arity, not sure of importance
#_([^chars cbuf ^Integer off ^Integer len]
- (.write writer cbuf off len))
+ (.write writer cbuf off len))
[this x]
(condp = (type x)
js/String
@@ -1990,7 +1990,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
(-write
;;no multi-arity
#_([^chars cbuf ^Integer off ^Integer len]
- (.write writer cbuf off len))
+ (.write writer cbuf off len))
[this x]
(condp = (type x)
js/String
@@ -2016,7 +2016,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
(-write
;;no multi-arity
#_([^chars cbuf ^Integer off ^Integer len]
- (.write writer cbuf off len))
+ (.write writer cbuf off len))
[this x]
(condp = (type x)
js/String
@@ -2165,279 +2165,279 @@ not a pretty writer (which keeps track of columns), this function always outputs
(defdirectives
(\A
- [:mincol [0 js/Number] :colinc [1 js/Number] :minpad [0 js/Number] :padchar [\space js/String]]
- #{:at :colon :both} {}
- #(format-ascii print-str %1 %2 %3))
+ [:mincol [0 js/Number] :colinc [1 js/Number] :minpad [0 js/Number] :padchar [\space js/String]]
+ #{:at :colon :both} {}
+ #(format-ascii print-str %1 %2 %3))
(\S
- [:mincol [0 js/Number] :colinc [1 js/Number] :minpad [0 js/Number] :padchar [\space js/String]]
- #{:at :colon :both} {}
- #(format-ascii pr-str %1 %2 %3))
+ [:mincol [0 js/Number] :colinc [1 js/Number] :minpad [0 js/Number] :padchar [\space js/String]]
+ #{:at :colon :both} {}
+ #(format-ascii pr-str %1 %2 %3))
(\D
- [:mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
- :commainterval [3 js/Number]]
- #{:at :colon :both} {}
- #(format-integer 10 %1 %2 %3))
+ [:mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
+ :commainterval [3 js/Number]]
+ #{:at :colon :both} {}
+ #(format-integer 10 %1 %2 %3))
(\B
- [:mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
- :commainterval [3 js/Number]]
- #{:at :colon :both} {}
- #(format-integer 2 %1 %2 %3))
+ [:mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
+ :commainterval [3 js/Number]]
+ #{:at :colon :both} {}
+ #(format-integer 2 %1 %2 %3))
(\O
- [:mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
- :commainterval [3 js/Number]]
- #{:at :colon :both} {}
- #(format-integer 8 %1 %2 %3))
+ [:mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
+ :commainterval [3 js/Number]]
+ #{:at :colon :both} {}
+ #(format-integer 8 %1 %2 %3))
(\X
- [:mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
- :commainterval [3 js/Number]]
- #{:at :colon :both} {}
- #(format-integer 16 %1 %2 %3))
+ [:mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
+ :commainterval [3 js/Number]]
+ #{:at :colon :both} {}
+ #(format-integer 16 %1 %2 %3))
(\R
- [:base [nil js/Number] :mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
- :commainterval [3 js/Number]]
- #{:at :colon :both} {}
- (do
- (cond ; ~R is overloaded with bizareness
- (first (:base params)) #(format-integer (:base %1) %1 %2 %3)
- (and (:at params) (:colon params)) #(format-old-roman %1 %2 %3)
- (:at params) #(format-new-roman %1 %2 %3)
- (:colon params) #(format-ordinal-english %1 %2 %3)
- true #(format-cardinal-english %1 %2 %3))))
+ [:base [nil js/Number] :mincol [0 js/Number] :padchar [\space js/String] :commachar [\, js/String]
+ :commainterval [3 js/Number]]
+ #{:at :colon :both} {}
+ (do
+ (cond ; ~R is overloaded with bizareness
+ (first (:base params)) #(format-integer (:base %1) %1 %2 %3)
+ (and (:at params) (:colon params)) #(format-old-roman %1 %2 %3)
+ (:at params) #(format-new-roman %1 %2 %3)
+ (:colon params) #(format-ordinal-english %1 %2 %3)
+ true #(format-cardinal-english %1 %2 %3))))
(\P
- []
- #{:at :colon :both} {}
- (fn [params navigator offsets]
- (let [navigator (if (:colon params) (relative-reposition navigator -1) navigator)
- strs (if (:at params) ["y" "ies"] ["" "s"])
- [arg navigator] (next-arg navigator)]
- (print (if (= arg 1) (first strs) (second strs)))
- navigator)))
+ []
+ #{:at :colon :both} {}
+ (fn [params navigator offsets]
+ (let [navigator (if (:colon params) (relative-reposition navigator -1) navigator)
+ strs (if (:at params) ["y" "ies"] ["" "s"])
+ [arg navigator] (next-arg navigator)]
+ (print (if (= arg 1) (first strs) (second strs)))
+ navigator)))
(\C
- [:char-format [nil js/String]]
- #{:at :colon :both} {}
- (cond
- (:colon params) pretty-character
- (:at params) readable-character
- :else plain-character))
+ [:char-format [nil js/String]]
+ #{:at :colon :both} {}
+ (cond
+ (:colon params) pretty-character
+ (:at params) readable-character
+ :else plain-character))
(\F
- [:w [nil js/Number] :d [nil js/Number] :k [0 js/Number] :overflowchar [nil js/String]
- :padchar [\space js/String]]
- #{:at} {}
- fixed-float)
+ [:w [nil js/Number] :d [nil js/Number] :k [0 js/Number] :overflowchar [nil js/String]
+ :padchar [\space js/String]]
+ #{:at} {}
+ fixed-float)
(\E
- [:w [nil js/Number] :d [nil js/Number] :e [nil js/Number] :k [1 js/Number]
- :overflowchar [nil js/String] :padchar [\space js/String]
- :exponentchar [nil js/String]]
- #{:at} {}
- exponential-float)
+ [:w [nil js/Number] :d [nil js/Number] :e [nil js/Number] :k [1 js/Number]
+ :overflowchar [nil js/String] :padchar [\space js/String]
+ :exponentchar [nil js/String]]
+ #{:at} {}
+ exponential-float)
(\G
- [:w [nil js/Number] :d [nil js/Number] :e [nil js/Number] :k [1 js/Number]
- :overflowchar [nil js/String] :padchar [\space js/String]
- :exponentchar [nil js/String]]
- #{:at} {}
- general-float)
+ [:w [nil js/Number] :d [nil js/Number] :e [nil js/Number] :k [1 js/Number]
+ :overflowchar [nil js/String] :padchar [\space js/String]
+ :exponentchar [nil js/String]]
+ #{:at} {}
+ general-float)
(\$
- [:d [2 js/Number] :n [1 js/Number] :w [0 js/Number] :padchar [\space js/String]]
- #{:at :colon :both} {}
- dollar-float)
+ [:d [2 js/Number] :n [1 js/Number] :w [0 js/Number] :padchar [\space js/String]]
+ #{:at :colon :both} {}
+ dollar-float)
(\%
- [:count [1 js/Number]]
- #{} {}
- (fn [params arg-navigator offsets]
- (dotimes [i (:count params)]
- (prn))
- arg-navigator))
+ [:count [1 js/Number]]
+ #{} {}
+ (fn [params arg-navigator offsets]
+ (dotimes [i (:count params)]
+ (prn))
+ arg-navigator))
(\&
- [:count [1 js/Number]]
- #{:pretty} {}
- (fn [params arg-navigator offsets]
- (let [cnt (:count params)]
- (if (pos? cnt) (fresh-line))
- (dotimes [i (dec cnt)]
- (prn)))
- arg-navigator))
+ [:count [1 js/Number]]
+ #{:pretty} {}
+ (fn [params arg-navigator offsets]
+ (let [cnt (:count params)]
+ (if (pos? cnt) (fresh-line))
+ (dotimes [i (dec cnt)]
+ (prn)))
+ arg-navigator))
(\|
- [:count [1 js/Number]]
- #{} {}
- (fn [params arg-navigator offsets]
- (dotimes [i (:count params)]
- (print \formfeed))
- arg-navigator))
+ [:count [1 js/Number]]
+ #{} {}
+ (fn [params arg-navigator offsets]
+ (dotimes [i (:count params)]
+ (print \formfeed))
+ arg-navigator))
(\~
- [:n [1 js/Number]]
- #{} {}
- (fn [params arg-navigator offsets]
- (let [n (:n params)]
- (print (apply str (repeat n \~)))
- arg-navigator)))
+ [:n [1 js/Number]]
+ #{} {}
+ (fn [params arg-navigator offsets]
+ (let [n (:n params)]
+ (print (apply str (repeat n \~)))
+ arg-navigator)))
(\newline ;; Whitespace supression is handled in the compilation loop
- []
- #{:colon :at} {}
- (fn [params arg-navigator offsets]
- (if (:at params)
- (prn))
- arg-navigator))
+ []
+ #{:colon :at} {}
+ (fn [params arg-navigator offsets]
+ (if (:at params)
+ (prn))
+ arg-navigator))
(\T
- [:colnum [1 js/Number] :colinc [1 js/Number]]
- #{:at :pretty} {}
- (if (:at params)
- #(relative-tabulation %1 %2 %3)
- #(absolute-tabulation %1 %2 %3)))
+ [:colnum [1 js/Number] :colinc [1 js/Number]]
+ #{:at :pretty} {}
+ (if (:at params)
+ #(relative-tabulation %1 %2 %3)
+ #(absolute-tabulation %1 %2 %3)))
(\*
- [:n [1 js/Number]]
- #{:colon :at} {}
- (fn [params navigator offsets]
- (let [n (:n params)]
- (if (:at params)
- (absolute-reposition navigator n)
- (relative-reposition navigator (if (:colon params) (- n) n))))))
+ [:n [1 js/Number]]
+ #{:colon :at} {}
+ (fn [params navigator offsets]
+ (let [n (:n params)]
+ (if (:at params)
+ (absolute-reposition navigator n)
+ (relative-reposition navigator (if (:colon params) (- n) n))))))
(\?
- []
- #{:at} {}
- (if (:at params)
- (fn [params navigator offsets] ; args from main arg list
- (let [[subformat navigator] (get-format-arg navigator)]
- (execute-sub-format subformat navigator (:base-args params))))
- (fn [params navigator offsets] ; args from sub-list
- (let [[subformat navigator] (get-format-arg navigator)
- [subargs navigator] (next-arg navigator)
- sub-navigator (init-navigator subargs)]
- (execute-sub-format subformat sub-navigator (:base-args params))
- navigator))))
+ []
+ #{:at} {}
+ (if (:at params)
+ (fn [params navigator offsets] ; args from main arg list
+ (let [[subformat navigator] (get-format-arg navigator)]
+ (execute-sub-format subformat navigator (:base-args params))))
+ (fn [params navigator offsets] ; args from sub-list
+ (let [[subformat navigator] (get-format-arg navigator)
+ [subargs navigator] (next-arg navigator)
+ sub-navigator (init-navigator subargs)]
+ (execute-sub-format subformat sub-navigator (:base-args params))
+ navigator))))
(\(
- []
- #{:colon :at :both} {:right \), :allows-separator nil, :else nil}
- (let [mod-case-writer (cond
- (and (:at params) (:colon params))
- upcase-writer
+ []
+ #{:colon :at :both} {:right \), :allows-separator nil, :else nil}
+ (let [mod-case-writer (cond
+ (and (:at params) (:colon params))
+ upcase-writer
- (:colon params)
- capitalize-word-writer
+ (:colon params)
+ capitalize-word-writer
- (:at params)
- init-cap-writer
+ (:at params)
+ init-cap-writer
- :else
- downcase-writer)]
- #(modify-case mod-case-writer %1 %2 %3)))
+ :else
+ downcase-writer)]
+ #(modify-case mod-case-writer %1 %2 %3)))
(\) [] #{} {} nil)
(\[
- [:selector [nil js/Number]]
- #{:colon :at} {:right \], :allows-separator true, :else :last}
- (cond
- (:colon params)
- boolean-conditional
+ [:selector [nil js/Number]]
+ #{:colon :at} {:right \], :allows-separator true, :else :last}
+ (cond
+ (:colon params)
+ boolean-conditional
- (:at params)
- check-arg-conditional
+ (:at params)
+ check-arg-conditional
- true
- choice-conditional))
+ true
+ choice-conditional))
(\; [:min-remaining [nil js/Number] :max-columns [nil js/Number]]
- #{:colon} {:separator true} nil)
+ #{:colon} {:separator true} nil)
(\] [] #{} {} nil)
(\{
- [:max-iterations [nil js/Number]]
- #{:colon :at :both} {:right \}, :allows-separator false}
- (cond
- (and (:at params) (:colon params))
- iterate-main-sublists
+ [:max-iterations [nil js/Number]]
+ #{:colon :at :both} {:right \}, :allows-separator false}
+ (cond
+ (and (:at params) (:colon params))
+ iterate-main-sublists
- (:colon params)
- iterate-list-of-sublists
+ (:colon params)
+ iterate-list-of-sublists
- (:at params)
- iterate-main-list
+ (:at params)
+ iterate-main-list
- true
- iterate-sublist))
+ true
+ iterate-sublist))
(\} [] #{:colon} {} nil)
(\<
- [:mincol [0 js/Number] :colinc [1 js/Number] :minpad [0 js/Number] :padchar [\space js/String]]
- #{:colon :at :both :pretty} {:right \>, :allows-separator true, :else :first}
- logical-block-or-justify)
+ [:mincol [0 js/Number] :colinc [1 js/Number] :minpad [0 js/Number] :padchar [\space js/String]]
+ #{:colon :at :both :pretty} {:right \>, :allows-separator true, :else :first}
+ logical-block-or-justify)
(\> [] #{:colon} {} nil)
;; TODO: detect errors in cases where colon not allowed
(\^ [:arg1 [nil js/Number] :arg2 [nil js/Number] :arg3 [nil js/Number]]
- #{:colon} {}
- (fn [params navigator offsets]
- (let [arg1 (:arg1 params)
- arg2 (:arg2 params)
- arg3 (:arg3 params)
- exit (if (:colon params) :colon-up-arrow :up-arrow)]
- (cond
- (and arg1 arg2 arg3)
- (if (<= arg1 arg2 arg3) [exit navigator] navigator)
+ #{:colon} {}
+ (fn [params navigator offsets]
+ (let [arg1 (:arg1 params)
+ arg2 (:arg2 params)
+ arg3 (:arg3 params)
+ exit (if (:colon params) :colon-up-arrow :up-arrow)]
+ (cond
+ (and arg1 arg2 arg3)
+ (if (<= arg1 arg2 arg3) [exit navigator] navigator)
- (and arg1 arg2)
- (if (= arg1 arg2) [exit navigator] navigator)
+ (and arg1 arg2)
+ (if (= arg1 arg2) [exit navigator] navigator)
- arg1
- (if (= arg1 0) [exit navigator] navigator)
+ arg1
+ (if (= arg1 0) [exit navigator] navigator)
- true ; TODO: handle looking up the arglist stack for info
- (if (if (:colon params)
- (empty? (:rest (:base-args params)))
- (empty? (:rest navigator)))
- [exit navigator] navigator)))))
+ true ; TODO: handle looking up the arglist stack for info
+ (if (if (:colon params)
+ (empty? (:rest (:base-args params)))
+ (empty? (:rest navigator)))
+ [exit navigator] navigator)))))
(\W
- []
- #{:at :colon :both :pretty} {}
- (if (or (:at params) (:colon params))
- (let [bindings (concat
- (if (:at params) [:level nil :length nil] [])
- (if (:colon params) [:pretty true] []))]
- (fn [params navigator offsets]
- (let [[arg navigator] (next-arg navigator)]
- (if (apply write arg bindings)
- [:up-arrow navigator]
- navigator))))
- (fn [params navigator offsets]
- (let [[arg navigator] (next-arg navigator)]
- (if (write-out arg)
- [:up-arrow navigator]
- navigator)))))
+ []
+ #{:at :colon :both :pretty} {}
+ (if (or (:at params) (:colon params))
+ (let [bindings (concat
+ (if (:at params) [:level nil :length nil] [])
+ (if (:colon params) [:pretty true] []))]
+ (fn [params navigator offsets]
+ (let [[arg navigator] (next-arg navigator)]
+ (if (apply write arg bindings)
+ [:up-arrow navigator]
+ navigator))))
+ (fn [params navigator offsets]
+ (let [[arg navigator] (next-arg navigator)]
+ (if (write-out arg)
+ [:up-arrow navigator]
+ navigator)))))
(\_
- []
- #{:at :colon :both} {}
- conditional-newline)
+ []
+ #{:at :colon :both} {}
+ conditional-newline)
(\I
- [:n [0 js/Number]]
- #{:colon} {}
- set-indent)
+ [:n [0 js/Number]]
+ #{:colon} {}
+ set-indent)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2527,12 +2527,12 @@ of parameters as well."
(second (first params))))
(doall
(map #(let [val (first %1)]
- (if (not (or (nil? val) (contains? special-params val)
- (= (second (second %2)) (type val))))
- (format-error (str "Parameter " (name (first %2))
- " has bad type in directive \"" (:directive def) "\": "
- (type val))
- (second %1))) )
+ (if (not (or (nil? val) (contains? special-params val)
+ (= (second (second %2)) (type val))))
+ (format-error (str "Parameter " (name (first %2))
+ " has bad type in directive \"" (:directive def) "\": "
+ (type val))
+ (second %1))) )
params (:params def)))
(merge ; create the result map
@@ -2866,8 +2866,8 @@ column number or pretty printing"
(def pprint-set (formatter-out "~<#{~;~@{~w~^ ~:_~}~;}~:>"))
(def ^{:private true}
-type-map {"core$future_call" "Future",
- "core$promise" "Promise"})
+ type-map {"core$future_call" "Future",
+ "core$promise" "Promise"})
(defn- map-ref-type
"Map ugly type names to something simpler"
@@ -2955,7 +2955,7 @@ type-map {"core$future_call" "Future",
((formatter-out (if (vector? lis)
"~<[~;~@{~w~^ ~:_~}~;]~:>"
"~<(~;~@{~w~^ ~:_~}~;)~:>"))
- lis)
+ lis)
(write-out lis)))
(apply (formatter-out "~w ~:i~@{~w~^ ~:_~}") arg)))
(when (next args)
@@ -3164,9 +3164,9 @@ type-map {"core$future_call" "Future",
(let [core "clojure.core"]
(into {}
(map #(let [[s f] %]
- (if (not (or (namespace s) (special-symbol? s)))
- [(symbol core (name s)) f]
- %))
+ (if (not (or (namespace s) (special-symbol? s)))
+ [(symbol core (name s)) f]
+ %))
amap))))
(def ^:dynamic ^{:private true} *code-table*
diff --git a/src/main/cljs/cljs/reader.cljs b/src/main/cljs/cljs/reader.cljs
index 964f6be3..732a4fb8 100644
--- a/src/main/cljs/cljs/reader.cljs
+++ b/src/main/cljs/cljs/reader.cljs
@@ -9,8 +9,8 @@
(ns cljs.reader
(:require-macros [cljs.reader :refer [add-data-readers]])
(:require [goog.object :as gobject]
- [cljs.tools.reader :as treader]
- [cljs.tools.reader.edn :as edn])
+ [cljs.tools.reader :as treader]
+ [cljs.tools.reader.edn :as edn])
(:import [goog.string StringBuffer]))
(defn ^:private zero-fill-right-and-truncate [s width]
diff --git a/src/main/cljs/cljs/repl.cljs b/src/main/cljs/cljs/repl.cljs
index 7999ed42..5d77559f 100644
--- a/src/main/cljs/cljs/repl.cljs
+++ b/src/main/cljs/cljs/repl.cljs
@@ -9,8 +9,8 @@
(ns cljs.repl
(:require-macros cljs.repl)
(:require [cljs.spec.alpha :as spec]
- [goog.string :as gstring]
- [goog.string.format]))
+ [goog.string :as gstring]
+ [goog.string.format]))
(defn print-doc [{n :ns nm :name :as m}]
(println "-------------------------")
@@ -22,12 +22,12 @@
(println " " f))
(:arglists m) (let [arglists (:arglists m)]
(if (or (:macro m)
- (:repl-special-function m))
- (prn arglists)
- (prn
- (if (= 'quote (first arglists))
- (second arglists)
- arglists)))))
+ (:repl-special-function m))
+ (prn arglists)
+ (prn
+ (if (= 'quote (first arglists))
+ (second arglists)
+ arglists)))))
(if (:special-form m)
(do
(println "Special Form")
@@ -85,8 +85,8 @@
(when-let [ed (ex-data t)]
{:data ed})
#_(let [st (extract-canonical-stacktrace t)]
- (when (pos? (count st))
- {:at st}))))
+ (when (pos? (count st))
+ {:at st}))))
via (loop [via [], t o]
(if t
(recur (conj via t) (ex-cause t))
@@ -121,41 +121,41 @@
{::spec/keys [:problems :fn :cljs.spec.test.alpha/caller]} data
{:keys [:clojure.error/source] :as top-data} (:data (first via))]
(assoc
- (case phase
- :read-source
- (let [{:keys [:clojure.error/line :clojure.error/column]} data]
- (cond-> (merge (-> via second :data) top-data)
- source (assoc :clojure.error/source source)
- (#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} source) (dissoc :clojure.error/source)
- message (assoc :clojure.error/cause message)))
-
- (:compile-syntax-check :compilation :macro-syntax-check :macroexpansion)
- (cond-> top-data
- source (assoc :clojure.error/source source)
- (#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} source) (dissoc :clojure.error/source)
- type (assoc :clojure.error/class type)
- message (assoc :clojure.error/cause message)
- problems (assoc :clojure.error/spec data))
-
- (:read-eval-result :print-eval-result)
- (let [[source method file line] (-> trace first)]
- (cond-> top-data
- line (assoc :clojure.error/line line)
- file (assoc :clojure.error/source file)
- (and source method) (assoc :clojure.error/symbol (vector #_java-loc->source source method))
- type (assoc :clojure.error/class type)
- message (assoc :clojure.error/cause message)))
-
- :execution
- (let [[source method file line] (->> trace #_(drop-while #(core-class? (name (first %)))) first)
- file (first (remove #(or (nil? %) (#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} %)) [(:file caller) file]))
- err-line (or (:line caller) line)]
- (cond-> {:clojure.error/class type}
- err-line (assoc :clojure.error/line err-line)
- message (assoc :clojure.error/cause message)
- (or fn (and source method)) (assoc :clojure.error/symbol (or fn (vector #_java-loc->source source method)))
- file (assoc :clojure.error/source file)
- problems (assoc :clojure.error/spec data))))
+ (case phase
+ :read-source
+ (let [{:keys [:clojure.error/line :clojure.error/column]} data]
+ (cond-> (merge (-> via second :data) top-data)
+ source (assoc :clojure.error/source source)
+ (#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} source) (dissoc :clojure.error/source)
+ message (assoc :clojure.error/cause message)))
+
+ (:compile-syntax-check :compilation :macro-syntax-check :macroexpansion)
+ (cond-> top-data
+ source (assoc :clojure.error/source source)
+ (#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} source) (dissoc :clojure.error/source)
+ type (assoc :clojure.error/class type)
+ message (assoc :clojure.error/cause message)
+ problems (assoc :clojure.error/spec data))
+
+ (:read-eval-result :print-eval-result)
+ (let [[source method file line] (-> trace first)]
+ (cond-> top-data
+ line (assoc :clojure.error/line line)
+ file (assoc :clojure.error/source file)
+ (and source method) (assoc :clojure.error/symbol (vector #_java-loc->source source method))
+ type (assoc :clojure.error/class type)
+ message (assoc :clojure.error/cause message)))
+
+ :execution
+ (let [[source method file line] (->> trace #_(drop-while #(core-class? (name (first %)))) first)
+ file (first (remove #(or (nil? %) (#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} %)) [(:file caller) file]))
+ err-line (or (:line caller) line)]
+ (cond-> {:clojure.error/class type}
+ err-line (assoc :clojure.error/line err-line)
+ message (assoc :clojure.error/cause message)
+ (or fn (and source method)) (assoc :clojure.error/symbol (or fn (vector #_java-loc->source source method)))
+ file (assoc :clojure.error/source file)
+ problems (assoc :clojure.error/spec data))))
:clojure.error/phase phase)))
(defn ex-str
diff --git a/src/main/cljs/cljs/source_map.cljs b/src/main/cljs/cljs/source_map.cljs
index 7009bfd7..7f91dad0 100644
--- a/src/main/cljs/cljs/source_map.cljs
+++ b/src/main/cljs/cljs/source_map.cljs
@@ -8,9 +8,9 @@
(ns cljs.source-map
(:require [goog.object :as gobj]
- [clojure.string :as string]
- [clojure.set :as set]
- [cljs.source-map.base64-vlq :as base64-vlq]))
+ [clojure.string :as string]
+ [clojure.set :as set]
+ [cljs.source-map.base64-vlq :as base64-vlq]))
;; =============================================================================
;; Source map code in the file assumes the following in memory
@@ -55,12 +55,12 @@
and return a map."
[seg source-map]
(let [[gcol source line col name] seg]
- {:gcol gcol
- :source (aget (gobj/get source-map "sources") source)
- :line line
- :col col
- :name (when-let [name (-> seg meta :name)]
- (aget (gobj/get source-map "names") name))}))
+ {:gcol gcol
+ :source (aget (gobj/get source-map "sources") source)
+ :line line
+ :col col
+ :name (when-let [name (-> seg meta :name)]
+ (aget (gobj/get source-map "names") name))}))
(defn seg-combine
"Combine a source map segment vector and a relative
@@ -147,27 +147,27 @@
generated JavaScript source locations to the original
ClojureScript."
([source-map]
- (decode (gobj/get source-map "mappings") source-map))
+ (decode (gobj/get source-map "mappings") source-map))
([mappings source-map]
- (let [sources (gobj/get source-map "sources")
- relseg-init [0 0 0 0 0]
- lines (seq (string/split mappings #";"))]
- (loop [gline 0 lines lines relseg relseg-init result {}]
- (if lines
- (let [line (first lines)
+ (let [sources (gobj/get source-map "sources")
+ relseg-init [0 0 0 0 0]
+ lines (seq (string/split mappings #";"))]
+ (loop [gline 0 lines lines relseg relseg-init result {}]
+ (if lines
+ (let [line (first lines)
+ [result relseg]
+ (if (string/blank? line)
[result relseg]
- (if (string/blank? line)
- [result relseg]
- (let [segs (seq (string/split line #","))]
- (loop [segs segs relseg relseg result result]
- (if segs
- (let [seg (first segs)
- nrelseg (seg-combine (base64-vlq/decode seg) relseg)]
- (recur (next segs) nrelseg
- (update-result result (seg->map nrelseg source-map) gline)))
- [result relseg]))))]
- (recur (inc gline) (next lines) (assoc relseg 0 0) result))
- result)))))
+ (let [segs (seq (string/split line #","))]
+ (loop [segs segs relseg relseg result result]
+ (if segs
+ (let [seg (first segs)
+ nrelseg (seg-combine (base64-vlq/decode seg) relseg)]
+ (recur (next segs) nrelseg
+ (update-result result (seg->map nrelseg source-map) gline)))
+ [result relseg]))))]
+ (recur (inc gline) (next lines) (assoc relseg 0 0) result))
+ result)))))
;; -----------------------------------------------------------------------------
;; Encoding
diff --git a/src/main/cljs/cljs/source_map/base64.cljs b/src/main/cljs/cljs/source_map/base64.cljs
index c5dfc2b1..eb2a3cf5 100644
--- a/src/main/cljs/cljs/source_map/base64.cljs
+++ b/src/main/cljs/cljs/source_map/base64.cljs
@@ -14,12 +14,12 @@
(defn encode [n]
(let [e (find int->char n)]
- (if e
- (second e)
- (throw (js/Error. (str "Must be between 0 and 63: " n))))))
+ (if e
+ (second e)
+ (throw (js/Error. (str "Must be between 0 and 63: " n))))))
(defn decode [c]
(let [e (find char->int c)]
- (if e
- (second e)
- (throw (js/Error. (str "Not a valid base 64 digit: " c))))))
+ (if e
+ (second e)
+ (throw (js/Error. (str "Not a valid base 64 digit: " c))))))
diff --git a/src/main/cljs/cljs/source_map/base64_vlq.cljs b/src/main/cljs/cljs/source_map/base64_vlq.cljs
index ff4d02b2..6941a9c8 100644
--- a/src/main/cljs/cljs/source_map/base64_vlq.cljs
+++ b/src/main/cljs/cljs/source_map/base64_vlq.cljs
@@ -8,7 +8,7 @@
(ns cljs.source-map.base64-vlq
(:require [clojure.string :as string]
- [cljs.source-map.base64 :as base64])
+ [cljs.source-map.base64 :as base64])
(:import [goog.string StringBuffer]))
(def ^:const vlq-base-shift 5)
@@ -58,10 +58,10 @@
(if continuation?
(recur i result shift)
(lazy-seq
- (cons (from-vlq-signed result)
- (let [s (.substring s i)]
- (when-not (string/blank? s)
- (decode s)))))))))))
+ (cons (from-vlq-signed result)
+ (let [s (.substring s i)]
+ (when-not (string/blank? s)
+ (decode s)))))))))))
(comment
;; tests
diff --git a/src/main/cljs/cljs/spec/alpha.cljs b/src/main/cljs/cljs/spec/alpha.cljs
index 19a9241f..db2c7372 100644
--- a/src/main/cljs/cljs/spec/alpha.cljs
+++ b/src/main/cljs/cljs/spec/alpha.cljs
@@ -9,12 +9,12 @@
(ns cljs.spec.alpha
(:refer-clojure :exclude [+ * and or cat def keys merge])
(:require-macros [cljs.core :as c]
- [cljs.spec.alpha :as s])
+ [cljs.spec.alpha :as s])
(:require [goog.object :as gobj]
- [cljs.core :as c]
- [clojure.walk :as walk]
- [cljs.spec.gen.alpha :as gen]
- [clojure.string :as str]))
+ [cljs.core :as c]
+ [clojure.walk :as walk]
+ [cljs.spec.gen.alpha :as gen]
+ [clojure.string :as str]))
(def ^:const MAX_INT 9007199254740991)
@@ -84,20 +84,20 @@
(defn- with-name [spec name]
(cond
- (ident? spec) spec
- (regex? spec) (assoc spec ::name name)
+ (ident? spec) spec
+ (regex? spec) (assoc spec ::name name)
- (implements? IMeta spec)
- (with-meta spec (assoc (meta spec) ::name name))))
+ (implements? IMeta spec)
+ (with-meta spec (assoc (meta spec) ::name name))))
(defn- spec-name [spec]
(cond
- (ident? spec) spec
+ (ident? spec) spec
- (regex? spec) (::name spec)
+ (regex? spec) (::name spec)
- (implements? IMeta spec)
- (-> (meta spec) ::name)))
+ (implements? IMeta spec)
+ (-> (meta spec) ::name)))
(declare ^{:arglists '([form pred gfn cpred?] [form pred gfn cpred? unc])} spec-impl)
(declare ^{:arglists '([re gfn])} regex-spec-impl)
@@ -547,8 +547,8 @@
([form mmvar retag gfn]
(let [id (random-uuid)
predx #(let [mm @mmvar]
- (c/and (-get-method mm ((-dispatch-fn mm) %))
- (mm %)))
+ (c/and (-get-method mm ((-dispatch-fn mm) %))
+ (mm %)))
dval #((-dispatch-fn @mmvar) %)
tag (if (keyword? retag)
#(assoc %1 retag %2)
@@ -795,20 +795,20 @@
(let [pred (c/or kfn coll?)
kform (c/or kform `coll?)]
(cond
- (not (pvalid? pred x))
- (explain-1 kform pred path via in x)
+ (not (pvalid? pred x))
+ (explain-1 kform pred path via in x)
- (c/and count (not= count (bounded-count count x)))
- [{:path path :pred `(= ~count (c/count ~'%)) :val x :via via :in in}]
+ (c/and count (not= count (bounded-count count x)))
+ [{:path path :pred `(= ~count (c/count ~'%)) :val x :via via :in in}]
- (c/and (c/or min-count max-count)
- (not (<= (c/or min-count 0)
- (bounded-count (if max-count (inc max-count) min-count) x)
- (c/or max-count MAX_INT))))
- [{:path path :pred `(<= ~(c/or min-count 0) (c/count ~'%) ~(c/or max-count MAX_INT)) :val x :via via :in in}]
+ (c/and (c/or min-count max-count)
+ (not (<= (c/or min-count 0)
+ (bounded-count (if max-count (inc max-count) min-count) x)
+ (c/or max-count MAX_INT))))
+ [{:path path :pred `(<= ~(c/or min-count 0) (c/count ~'%) ~(c/or max-count MAX_INT)) :val x :via via :in in}]
- (c/and distinct (not (empty? x)) (not (apply distinct? x)))
- [{:path path :pred 'distinct? :val x :via via :in in}])))
+ (c/and distinct (not (empty? x)) (not (apply distinct? x)))
+ [{:path path :pred 'distinct? :val x :via via :in in}])))
(defn ^:skip-wiki merge-spec-impl
"Do not call this directly, use 'merge'"
@@ -928,13 +928,13 @@
path via in)
(apply concat
((if conform-all identity (partial take *coll-error-limit*))
- (keep identity
- (map (fn [i v]
- (let [k (kfn i v)]
- (when-not (check? v)
- (let [prob (explain-1 form pred path via (conj in k) v)]
- prob))))
- (range) x))))))
+ (keep identity
+ (map (fn [i v]
+ (let [k (kfn i v)]
+ (when-not (check? v)
+ (let [prob (explain-1 form pred path via (conj in k) v)]
+ prob))))
+ (range) x))))))
(gen* [_ overrides path rmap]
(if gfn
(gfn)
@@ -1110,7 +1110,7 @@
(defn- add-ret [p r k]
(let [{:keys [::op ps splice] :as p} (reg-resolve! p)
prop #(let [ret (preturn p)]
- (if (empty? ret) r ((if splice into conj) r (if k {k ret} ret))))]
+ (if (empty? ret) r ((if splice into conj) r (if k {k ret} ret))))]
(case op
nil r
(::alt ::accept ::amp)
@@ -1372,11 +1372,11 @@
(explain-1 fform fnspec (conj path :fn) via in {:args cargs :ret cret})))))))))
[{:path path :pred 'ifn? :val f :via via :in in}]))
(gen* [_ overrides _ _] (if gfn
- (gfn)
- (gen/return
- (fn [& args]
- (assert (pvalid? argspec args) (with-out-str (explain argspec args)))
- (gen/generate (gen retspec overrides))))))
+ (gfn)
+ (gen/return
+ (fn [& args]
+ (assert (pvalid? argspec args) (with-out-str (explain argspec args)))
+ (gen/generate (gen retspec overrides))))))
(with-gen* [_ gfn] (fspec-impl argspec aform retspec rform fnspec fform gfn))
(describe* [_] `(fspec :args ~aform :ret ~rform :fn ~fform)))))
@@ -1389,20 +1389,20 @@
[spec]
(let [spec (delay (specize spec))]
(reify
- Specize
- (specize* [s] s)
- (specize* [s _] s)
-
- Spec
- (conform* [_ x] (let [ret (conform* @spec x)]
- (if (invalid? ret)
- ::invalid
- x)))
- (unform* [_ x] (unform* @spec x))
- (explain* [_ path via in x] (explain* @spec path via in x))
- (gen* [_ overrides path rmap] (gen* @spec overrides path rmap))
- (with-gen* [_ gfn] (nonconforming (with-gen* @spec gfn)))
- (describe* [_] `(nonconforming ~(describe* @spec))))))
+ Specize
+ (specize* [s] s)
+ (specize* [s _] s)
+
+ Spec
+ (conform* [_ x] (let [ret (conform* @spec x)]
+ (if (invalid? ret)
+ ::invalid
+ x)))
+ (unform* [_ x] (unform* @spec x))
+ (explain* [_ path via in x] (explain* @spec path via in x))
+ (gen* [_ overrides path rmap] (gen* @spec overrides path rmap))
+ (with-gen* [_ gfn] (nonconforming (with-gen* @spec gfn)))
+ (describe* [_] `(nonconforming ~(describe* @spec))))))
(defn ^:skip-wiki nilable-impl
"Do not call this directly, use 'nilable'"
@@ -1500,4 +1500,4 @@ Defaults to false."
(let [ed (c/merge (assoc (explain-data* spec [] [] [] x)
::failure :assertion-failed))]
(throw (js/Error.
- (str "Spec assertion failed\n" (with-out-str (explain-out ed))))))))
+ (str "Spec assertion failed\n" (with-out-str (explain-out ed))))))))
diff --git a/src/main/cljs/cljs/spec/gen/alpha.cljs b/src/main/cljs/cljs/spec/gen/alpha.cljs
index 65b0a87a..e00dacd7 100644
--- a/src/main/cljs/cljs/spec/gen/alpha.cljs
+++ b/src/main/cljs/cljs/spec/gen/alpha.cljs
@@ -10,7 +10,7 @@
(:refer-clojure :exclude [boolean cat hash-map list map not-empty set vector
char double int keyword symbol string uuid delay shuffle])
(:require-macros [cljs.core :as c]
- [cljs.spec.gen.alpha :as gen :refer [dynaload lazy-combinators lazy-prims]])
+ [cljs.spec.gen.alpha :as gen :refer [dynaload lazy-combinators lazy-prims]])
(:require [cljs.core :as c])
(:import (goog Uri)))
@@ -85,7 +85,7 @@ gens, each of which should generate something sequential."
(defn- ^boolean qualified? [ident] (not (nil? (namespace ident))))
(def ^:private
-gen-builtins
+ gen-builtins
(c/delay
(let [simple (simple-type-printable)]
{any? (one-of [(return nil) (any-printable)])
@@ -111,7 +111,7 @@ gen-builtins
uuid? (uuid)
uri? (fmap #(Uri. (str "http://" % ".com")) (uuid))
inst? (fmap #(js/Date. %)
- (large-integer))
+ (large-integer))
seqable? (one-of [(return nil)
(list simple)
(vector simple)
@@ -162,10 +162,10 @@ gen-builtins
opts {:c (gen-for-pred string?)}]
(generate (bind (choose 0 (count opts))
#(let [args (concat (seq reqs) (c/shuffle (seq opts)))]
- (->> args
- (take (+ % (count reqs)))
- (mapcat identity)
- (apply hash-map))))))
+ (->> args
+ (take (+ % (count reqs)))
+ (mapcat identity)
+ (apply hash-map))))))
(generate (cat (list (gen-for-pred string?))
(list (gen-for-pred integer?))))
diff --git a/src/main/cljs/cljs/spec/test/alpha.cljs b/src/main/cljs/cljs/spec/test/alpha.cljs
index 897c2911..4043c90b 100644
--- a/src/main/cljs/cljs/spec/test/alpha.cljs
+++ b/src/main/cljs/cljs/spec/test/alpha.cljs
@@ -9,15 +9,15 @@
(ns cljs.spec.test.alpha
(:require-macros [cljs.spec.test.alpha :as m :refer [with-instrument-disabled setup-static-dispatches]])
(:require
- [goog.object :as gobj]
- [goog.userAgent.product :as product]
- [clojure.string :as string]
- [cljs.stacktrace :as st]
- [cljs.pprint :as pp]
- [cljs.spec.alpha :as s]
- [cljs.spec.gen.alpha :as gen]
- [clojure.test.check :as stc]
- [clojure.test.check.properties]))
+ [goog.object :as gobj]
+ [goog.userAgent.product :as product]
+ [clojure.string :as string]
+ [cljs.stacktrace :as st]
+ [cljs.pprint :as pp]
+ [cljs.spec.alpha :as s]
+ [cljs.spec.gen.alpha :as gen]
+ [clojure.test.check :as stc]
+ [clojure.test.check.properties]))
(defn distinct-by
([f coll]
@@ -29,7 +29,7 @@
(if (contains? seen v)
(recur (rest s) seen)
(cons x (step (rest s) (conj seen v)))))))
- xs seen)))]
+ xs seen)))]
(step coll #{}))))
(defn ->sym
diff --git a/src/main/cljs/cljs/test.cljs b/src/main/cljs/cljs/test.cljs
index a6aa186c..ca196ae5 100644
--- a/src/main/cljs/cljs/test.cljs
+++ b/src/main/cljs/cljs/test.cljs
@@ -7,10 +7,10 @@
; You must not remove this notice, or any other, from this software.
(ns
-^{:author "Stuart Sierra, with contributions and suggestions by
+ ^{:author "Stuart Sierra, with contributions and suggestions by
Chas Emerick, Allen Rohner, Stuart Halloway, David Nolen, and
Leon Grapenthin",
- :doc "A unit testing framework.
+ :doc "A unit testing framework.
ASSERTIONS
@@ -242,9 +242,9 @@
"}
cljs.test
(:require-macros [clojure.template :as temp]
- [cljs.test :as test])
+ [cljs.test :as test])
(:require [clojure.string :as string]
- [cljs.pprint :as pprint]))
+ [cljs.pprint :as pprint]))
;; =============================================================================
;; Default Reporting
@@ -314,7 +314,7 @@
different report formats (e.g., TAP, JUnit). Assertions such as
'is' call 'report' to indicate results. The argument given to
'report' will be a map with a :type key."
- :dynamic true}
+ :dynamic true}
report (fn [m] [(:reporter (get-current-env)) (:type m)]))
(defmethod report :default [m])
@@ -478,10 +478,10 @@
(case e
::async-disabled (throw "Async tests require fixtures to be specified as maps. Testing aborted.")
(do-report
- {:type :error
- :message "Uncaught exception, not in assertion."
- :expected nil
- :actual e})))))
+ {:type :error
+ :message "Uncaught exception, not in assertion."
+ :expected nil
+ :actual e})))))
(fn []
(do-report {:type :end-test-var :var v})
(update-current-env! [:testing-vars] rest))])
@@ -558,33 +558,33 @@
later execution."
[vars]
(map
- (fn [[ns vars]]
- (fn []
- (block
- (let [env (get-current-env)
- once-fixtures (get-in env [:once-fixtures ns])
- each-fixtures (get-in env [:each-fixtures ns])]
- (case (execution-strategy once-fixtures each-fixtures)
- :async
- (->> vars
- (filter (comp :test meta))
- (mapcat (comp (partial wrap-map-fixtures each-fixtures)
- test-var-block))
- (wrap-map-fixtures once-fixtures))
- :sync
- (let [each-fixture-fn (join-fixtures each-fixtures)]
- [(fn []
- ((join-fixtures once-fixtures)
- (fn []
- (doseq [v vars]
- (when-let [t (:test (meta v))]
- ;; (alter-meta! v update :test disable-async)
- (each-fixture-fn
- (fn []
- ;; (test-var v)
- (run-block
- (test-var-block* v (disable-async t))))))))))]))))))
- (group-by (comp :ns meta) vars)))
+ (fn [[ns vars]]
+ (fn []
+ (block
+ (let [env (get-current-env)
+ once-fixtures (get-in env [:once-fixtures ns])
+ each-fixtures (get-in env [:each-fixtures ns])]
+ (case (execution-strategy once-fixtures each-fixtures)
+ :async
+ (->> vars
+ (filter (comp :test meta))
+ (mapcat (comp (partial wrap-map-fixtures each-fixtures)
+ test-var-block))
+ (wrap-map-fixtures once-fixtures))
+ :sync
+ (let [each-fixture-fn (join-fixtures each-fixtures)]
+ [(fn []
+ ((join-fixtures once-fixtures)
+ (fn []
+ (doseq [v vars]
+ (when-let [t (:test (meta v))]
+ ;; (alter-meta! v update :test disable-async)
+ (each-fixture-fn
+ (fn []
+ ;; (test-var v)
+ (run-block
+ (test-var-block* v (disable-async t))))))))))]))))))
+ (group-by (comp :ns meta) vars)))
(defn test-vars
"Groups vars by their namespace and runs test-vars on them with
diff --git a/src/main/cljs/clojure/browser/dom.cljs b/src/main/cljs/clojure/browser/dom.cljs
index 8c6a0a04..8e755ea3 100644
--- a/src/main/cljs/clojure/browser/dom.cljs
+++ b/src/main/cljs/clojure/browser/dom.cljs
@@ -8,7 +8,7 @@
(ns clojure.browser.dom
(:require [goog.dom :as gdom]
- [goog.object :as gobject]))
+ [goog.object :as gobject]))
(defn append [parent & children]
(apply gdom/append parent children)
@@ -28,39 +28,39 @@
string
(-element
([this]
- (log "string (-element " this ")")
- (cond (keyword? this) (gdom/createElement (name this))
- :else (gdom/createTextNode (name this))))
+ (log "string (-element " this ")")
+ (cond (keyword? this) (gdom/createElement (name this))
+ :else (gdom/createTextNode (name this))))
([this attrs-or-children]
- (log "string (-element " this " " attrs-or-children ")")
- (let [attrs (first attrs-or-children)]
- (if (map? attrs)
- (-element this attrs (rest attrs-or-children))
- (-element this nil attrs-or-children))))
+ (log "string (-element " this " " attrs-or-children ")")
+ (let [attrs (first attrs-or-children)]
+ (if (map? attrs)
+ (-element this attrs (rest attrs-or-children))
+ (-element this nil attrs-or-children))))
([this attrs children]
- (log "string (-element " this " " attrs " " children ")")
- (let [str-attrs (if (and (map? attrs) (seq attrs))
- (reduce (fn [o [k v]]
- (let [o (if (nil? o) (js-obj) o)]
- (log "o = " o)
- (log "k = " k)
- (log "v = " v)
- (when (or (keyword? k)
- (string? k))
- (doto o (gobject/set (name k) v)))))
- (js-obj)
- attrs)
- nil)]
- (log-obj str-attrs)
- (if (seq children)
- (apply gdom/createDom
- (name this)
- str-attrs
- (map -element children))
- (gdom/createDom (name this)
- str-attrs)))))
+ (log "string (-element " this " " attrs " " children ")")
+ (let [str-attrs (if (and (map? attrs) (seq attrs))
+ (reduce (fn [o [k v]]
+ (let [o (if (nil? o) (js-obj) o)]
+ (log "o = " o)
+ (log "k = " k)
+ (log "v = " v)
+ (when (or (keyword? k)
+ (string? k))
+ (doto o (gobject/set (name k) v)))))
+ (js-obj)
+ attrs)
+ nil)]
+ (log-obj str-attrs)
+ (if (seq children)
+ (apply gdom/createDom
+ (name this)
+ str-attrs
+ (map -element children))
+ (gdom/createDom (name this)
+ str-attrs)))))
PersistentVector
(-element
@@ -80,14 +80,14 @@
(defn element
([tag-or-text]
- (log "(element " tag-or-text ")")
- (-element tag-or-text))
+ (log "(element " tag-or-text ")")
+ (-element tag-or-text))
([tag & children]
- (log "(element " tag " " children ")")
- (let [attrs (first children)]
- (if (map? attrs)
- (-element tag attrs (rest children))
- (-element tag nil children)))))
+ (log "(element " tag " " children ")")
+ (let [attrs (first children)]
+ (if (map? attrs)
+ (-element tag attrs (rest children))
+ (-element tag nil children)))))
(defn remove-children
"Remove all children from the element with the passed id."
diff --git a/src/main/cljs/clojure/browser/event.cljs b/src/main/cljs/clojure/browser/event.cljs
index b04dcd2f..fcf3c093 100644
--- a/src/main/cljs/clojure/browser/event.cljs
+++ b/src/main/cljs/clojure/browser/event.cljs
@@ -23,11 +23,11 @@ events. It is based on the Google Closure Library event system."
[this]
(into {}
(map
- (fn [[k v]]
- [(keyword (.toLowerCase k))
- v])
- (merge
- (js->clj EventType))))))
+ (fn [[k v]]
+ [(keyword (.toLowerCase k))
+ v])
+ (merge
+ (js->clj EventType))))))
(when (exists? js/Element)
(extend-protocol IEventType
@@ -37,38 +37,38 @@ events. It is based on the Google Closure Library event system."
[this]
(into {}
(map
- (fn [[k v]]
- [(keyword (.toLowerCase k))
- v])
- (merge
- (js->clj EventType)))))))
+ (fn [[k v]]
+ [(keyword (.toLowerCase k))
+ v])
+ (merge
+ (js->clj EventType)))))))
(defn listen
([src type fn]
- (listen src type fn false))
+ (listen src type fn false))
([src type fn capture?]
- (events/listen src
- (get (event-types src) type type)
- fn
- capture?)))
+ (events/listen src
+ (get (event-types src) type type)
+ fn
+ capture?)))
(defn listen-once
([src type fn]
- (listen-once src type fn false))
+ (listen-once src type fn false))
([src type fn capture?]
- (events/listenOnce src
- (get (event-types src) type type)
- fn
- capture?)))
+ (events/listenOnce src
+ (get (event-types src) type type)
+ fn
+ capture?)))
(defn unlisten
([src type fn]
- (unlisten src type fn false))
+ (unlisten src type fn false))
([src type fn capture?]
- (events/unlisten src
- (get (event-types src) type type)
- fn
- capture?)))
+ (events/unlisten src
+ (get (event-types src) type type)
+ fn
+ capture?)))
(defn unlisten-by-key
[key]
diff --git a/src/main/cljs/clojure/browser/net.cljs b/src/main/cljs/clojure/browser/net.cljs
index 016e1046..9f53928a 100644
--- a/src/main/cljs/clojure/browser/net.cljs
+++ b/src/main/cljs/clojure/browser/net.cljs
@@ -11,22 +11,22 @@ Includes a common API over XhrIo, CrossPageChannel, and Websockets."
:author "Bobby Calderwood and Alex Redington"}
clojure.browser.net
(:require [clojure.browser.event :as event]
- [goog.json :as gjson]
- [goog.object :as gobj])
+ [goog.json :as gjson]
+ [goog.object :as gobj])
(:import [goog.net XhrIo EventType WebSocket]
- [goog.net.xpc CfgFields CrossPageChannel]
- [goog Uri]))
+ [goog.net.xpc CfgFields CrossPageChannel]
+ [goog Uri]))
(def *timeout* 10000)
(def event-types
(into {}
(map
- (fn [[k v]]
- [(keyword (.toLowerCase k))
- v])
- (merge
- (js->clj EventType)))))
+ (fn [[k v]]
+ [(keyword (.toLowerCase k))
+ v])
+ (merge
+ (js->clj EventType)))))
(defprotocol IConnection
(connect
@@ -47,37 +47,37 @@ Includes a common API over XhrIo, CrossPageChannel, and Websockets."
IConnection
(transmit
([this uri]
- (transmit this uri "GET" nil nil *timeout*))
+ (transmit this uri "GET" nil nil *timeout*))
([this uri method]
- (transmit this uri method nil nil *timeout*))
+ (transmit this uri method nil nil *timeout*))
([this uri method content]
- (transmit this uri method content nil *timeout*))
+ (transmit this uri method content nil *timeout*))
([this uri method content headers]
- (transmit this uri method content headers *timeout*))
+ (transmit this uri method content headers *timeout*))
([this uri method content headers timeout]
- (.setTimeoutInterval this timeout)
- (.send this uri method content headers)))
+ (.setTimeoutInterval this timeout)
+ (.send this uri method content headers)))
event/IEventType
(event-types [this]
(into {}
(map
- (fn [[k v]]
- [(keyword (.toLowerCase k))
- v])
- (merge
- (js->clj EventType))))))
+ (fn [[k v]]
+ [(keyword (.toLowerCase k))
+ v])
+ (merge
+ (js->clj EventType))))))
;; TODO jQuery/sinatra/RestClient style API: (get [uri]), (post [uri payload]), (put [uri payload]), (delete [uri])
(def xpc-config-fields
(into {}
(map
- (fn [[k v]]
- [(keyword (.toLowerCase k))
- v])
- (js->clj CfgFields))))
+ (fn [[k v]]
+ [(keyword (.toLowerCase k))
+ v])
+ (js->clj CfgFields))))
(defn xhr-connection
"Returns an XhrIo connection"
@@ -92,21 +92,21 @@ Includes a common API over XhrIo, CrossPageChannel, and Websockets."
ICrossPageChannel
(register-service
([this service-name fn]
- (register-service this service-name fn false))
+ (register-service this service-name fn false))
([this service-name fn encode-json?]
- (.registerService this (name service-name) fn encode-json?)))
+ (.registerService this (name service-name) fn encode-json?)))
IConnection
(connect
([this]
- (connect this nil))
+ (connect this nil))
([this on-connect-fn]
- (.connect this on-connect-fn))
+ (.connect this on-connect-fn))
([this on-connect-fn config-iframe-fn]
- (connect this on-connect-fn config-iframe-fn (.-body js/document)))
+ (connect this on-connect-fn config-iframe-fn (.-body js/document)))
([this on-connect-fn config-iframe-fn iframe-parent]
- (.createPeerIframe this iframe-parent config-iframe-fn)
- (.connect this on-connect-fn)))
+ (.createPeerIframe this iframe-parent config-iframe-fn)
+ (.connect this on-connect-fn)))
(transmit [this service-name payload]
(.send this (name service-name) payload))
@@ -125,18 +125,18 @@ Includes a common API over XhrIo, CrossPageChannel, and Websockets."
and the config is automatically taken from the URL param 'xpc', as
per the CrossPageChannel API."
([]
- (when-let [config (.getParameterValue
- (Uri. (.-href (.-location js/window)))
- "xpc")]
- (CrossPageChannel. (gjson/parse config))))
+ (when-let [config (.getParameterValue
+ (Uri. (.-href (.-location js/window)))
+ "xpc")]
+ (CrossPageChannel. (gjson/parse config))))
([config]
- (CrossPageChannel.
- (reduce (fn [sum [k v]]
- (if-let [field (get xpc-config-fields k)]
- (doto sum (gobj/set field v))
- sum))
- (js-obj)
- config))))
+ (CrossPageChannel.
+ (reduce (fn [sum [k v]]
+ (if-let [field (get xpc-config-fields k)]
+ (doto sum (gobj/set field v))
+ sum))
+ (js-obj)
+ config))))
;; WebSocket is not supported in the 3/23/11 release of Google
;; Closure, but will be included in the next release.
@@ -174,8 +174,8 @@ Includes a common API over XhrIo, CrossPageChannel, and Websockets."
(defn websocket-connection
([]
- (websocket-connection nil nil))
+ (websocket-connection nil nil))
([auto-reconnect?]
- (websocket-connection auto-reconnect? nil))
+ (websocket-connection auto-reconnect? nil))
([auto-reconnect? next-reconnect-fn]
- (WebSocket. auto-reconnect? next-reconnect-fn)))
+ (WebSocket. auto-reconnect? next-reconnect-fn)))
diff --git a/src/main/cljs/clojure/browser/repl.cljs b/src/main/cljs/clojure/browser/repl.cljs
index ba518b18..09e55d6d 100644
--- a/src/main/cljs/clojure/browser/repl.cljs
+++ b/src/main/cljs/clojure/browser/repl.cljs
@@ -16,17 +16,17 @@
:author "Bobby Calderwood and Alex Redington"}
clojure.browser.repl
(:require [goog.dom :as gdom]
- [goog.object :as gobj]
- [goog.array :as garray]
- [goog.json :as json]
- [goog.userAgent.product :as product]
- [clojure.browser.net :as net]
- [clojure.browser.event :as event]
- ;; repl-connection callback will receive goog.require('cljs.repl')
- ;; and monkey-patched require expects to be able to derive it
- ;; via goog.basePath, so this namespace should be compiled together
- ;; with clojure.browser.repl:
- [cljs.repl]))
+ [goog.object :as gobj]
+ [goog.array :as garray]
+ [goog.json :as json]
+ [goog.userAgent.product :as product]
+ [clojure.browser.net :as net]
+ [clojure.browser.event :as event]
+ ;; repl-connection callback will receive goog.require('cljs.repl')
+ ;; and monkey-patched require expects to be able to derive it
+ ;; via goog.basePath, so this namespace should be compiled together
+ ;; with clojure.browser.repl:
+ [cljs.repl]))
(goog-define HOST "localhost")
(goog-define PORT 9000)
diff --git a/src/main/cljs/clojure/core/reducers.cljs b/src/main/cljs/clojure/core/reducers.cljs
index 159cb8ef..8cebb282 100644
--- a/src/main/cljs/clojure/core/reducers.cljs
+++ b/src/main/cljs/clojure/core/reducers.cljs
@@ -36,12 +36,12 @@
Maps are reduced with reduce-kv"
([f coll] (reduce f (f) coll))
([f init coll]
- (if (map? coll)
- (-kv-reduce coll f init)
- (cond
- (nil? coll) init
- (array? coll) (#'array-reduce coll f init)
- :else (-reduce coll f init)))))
+ (if (map? coll)
+ (-kv-reduce coll f init)
+ (cond
+ (nil? coll) init
+ (array? coll) (#'array-reduce coll f init)
+ :else (-reduce coll f init)))))
(defprotocol CollFold
(coll-fold [coll n combinef reducef]))
@@ -61,7 +61,7 @@
([reducef coll] (fold reducef reducef coll))
([combinef reducef coll] (fold 512 combinef reducef coll))
([n combinef reducef coll]
- (coll-fold coll n combinef reducef)))
+ (coll-fold coll n combinef reducef)))
(defn reducer
"Given a reducible collection, and a transformation function xf,
@@ -69,12 +69,12 @@
fn will be transformed by xf. xf is a function of reducing fn to
reducing fn."
([coll xf]
- (reify
- cljs.core/IReduce
- (-reduce [this f1]
- (-reduce this f1 (f1)))
- (-reduce [_ f1 init]
- (-reduce coll (xf f1) init)))))
+ (reify
+ cljs.core/IReduce
+ (-reduce [this f1]
+ (-reduce this f1 (f1)))
+ (-reduce [_ f1 init]
+ (-reduce coll (xf f1) init)))))
(defn folder
"Given a foldable collection, and a transformation function xf,
@@ -82,26 +82,26 @@
fn will be transformed by xf. xf is a function of reducing fn to
reducing fn."
([coll xf]
- (reify
- cljs.core/IReduce
- (-reduce [_ f1]
- (-reduce coll (xf f1) (f1)))
- (-reduce [_ f1 init]
- (-reduce coll (xf f1) init))
+ (reify
+ cljs.core/IReduce
+ (-reduce [_ f1]
+ (-reduce coll (xf f1) (f1)))
+ (-reduce [_ f1 init]
+ (-reduce coll (xf f1) init))
- CollFold
- (coll-fold [_ n combinef reducef]
- (coll-fold coll n combinef (xf reducef))))))
+ CollFold
+ (coll-fold [_ n combinef reducef]
+ (coll-fold coll n combinef (xf reducef))))))
(defcurried map
"Applies f to every value in the reduction of coll. Foldable."
{}
[f coll]
(folder coll
- (fn [f1]
- (rfn [f1 k]
- ([ret k v]
- (f1 ret (f k v)))))))
+ (fn [f1]
+ (rfn [f1 k]
+ ([ret k v]
+ (f1 ret (f k v)))))))
(defcurried mapcat
"Applies f to every value in the reduction of coll, concatenating the result
@@ -109,10 +109,10 @@
{}
[f coll]
(folder coll
- (fn [f1]
- (rfn [f1 k]
- ([ret k v]
- (reduce f1 ret (f k v)))))))
+ (fn [f1]
+ (rfn [f1 k]
+ ([ret k v]
+ (reduce f1 ret (f k v)))))))
(defcurried filter
"Retains values in the reduction of coll for which (pred val)
@@ -120,12 +120,12 @@
{}
[pred coll]
(folder coll
- (fn [f1]
- (rfn [f1 k]
- ([ret k v]
- (if (pred k v)
- (f1 ret k v)
- ret))))))
+ (fn [f1]
+ (rfn [f1 k]
+ ([ret k v]
+ (if (pred k v)
+ (f1 ret k v)
+ ret))))))
(defcurried flatten
"Takes any nested combination of sequential things (lists, vectors,
@@ -134,13 +134,13 @@
{}
[coll]
(folder coll
- (fn [f1]
- (fn
- ([] (f1))
- ([ret v]
- (if (sequential? v)
- (-reduce (flatten v) f1 ret)
- (f1 ret v)))))))
+ (fn [f1]
+ (fn
+ ([] (f1))
+ ([ret v]
+ (if (sequential? v)
+ (-reduce (flatten v) f1 ret)
+ (f1 ret v)))))))
(defcurried remove
"Removes values in the reduction of coll for which (pred val)
@@ -154,40 +154,40 @@
{}
[pred coll]
(reducer coll
- (fn [f1]
- (rfn [f1 k]
- ([ret k v]
- (if (pred k v)
- (f1 ret k v)
- (reduced ret)))))))
+ (fn [f1]
+ (rfn [f1 k]
+ ([ret k v]
+ (if (pred k v)
+ (f1 ret k v)
+ (reduced ret)))))))
(defcurried take
"Ends the reduction of coll after consuming n values."
{}
[n coll]
(reducer coll
- (fn [f1]
- (let [cnt (atom n)]
- (rfn [f1 k]
- ([ret k v]
- (swap! cnt dec)
- (if (neg? @cnt)
- (reduced ret)
- (f1 ret k v))))))))
+ (fn [f1]
+ (let [cnt (atom n)]
+ (rfn [f1 k]
+ ([ret k v]
+ (swap! cnt dec)
+ (if (neg? @cnt)
+ (reduced ret)
+ (f1 ret k v))))))))
(defcurried drop
"Elides the first n values from the reduction of coll."
{}
[n coll]
(reducer coll
- (fn [f1]
- (let [cnt (atom n)]
- (rfn [f1 k]
- ([ret k v]
- (swap! cnt dec)
- (if (neg? @cnt)
- (f1 ret k v)
- ret)))))))
+ (fn [f1]
+ (let [cnt (atom n)]
+ (rfn [f1 k]
+ ([ret k v]
+ (swap! cnt dec)
+ (if (neg? @cnt)
+ (f1 ret k v)
+ ret)))))))
;;do not construct this directly, use cat
(deftype Cat [cnt left right]
@@ -202,8 +202,8 @@
(-reduce
[_ f1 init]
(-reduce
- right f1
- (-reduce left f1 init)))
+ right f1
+ (-reduce left f1 init)))
CollFold
(coll-fold
@@ -219,15 +219,15 @@
with (zero? (count x)). See also foldcat."
([] (array))
([ctor]
- (fn
- ([] (ctor))
- ([left right] (cat left right))))
+ (fn
+ ([] (ctor))
+ ([left right] (cat left right))))
([left right]
- (cond
- (zero? (count left)) right
- (zero? (count right)) left
- :else
- (Cat. (+ (count left) (count right)) left right))))
+ (cond
+ (zero? (count left)) right
+ (zero? (count right)) left
+ :else
+ (Cat. (+ (count left) (count right)) left right))))
(defn append!
".adds x to acc and returns acc"
@@ -250,63 +250,63 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(comment
-(require '[clojure.core.reduce :as r])
-(def v (take 1000000 (range)))
-(reduce + 0 (r/map inc [1 2 3 4]))
-(into [] (r/take 12 (range 100)))
-(into [] (r/drop 12 (range 100)))
-(reduce + 0 (r/filter even? [1 2 3 4]))
-(into [] (r/filter even? [1 2 3 4]))
-(reduce + (filter even? [1 2 3 4]))
-(dotimes [_ 10] (time (reduce + 0 (r/map inc v))))
-(dotimes [_ 10] (time (reduce + 0 (map inc v))))
-(dotimes [_ 100] (time (reduce + 0 v)))
-(dotimes [_ 100] (time (reduce + 0 v)))
-(dotimes [_ 20] (time (reduce + 0 (r/map inc (r/filter even? v)))))
-(dotimes [_ 20] (time (reduce + 0 (map inc (filter even? v)))))
-(reduce + 0 (r/take-while even? [2 4 3]))
-(into [] (r/filter even? (r/flatten (r/remove #{4} [[1 2 3] 4 [5 [6 7 8]] [9] 10]))))
-(into [] (r/flatten nil))
-)
+ (require '[clojure.core.reduce :as r])
+ (def v (take 1000000 (range)))
+ (reduce + 0 (r/map inc [1 2 3 4]))
+ (into [] (r/take 12 (range 100)))
+ (into [] (r/drop 12 (range 100)))
+ (reduce + 0 (r/filter even? [1 2 3 4]))
+ (into [] (r/filter even? [1 2 3 4]))
+ (reduce + (filter even? [1 2 3 4]))
+ (dotimes [_ 10] (time (reduce + 0 (r/map inc v))))
+ (dotimes [_ 10] (time (reduce + 0 (map inc v))))
+ (dotimes [_ 100] (time (reduce + 0 v)))
+ (dotimes [_ 100] (time (reduce + 0 v)))
+ (dotimes [_ 20] (time (reduce + 0 (r/map inc (r/filter even? v)))))
+ (dotimes [_ 20] (time (reduce + 0 (map inc (filter even? v)))))
+ (reduce + 0 (r/take-while even? [2 4 3]))
+ (into [] (r/filter even? (r/flatten (r/remove #{4} [[1 2 3] 4 [5 [6 7 8]] [9] 10]))))
+ (into [] (r/flatten nil))
+ )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fold impls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn- foldvec
[v n combinef reducef]
(cond
- (empty? v) (combinef)
- (<= (count v) n) (reduce reducef (combinef) v)
- :else
- (let [split (quot (count v) 2)
- v1 (subvec v 0 split)
- v2 (subvec v split (count v))
- fc (fn [child] #(foldvec child n combinef reducef))]
- (fjinvoke
- #(let [f1 (fc v1)
- t2 (fjtask (fc v2))]
- (fjfork t2)
- (combinef (f1) (fjjoin t2)))))))
+ (empty? v) (combinef)
+ (<= (count v) n) (reduce reducef (combinef) v)
+ :else
+ (let [split (quot (count v) 2)
+ v1 (subvec v 0 split)
+ v2 (subvec v split (count v))
+ fc (fn [child] #(foldvec child n combinef reducef))]
+ (fjinvoke
+ #(let [f1 (fc v1)
+ t2 (fjtask (fc v2))]
+ (fjfork t2)
+ (combinef (f1) (fjjoin t2)))))))
(extend-protocol CollFold
- nil
- (coll-fold
- [coll n combinef reducef]
- (combinef))
-
- object
- (coll-fold
- [coll n combinef reducef]
- ;;can't fold, single reduce
- (reduce reducef (combinef) coll))
-
- cljs.core/PersistentVector
- (coll-fold
- [v n combinef reducef]
- (foldvec v n combinef reducef))
-
- #_
- cljs.core/PersistentHashMap
- #_
- (coll-fold
- [m n combinef reducef]
- (.fold m n combinef reducef fjinvoke fjtask fjfork fjjoin)))
+ nil
+ (coll-fold
+ [coll n combinef reducef]
+ (combinef))
+
+ object
+ (coll-fold
+ [coll n combinef reducef]
+ ;;can't fold, single reduce
+ (reduce reducef (combinef) coll))
+
+ cljs.core/PersistentVector
+ (coll-fold
+ [v n combinef reducef]
+ (foldvec v n combinef reducef))
+
+ #_
+ cljs.core/PersistentHashMap
+ #_
+ (coll-fold
+ [m n combinef reducef]
+ (.fold m n combinef reducef fjinvoke fjtask fjfork fjjoin)))
diff --git a/src/main/cljs/clojure/data.cljs b/src/main/cljs/clojure/data.cljs
index 80a608cd..98486259 100644
--- a/src/main/cljs/clojure/data.cljs
+++ b/src/main/cljs/clojure/data.cljs
@@ -26,9 +26,9 @@
[m]
(when (seq m)
(reduce
- (fn [result [k v]] (assoc result k v))
- (vec (repeat (apply max (keys m)) nil))
- m)))
+ (fn [result [k v]] (assoc result k v))
+ (vec (repeat (apply max (keys m)) nil))
+ m)))
(defn- diff-associative-key
"Diff associative things a and b, comparing only the key k."
@@ -49,22 +49,22 @@
(defn- diff-associative
"Diff associative things a and b, comparing only keys in ks (if supplied)."
([a b]
- (diff-associative a b (set/union (keys a) (keys b))))
+ (diff-associative a b (set/union (keys a) (keys b))))
([a b ks]
- (reduce
- (fn [diff1 diff2]
- (doall (map merge diff1 diff2)))
- [nil nil nil]
- (map
+ (reduce
+ (fn [diff1 diff2]
+ (doall (map merge diff1 diff2)))
+ [nil nil nil]
+ (map
(partial diff-associative-key a b)
ks))))
(defn- diff-sequential
[a b]
(vec (map vectorize (diff-associative
- (if (vector? a) a (vec a))
- (if (vector? b) b (vec b))
- (range (max (count a) (count b)))))))
+ (if (vector? a) a (vec a))
+ (if (vector? b) b (vec b))
+ (range (max (count a) (count b)))))))
(defn- diff-set
[a b]
@@ -102,10 +102,10 @@
default
(equality-partition [x]
(cond
- (satisfies? IMap x) :map
- (satisfies? ISet x) :set
- (satisfies? ISequential x) :sequential
- :default :atom)))
+ (satisfies? IMap x) :map
+ (satisfies? ISet x) :set
+ (satisfies? ISequential x) :sequential
+ :default :atom)))
(extend-protocol Diff
nil
diff --git a/src/main/cljs/clojure/datafy.cljs b/src/main/cljs/clojure/datafy.cljs
index 6a969d8a..83790af4 100644
--- a/src/main/cljs/clojure/datafy.cljs
+++ b/src/main/cljs/clojure/datafy.cljs
@@ -8,7 +8,7 @@
(ns
^{:doc "Functions to turn objects into data. Alpha, subject to change"}
- clojure.datafy
+ clojure.datafy
(:require [clojure.core.protocols :as p]))
(defn datafy
diff --git a/src/main/cljs/clojure/reflect.cljs b/src/main/cljs/clojure/reflect.cljs
index 9ca86610..b944f5b8 100644
--- a/src/main/cljs/clojure/reflect.cljs
+++ b/src/main/cljs/clojure/reflect.cljs
@@ -2,7 +2,7 @@
^{:doc "DEPRECATED. Do not use, superceded by REPL enhancements."}
(:refer-clojure :exclude [meta macroexpand])
(:require [clojure.browser.net :as net]
- [clojure.browser.event :as event]))
+ [clojure.browser.event :as event]))
(defn- evaluate-javascript [block]
(let [result (try (js* "eval(~{block})")
diff --git a/src/main/cljs/clojure/set.cljs b/src/main/cljs/clojure/set.cljs
index b9ba41f7..303b074d 100644
--- a/src/main/cljs/clojure/set.cljs
+++ b/src/main/cljs/clojure/set.cljs
@@ -7,8 +7,8 @@
; You must not remove this notice, or any other, from this software.
(ns ^{:doc "Set operations such as union/intersection."
- :author "Rich Hickey"}
- clojure.set)
+ :author "Rich Hickey"}
+ clojure.set)
(defn- bubble-max-key [k coll]
"Move a maximal element of coll according to fn k (which returns a number)
@@ -21,78 +21,78 @@
([] #{})
([s1] s1)
([s1 s2]
- (if (< (count s1) (count s2))
- (reduce conj s2 s1)
- (reduce conj s1 s2)))
+ (if (< (count s1) (count s2))
+ (reduce conj s2 s1)
+ (reduce conj s1 s2)))
([s1 s2 & sets]
- (let [bubbled-sets (bubble-max-key count (conj sets s2 s1))]
- (reduce into (first bubbled-sets) (rest bubbled-sets)))))
+ (let [bubbled-sets (bubble-max-key count (conj sets s2 s1))]
+ (reduce into (first bubbled-sets) (rest bubbled-sets)))))
(defn intersection
"Return a set that is the intersection of the input sets"
([s1] s1)
([s1 s2]
- (if (< (count s2) (count s1))
- (recur s2 s1)
- (reduce (fn [result item]
- (if (contains? s2 item)
- result
- (disj result item)))
- s1 s1)))
+ (if (< (count s2) (count s1))
+ (recur s2 s1)
+ (reduce (fn [result item]
+ (if (contains? s2 item)
+ result
+ (disj result item)))
+ s1 s1)))
([s1 s2 & sets]
- (let [bubbled-sets (bubble-max-key #(- (count %)) (conj sets s2 s1))]
- (reduce intersection (first bubbled-sets) (rest bubbled-sets)))))
+ (let [bubbled-sets (bubble-max-key #(- (count %)) (conj sets s2 s1))]
+ (reduce intersection (first bubbled-sets) (rest bubbled-sets)))))
(defn difference
"Return a set that is the first set without elements of the remaining sets"
([s1] s1)
([s1 s2]
- (if (< (count s1) (count s2))
- (reduce (fn [result item]
- (if (contains? s2 item)
- (disj result item)
- result))
- s1 s1)
- (reduce disj s1 s2)))
+ (if (< (count s1) (count s2))
+ (reduce (fn [result item]
+ (if (contains? s2 item)
+ (disj result item)
+ result))
+ s1 s1)
+ (reduce disj s1 s2)))
([s1 s2 & sets]
- (reduce difference s1 (conj sets s2))))
+ (reduce difference s1 (conj sets s2))))
(defn select
"Returns a set of the elements for which pred is true"
[pred xset]
- (reduce (fn [s k] (if (pred k) s (disj s k)))
- xset xset))
+ (reduce (fn [s k] (if (pred k) s (disj s k)))
+ xset xset))
(defn project
"Returns a rel of the elements of xrel with only the keys in ks"
[xrel ks]
- (set (map #(select-keys % ks) xrel)))
+ (set (map #(select-keys % ks) xrel)))
(defn rename-keys
"Returns the map with the keys in kmap renamed to the vals in kmap"
[map kmap]
- (reduce
- (fn [m [old new]]
- (if (contains? map old)
- (assoc m new (get map old))
- m))
- (apply dissoc map (keys kmap)) kmap))
+ (reduce
+ (fn [m [old new]]
+ (if (contains? map old)
+ (assoc m new (get map old))
+ m))
+ (apply dissoc map (keys kmap)) kmap))
(defn rename
"Returns a rel of the maps in xrel with the keys in kmap renamed to the vals in kmap"
[xrel kmap]
- (set (map #(rename-keys % kmap) xrel)))
+ (set (map #(rename-keys % kmap) xrel)))
(defn index
"Returns a map of the distinct values of ks in the xrel mapped to a
set of the maps in xrel with the corresponding values of ks."
[xrel ks]
- (reduce
- (fn [m x]
- (let [ik (select-keys x ks)]
- (assoc m ik (conj (get m ik #{}) x))))
- {} xrel))
+ (reduce
+ (fn [m x]
+ (let [ik (select-keys x ks)]
+ (assoc m ik (conj (get m ik #{}) x))))
+ {} xrel))
(defn map-invert
"Returns the map with the vals mapped to the keys."
@@ -141,21 +141,21 @@
(every? #(contains? set1 %) set2)))
(comment
-(refer 'set)
-(def xs #{{:a 11 :b 1 :c 1 :d 4}
- {:a 2 :b 12 :c 2 :d 6}
- {:a 3 :b 3 :c 3 :d 8 :f 42}})
+ (refer 'set)
+ (def xs #{{:a 11 :b 1 :c 1 :d 4}
+ {:a 2 :b 12 :c 2 :d 6}
+ {:a 3 :b 3 :c 3 :d 8 :f 42}})
-(def ys #{{:a 11 :b 11 :c 11 :e 5}
- {:a 12 :b 11 :c 12 :e 3}
- {:a 3 :b 3 :c 3 :e 7 }})
+ (def ys #{{:a 11 :b 11 :c 11 :e 5}
+ {:a 12 :b 11 :c 12 :e 3}
+ {:a 3 :b 3 :c 3 :e 7 }})
-(join xs ys)
-(join xs (rename ys {:b :yb :c :yc}) {:a :a})
+ (join xs ys)
+ (join xs (rename ys {:b :yb :c :yc}) {:a :a})
-(union #{:a :b :c} #{:c :d :e })
-(difference #{:a :b :c} #{:c :d :e})
-(intersection #{:a :b :c} #{:c :d :e})
+ (union #{:a :b :c} #{:c :d :e })
+ (difference #{:a :b :c} #{:c :d :e})
+ (intersection #{:a :b :c} #{:c :d :e})
-(index ys [:b]))
+ (index ys [:b]))
diff --git a/src/main/cljs/clojure/string.cljs b/src/main/cljs/clojure/string.cljs
index 26f63f26..75faafc6 100644
--- a/src/main/cljs/clojure/string.cljs
+++ b/src/main/cljs/clojure/string.cljs
@@ -168,25 +168,25 @@
"Splits string on a regular expression. Optional argument limit is
the maximum number of splits. Not lazy. Returns vector of the splits."
([s re]
- (split s re 0))
- ([s re limit]
- (discard-trailing-if-needed limit
- (if (identical? "/(?:)/" (str re))
- (split-with-empty-regex s limit)
- (if (< limit 1)
- (vec (.split (str s) re))
- (loop [s s
- limit limit
- parts []]
- (if (== 1 limit)
- (conj parts s)
- (let [m (re-find re s)]
- (if-not (nil? m)
- (let [index (.indexOf s m)]
- (recur (.substring s (+ index (count m)))
- (dec limit)
- (conj parts (.substring s 0 index))))
- (conj parts s))))))))))
+ (split s re 0))
+ ([s re limit]
+ (discard-trailing-if-needed limit
+ (if (identical? "/(?:)/" (str re))
+ (split-with-empty-regex s limit)
+ (if (< limit 1)
+ (vec (.split (str s) re))
+ (loop [s s
+ limit limit
+ parts []]
+ (if (== 1 limit)
+ (conj parts s)
+ (let [m (re-find re s)]
+ (if-not (nil? m)
+ (let [index (.indexOf s m)]
+ (recur (.substring s (+ index (count m)))
+ (dec limit)
+ (conj parts (.substring s 0 index))))
+ (conj parts s))))))))))
(defn split-lines
"Splits s on \\n or \\r\\n."
diff --git a/src/main/cljs/clojure/walk.cljs b/src/main/cljs/clojure/walk.cljs
index d92d61c9..3c5fa6e2 100644
--- a/src/main/cljs/clojure/walk.cljs
+++ b/src/main/cljs/clojure/walk.cljs
@@ -22,7 +22,7 @@
(ns
^{:author "Stuart Sierra",
- :doc "This file defines a generic tree walker for Clojure data
+ :doc "This file defines a generic tree walker for Clojure data
structures. It takes any data structure (list, vector, map, set,
seq), calls a function on every element, and uses the return value
of the function in place of the original. This makes it fairly
diff --git a/src/main/cljs/clojure/zip.cljs b/src/main/cljs/clojure/zip.cljs
index 5ec83bff..f4b42db0 100644
--- a/src/main/cljs/clojure/zip.cljs
+++ b/src/main/cljs/clojure/zip.cljs
@@ -11,7 +11,7 @@
(ns ^{:doc "Functional hierarchical zipper, with navigation, editing,
and enumeration. See Huet"
- :author "Rich Hickey"}
+ :author "Rich Hickey"}
clojure.zip
(:refer-clojure :exclude (replace remove next)))
@@ -28,34 +28,34 @@
children, returns a new branch node with the supplied children.
root is the root node."
[branch? children make-node root]
- ^{:zip/branch? branch? :zip/children children :zip/make-node make-node}
- [root nil])
+ ^{:zip/branch? branch? :zip/children children :zip/make-node make-node}
+ [root nil])
(defn seq-zip
"Returns a zipper for nested sequences, given a root sequence"
[root]
- (zipper seq?
- identity
- (fn [node children] (with-meta children (meta node)))
- root))
+ (zipper seq?
+ identity
+ (fn [node children] (with-meta children (meta node)))
+ root))
(defn vector-zip
"Returns a zipper for nested vectors, given a root vector"
[root]
- (zipper vector?
- seq
- (fn [node children] (with-meta (vec children) (meta node)))
- root))
+ (zipper vector?
+ seq
+ (fn [node children] (with-meta (vec children) (meta node)))
+ root))
(defn xml-zip
"Returns a zipper for xml elements (as from xml/parse),
given a root element"
[root]
- (zipper (complement string?)
- (comp seq :content)
- (fn [node children]
- (assoc node :content (and children (apply vector children))))
- root))
+ (zipper (complement string?)
+ (comp seq :content)
+ (fn [node children]
+ (assoc node :content (and children (apply vector children))))
+ root))
(defn node
"Returns the node at loc"
@@ -64,228 +64,228 @@
(defn branch?
"Returns true if the node at loc is a branch"
[loc]
- ((:zip/branch? (meta loc)) (node loc)))
+ ((:zip/branch? (meta loc)) (node loc)))
(defn children
"Returns a seq of the children of node at loc, which must be a branch"
[loc]
- (if (branch? loc)
- ((:zip/children (meta loc)) (node loc))
- (throw "called children on a leaf node")))
+ (if (branch? loc)
+ ((:zip/children (meta loc)) (node loc))
+ (throw "called children on a leaf node")))
(defn make-node
"Returns a new branch node, given an existing node and new
children. The loc is only used to supply the constructor."
[loc node children]
- ((:zip/make-node (meta loc)) node children))
+ ((:zip/make-node (meta loc)) node children))
(defn path
"Returns a seq of nodes leading to this loc"
[loc]
- (:pnodes (loc 1)))
+ (:pnodes (loc 1)))
(defn lefts
"Returns a seq of the left siblings of this loc"
[loc]
- (seq (:l (loc 1))))
+ (seq (:l (loc 1))))
(defn rights
"Returns a seq of the right siblings of this loc"
[loc]
- (:r (loc 1)))
+ (:r (loc 1)))
(defn down
"Returns the loc of the leftmost child of the node at this loc, or
nil if no children"
[loc]
- (when (branch? loc)
- (let [[node path] loc
- [c & cnext :as cs] (children loc)]
- (when cs
- (with-meta [c {:l []
- :pnodes (if path (conj (:pnodes path) node) [node])
- :ppath path
- :r cnext}] (meta loc))))))
+ (when (branch? loc)
+ (let [[node path] loc
+ [c & cnext :as cs] (children loc)]
+ (when cs
+ (with-meta [c {:l []
+ :pnodes (if path (conj (:pnodes path) node) [node])
+ :ppath path
+ :r cnext}] (meta loc))))))
(defn up
"Returns the loc of the parent of the node at this loc, or nil if at
the top"
[loc]
- (let [[node {l :l, ppath :ppath, pnodes :pnodes r :r, changed? :changed?, :as path}] loc]
- (when pnodes
- (let [pnode (peek pnodes)]
- (with-meta (if changed?
- [(make-node loc pnode (concat l (cons node r)))
- (and ppath (assoc ppath :changed? true))]
- [pnode ppath])
- (meta loc))))))
+ (let [[node {l :l, ppath :ppath, pnodes :pnodes r :r, changed? :changed?, :as path}] loc]
+ (when pnodes
+ (let [pnode (peek pnodes)]
+ (with-meta (if changed?
+ [(make-node loc pnode (concat l (cons node r)))
+ (and ppath (assoc ppath :changed? true))]
+ [pnode ppath])
+ (meta loc))))))
(defn root
"zips all the way up and returns the root node, reflecting any
changes."
[loc]
- (if (= :end (loc 1))
- (node loc)
- (let [p (up loc)]
- (if p
- (recur p)
- (node loc)))))
+ (if (= :end (loc 1))
+ (node loc)
+ (let [p (up loc)]
+ (if p
+ (recur p)
+ (node loc)))))
(defn right
"Returns the loc of the right sibling of the node at this loc, or nil"
[loc]
- (let [[node {l :l [r & rnext :as rs] :r :as path}] loc]
- (when (and path rs)
- (with-meta [r (assoc path :l (conj l node) :r rnext)] (meta loc)))))
+ (let [[node {l :l [r & rnext :as rs] :r :as path}] loc]
+ (when (and path rs)
+ (with-meta [r (assoc path :l (conj l node) :r rnext)] (meta loc)))))
(defn rightmost
"Returns the loc of the rightmost sibling of the node at this loc, or self"
[loc]
- (let [[node {l :l r :r :as path}] loc]
- (if (and path r)
- (with-meta [(last r) (assoc path :l (apply conj l node (butlast r)) :r nil)] (meta loc))
- loc)))
+ (let [[node {l :l r :r :as path}] loc]
+ (if (and path r)
+ (with-meta [(last r) (assoc path :l (apply conj l node (butlast r)) :r nil)] (meta loc))
+ loc)))
(defn left
"Returns the loc of the left sibling of the node at this loc, or nil"
[loc]
- (let [[node {l :l r :r :as path}] loc]
- (when (and path (seq l))
- (with-meta [(peek l) (assoc path :l (pop l) :r (cons node r))] (meta loc)))))
+ (let [[node {l :l r :r :as path}] loc]
+ (when (and path (seq l))
+ (with-meta [(peek l) (assoc path :l (pop l) :r (cons node r))] (meta loc)))))
(defn leftmost
"Returns the loc of the leftmost sibling of the node at this loc, or self"
[loc]
- (let [[node {l :l r :r :as path}] loc]
- (if (and path (seq l))
- (with-meta [(first l) (assoc path :l [] :r (concat (rest l) [node] r))] (meta loc))
- loc)))
+ (let [[node {l :l r :r :as path}] loc]
+ (if (and path (seq l))
+ (with-meta [(first l) (assoc path :l [] :r (concat (rest l) [node] r))] (meta loc))
+ loc)))
(defn insert-left
"Inserts the item as the left sibling of the node at this loc,
without moving"
[loc item]
- (let [[node {l :l :as path}] loc]
- (if (nil? path)
- (throw "Insert at top")
- (with-meta [node (assoc path :l (conj l item) :changed? true)] (meta loc)))))
+ (let [[node {l :l :as path}] loc]
+ (if (nil? path)
+ (throw "Insert at top")
+ (with-meta [node (assoc path :l (conj l item) :changed? true)] (meta loc)))))
(defn insert-right
"Inserts the item as the right sibling of the node at this loc,
without moving"
[loc item]
- (let [[node {r :r :as path}] loc]
- (if (nil? path)
- (throw "Insert at top")
- (with-meta [node (assoc path :r (cons item r) :changed? true)] (meta loc)))))
+ (let [[node {r :r :as path}] loc]
+ (if (nil? path)
+ (throw "Insert at top")
+ (with-meta [node (assoc path :r (cons item r) :changed? true)] (meta loc)))))
(defn replace
"Replaces the node at this loc, without moving"
[loc node]
- (let [[_ path] loc]
- (with-meta [node (assoc path :changed? true)] (meta loc))))
+ (let [[_ path] loc]
+ (with-meta [node (assoc path :changed? true)] (meta loc))))
(defn edit
"Replaces the node at this loc with the value of (f node args)"
[loc f & args]
- (replace loc (apply f (node loc) args)))
+ (replace loc (apply f (node loc) args)))
(defn insert-child
"Inserts the item as the leftmost child of the node at this loc,
without moving"
[loc item]
- (replace loc (make-node loc (node loc) (cons item (children loc)))))
+ (replace loc (make-node loc (node loc) (cons item (children loc)))))
(defn append-child
"Inserts the item as the rightmost child of the node at this loc,
without moving"
[loc item]
- (replace loc (make-node loc (node loc) (concat (children loc) [item]))))
+ (replace loc (make-node loc (node loc) (concat (children loc) [item]))))
(defn next
"Moves to the next loc in the hierarchy, depth-first. When reaching
the end, returns a distinguished loc detectable via end?. If already
at the end, stays there."
[loc]
- (if (= :end (loc 1))
- loc
- (or
- (and (branch? loc) (down loc))
- (right loc)
- (loop [p loc]
- (if (up p)
- (or (right (up p)) (recur (up p)))
- [(node p) :end])))))
+ (if (= :end (loc 1))
+ loc
+ (or
+ (and (branch? loc) (down loc))
+ (right loc)
+ (loop [p loc]
+ (if (up p)
+ (or (right (up p)) (recur (up p)))
+ [(node p) :end])))))
(defn prev
"Moves to the previous loc in the hierarchy, depth-first. If already
at the root, returns nil."
[loc]
- (if-let [lloc (left loc)]
- (loop [loc lloc]
- (if-let [child (and (branch? loc) (down loc))]
- (recur (rightmost child))
- loc))
- (up loc)))
+ (if-let [lloc (left loc)]
+ (loop [loc lloc]
+ (if-let [child (and (branch? loc) (down loc))]
+ (recur (rightmost child))
+ loc))
+ (up loc)))
(defn end?
"Returns true if loc represents the end of a depth-first walk"
[loc]
- (= :end (loc 1)))
+ (= :end (loc 1)))
(defn remove
"Removes the node at loc, returning the loc that would have preceded
it in a depth-first walk."
[loc]
- (let [[node {l :l, ppath :ppath, pnodes :pnodes, rs :r, :as path}] loc]
- (if (nil? path)
- (throw "Remove at top")
- (if (pos? (count l))
- (loop [loc (with-meta [(peek l) (assoc path :l (pop l) :changed? true)] (meta loc))]
- (if-let [child (and (branch? loc) (down loc))]
- (recur (rightmost child))
- loc))
- (with-meta [(make-node loc (peek pnodes) rs)
- (and ppath (assoc ppath :changed? true))]
- (meta loc))))))
+ (let [[node {l :l, ppath :ppath, pnodes :pnodes, rs :r, :as path}] loc]
+ (if (nil? path)
+ (throw "Remove at top")
+ (if (pos? (count l))
+ (loop [loc (with-meta [(peek l) (assoc path :l (pop l) :changed? true)] (meta loc))]
+ (if-let [child (and (branch? loc) (down loc))]
+ (recur (rightmost child))
+ loc))
+ (with-meta [(make-node loc (peek pnodes) rs)
+ (and ppath (assoc ppath :changed? true))]
+ (meta loc))))))
(comment
-(load-file "/Users/rich/dev/clojure/src/zip.clj")
-(refer 'zip)
-(def data '[[a * b] + [c * d]])
-(def dz (vector-zip data))
-
-(right (down dz))
-(right (down (right (right (down dz)))))
-(lefts (right (down (right (right (down dz))))))
-(rights (right (down (right (right (down dz))))))
-(up (up (right (down (right (right (down dz)))))))
-(path (right (down (right (right (down dz))))))
-
-(-> dz down right right down right)
-(-> dz down right right down right (replace '/) root)
-(-> dz next next (edit str) next next next (replace '/) root)
-(-> dz next next next next next next next next next remove root)
-(-> dz next next next next next next next next next remove (insert-right 'e) root)
-(-> dz next next next next next next next next next remove up (append-child 'e) root)
-
-(end? (-> dz next next next next next next next next next remove next))
-
-(-> dz next remove next remove root)
-
-(loop [loc dz]
- (if (end? loc)
- (root loc)
- (recur (next (if (= '* (node loc))
- (replace loc '/)
- loc)))))
-
-(loop [loc dz]
- (if (end? loc)
- (root loc)
- (recur (next (if (= '* (node loc))
- (remove loc)
- loc)))))
-)
+ (load-file "/Users/rich/dev/clojure/src/zip.clj")
+ (refer 'zip)
+ (def data '[[a * b] + [c * d]])
+ (def dz (vector-zip data))
+
+ (right (down dz))
+ (right (down (right (right (down dz)))))
+ (lefts (right (down (right (right (down dz))))))
+ (rights (right (down (right (right (down dz))))))
+ (up (up (right (down (right (right (down dz)))))))
+ (path (right (down (right (right (down dz))))))
+
+ (-> dz down right right down right)
+ (-> dz down right right down right (replace '/) root)
+ (-> dz next next (edit str) next next next (replace '/) root)
+ (-> dz next next next next next next next next next remove root)
+ (-> dz next next next next next next next next next remove (insert-right 'e) root)
+ (-> dz next next next next next next next next next remove up (append-child 'e) root)
+
+ (end? (-> dz next next next next next next next next next remove next))
+
+ (-> dz next remove next remove root)
+
+ (loop [loc dz]
+ (if (end? loc)
+ (root loc)
+ (recur (next (if (= '* (node loc))
+ (replace loc '/)
+ loc)))))
+
+ (loop [loc dz]
+ (if (end? loc)
+ (root loc)
+ (recur (next (if (= '* (node loc))
+ (remove loc)
+ loc)))))
+ )
diff --git a/src/main/clojure/cljs/analyzer/utils.clj b/src/main/clojure/cljs/analyzer/utils.clj
index f61f201d..592732f3 100644
--- a/src/main/clojure/cljs/analyzer/utils.clj
+++ b/src/main/clojure/cljs/analyzer/utils.clj
@@ -24,13 +24,13 @@
(defn to-ast
([form] (to-ast 'cljs.user form))
([ns form]
- (let [env (assoc-in (ana/empty-env) [:ns :name] ns)]
- (binding [ana/*passes*
- (or ana/*passes*
- [elide-children simplify-env ana/infer-type])]
- (ana/analyze env form)))))
+ (let [env (assoc-in (ana/empty-env) [:ns :name] ns)]
+ (binding [ana/*passes*
+ (or ana/*passes*
+ [elide-children simplify-env ana/infer-type])]
+ (ana/analyze env form)))))
(comment
(require '[clojure.pprint :as pp])
(pp/pprint (to-ast '(defn foo [a b] (+ a b))))
-)
+ )
diff --git a/src/main/clojure/cljs/build/api.clj b/src/main/clojure/cljs/build/api.clj
index 4d10521e..dee67a9a 100644
--- a/src/main/clojure/cljs/build/api.clj
+++ b/src/main/clojure/cljs/build/api.clj
@@ -13,14 +13,14 @@
files so that they will be recompiled."
(:refer-clojure :exclude [compile])
(:require [clojure.java.io :as io]
- [clojure.string :as string]
- [clojure.data.json :as json]
- [cljs.util :as util]
- [cljs.env :as env]
- [cljs.analyzer :as ana]
- [cljs.compiler :as comp]
- [cljs.closure :as closure]
- [cljs.js-deps :as js-deps])
+ [clojure.string :as string]
+ [clojure.data.json :as json]
+ [cljs.util :as util]
+ [cljs.env :as env]
+ [cljs.analyzer :as ana]
+ [cljs.compiler :as comp]
+ [cljs.closure :as closure]
+ [cljs.js-deps :as js-deps])
(:import [java.io File]))
;; =============================================================================
@@ -300,8 +300,8 @@
(env/with-compiler-env test-cenv
(ana/no-warn
(ana/analyze test-env
- '(ns cljs.user
- (:use [clojure.string :only [join]]))))))
+ '(ns cljs.user
+ (:use [clojure.string :only [join]]))))))
(env/with-compiler-env test-cenv
(ns-dependents 'clojure.string))
@@ -309,5 +309,5 @@
(map
#(target-file-for-cljs-ns % "out-dev")
(env/with-compiler-env test-cenv
- (ns-dependents 'clojure.string)))
+ (ns-dependents 'clojure.string)))
)
diff --git a/src/main/clojure/cljs/cli.clj b/src/main/clojure/cljs/cli.clj
index 6dc57533..8e7766c3 100644
--- a/src/main/clojure/cljs/cli.clj
+++ b/src/main/clojure/cljs/cli.clj
@@ -8,19 +8,19 @@
(ns cljs.cli
(:require [clojure.java.io :as io]
- [clojure.string :as string]
- [clojure.edn :as edn]
- [cljs.util :as util]
- [cljs.env :as env]
- [cljs.analyzer :as ana]
- [cljs.analyzer.api :as ana-api]
- [cljs.compiler.api :as comp]
- [cljs.build.api :as build]
- [cljs.closure :as closure]
- [cljs.repl :as repl])
+ [clojure.string :as string]
+ [clojure.edn :as edn]
+ [cljs.util :as util]
+ [cljs.env :as env]
+ [cljs.analyzer :as ana]
+ [cljs.analyzer.api :as ana-api]
+ [cljs.compiler.api :as comp]
+ [cljs.build.api :as build]
+ [cljs.closure :as closure]
+ [cljs.repl :as repl])
(:import [java.io File StringReader FileWriter]
- [java.text BreakIterator]
- [java.util Locale]))
+ [java.text BreakIterator]
+ [java.util Locale]))
(declare main)
@@ -209,13 +209,13 @@ classpath. Classpath-relative paths have prefix of @ or @/")
(edn/read-string (slurp rsrc))
(missing-resource orig-str)))]
(cond
- (string/starts-with? str "@/") (read-rsrc (subs str 2) str)
- (string/starts-with? str "@") (read-rsrc (subs str 1) str)
- :else
- (let [f (io/file str)]
- (if (.exists f)
- (edn/read-string (slurp f))
- (missing-file str))))))
+ (string/starts-with? str "@/") (read-rsrc (subs str 2) str)
+ (string/starts-with? str "@") (read-rsrc (subs str 1) str)
+ :else
+ (let [f (io/file str)]
+ (if (.exists f)
+ (edn/read-string (slurp f))
+ (missing-file str))))))
(defn load-edn-opts [str]
(reduce merge {} (map read-edn-opts (util/split-paths str))))
@@ -264,7 +264,7 @@ classpath. Classpath-relative paths have prefix of @ or @/")
(defn get-dispatch
([commands k opt]
- (get-dispatch commands k opt nil))
+ (get-dispatch commands k opt nil))
([commands k opt default]
(let [k' (keyword (str (name k) "-dispatch"))]
(or (get-in commands [k' opt]) default))))
@@ -414,13 +414,13 @@ present"
the command line."
[repl-env [_ ns & args] cfg]
((::main (repl/repl-options (repl-env)) default-main)
- repl-env (merge cfg {:main ns :args args})))
+ repl-env (merge cfg {:main ns :args args})))
(defn- null-opt
"No repl or script opt present, just bind args and run inits"
[repl-env args cfg]
((::main (repl/repl-options (repl-env)) default-main)
- repl-env (merge cfg {:args args})))
+ repl-env (merge cfg {:args args})))
(defn- help-opt
[repl-env _ _]
@@ -429,7 +429,7 @@ present"
(defn- script-opt
[repl-env [path & args] cfg]
((::main (repl/repl-options (repl-env)) default-main)
- repl-env (merge cfg {:script path :args args})))
+ repl-env (merge cfg {:script path :args args})))
(defn watch-proc [cenv path opts]
(let [log-file (io/file (util/output-directory opts) "watch.log")]
@@ -447,11 +447,11 @@ present"
["localhost" 9000])]
(require 'cljs.repl.browser)
((ns-resolve 'cljs.repl.browser 'serve)
- {:host host
- :port (if port
- (cond-> port (string? port) Integer/parseInt)
- 9000)
- :output-dir (:output-dir options "out")})))
+ {:host host
+ :port (if port
+ (cond-> port (string? port) Integer/parseInt)
+ 9000)
+ :output-dir (:output-dir options "out")})))
(defn default-compile
[repl-env {:keys [ns args options] :as cfg}]
@@ -503,7 +503,7 @@ present"
(defn- compile-opt
[repl-env [_ ns & args] cfg]
((::compile (repl/-repl-options (repl-env)) default-compile)
- repl-env (merge cfg {:args args :ns ns})))
+ repl-env (merge cfg {:args args :ns ns})))
(defn get-options [commands k]
(if (= :all k)
@@ -516,7 +516,7 @@ present"
(defn add-commands
([commands]
- (add-commands {:main-dispatch nil :init-dispatch nil} commands))
+ (add-commands {:main-dispatch nil :init-dispatch nil} commands))
([commands {:keys [groups main init]}]
(letfn [(merge-dispatch [st k options]
(update-in st [k]
@@ -615,7 +615,7 @@ present"
(let [pred (complement #{"-v" "--verbose"})
[pre post] ((juxt #(take-while pred %)
#(drop-while pred %))
- args)]
+ args)]
(cond
(= pre args) pre
@@ -644,7 +644,7 @@ present"
(if (dispatch? commands :init opt)
(recur more (conj inits [opt arg]))
((get-dispatch commands :main opt script-opt)
- repl-env args (initialize inits commands))))
+ repl-env args (initialize inits commands))))
(repl-opt repl-env nil nil)))
(finally
(flush))))
diff --git a/src/main/clojure/cljs/closure.clj b/src/main/clojure/cljs/closure.clj
index c8f5e6f5..f56f1c8b 100644
--- a/src/main/clojure/cljs/closure.clj
+++ b/src/main/clojure/cljs/closure.clj
@@ -9,43 +9,43 @@
(ns cljs.closure
(:refer-clojure :exclude [compile])
(:require [cljs.util :as util :refer [distinct-by]]
- [cljs.core :as cljsm]
- [cljs.compiler :as comp]
- [cljs.analyzer :as ana]
- [cljs.source-map :as sm]
- [cljs.env :as env]
- [cljs.js-deps :as deps]
- [clojure.java.io :as io]
- [clojure.reflect]
- [clojure.set :as set]
- [clojure.string :as string]
- [clojure.data.json :as json]
- [clojure.tools.reader :as reader]
- [clojure.tools.reader.reader-types :as readers]
- [cljs.module-graph :as module-graph])
+ [cljs.core :as cljsm]
+ [cljs.compiler :as comp]
+ [cljs.analyzer :as ana]
+ [cljs.source-map :as sm]
+ [cljs.env :as env]
+ [cljs.js-deps :as deps]
+ [clojure.java.io :as io]
+ [clojure.reflect]
+ [clojure.set :as set]
+ [clojure.string :as string]
+ [clojure.data.json :as json]
+ [clojure.tools.reader :as reader]
+ [clojure.tools.reader.reader-types :as readers]
+ [cljs.module-graph :as module-graph])
(:import [java.lang ProcessBuilder]
- [java.io
- File BufferedInputStream BufferedReader
- Writer InputStreamReader IOException StringWriter ByteArrayInputStream]
- [java.net URL]
- [java.util.logging Level]
- [java.util List Random]
- [java.util.concurrent
- TimeUnit LinkedBlockingDeque Executors CountDownLatch]
- [com.google.javascript.jscomp CompilerOptions CompilationLevel
- CompilerInput CompilerInput$ModuleType DependencyOptions
- CompilerOptions$LanguageMode SourceMap$Format
- SourceMap$DetailLevel ClosureCodingConvention SourceFile
- Result JSError CheckLevel DiagnosticGroups
- CommandLineRunner AnonymousFunctionNamingPolicy
- JSModule SourceMap VariableMap]
- [com.google.javascript.jscomp.deps ModuleLoader$ResolutionMode ModuleNames]
- [com.google.javascript.rhino Node]
- [java.nio.file Path Paths Files StandardWatchEventKinds WatchKey
- WatchEvent FileVisitor FileVisitResult]
- [java.nio.charset Charset StandardCharsets]
- [com.sun.nio.file SensitivityWatchEventModifier]
- [com.google.common.base Throwables]))
+ [java.io
+ File BufferedInputStream BufferedReader
+ Writer InputStreamReader IOException StringWriter ByteArrayInputStream]
+ [java.net URL]
+ [java.util.logging Level]
+ [java.util List Random]
+ [java.util.concurrent
+ TimeUnit LinkedBlockingDeque Executors CountDownLatch]
+ [com.google.javascript.jscomp CompilerOptions CompilationLevel
+ CompilerInput CompilerInput$ModuleType DependencyOptions
+ CompilerOptions$LanguageMode SourceMap$Format
+ SourceMap$DetailLevel ClosureCodingConvention SourceFile
+ Result JSError CheckLevel DiagnosticGroups
+ CommandLineRunner AnonymousFunctionNamingPolicy
+ JSModule SourceMap VariableMap]
+ [com.google.javascript.jscomp.deps ModuleLoader$ResolutionMode ModuleNames]
+ [com.google.javascript.rhino Node]
+ [java.nio.file Path Paths Files StandardWatchEventKinds WatchKey
+ WatchEvent FileVisitor FileVisitResult]
+ [java.nio.charset Charset StandardCharsets]
+ [com.sun.nio.file SensitivityWatchEventModifier]
+ [com.google.common.base Throwables]))
;; Copied from clojure.tools.gitlibs
@@ -473,10 +473,10 @@
(-source
([this] (deps/-source this nil))
([this opts]
- (if-let [s (:source this)]
- s
- (with-open [reader (io/reader (deps/-url this opts))]
- (slurp reader))))))
+ (if-let [s (:source this)]
+ s
+ (with-open [reader (io/reader (deps/-url this opts))]
+ (slurp reader))))))
(defrecord JavaScriptFile [foreign ^URL url ^URL source-url provides requires lines source-map]
deps/IJavaScript
@@ -498,10 +498,10 @@
(defn javascript-file
([foreign ^URL url provides requires]
- (javascript-file foreign url nil provides requires nil nil))
+ (javascript-file foreign url nil provides requires nil nil))
([foreign ^URL url source-url provides requires lines source-map]
- (assert (first provides) (str source-url " does not provide a namespace"))
- (JavaScriptFile. foreign url source-url (map name provides) (map name requires) lines source-map)))
+ (assert (first provides) (str source-url " does not provide a namespace"))
+ (JavaScriptFile. foreign url source-url (map name provides) (map name requires) lines source-map)))
(defn map->javascript-file [m]
(merge
@@ -569,9 +569,9 @@
(defn compile-form-seq
"Compile a sequence of forms to a JavaScript source string."
([forms]
- (compile-form-seq forms
- (when env/*compiler*
- (:options @env/*compiler*))))
+ (compile-form-seq forms
+ (when env/*compiler*
+ (:options @env/*compiler*))))
([forms opts]
(comp/with-core-cljs opts
(fn []
@@ -635,26 +635,26 @@
returns a JavaScriptFile. In either case the return value satisfies
IJavaScript."
[^File file {:keys [output-file] :as opts}]
- (if output-file
- (let [out-file (io/file (util/output-directory opts) output-file)]
- (if (and (aot-cache? opts)
- (gitlibs-src? file))
- (let [cacheable (ana/cacheable-files file (util/ext file) opts)
- cache-path (ana/cache-base-path (util/path file) opts)]
- (if (not (.exists (:output-file cacheable)))
- (let [ret (compiled-file (comp/compile-file file (:output-file cacheable)
- (assoc opts :output-dir (util/path cache-path))))]
- (copy-from-cache cache-path cacheable file opts)
- ret)
- (do
- (when-not (.exists out-file)
- (copy-from-cache cache-path cacheable file opts))
- (compiled-file (comp/compile-file file (.toString out-file) opts)))))
- (compiled-file (comp/compile-file file (.toString out-file) opts))))
- (let [path (.getPath ^File file)]
- (binding [ana/*cljs-file* path]
- (with-open [rdr (io/reader file)]
- (compile-form-seq (ana/forms-seq* rdr path)))))))
+ (if output-file
+ (let [out-file (io/file (util/output-directory opts) output-file)]
+ (if (and (aot-cache? opts)
+ (gitlibs-src? file))
+ (let [cacheable (ana/cacheable-files file (util/ext file) opts)
+ cache-path (ana/cache-base-path (util/path file) opts)]
+ (if (not (.exists (:output-file cacheable)))
+ (let [ret (compiled-file (comp/compile-file file (:output-file cacheable)
+ (assoc opts :output-dir (util/path cache-path))))]
+ (copy-from-cache cache-path cacheable file opts)
+ ret)
+ (do
+ (when-not (.exists out-file)
+ (copy-from-cache cache-path cacheable file opts))
+ (compiled-file (comp/compile-file file (.toString out-file) opts)))))
+ (compiled-file (comp/compile-file file (.toString out-file) opts))))
+ (let [path (.getPath ^File file)]
+ (binding [ana/*cljs-file* path]
+ (with-open [rdr (io/reader file)]
+ (compile-form-seq (ana/forms-seq* rdr path)))))))
(defn compile-dir
"Recursively compile all cljs files under the given source
@@ -673,9 +673,9 @@
(defn jar-file-to-disk
"Copy a file contained within a jar to disk. Return the created file."
([url out-dir]
- (jar-file-to-disk url out-dir
- (when env/*compiler*
- (:options @env/*compiler*))))
+ (jar-file-to-disk url out-dir
+ (when env/*compiler*
+ (:options @env/*compiler*))))
([url out-dir opts]
(let [out-file (io/file out-dir (path-from-jarfile url))
content (with-open [reader (io/reader url)]
@@ -869,20 +869,20 @@
(if-let [js-res (io/resource relpath)]
{:relative-path relpath :uri js-res :ext :js}
(let [ijs (get-in @compiler-env [:js-dependency-index (str ns)])
- relpath (or (:file ijs) (:url ijs))]
- (if-let [js-res (and relpath
- ;; try to parse URL, otherwise just return local
- ;; resource
- (or (and (util/url? relpath) relpath)
- (try (URL. relpath) (catch Throwable t))
- (io/resource relpath)))]
- {:relative-path relpath :uri js-res :ext :js}
- (throw
- (util/compilation-error
- (IllegalArgumentException.
- (str "Namespace " ns " does not exist."
- (when (string/includes? ns "-")
- " Please check that namespaces with dashes use underscores in the ClojureScript file name."))))))))))))))
+ relpath (or (:file ijs) (:url ijs))]
+ (if-let [js-res (and relpath
+ ;; try to parse URL, otherwise just return local
+ ;; resource
+ (or (and (util/url? relpath) relpath)
+ (try (URL. relpath) (catch Throwable t))
+ (io/resource relpath)))]
+ {:relative-path relpath :uri js-res :ext :js}
+ (throw
+ (util/compilation-error
+ (IllegalArgumentException.
+ (str "Namespace " ns " does not exist."
+ (when (string/includes? ns "-")
+ " Please check that namespaces with dashes use underscores in the ClojureScript file name."))))))))))))))
(defn cljs-dependencies
"Given a list of all required namespaces, return a list of
@@ -973,9 +973,9 @@
;; ignore :seed inputs, only for REPL - David
(if (not= :seed type)
(let [url (or url (io/resource file))]
- (merge
- (javascript-file foreign url provides requires)
- js-map))
+ (merge
+ (javascript-file foreign url provides requires)
+ js-map))
js-map))
required-js)
(when (-> @env/*compiler* :options :emit-constants)
@@ -1492,22 +1492,22 @@
(do
(write-variable-maps result opts)
(let [source (.toSource closure-compiler)]
- (when-let [name (:source-map opts)]
- (let [name' (str name ".closure")
- sw (StringWriter.)
- sm-json-str (do
- (.appendTo (.getSourceMap closure-compiler) sw name')
- (.toString sw))]
- (when (true? (:closure-source-map opts))
- (spit (io/file name') sm-json-str))
- (emit-optimized-source-map
- (json/read-str sm-json-str :key-fn keyword)
- sources name
- (assoc opts
- :preamble-line-count
- (+ (- (count (.split #"\r?\n" (make-preamble opts) -1)) 1)
- (if (:output-wrapper opts) 1 0))))))
- source))
+ (when-let [name (:source-map opts)]
+ (let [name' (str name ".closure")
+ sw (StringWriter.)
+ sm-json-str (do
+ (.appendTo (.getSourceMap closure-compiler) sw name')
+ (.toString sw))]
+ (when (true? (:closure-source-map opts))
+ (spit (io/file name') sm-json-str))
+ (emit-optimized-source-map
+ (json/read-str sm-json-str :key-fn keyword)
+ sources name
+ (assoc opts
+ :preamble-line-count
+ (+ (- (count (.split #"\r?\n" (make-preamble opts) -1)) 1)
+ (if (:output-wrapper opts) 1 0))))))
+ source))
(report-failure result))))
(comment
@@ -1640,7 +1640,7 @@
(defn preloads
([syms]
- (preloads syms nil))
+ (preloads syms nil))
([syms mode]
(letfn [(preload-str [sym]
(str (when (= :browser mode) "document.write('<script>")
@@ -1673,7 +1673,7 @@
"load((new java.io.File(new java.io.File(new java.io.File(\"" asset-path "\",\"goog\"),\"bootstrap\"),\"" (name (:target opts)) ".js\")).getPath());\n"
"load((new java.io.File(\"" asset-path "\",\"cljs_deps.js\")).getPath());\n"
"goog.global.CLOSURE_UNCOMPILED_DEFINES = " closure-defines ";\n"
- (apply str (preloads (:preloads opts)))))
+ (apply str (preloads (:preloads opts)))))
(apply str
(map (fn [entry]
(str "goog.require(\"" (comp/munge entry) "\");\n"))
@@ -1696,7 +1696,7 @@
"require(path.join(path.resolve(\".\"),\"" asset-path "\",\"goog\",\"bootstrap\",\"nodejs.js\"));\n"
"require(path.join(path.resolve(\".\"),\"" asset-path "\",\"cljs_deps.js\"));\n"
"goog.global.CLOSURE_UNCOMPILED_DEFINES = " closure-defines ";\n"
- (apply str (preloads (:preloads opts)))))
+ (apply str (preloads (:preloads opts)))))
(apply str
(map (fn [entry]
(str "goog.require(\"" (comp/munge entry) "\");\n"))
@@ -1716,7 +1716,7 @@
"var CLOSURE_IMPORT_SCRIPT = (function(global) { return function(src) {global['importScripts'](src); return true;};})(this);\n"
"if(typeof goog == 'undefined') importScripts(\"" asset-path "/goog/base.js\");\n"
"importScripts(\"" asset-path "/cljs_deps.js\");\n"
- (apply str (preloads (:preloads opts)))))
+ (apply str (preloads (:preloads opts)))))
(apply str
(map (fn [entry]
(when-not (= "goog" entry)
@@ -1726,7 +1726,7 @@
(when-let [main (:main opts)]
[main]))))))
- (output-one-file
+ (output-one-file
(merge opts
(when module
{:output-to (:output-to module)}))
@@ -1737,7 +1737,7 @@
"document.write('<script src=\"" asset-path "/goog/deps.js\"></script>');\n"
"document.write('<script src=\"" asset-path "/cljs_deps.js\"></script>');\n"
"document.write('<script>if (typeof goog == \"undefined\") console.warn(\"ClojureScript could not load :main, did you forget to specify :asset-path?\");</script>');\n"
- (apply str (preloads (:preloads opts) :browser))))
+ (apply str (preloads (:preloads opts) :browser))))
(apply str
(map (fn [entry]
(when-not (= "goog" entry)
@@ -2925,145 +2925,145 @@
([opts]
(build nil opts))
([source opts]
- (build source opts
- (if-not (nil? env/*compiler*)
- env/*compiler*
- (env/default-compiler-env
- ;; need to dissoc :foreign-libs since we won't know what overriding
- ;; foreign libspecs are referring to until after add-implicit-options
- ;; - David
- (add-externs-sources (dissoc opts :foreign-libs))))))
+ (build source opts
+ (if-not (nil? env/*compiler*)
+ env/*compiler*
+ (env/default-compiler-env
+ ;; need to dissoc :foreign-libs since we won't know what overriding
+ ;; foreign libspecs are referring to until after add-implicit-options
+ ;; - David
+ (add-externs-sources (dissoc opts :foreign-libs))))))
([source opts compiler-env]
- (env/with-compiler-env compiler-env
- (let [orig-opts opts
- opts (add-implicit-options opts)
- ;; we want to warn about NPM dep conflicts before installing the modules
- _ (when (:install-deps opts)
- (check-npm-deps opts)
- (swap! compiler-env update-in [:npm-deps-installed?]
- (fn [installed?]
- (if-not installed?
- (maybe-install-node-deps! opts)
- installed?))))
-
- compiler-stats (:compiler-stats opts)
- checked-arrays (or (:checked-arrays opts)
- ana/*checked-arrays*)
- static-fns? (or (and (= (:optimizations opts) :advanced)
- (not (false? (:static-fns opts))))
- (:static-fns opts)
- ana/*cljs-static-fns*)
- sources (when source
- (-find-sources source opts))]
- (validate-opts opts)
- (swap! compiler-env
- #(-> %
- (update-in [:options] merge opts)
- (assoc :target (:target opts))
- ;; Save the current js-dependency index once we have computed opts
- ;; or the analyzer won't be able to find upstream dependencies - Antonio
- (assoc :js-dependency-index (deps/js-dependency-index opts))
- ;; Save list of sources for cljs.analyzer/locate-src - Juho Teperi
- (assoc :sources sources)))
- (binding [comp/*recompiled* (when-not (false? (:recompile-dependents opts))
- (atom #{}))
- ana/*checked-arrays* checked-arrays
- ana/parse-ns (memoize ana/parse-ns)
- ana/*cljs-static-fns* static-fns?
- ana/*fn-invoke-direct* (or (and static-fns?
- (:fn-invoke-direct opts))
- ana/*fn-invoke-direct*)
- *assert* (not= (:elide-asserts opts) true)
- ana/*load-tests* (not= (:load-tests opts) false)
- ana/*cljs-warnings*
- (let [warnings (opts :warnings true)]
- (merge
- ana/*cljs-warnings*
- (if (or (true? warnings)
- (false? warnings))
- (zipmap
- [:unprovided :undeclared-var
- :undeclared-ns :undeclared-ns-form]
- (repeat warnings))
- warnings)))
- ana/*verbose* (:verbose opts)]
- (when ana/*verbose*
- (util/debug-prn "Options passed to ClojureScript compiler:" (pr-str opts)))
- (let [one-file? (and (:main opts)
- (#{:advanced :simple :whitespace} (:optimizations opts)))
- source (if one-file?
- (let [main (:main opts)
- uri (:uri (cljs-source-for-namespace main))]
- (assert uri (str "No file for namespace " main " exists"))
- uri)
- source)
- compile-opts (if one-file?
- (assoc opts :output-file (:output-to opts))
- opts)
- _ (load-data-readers! compiler-env)
- ;; reset :js-module-index so that ana/parse-ns called by -find-sources
- ;; can find the missing JS modules
- js-sources (env/with-compiler-env (dissoc @compiler-env :js-module-index)
- (-> (if source
- (-find-sources source opts)
- (-find-sources (reduce into #{} (map (comp :entries val) (:modules opts))) opts))
- (add-dependency-sources compile-opts)))
- opts (handle-js-modules opts js-sources compiler-env)
- js-sources (-> js-sources
- deps/dependency-order
- (compile-sources compiler-stats compile-opts)
- (#(map add-core-macros-if-cljs-js %))
- (add-js-sources opts)
- (cond-> (= :nodejs (:target opts)) (concat [(-compile (io/resource "cljs/nodejs.cljs") opts)]))
- deps/dependency-order
- (add-preloads opts)
- remove-goog-base
- add-goog-base
- (cond-> (= :nodejs (:target opts)) (concat [(-compile (io/resource "cljs/nodejscli.cljs") opts)]))
- (->> (map #(source-on-disk opts %)) doall)
- (compile-loader opts))
- _ (when (:emit-constants opts)
- (comp/emit-constants-table-to-file
- (::ana/constant-table @env/*compiler*)
- (constants-filename opts)))
- _ (when (:infer-externs opts)
- (comp/emit-inferred-externs-to-file
- (reduce util/map-merge {}
- (map (comp :externs second)
- (get @compiler-env ::ana/namespaces)))
- (str (util/output-directory opts) "/inferred_externs.js")))
- _ (spit (io/file (util/output-directory opts) (:opts-cache opts)) (pr-str orig-opts))
- optim (:optimizations opts)
- ret (if (and optim (not= optim :none))
- (do
- (when-let [fname (:source-map opts)]
- (assert (or (nil? (:output-to opts)) (:modules opts) (string? fname))
- (str ":source-map must name a file when using :whitespace, "
- ":simple, or :advanced optimizations with :output-to")))
- (if (:modules opts)
+ (env/with-compiler-env compiler-env
+ (let [orig-opts opts
+ opts (add-implicit-options opts)
+ ;; we want to warn about NPM dep conflicts before installing the modules
+ _ (when (:install-deps opts)
+ (check-npm-deps opts)
+ (swap! compiler-env update-in [:npm-deps-installed?]
+ (fn [installed?]
+ (if-not installed?
+ (maybe-install-node-deps! opts)
+ installed?))))
+
+ compiler-stats (:compiler-stats opts)
+ checked-arrays (or (:checked-arrays opts)
+ ana/*checked-arrays*)
+ static-fns? (or (and (= (:optimizations opts) :advanced)
+ (not (false? (:static-fns opts))))
+ (:static-fns opts)
+ ana/*cljs-static-fns*)
+ sources (when source
+ (-find-sources source opts))]
+ (validate-opts opts)
+ (swap! compiler-env
+ #(-> %
+ (update-in [:options] merge opts)
+ (assoc :target (:target opts))
+ ;; Save the current js-dependency index once we have computed opts
+ ;; or the analyzer won't be able to find upstream dependencies - Antonio
+ (assoc :js-dependency-index (deps/js-dependency-index opts))
+ ;; Save list of sources for cljs.analyzer/locate-src - Juho Teperi
+ (assoc :sources sources)))
+ (binding [comp/*recompiled* (when-not (false? (:recompile-dependents opts))
+ (atom #{}))
+ ana/*checked-arrays* checked-arrays
+ ana/parse-ns (memoize ana/parse-ns)
+ ana/*cljs-static-fns* static-fns?
+ ana/*fn-invoke-direct* (or (and static-fns?
+ (:fn-invoke-direct opts))
+ ana/*fn-invoke-direct*)
+ *assert* (not= (:elide-asserts opts) true)
+ ana/*load-tests* (not= (:load-tests opts) false)
+ ana/*cljs-warnings*
+ (let [warnings (opts :warnings true)]
+ (merge
+ ana/*cljs-warnings*
+ (if (or (true? warnings)
+ (false? warnings))
+ (zipmap
+ [:unprovided :undeclared-var
+ :undeclared-ns :undeclared-ns-form]
+ (repeat warnings))
+ warnings)))
+ ana/*verbose* (:verbose opts)]
+ (when ana/*verbose*
+ (util/debug-prn "Options passed to ClojureScript compiler:" (pr-str opts)))
+ (let [one-file? (and (:main opts)
+ (#{:advanced :simple :whitespace} (:optimizations opts)))
+ source (if one-file?
+ (let [main (:main opts)
+ uri (:uri (cljs-source-for-namespace main))]
+ (assert uri (str "No file for namespace " main " exists"))
+ uri)
+ source)
+ compile-opts (if one-file?
+ (assoc opts :output-file (:output-to opts))
+ opts)
+ _ (load-data-readers! compiler-env)
+ ;; reset :js-module-index so that ana/parse-ns called by -find-sources
+ ;; can find the missing JS modules
+ js-sources (env/with-compiler-env (dissoc @compiler-env :js-module-index)
+ (-> (if source
+ (-find-sources source opts)
+ (-find-sources (reduce into #{} (map (comp :entries val) (:modules opts))) opts))
+ (add-dependency-sources compile-opts)))
+ opts (handle-js-modules opts js-sources compiler-env)
+ js-sources (-> js-sources
+ deps/dependency-order
+ (compile-sources compiler-stats compile-opts)
+ (#(map add-core-macros-if-cljs-js %))
+ (add-js-sources opts)
+ (cond-> (= :nodejs (:target opts)) (concat [(-compile (io/resource "cljs/nodejs.cljs") opts)]))
+ deps/dependency-order
+ (add-preloads opts)
+ remove-goog-base
+ add-goog-base
+ (cond-> (= :nodejs (:target opts)) (concat [(-compile (io/resource "cljs/nodejscli.cljs") opts)]))
+ (->> (map #(source-on-disk opts %)) doall)
+ (compile-loader opts))
+ _ (when (:emit-constants opts)
+ (comp/emit-constants-table-to-file
+ (::ana/constant-table @env/*compiler*)
+ (constants-filename opts)))
+ _ (when (:infer-externs opts)
+ (comp/emit-inferred-externs-to-file
+ (reduce util/map-merge {}
+ (map (comp :externs second)
+ (get @compiler-env ::ana/namespaces)))
+ (str (util/output-directory opts) "/inferred_externs.js")))
+ _ (spit (io/file (util/output-directory opts) (:opts-cache opts)) (pr-str orig-opts))
+ optim (:optimizations opts)
+ ret (if (and optim (not= optim :none))
+ (do
+ (when-let [fname (:source-map opts)]
+ (assert (or (nil? (:output-to opts)) (:modules opts) (string? fname))
+ (str ":source-map must name a file when using :whitespace, "
+ ":simple, or :advanced optimizations with :output-to")))
+ (if (:modules opts)
+ (->>
+ (util/measure compiler-stats
+ (str "Optimizing " (count js-sources) " sources")
+ (apply optimize-modules opts js-sources))
+ (output-modules opts js-sources))
+ (let [fdeps-str (foreign-deps-str opts
+ (filter foreign-source? js-sources))
+ opts (assoc opts
+ :foreign-deps-line-count
+ (- (count (.split #"\r?\n" fdeps-str -1)) 1))]
(->>
(util/measure compiler-stats
(str "Optimizing " (count js-sources) " sources")
- (apply optimize-modules opts js-sources))
- (output-modules opts js-sources))
- (let [fdeps-str (foreign-deps-str opts
- (filter foreign-source? js-sources))
- opts (assoc opts
- :foreign-deps-line-count
- (- (count (.split #"\r?\n" fdeps-str -1)) 1))]
- (->>
- (util/measure compiler-stats
- (str "Optimizing " (count js-sources) " sources")
- (apply optimize opts
- (remove foreign-source? js-sources)))
- (add-wrapper opts)
- (add-source-map-link opts)
- (str fdeps-str)
- (add-header opts)
- (output-one-file opts)))))
- (apply output-unoptimized opts js-sources))]
- (output-bootstrap opts)
- ret))))))
+ (apply optimize opts
+ (remove foreign-source? js-sources)))
+ (add-wrapper opts)
+ (add-source-map-link opts)
+ (str fdeps-str)
+ (add-header opts)
+ (output-one-file opts)))))
+ (apply output-unoptimized opts js-sources))]
+ (output-bootstrap opts)
+ ret))))))
(comment
;; testing modules
@@ -3114,93 +3114,93 @@
be a function value or a namespaced symbol, loaded as
with :watch-fn."
([source opts]
- (watch source opts
- (if-not (nil? env/*compiler*)
- env/*compiler*
- (env/default-compiler-env opts))))
+ (watch source opts
+ (if-not (nil? env/*compiler*)
+ env/*compiler*
+ (env/default-compiler-env opts))))
([source opts compiler-env]
- (watch source opts compiler-env nil))
+ (watch source opts compiler-env nil))
([source opts compiler-env quit]
- (let [opts (cond-> opts
- (= (:verbose opts :not-found) :not-found)
- (assoc :verbose true))
- paths (map #(Paths/get (.toURI %)) (-paths source))
- path (first paths)
- fs (.getFileSystem path)
- srvc (.newWatchService fs)]
- (letfn [(buildf []
- (try
- (let [start (System/nanoTime)]
- (build source opts compiler-env)
- (println "... done. Elapsed"
- (/ (unchecked-subtract (System/nanoTime) start) 1e9) "seconds")
- (flush))
- (when-let [f (opts-fn :watch-fn opts)]
- (f))
- (catch Throwable e
- (if-let [f (opts-fn :watch-error-fn opts)]
- (f e)
- (binding [*out* *err*]
- (println (Throwables/getStackTraceAsString e)))))))
- (watch-all [^Path root]
- (Files/walkFileTree root
- (reify
- FileVisitor
- (preVisitDirectory [_ dir _]
- (let [^Path dir dir]
- (. dir
- (register srvc
- (into-array [StandardWatchEventKinds/ENTRY_CREATE
- StandardWatchEventKinds/ENTRY_DELETE
- StandardWatchEventKinds/ENTRY_MODIFY])
- (into-array [SensitivityWatchEventModifier/HIGH]))))
- FileVisitResult/CONTINUE)
- (postVisitDirectory [_ dir exc]
- FileVisitResult/CONTINUE)
- (visitFile [_ file attrs]
- FileVisitResult/CONTINUE)
- (visitFileFailed [_ file exc]
- FileVisitResult/CONTINUE))))]
- (println "Building ...")
- (flush)
- (buildf)
- (println "Watching paths:" (apply str (interpose ", " paths)))
- (doseq [path paths]
- (watch-all path))
- (loop [key nil]
- (when (and (or (nil? quit) (not @quit))
- (or (nil? key) (. ^WatchKey key reset)))
- (let [key (. srvc (poll 300 TimeUnit/MILLISECONDS))
- poll-events-seq (when key (seq (.pollEvents key)))]
- (when (and key
- (some
- (fn [^WatchEvent e]
- (let [fstr (.. e context toString)]
- (and (or (. fstr (endsWith "cljc"))
- (. fstr (endsWith "cljs"))
- (. fstr (endsWith "clj"))
- (. fstr (endsWith "js")))
- (not (. fstr (startsWith ".#"))))))
- poll-events-seq))
- (when-let [clj-files (seq (keep (fn [^WatchEvent e]
- (let [ctx (.context e)
- fstr (.toString ctx)]
- (when (and (or (. fstr (endsWith "cljc"))
- (. fstr (endsWith "clj")))
- (not (. fstr (startsWith ".#"))))
- ctx)))
- poll-events-seq))]
- (let [^Path dir (.watchable key)
- file-seq (map #(.toFile (.resolve dir %)) clj-files)
- nses (map (comp :ns ana/parse-ns) file-seq)]
- (doseq [ns nses]
- (require ns :reload))
- (doseq [ns (cljs-dependents-for-macro-namespaces compiler-env nses)]
- (mark-cljs-ns-for-recompile! ns (:output-dir opts)))))
- (println "Change detected, recompiling ...")
- (flush)
- (buildf))
- (recur key))))))))
+ (let [opts (cond-> opts
+ (= (:verbose opts :not-found) :not-found)
+ (assoc :verbose true))
+ paths (map #(Paths/get (.toURI %)) (-paths source))
+ path (first paths)
+ fs (.getFileSystem path)
+ srvc (.newWatchService fs)]
+ (letfn [(buildf []
+ (try
+ (let [start (System/nanoTime)]
+ (build source opts compiler-env)
+ (println "... done. Elapsed"
+ (/ (unchecked-subtract (System/nanoTime) start) 1e9) "seconds")
+ (flush))
+ (when-let [f (opts-fn :watch-fn opts)]
+ (f))
+ (catch Throwable e
+ (if-let [f (opts-fn :watch-error-fn opts)]
+ (f e)
+ (binding [*out* *err*]
+ (println (Throwables/getStackTraceAsString e)))))))
+ (watch-all [^Path root]
+ (Files/walkFileTree root
+ (reify
+ FileVisitor
+ (preVisitDirectory [_ dir _]
+ (let [^Path dir dir]
+ (. dir
+ (register srvc
+ (into-array [StandardWatchEventKinds/ENTRY_CREATE
+ StandardWatchEventKinds/ENTRY_DELETE
+ StandardWatchEventKinds/ENTRY_MODIFY])
+ (into-array [SensitivityWatchEventModifier/HIGH]))))
+ FileVisitResult/CONTINUE)
+ (postVisitDirectory [_ dir exc]
+ FileVisitResult/CONTINUE)
+ (visitFile [_ file attrs]
+ FileVisitResult/CONTINUE)
+ (visitFileFailed [_ file exc]
+ FileVisitResult/CONTINUE))))]
+ (println "Building ...")
+ (flush)
+ (buildf)
+ (println "Watching paths:" (apply str (interpose ", " paths)))
+ (doseq [path paths]
+ (watch-all path))
+ (loop [key nil]
+ (when (and (or (nil? quit) (not @quit))
+ (or (nil? key) (. ^WatchKey key reset)))
+ (let [key (. srvc (poll 300 TimeUnit/MILLISECONDS))
+ poll-events-seq (when key (seq (.pollEvents key)))]
+ (when (and key
+ (some
+ (fn [^WatchEvent e]
+ (let [fstr (.. e context toString)]
+ (and (or (. fstr (endsWith "cljc"))
+ (. fstr (endsWith "cljs"))
+ (. fstr (endsWith "clj"))
+ (. fstr (endsWith "js")))
+ (not (. fstr (startsWith ".#"))))))
+ poll-events-seq))
+ (when-let [clj-files (seq (keep (fn [^WatchEvent e]
+ (let [ctx (.context e)
+ fstr (.toString ctx)]
+ (when (and (or (. fstr (endsWith "cljc"))
+ (. fstr (endsWith "clj")))
+ (not (. fstr (startsWith ".#"))))
+ ctx)))
+ poll-events-seq))]
+ (let [^Path dir (.watchable key)
+ file-seq (map #(.toFile (.resolve dir %)) clj-files)
+ nses (map (comp :ns ana/parse-ns) file-seq)]
+ (doseq [ns nses]
+ (require ns :reload))
+ (doseq [ns (cljs-dependents-for-macro-namespaces compiler-env nses)]
+ (mark-cljs-ns-for-recompile! ns (:output-dir opts)))))
+ (println "Change detected, recompiling ...")
+ (flush)
+ (buildf))
+ (recur key))))))))
(comment
(watch "samples/hello/src"
@@ -3231,32 +3231,32 @@
(when env/*compiler*
(:options @env/*compiler*))))
([src opts]
- (util/to-target-file
- (when (:output-dir opts)
- (util/output-directory opts))
- (ana/parse-ns src))))
+ (util/to-target-file
+ (when (:output-dir opts)
+ (util/output-directory opts))
+ (ana/parse-ns src))))
(defn ^String src-file->goog-require
([src] (src-file->goog-require src {:wrap true}))
([src {:keys [wrap all-provides macros-ns] :as options}]
- (let [goog-ns
- (case (util/ext src)
- ("cljs" "cljc") (let [ns-str (str (comp/munge (:ns (ana/parse-ns src))))]
- (cond-> ns-str
- (and macros-ns (not (.endsWith ns-str "$macros")))
- (str "$macros")))
- "js" (cond-> (:provides (parse-js-ns src))
- (not all-provides) first)
- (throw
- (util/compilation-error (IllegalArgumentException.
- (str "Can't create goog.require expression for " src)))))]
- (if (and (not all-provides) wrap)
- (if (:reload options)
- (str "goog.require(\"" goog-ns "\", true);")
- (str "goog.require(\"" goog-ns "\");"))
- (if (vector? goog-ns)
- goog-ns
- (str goog-ns))))))
+ (let [goog-ns
+ (case (util/ext src)
+ ("cljs" "cljc") (let [ns-str (str (comp/munge (:ns (ana/parse-ns src))))]
+ (cond-> ns-str
+ (and macros-ns (not (.endsWith ns-str "$macros")))
+ (str "$macros")))
+ "js" (cond-> (:provides (parse-js-ns src))
+ (not all-provides) first)
+ (throw
+ (util/compilation-error (IllegalArgumentException.
+ (str "Can't create goog.require expression for " src)))))]
+ (if (and (not all-provides) wrap)
+ (if (:reload options)
+ (str "goog.require(\"" goog-ns "\", true);")
+ (str "goog.require(\"" goog-ns "\");"))
+ (if (vector? goog-ns)
+ goog-ns
+ (str goog-ns))))))
;; Browser REPL client stuff
@@ -3268,7 +3268,7 @@
(build
'[(ns clojure.browser.repl.client
(:require [goog.events :as event]
- [clojure.browser.repl :as repl]))
+ [clojure.browser.repl :as repl]))
(defn start [url]
(event/listen js/window
"load"
diff --git a/src/main/clojure/cljs/compiler/api.clj b/src/main/clojure/cljs/compiler/api.clj
index 811a6028..7ddab8c0 100644
--- a/src/main/clojure/cljs/compiler/api.clj
+++ b/src/main/clojure/cljs/compiler/api.clj
@@ -10,10 +10,10 @@
"This is intended to be a stable api for those who need programmatic access
to the compiler."
(:require [cljs.util :as util]
- [cljs.env :as env]
- [cljs.analyzer :as ana]
- [cljs.compiler :as comp]
- [cljs.closure :as closure]))
+ [cljs.env :as env]
+ [cljs.analyzer :as ana]
+ [cljs.compiler :as comp]
+ [cljs.closure :as closure]))
;; =============================================================================
;; Main API
diff --git a/src/main/clojure/cljs/core/macros.clj b/src/main/clojure/cljs/core/macros.clj
index 8aaa8795..ce11efb3 100644
--- a/src/main/clojure/cljs/core/macros.clj
+++ b/src/main/clojure/cljs/core/macros.clj
@@ -9,11 +9,11 @@
(ns cljs.core.macros
(:refer-clojure :exclude [alias])
(:require [clojure.java.io :as io]
- [clojure.tools.reader :as reader]
- [clojure.tools.reader.reader-types :as readers]
- [cljs.env :as env]
- [cljs.analyzer :as ana]
- [cljs.repl :refer [source]])
+ [clojure.tools.reader :as reader]
+ [clojure.tools.reader.reader-types :as readers]
+ [cljs.env :as env]
+ [cljs.analyzer :as ana]
+ [cljs.repl :refer [source]])
(:import [java.io PushbackReader]))
(defn source-fn
@@ -34,8 +34,8 @@
(letfn [(->cljs-macro [[_ & rest]]
`(cljs.core/defmacro ~@rest))]
`(do
- ~@(binding [*ns* (find-ns ns)]
- (doall (map (comp ->cljs-macro source-fn) vars))))))
+ ~@(binding [*ns* (find-ns ns)]
+ (doall (map (comp ->cljs-macro source-fn) vars))))))
(defmacro alias [[_ ns] [_ alias]]
(swap! env/*compiler* assoc-in
diff --git a/src/main/clojure/cljs/core/server.clj b/src/main/clojure/cljs/core/server.clj
index 11c5a272..7a2179e8 100644
--- a/src/main/clojure/cljs/core/server.clj
+++ b/src/main/clojure/cljs/core/server.clj
@@ -9,14 +9,14 @@
(ns cljs.core.server
(:refer-clojure :exclude [with-bindings resolve-fn prepl io-prepl])
(:require [clojure.tools.reader.reader-types :as readers]
- [clojure.tools.reader :as reader]
- [cljs.env :as env]
- [cljs.closure :as closure]
- [cljs.analyzer :as ana]
- [cljs.analyzer.api :as ana-api]
- [cljs.repl :as repl]
- [cljs.compiler :as comp]
- [cljs.tagged-literals :as tags]))
+ [clojure.tools.reader :as reader]
+ [cljs.env :as env]
+ [cljs.closure :as closure]
+ [cljs.analyzer :as ana]
+ [cljs.analyzer.api :as ana-api]
+ [cljs.repl :as repl]
+ [cljs.compiler :as comp]
+ [cljs.tagged-literals :as tags]))
(defmacro with-bindings [& body]
`(binding [ana/*cljs-ns* ana/*cljs-ns*
@@ -95,7 +95,7 @@
reader/*alias-map*
(apply merge
((juxt :requires :require-macros)
- (ana/get-namespace ana/*cljs-ns*)))]
+ (ana/get-namespace ana/*cljs-ns*)))]
(reader/read+string in-reader
{:eof EOF :read-cond :allow :features #{:cljs}}))]
(try
diff --git a/src/main/clojure/cljs/env/macros.clj b/src/main/clojure/cljs/env/macros.clj
index 86349084..2b25a5b1 100644
--- a/src/main/clojure/cljs/env/macros.clj
+++ b/src/main/clojure/cljs/env/macros.clj
@@ -10,20 +10,20 @@
(:refer-clojure :exclude [binding ensure]))
(defmacro with-compiler-env
- "Evaluates [body] with [env] bound as the value of the `*compiler*` var in
+ "Evaluates [body] with [env] bound as the value of the `*compiler*` var in
this namespace."
[env & body]
- `(let [env# ~env
- env# (cond
- (map? env#) (atom env#)
- (and (instance? cljs.core/Atom env#) (map? @env#)) env#
- :default
- (throw
- (js/Error.
- (str "Compiler environment must be a map or atom containing a map, not "
- (type env#)))))]
- (cljs.core/binding [cljs.env/*compiler* env#]
- ~@body)))
+ `(let [env# ~env
+ env# (cond
+ (map? env#) (atom env#)
+ (and (instance? cljs.core/Atom env#) (map? @env#)) env#
+ :default
+ (throw
+ (js/Error.
+ (str "Compiler environment must be a map or atom containing a map, not "
+ (type env#)))))]
+ (cljs.core/binding [cljs.env/*compiler* env#]
+ ~@body)))
(defmacro ensure
[& body]
diff --git a/src/main/clojure/cljs/externs.clj b/src/main/clojure/cljs/externs.clj
index e672b1b9..9039021e 100644
--- a/src/main/clojure/cljs/externs.clj
+++ b/src/main/clojure/cljs/externs.clj
@@ -8,14 +8,14 @@
(ns cljs.externs
(:require [clojure.string :as string]
- [cljs.util :as util]
- [clojure.java.io :as io]
- [cljs.js-deps :as js-deps])
+ [cljs.util :as util]
+ [clojure.java.io :as io]
+ [cljs.js-deps :as js-deps])
(:import [java.util.logging Level]
- [com.google.javascript.jscomp
- CompilerOptions SourceFile JsAst CommandLineRunner]
- [com.google.javascript.rhino
- Node Token JSTypeExpression]))
+ [com.google.javascript.jscomp
+ CompilerOptions SourceFile JsAst CommandLineRunner]
+ [com.google.javascript.rhino
+ Node Token JSTypeExpression]))
;; ------------------------------------------------------------------------------
;; Externs Parsing
diff --git a/src/main/clojure/cljs/repl/browser.clj b/src/main/clojure/cljs/repl/browser.clj
index 83c2ad0d..8386bd1c 100644
--- a/src/main/clojure/cljs/repl/browser.clj
+++ b/src/main/clojure/cljs/repl/browser.clj
@@ -9,19 +9,19 @@
(ns cljs.repl.browser
(:refer-clojure :exclude [loaded-libs])
(:require [clojure.java.io :as io]
- [clojure.java.browse :as browse]
- [clojure.string :as string]
- [clojure.edn :as edn]
- [clojure.data.json :as json]
- [cljs.util :as util]
- [cljs.closure :as cljsc]
- [cljs.repl :as repl]
- [cljs.cli :as cli]
- [cljs.repl.server :as server]
- [cljs.stacktrace :as st]
- [cljs.analyzer :as ana]
- [cljs.build.api :as build]
- [clojure.string :as str])
+ [clojure.java.browse :as browse]
+ [clojure.string :as string]
+ [clojure.edn :as edn]
+ [clojure.data.json :as json]
+ [cljs.util :as util]
+ [cljs.closure :as cljsc]
+ [cljs.repl :as repl]
+ [cljs.cli :as cli]
+ [cljs.repl.server :as server]
+ [cljs.stacktrace :as st]
+ [cljs.analyzer :as ana]
+ [cljs.build.api :as build]
+ [clojure.string :as str])
(:import [java.util.concurrent Executors ConcurrentHashMap]))
(def ^:dynamic browser-state nil)
@@ -72,14 +72,14 @@
browser for evaluation. The return value function will be called
when the return value is received."
([form return-value-fn]
- (send-for-eval @(server/connection) form return-value-fn))
+ (send-for-eval @(server/connection) form return-value-fn))
([conn form return-value-fn]
- (set-return-value-fn return-value-fn)
- (server/send-and-close conn 200
- (json/write-str
- {"repl" (thread-name)
- "form" form})
- "application/json")))
+ (set-return-value-fn return-value-fn)
+ (server/send-and-close conn 200
+ (json/write-str
+ {"repl" (thread-name)
+ "form" form})
+ "application/json")))
(defn- return-value
"Called by the server when a return value is received."
@@ -228,12 +228,12 @@
(assoc ana/*cljs-warnings*
:undeclared-var false)]
(cljsc/-compile
- '[(set! *print-fn* clojure.browser.repl/repl-print)
- (set! *print-err-fn* clojure.browser.repl/repl-print)
- (set! *print-newline* true)
- (when (pos? (count clojure.browser.repl/print-queue))
- (clojure.browser.repl/flush-print-queue!
- @clojure.browser.repl/xpc-connection))] {}))
+ '[(set! *print-fn* clojure.browser.repl/repl-print)
+ (set! *print-err-fn* clojure.browser.repl/repl-print)
+ (set! *print-newline* true)
+ (when (pos? (count clojure.browser.repl/print-queue))
+ (clojure.browser.repl/flush-print-queue!
+ @clojure.browser.repl/xpc-connection))] {}))
identity))
(defn add-in-order [{:keys [expecting fns]} order f]
diff --git a/src/main/clojure/cljs/repl/graaljs.clj b/src/main/clojure/cljs/repl/graaljs.clj
index 55b0daae..b2920b30 100644
--- a/src/main/clojure/cljs/repl/graaljs.clj
+++ b/src/main/clojure/cljs/repl/graaljs.clj
@@ -8,17 +8,17 @@
(ns cljs.repl.graaljs
(:require [clojure.java.io :as io]
- [clojure.string :as string]
- [clojure.stacktrace]
- [clojure.data.json :as json]
- [cljs.analyzer :as ana]
- [cljs.env :as env]
- [cljs.util :as util]
- [cljs.repl :as repl]
- [cljs.cli :as cli]
- [cljs.compiler :as comp]
- [cljs.closure :as closure]
- [cljs.stacktrace :as st])
+ [clojure.string :as string]
+ [clojure.stacktrace]
+ [clojure.data.json :as json]
+ [cljs.analyzer :as ana]
+ [cljs.env :as env]
+ [cljs.util :as util]
+ [cljs.repl :as repl]
+ [cljs.cli :as cli]
+ [cljs.compiler :as comp]
+ [cljs.closure :as closure]
+ [cljs.stacktrace :as st])
(:import [javax.script ScriptEngine ScriptException]))
(defn- js-opt-key? [k]
@@ -81,8 +81,8 @@
core (io/resource "cljs/core.cljs")
core-js (closure/compile core
(assoc opts :output-file
- (closure/src-file->target-file
- core (dissoc opts :output-dir))))
+ (closure/src-file->target-file
+ core (dissoc opts :output-dir))))
deps (closure/add-dependencies opts core-js)]
;; output unoptimized code and the deps file
;; for all compiled namespaces
@@ -152,21 +152,21 @@
{:status :exception
:value (.getMessage root-cause)
:stacktrace
- (apply str
- (interpose "\n"
- (map #(subs % 5)
- (filter #(clojure.string/starts-with? % "<js>.")
- (map str
- (.getStackTrace root-cause))))))}))
+ (apply str
+ (interpose "\n"
+ (map #(subs % 5)
+ (filter #(clojure.string/starts-with? % "<js>.")
+ (map str
+ (.getStackTrace root-cause))))))}))
(catch Throwable e
(let [^Throwable root-cause (clojure.stacktrace/root-cause e)]
{:status :exception
:value (.getMessage root-cause)
:stacktrace
- (apply str
- (interpose "\n"
- (map str
- (.getStackTrace root-cause))))}))))
+ (apply str
+ (interpose "\n"
+ (map str
+ (.getStackTrace root-cause))))}))))
(-load [{engine :engine :as this} ns url]
(load-ns engine ns))
(-tear-down [this]
diff --git a/src/main/clojure/cljs/repl/nashorn.clj b/src/main/clojure/cljs/repl/nashorn.clj
index 4bd767de..9488ff1b 100644
--- a/src/main/clojure/cljs/repl/nashorn.clj
+++ b/src/main/clojure/cljs/repl/nashorn.clj
@@ -8,17 +8,17 @@
(ns cljs.repl.nashorn
(:require [clojure.java.io :as io]
- [clojure.string :as string]
- [clojure.stacktrace]
- [clojure.data.json :as json]
- [cljs.analyzer :as ana]
- [cljs.env :as env]
- [cljs.util :as util]
- [cljs.repl :as repl]
- [cljs.cli :as cli]
- [cljs.compiler :as comp]
- [cljs.closure :as closure]
- [cljs.stacktrace :as st])
+ [clojure.string :as string]
+ [clojure.stacktrace]
+ [clojure.data.json :as json]
+ [cljs.analyzer :as ana]
+ [cljs.env :as env]
+ [cljs.util :as util]
+ [cljs.repl :as repl]
+ [cljs.cli :as cli]
+ [cljs.compiler :as comp]
+ [cljs.closure :as closure]
+ [cljs.stacktrace :as st])
(:import [javax.script ScriptEngine ScriptEngineManager ScriptException ScriptEngineFactory]))
(util/compile-if (Class/forName "jdk.nashorn.api.scripting.NashornException")
diff --git a/src/main/clojure/cljs/repl/node.clj b/src/main/clojure/cljs/repl/node.clj
index 363880ec..3171b7b1 100644
--- a/src/main/clojure/cljs/repl/node.clj
+++ b/src/main/clojure/cljs/repl/node.clj
@@ -8,19 +8,19 @@
(ns cljs.repl.node
(:require [clojure.string :as string]
- [clojure.java.io :as io]
- [cljs.util :as util]
- [cljs.analyzer :as ana]
- [cljs.compiler :as comp]
- [cljs.repl :as repl]
- [cljs.cli :as cli]
- [cljs.closure :as closure]
- [clojure.data.json :as json])
+ [clojure.java.io :as io]
+ [cljs.util :as util]
+ [cljs.analyzer :as ana]
+ [cljs.compiler :as comp]
+ [cljs.repl :as repl]
+ [cljs.cli :as cli]
+ [cljs.closure :as closure]
+ [clojure.data.json :as json])
(:import [java.net Socket]
- [java.lang StringBuilder]
- [java.io File BufferedReader BufferedWriter IOException]
- [java.lang ProcessBuilder Process]
- [java.util.concurrent ConcurrentHashMap LinkedBlockingQueue]))
+ [java.lang StringBuilder]
+ [java.io File BufferedReader BufferedWriter IOException]
+ [java.lang ProcessBuilder Process]
+ [java.util.concurrent ConcurrentHashMap LinkedBlockingQueue]))
(def lock (Object.))
(def results (ConcurrentHashMap.))
@@ -52,10 +52,10 @@
(loop [sb sb c (.read in)]
(case c
-1 (throw (IOException. "Stream closed"))
- 0 (str sb)
- (do
- (.append sb (char c))
- (recur sb (.read in)))))))
+ 0 (str sb)
+ (do
+ (.append sb (char c))
+ (recur sb (.read in)))))))
(defn node-eval
"Evaluate a JavaScript string in the Node REPL process."
@@ -163,8 +163,8 @@
;; resources in JARs
(let [core-js (closure/compile core
(assoc opts :output-file
- (closure/src-file->target-file
- core (dissoc opts :output-dir))))
+ (closure/src-file->target-file
+ core (dissoc opts :output-dir))))
deps (closure/add-dependencies opts core-js)]
;; output unoptimized code and the deps file
;; for all compiled namespaces
diff --git a/src/main/clojure/cljs/repl/reflect.clj b/src/main/clojure/cljs/repl/reflect.clj
index 48302db5..29d764e1 100644
--- a/src/main/clojure/cljs/repl/reflect.clj
+++ b/src/main/clojure/cljs/repl/reflect.clj
@@ -9,10 +9,10 @@
(ns cljs.repl.reflect
(:refer-clojure :exclude [macroexpand])
(:require [cljs.repl.server :as server]
- [cljs.analyzer :as analyzer]
- [cljs.compiler :as compiler]
- [clojure.string :as str]
- [clojure.pprint :as pprint]))
+ [cljs.analyzer :as analyzer]
+ [cljs.compiler :as compiler]
+ [clojure.string :as str]
+ [clojure.pprint :as pprint]))
(defn- dissoc-unless
"Dissoc all keys from map that do not appear in key-set.
diff --git a/src/main/clojure/cljs/repl/rhino.clj b/src/main/clojure/cljs/repl/rhino.clj
index 2161a351..0158db2e 100644
--- a/src/main/clojure/cljs/repl/rhino.clj
+++ b/src/main/clojure/cljs/repl/rhino.clj
@@ -9,18 +9,18 @@
(ns cljs.repl.rhino
(:refer-clojure :exclude [load-file])
(:require [clojure.string :as string]
- [clojure.java.io :as io]
- [clojure.data.json :as json]
- [cljs.compiler :as comp]
- [cljs.closure :as closure]
- [cljs.analyzer :as ana]
- [cljs.repl :as repl]
- [cljs.cli :as cli]
- [cljs.util :as util]
- [cljs.stacktrace :as st])
+ [clojure.java.io :as io]
+ [clojure.data.json :as json]
+ [cljs.compiler :as comp]
+ [cljs.closure :as closure]
+ [cljs.analyzer :as ana]
+ [cljs.repl :as repl]
+ [cljs.cli :as cli]
+ [cljs.util :as util]
+ [cljs.stacktrace :as st])
(:import [java.io File Reader]
- [org.mozilla.javascript Context ScriptableObject
- RhinoException Undefined]))
+ [org.mozilla.javascript Context ScriptableObject
+ RhinoException Undefined]))
(def ^String bootjs
(str "var global = this;\n"
diff --git a/src/main/clojure/cljs/repl/server.clj b/src/main/clojure/cljs/repl/server.clj
index 63d43c71..ce5db03c 100644
--- a/src/main/clojure/cljs/repl/server.clj
+++ b/src/main/clojure/cljs/repl/server.clj
@@ -10,11 +10,11 @@
(:refer-clojure :exclude [loaded-libs])
(:require [clojure.string :as str])
(:import java.io.BufferedReader
- java.io.InputStreamReader
- java.io.ByteArrayOutputStream
- java.util.zip.GZIPOutputStream
- java.net.ServerSocket
- [java.util LinkedList]))
+ java.io.InputStreamReader
+ java.io.ByteArrayOutputStream
+ java.util.zip.GZIPOutputStream
+ java.net.ServerSocket
+ [java.util LinkedList]))
(def ^:dynamic state nil)
(def connq (LinkedList.))
@@ -53,11 +53,11 @@
and a request map and returns a boolean value based on whether or not
that request should be dispatched to the related handler."
([method pred handler]
- (dispatch-on method {:pred pred :handler handler}))
+ (dispatch-on method {:pred pred :handler handler}))
([method {:as m}]
- (swap! handlers
- (fn [old]
- (update-in old [method] #(conj (vec %) m))))))
+ (swap! handlers
+ (fn [old]
+ (update-in old [method] #(conj (vec %) m))))))
(defn parse-file-parts [file]
;; This is a port of java.net.URL.Parts, which is package private.
@@ -145,30 +145,30 @@
"Use the passed connection to send a form to the browser. Send a
proper HTTP response."
([conn status form]
- (send-and-close conn status form "text/html"))
+ (send-and-close conn status form "text/html"))
([conn status form content-type]
- (send-and-close conn status form content-type "UTF-8"))
+ (send-and-close conn status form content-type "UTF-8"))
([conn status form content-type encoding]
- (send-and-close conn status form content-type encoding false))
+ (send-and-close conn status form content-type encoding false))
([conn status form content-type encoding gzip?]
- (let [byte-form (cond-> (.getBytes form encoding) gzip? gzip)
- content-length (count byte-form)
- headers (map #(.getBytes (str % "\r\n"))
- (cond->
- [(status-line status)
- "Server: ClojureScript REPL"
- (str "Content-Type: "
- content-type
- "; charset=" encoding)
- (str "Content-Length: " content-length)]
- gzip? (conj "Content-Encoding: gzip")
- true (conj "")))]
- (with-open [os (.getOutputStream conn)]
- (doseq [header headers]
- (.write os header 0 (count header)))
- (.write os byte-form 0 content-length)
- (.flush os)
- (.close conn)))))
+ (let [byte-form (cond-> (.getBytes form encoding) gzip? gzip)
+ content-length (count byte-form)
+ headers (map #(.getBytes (str % "\r\n"))
+ (cond->
+ [(status-line status)
+ "Server: ClojureScript REPL"
+ (str "Content-Type: "
+ content-type
+ "; charset=" encoding)
+ (str "Content-Length: " content-length)]
+ gzip? (conj "Content-Encoding: gzip")
+ true (conj "")))]
+ (with-open [os (.getOutputStream conn)]
+ (doseq [header headers]
+ (.write os header 0 (count header)))
+ (.write os byte-form 0 content-length)
+ (.flush os)
+ (.close conn)))))
(defn send-404 [conn path]
(send-and-close conn 404
@@ -206,7 +206,7 @@
(.start
(Thread.
((ns-resolve 'clojure.core 'binding-conveyor-fn)
- (fn [] (handle-connection opts conn)))))
+ (fn [] (handle-connection opts conn)))))
(recur opts server-socket)))
(defn start
@@ -216,7 +216,7 @@
(.start
(Thread.
((ns-resolve 'clojure.core 'binding-conveyor-fn)
- (fn [] (server-loop opts ss)))))
+ (fn [] (server-loop opts ss)))))
(swap! state (fn [old] (assoc old :socket ss :port (:port opts))))))
(defn stop []
diff --git a/src/main/clojure/cljs/server/browser.clj b/src/main/clojure/cljs/server/browser.clj
index 1c429d70..f2e767e9 100644
--- a/src/main/clojure/cljs/server/browser.clj
+++ b/src/main/clojure/cljs/server/browser.clj
@@ -8,9 +8,9 @@
(ns cljs.server.browser
(:require [cljs.env :as env]
- [cljs.repl :as repl]
- [cljs.repl.browser :as browser]
- [cljs.core.server :as server])
+ [cljs.repl :as repl]
+ [cljs.repl.browser :as browser]
+ [cljs.core.server :as server])
(:import [java.net ServerSocket]))
(defonce envs (atom {}))
diff --git a/src/main/clojure/cljs/server/graaljs.clj b/src/main/clojure/cljs/server/graaljs.clj
index d3336051..6c9a0ebc 100644
--- a/src/main/clojure/cljs/server/graaljs.clj
+++ b/src/main/clojure/cljs/server/graaljs.clj
@@ -8,8 +8,8 @@
(ns cljs.server.graaljs
(:require [cljs.repl :as repl]
- [cljs.repl.graaljs :as graaljs]
- [cljs.core.server :as server]))
+ [cljs.repl.graaljs :as graaljs]
+ [cljs.core.server :as server]))
(defn repl
([]
diff --git a/src/main/clojure/cljs/server/nashorn.clj b/src/main/clojure/cljs/server/nashorn.clj
index cf91e770..f3b1f389 100644
--- a/src/main/clojure/cljs/server/nashorn.clj
+++ b/src/main/clojure/cljs/server/nashorn.clj
@@ -8,8 +8,8 @@
(ns cljs.server.nashorn
(:require [cljs.repl :as repl]
- [cljs.repl.nashorn :as nashorn]
- [cljs.core.server :as server]))
+ [cljs.repl.nashorn :as nashorn]
+ [cljs.core.server :as server]))
(defn repl
([]
diff --git a/src/main/clojure/cljs/server/node.clj b/src/main/clojure/cljs/server/node.clj
index 41b8fb42..27291708 100644
--- a/src/main/clojure/cljs/server/node.clj
+++ b/src/main/clojure/cljs/server/node.clj
@@ -8,9 +8,9 @@
(ns cljs.server.node
(:require [cljs.env :as env]
- [cljs.repl :as repl]
- [cljs.repl.node :as node]
- [cljs.core.server :as server])
+ [cljs.repl :as repl]
+ [cljs.repl.node :as node]
+ [cljs.core.server :as server])
(:import [java.net Socket]))
(defonce envs (atom {}))
diff --git a/src/main/clojure/cljs/server/rhino.clj b/src/main/clojure/cljs/server/rhino.clj
index d1d7df61..a434d4fc 100644
--- a/src/main/clojure/cljs/server/rhino.clj
+++ b/src/main/clojure/cljs/server/rhino.clj
@@ -8,8 +8,8 @@
(ns cljs.server.rhino
(:require [cljs.repl :as repl]
- [cljs.repl.rhino :as rhino]
- [cljs.core.server :as server]))
+ [cljs.repl.rhino :as rhino]
+ [cljs.core.server :as server]))
(defn repl
([]
diff --git a/src/main/clojure/cljs/source_map.clj b/src/main/clojure/cljs/source_map.clj
index 1fdddf4e..23acb200 100644
--- a/src/main/clojure/cljs/source_map.clj
+++ b/src/main/clojure/cljs/source_map.clj
@@ -8,10 +8,10 @@
(ns cljs.source-map
(:require [clojure.java.io :as io]
- [clojure.string :as string]
- [clojure.data.json :as json]
- [clojure.set :as set]
- [cljs.source-map.base64-vlq :as base64-vlq]))
+ [clojure.string :as string]
+ [clojure.data.json :as json]
+ [clojure.set :as set]
+ [cljs.source-map.base64-vlq :as base64-vlq]))
;; =============================================================================
;; All source map code in the file assumes the following in memory
@@ -62,12 +62,12 @@
and return a map."
[seg source-map]
(let [[gcol source line col name] seg]
- {:gcol gcol
- :source (nth (:sources source-map) source)
- :line line
- :col col
- :name (when-let [name (-> seg meta :name)]
- (nth (:names source-map) name))}))
+ {:gcol gcol
+ :source (nth (:sources source-map) source)
+ :line line
+ :col col
+ :name (when-let [name (-> seg meta :name)]
+ (nth (:names source-map) name))}))
(defn seg-combine
"Combine a source map segment vector and a relative
@@ -108,30 +108,30 @@
organized as file, line, and column. Note this source map
maps from *original* source location to generated source location."
([source-map]
- (decode-reverse (:mappings source-map) source-map))
+ (decode-reverse (:mappings source-map) source-map))
([mappings source-map]
- (let [{:keys [sources]} source-map
- relseg-init [0 0 0 0 0]
- lines (seq (string/split mappings #";"))]
- (loop [gline 0
- lines lines
- relseg relseg-init
- result (sorted-map-by (source-compare sources))]
- (if lines
- (let [line (first lines)
+ (let [{:keys [sources]} source-map
+ relseg-init [0 0 0 0 0]
+ lines (seq (string/split mappings #";"))]
+ (loop [gline 0
+ lines lines
+ relseg relseg-init
+ result (sorted-map-by (source-compare sources))]
+ (if lines
+ (let [line (first lines)
+ [result relseg]
+ (if (string/blank? line)
[result relseg]
- (if (string/blank? line)
- [result relseg]
- (let [segs (seq (string/split line #","))]
- (loop [segs segs relseg relseg result result]
- (if segs
- (let [seg (first segs)
- nrelseg (seg-combine (base64-vlq/decode seg) relseg)]
- (recur (next segs) nrelseg
- (update-reverse-result result (seg->map nrelseg source-map) gline)))
- [result relseg]))))]
- (recur (inc gline) (next lines) (assoc relseg 0 0) result))
- result)))))
+ (let [segs (seq (string/split line #","))]
+ (loop [segs segs relseg relseg result result]
+ (if segs
+ (let [seg (first segs)
+ nrelseg (seg-combine (base64-vlq/decode seg) relseg)]
+ (recur (next segs) nrelseg
+ (update-reverse-result result (seg->map nrelseg source-map) gline)))
+ [result relseg]))))]
+ (recur (inc gline) (next lines) (assoc relseg 0 0) result))
+ result)))))
(defn update-result
"Helper for decode. Take a source map and update it based on a
@@ -154,26 +154,26 @@
maps from *generated* source location to original source
location."
([source-map]
- (decode (:mappings source-map) source-map))
+ (decode (:mappings source-map) source-map))
([mappings source-map]
- (let [relseg-init [0 0 0 0 0]
- lines (seq (string/split mappings #";"))]
- (loop [gline 0 lines lines relseg relseg-init result {}]
- (if lines
- (let [line (first lines)
- [result relseg]
- (if (string/blank? line)
- [result relseg]
- (let [segs (seq (string/split line #","))]
- (loop [segs segs relseg relseg result result]
- (if segs
- (let [seg (first segs)
- nrelseg (seg-combine (base64-vlq/decode seg) relseg)]
- (recur (next segs) nrelseg
- (update-result result (seg->map nrelseg source-map) gline)))
- [result relseg]))))]
- (recur (inc gline) (next lines) (assoc relseg 0 0) result))
- result)))))
+ (let [relseg-init [0 0 0 0 0]
+ lines (seq (string/split mappings #";"))]
+ (loop [gline 0 lines lines relseg relseg-init result {}]
+ (if lines
+ (let [line (first lines)
+ [result relseg]
+ (if (string/blank? line)
+ [result relseg]
+ (let [segs (seq (string/split line #","))]
+ (loop [segs segs relseg relseg result result]
+ (if segs
+ (let [seg (first segs)
+ nrelseg (seg-combine (base64-vlq/decode seg) relseg)]
+ (recur (next segs) nrelseg
+ (update-result result (seg->map nrelseg source-map) gline)))
+ [result relseg]))))]
+ (recur (inc gline) (next lines) (assoc relseg 0 0) result))
+ result)))))
;; -----------------------------------------------------------------------------
;; Encoding
@@ -294,8 +294,8 @@
(if (true? (:source-map-pretty-print opts))
(with-out-str
(json/pprint
- source-map-file-contents
- :escape-slash false))
+ source-map-file-contents
+ :escape-slash false))
(json/write-str source-map-file-contents))))
;; -----------------------------------------------------------------------------
diff --git a/src/main/clojure/cljs/source_map/base64.clj b/src/main/clojure/cljs/source_map/base64.clj
index e786c74f..93e50cfd 100644
--- a/src/main/clojure/cljs/source_map/base64.clj
+++ b/src/main/clojure/cljs/source_map/base64.clj
@@ -14,12 +14,12 @@
(defn encode [n]
(let [e (find int->char n)]
- (if e
- (second e)
- (throw (Error. (str "Must be between 0 and 63: " n))))))
+ (if e
+ (second e)
+ (throw (Error. (str "Must be between 0 and 63: " n))))))
(defn ^Character decode [c]
(let [e (find char->int c)]
- (if e
- (second e)
- (throw (Error. (str "Not a valid base 64 digit: " c))))))
\ No newline at end of file
+ (if e
+ (second e)
+ (throw (Error. (str "Not a valid base 64 digit: " c))))))
\ No newline at end of file
diff --git a/src/main/clojure/cljs/source_map/base64_vlq.clj b/src/main/clojure/cljs/source_map/base64_vlq.clj
index b6d33cca..394b929c 100644
--- a/src/main/clojure/cljs/source_map/base64_vlq.clj
+++ b/src/main/clojure/cljs/source_map/base64_vlq.clj
@@ -8,7 +8,7 @@
(ns cljs.source-map.base64-vlq
(:require [clojure.string :as string]
- [cljs.source-map.base64 :as base64]))
+ [cljs.source-map.base64 :as base64]))
(def ^:const vlq-base-shift 5)
(def ^:const vlq-base (bit-shift-left 1 vlq-base-shift))
@@ -60,10 +60,10 @@
(if continuation?
(recur i result shift)
(lazy-seq
- (cons (from-vlq-signed result)
- (let [s (.substring s i)]
- (when-not (string/blank? s)
- (decode s)))))))))))
+ (cons (from-vlq-signed result)
+ (let [s (.substring s i)]
+ (when-not (string/blank? s)
+ (decode s)))))))))))
(comment
;; tests
diff --git a/src/test/cljs/cljs/array_access_test.cljs b/src/test/cljs/cljs/array_access_test.cljs
index a98898fa..5f642c18 100644
--- a/src/test/cljs/cljs/array_access_test.cljs
+++ b/src/test/cljs/cljs/array_access_test.cljs
@@ -9,7 +9,7 @@
(ns cljs.array-access-test
(:require-macros [cljs.array-access-test :refer [suppress-errs]])
(:require [cljs.test :as test :refer [deftest is]]
- [cljs.array-access.alpha :as alpha]))
+ [cljs.array-access.alpha :as alpha]))
(deftest cljs-2861-test
;; With cljs-2718, a typo led to (set! *unchecked-arrays* true) as
diff --git a/src/test/cljs/cljs/binding_test.cljs b/src/test/cljs/cljs/binding_test.cljs
index ce711697..29bbda06 100644
--- a/src/test/cljs/cljs/binding_test.cljs
+++ b/src/test/cljs/cljs/binding_test.cljs
@@ -8,7 +8,7 @@
(ns cljs.binding-test
(:require [cljs.test :refer-macros [deftest is]]
- [cljs.binding-test-other-ns :as o]))
+ [cljs.binding-test-other-ns :as o]))
(deftest test-binding
(is (binding [o/*foo* 2]
diff --git a/src/test/cljs/cljs/clojure_alias_test.cljs b/src/test/cljs/cljs/clojure_alias_test.cljs
index aa5ca715..611003d2 100644
--- a/src/test/cljs/cljs/clojure_alias_test.cljs
+++ b/src/test/cljs/cljs/clojure_alias_test.cljs
@@ -12,7 +12,7 @@
(:require-macros clojure.spec.gen.alpha)
;(:use-macros [clojure.analyzer.macros :only [no-warn]])
(:require [clojure.test :refer [deftest is] :rename {is is?}]
- [clojure.spec.alpha :as s :refer [spec? spec] :rename {spec foo}]))
+ [clojure.spec.alpha :as s :refer [spec? spec] :rename {spec foo}]))
(deftest normal-test
(is? (= 1 1)))
diff --git a/src/test/cljs/cljs/collections_test.cljs b/src/test/cljs/cljs/collections_test.cljs
index c4f33502..b23ec711 100644
--- a/src/test/cljs/cljs/collections_test.cljs
+++ b/src/test/cljs/cljs/collections_test.cljs
@@ -9,8 +9,8 @@
(ns cljs.collections-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is are run-tests]]
- [clojure.string :as s]
- [clojure.set :as set]))
+ [clojure.string :as s]
+ [clojure.set :as set]))
(deftest test-map-operations
(testing "Test basic map collection operations"
@@ -532,7 +532,7 @@
ISeq
(-first [this] (first from-seq))
(-rest [this] (make-seq (rest from-seq))))))
- [[:bar 2] [:baz 3]]))))))
+ [[:bar 2] [:baz 3]]))))))
)
(deftest test-849
diff --git a/src/test/cljs/cljs/core_test.cljs b/src/test/cljs/cljs/core_test.cljs
index f68168f0..1180e18b 100644
--- a/src/test/cljs/cljs/core_test.cljs
+++ b/src/test/cljs/cljs/core_test.cljs
@@ -9,13 +9,13 @@
(ns cljs.core-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is are]]
- [clojure.test.check :as tc]
- [clojure.test.check.clojure-test :refer-macros [defspec]]
- [clojure.test.check.generators :as gen]
- [clojure.test.check.properties :as prop :include-macros true]
- [clojure.string :as s]
- [clojure.set :as set]
- [goog.object :as gobject]))
+ [clojure.test.check :as tc]
+ [clojure.test.check.clojure-test :refer-macros [defspec]]
+ [clojure.test.check.generators :as gen]
+ [clojure.test.check.properties :as prop :include-macros true]
+ [clojure.string :as s]
+ [clojure.set :as set]
+ [goog.object :as gobject]))
(deftest test-metadata
(testing "Testing metadata"
@@ -133,9 +133,9 @@
(is (= {"a" true, "b" false} (js->clj (js* "{\"a\":true,\"b\":false}"))))
(is (= {:a 1, :b 2} (js->clj (js* "{\"a\":1,\"b\":2}") :keywordize-keys true)))
(is (= [[{:a 1, :b 2} {:a 1, :b 2}]]
- (js->clj (js* "[[{\"a\":1,\"b\":2}, {\"a\":1,\"b\":2}]]") :keywordize-keys true)))
+ (js->clj (js* "[[{\"a\":1,\"b\":2}, {\"a\":1,\"b\":2}]]") :keywordize-keys true)))
(is (= [[{:a 1, :b 2} {:a 1, :b 2}]]
- (js->clj [[{:a 1, :b 2} {:a 1, :b 2}]])))
+ (js->clj [[{:a 1, :b 2} {:a 1, :b 2}]])))
(is (= (js->clj nil) nil))
(let [map-entry (->MapEntry #js {:foo 1} #js [1 2] nil)]
(is (= (->MapEntry {"foo" 1} [1 2] nil) (js->clj map-entry)))))
@@ -152,10 +152,10 @@
(is (goog/isObject (clj->js {})))
(is (= (gobject/get (clj->js {:a 1}) "a") 1))
(is (= (-> (clj->js {:a {:b {{:k :ey} :d}}})
- (gobject/get "a")
- (gobject/get "b")
- (gobject/get "{:k :ey}"))
- "d")))
+ (gobject/get "a")
+ (gobject/get "b")
+ (gobject/get "{:k :ey}"))
+ "d")))
(is (= (-> (clj->js {:foo/bar "a"})
(gobject/get "bar"))
"a"))
@@ -234,9 +234,9 @@
(defn rect [wd ht] {:Shape :Rect :wd wd :ht ht})
(defn circle [radius] {:Shape :Circle :radius radius})
(defmethod area :Rect [r]
- (* (:wd r) (:ht r)))
+ (* (:wd r) (:ht r)))
(defmethod area :Circle [c]
- (* Math/PI (* (:radius c) (:radius c))))
+ (* Math/PI (* (:radius c) (:radius c))))
(defmethod area :default [x] :oops)
(defmulti foo2 (fn []))
(defmethod foo2 :default [] :foo)
@@ -303,7 +303,7 @@
;; multimethod hashing
(is (= foo2' (ffirst {foo2' 1})))
(is (= :parent (multi-with-h :child)))
-)))
+ )))
(deftest test-transducers
(testing "Testing transducers"
@@ -404,10 +404,10 @@
(str "Iterator exhausted before seq at(" n ")" ))))
(let [iv (.next i)
sv (first s)]
- (when-not (= iv sv)
- (throw
- (js/Error.
- (str "Iterator value " iv " and seq value " sv " did not match at ( " n ")")))))
+ (when-not (= iv sv)
+ (throw
+ (js/Error.
+ (str "Iterator value " iv " and seq value " sv " did not match at ( " n ")")))))
(recur (rest s) (inc n)))
(if (.hasNext i)
(throw
@@ -474,7 +474,7 @@
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (.-done (.next iter)))))
-))
+ ))
(deftest test-reader-literals
(testing "Testing reader literals"
@@ -492,16 +492,16 @@
(deftest test-uuid
(testing "Testing UUID"
(is (= (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000")
- (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000")))
+ (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000")))
(is (not (identical? (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000")
- (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000"))))
+ (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000"))))
(is (= 42 (get {(cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000") 42}
- (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000")
- :not-at-all-found)))
- (is (= :not-at-all-found
- (get {(cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000") 42}
- (cljs.core/uuid "666e8400-e29b-41d4-a716-446655440000")
+ (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000")
:not-at-all-found)))
+ (is (= :not-at-all-found
+ (get {(cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000") 42}
+ (cljs.core/uuid "666e8400-e29b-41d4-a716-446655440000")
+ :not-at-all-found)))
(is (= -1 (compare (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000")
(cljs.core/uuid "666e8400-e29b-41d4-a716-446655440000"))))
(is (= 1 (compare (cljs.core/uuid "550e8400-e29b-41d4-a716-446655440000")
@@ -619,14 +619,14 @@
(deftest test-reify-meta
(is (= (meta (with-meta (reify IFoo (foo [this] :foo)) {:foo :bar}))
- {:foo :bar})))
+ {:foo :bar})))
(defprotocol Slashy (/ [_]))
(extend-type string
- Slashy
- (/ [_] "result"))
+ Slashy
+ (/ [_] "result"))
(deftest test-protocol-with-slash
(is (= "result" (/ ""))))
@@ -638,9 +638,9 @@
(let [x "overwritten"]
(is (= "original" (original-closure-stmt))))
(is (= "original" (let [x "original"
- oce (fn [] x)
- x "overwritten"]
- (oce)))))
+ oce (fn [] x)
+ x "overwritten"]
+ (oce)))))
(deftest test-letfn-shadowing
(letfn [(x [] "original")
@@ -674,9 +674,9 @@
(deftest test-data-conveying-exceptions
(is (= {:foo 1}
- (try (throw (ex-info "asdf" {:foo 1}))
- (catch ExceptionInfo e
- (ex-data e)))))
+ (try (throw (ex-info "asdf" {:foo 1}))
+ (catch ExceptionInfo e
+ (ex-data e)))))
(is (instance? js/Error (ex-info "asdf" {:foo 1})))
(is (= (pr-str (ex-info "abc" {:x 1})) "#error {:message \"abc\", :data {:x 1}}"))
(is (= (pr-str (ex-info "abc" {:x 1} "def")) "#error {:message \"abc\", :data {:x 1}, :cause \"def\"}"))
@@ -693,7 +693,7 @@
(deftest test-435
(is (= (assoc {} 154618822656 1 261993005056 1)
- {154618822656 1 261993005056 1})))
+ {154618822656 1 261993005056 1})))
(deftest test-458
(is (= (get-in {:a {:b 1}} [:a :b :c] :nothing-there)
@@ -765,7 +765,7 @@
(deftest test-585
(is (= (last (map identity (into [] (range 32)))) 31))
(is (= (into #{} (range 32))
- (set (map identity (into [] (range 32)))))))
+ (set (map identity (into [] (range 32)))))))
(def foo580)
(def foo580 {:a (fn []) :b (fn [] (foo580 :a))})
@@ -874,7 +874,7 @@
(testing "Testing CLJS-739, with-out-str"
(binding [*print-newline* true]
(is (= (with-out-str (doseq [fn (cljs-739 [] [:a :b :c :d])] (fn)))
- ":a\n:b\n:c\n:d\n")))))
+ ":a\n:b\n:c\n:d\n")))))
(deftest print-ns-maps
(testing "Testing CLJS-1786, *print-namespace-maps*"
@@ -1188,7 +1188,7 @@
(is (not (js/isNaN (hash js/-Infinity))))
(is (not (js/isNaN (hash js/NaN))))
(is (= (hash-set js/Infinity js/-Infinity 0 1 2 3 4 5 6 7 8)
- (set (keys (zipmap [js/Infinity js/-Infinity 0 1 2 3 4 5 6 7 8] (repeat nil)))))))
+ (set (keys (zipmap [js/Infinity js/-Infinity 0 1 2 3 4 5 6 7 8] (repeat nil)))))))
(deftest test-cljs-1590
(is (= [""] (s/split "" #"\n")))
diff --git a/src/test/cljs/cljs/destructuring_test.cljs b/src/test/cljs/cljs/destructuring_test.cljs
index 7667bd65..04824eea 100644
--- a/src/test/cljs/cljs/destructuring_test.cljs
+++ b/src/test/cljs/cljs/destructuring_test.cljs
@@ -9,8 +9,8 @@
(ns cljs.destructuring-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is]]
- [clojure.string :as s]
- [clojure.set :as set]))
+ [clojure.string :as s]
+ [clojure.set :as set]))
(deftest test-destructuring
(testing "Testing destructuring"
diff --git a/src/test/cljs/cljs/foo/ns_shadow_test.cljs b/src/test/cljs/cljs/foo/ns_shadow_test.cljs
index 1d3d2200..2c7c6101 100644
--- a/src/test/cljs/cljs/foo/ns_shadow_test.cljs
+++ b/src/test/cljs/cljs/foo/ns_shadow_test.cljs
@@ -8,7 +8,7 @@
(ns foo.ns-shadow-test
(:require [cljs.test :refer-macros [deftest is]]
- baz))
+ baz))
(defn bar [] 1)
diff --git a/src/test/cljs/cljs/hashing_test.cljs b/src/test/cljs/cljs/hashing_test.cljs
index e4017834..6c636117 100644
--- a/src/test/cljs/cljs/hashing_test.cljs
+++ b/src/test/cljs/cljs/hashing_test.cljs
@@ -9,9 +9,9 @@
(ns cljs.hashing-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is]]
- [clojure.string :as s]
- [clojure.set :as set]
- [goog.object :as gobject]))
+ [clojure.string :as s]
+ [clojure.set :as set]
+ [goog.object :as gobject]))
(deftest test-hash-null
(is (zero? (hash (gobject/get (js-obj) "foo")))))
diff --git a/src/test/cljs/cljs/import_test.cljs b/src/test/cljs/cljs/import_test.cljs
index 8c54e18c..581d4457 100644
--- a/src/test/cljs/cljs/import_test.cljs
+++ b/src/test/cljs/cljs/import_test.cljs
@@ -9,8 +9,8 @@
(ns cljs.import-test
(:require [cljs.test :refer-macros [deftest is]])
(:import goog.math.Long
- [goog.math Vec2 Vec3]
- [goog.math Integer]))
+ [goog.math Vec2 Vec3]
+ [goog.math Integer]))
(deftest test-import
(is (fn? Long))
diff --git a/src/test/cljs/cljs/inference_test.cljs b/src/test/cljs/cljs/inference_test.cljs
index 86a91caa..12397313 100644
--- a/src/test/cljs/cljs/inference_test.cljs
+++ b/src/test/cljs/cljs/inference_test.cljs
@@ -9,7 +9,7 @@
(ns cljs.inference-test
(:require-macros [cljs.inference-util])
(:require [cljs.test :refer [deftest is]]
- [cljs.pprint]))
+ [cljs.pprint]))
(deftest test-cljs-2825
(cljs.inference-util/truth_-not-called?
diff --git a/src/test/cljs/cljs/keyword_test.cljs b/src/test/cljs/cljs/keyword_test.cljs
index 46228130..968af3fb 100644
--- a/src/test/cljs/cljs/keyword_test.cljs
+++ b/src/test/cljs/cljs/keyword_test.cljs
@@ -8,9 +8,9 @@
(ns cljs.keyword-test
(:require-macros [cljs.keyword-macros :as macros]
- [cljs.test :refer [deftest is]])
+ [cljs.test :refer [deftest is]])
(:require [cljs.keyword-other :as other]
- [cljs.test]))
+ [cljs.test]))
(deftest test-keyword
(is (= ::bar :cljs.keyword-test/bar))
diff --git a/src/test/cljs/cljs/new_new_test.cljs b/src/test/cljs/cljs/new_new_test.cljs
index 26d6b651..c481970f 100644
--- a/src/test/cljs/cljs/new_new_test.cljs
+++ b/src/test/cljs/cljs/new_new_test.cljs
@@ -9,8 +9,8 @@
(ns cljs.new-new-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is]]
- [clojure.string :as s]
- [clojure.set :as set]))
+ [clojure.string :as s]
+ [clojure.set :as set]))
(defprotocol IProtocolWithDocStrings
(-method1 [this] "some doc")
diff --git a/src/test/cljs/cljs/npm_deps_test.cljs b/src/test/cljs/cljs/npm_deps_test.cljs
index 9c19ab98..cf247339 100644
--- a/src/test/cljs/cljs/npm_deps_test.cljs
+++ b/src/test/cljs/cljs/npm_deps_test.cljs
@@ -1,10 +1,10 @@
(ns cljs.npm-deps-test
(:refer-clojure :exclude [array vector])
(:require [cljs.test :refer [deftest is]]
- ["lodash/array" :as array :refer [slice] :rename {slice slc}]
- [calculator :as vector :refer [add] :rename {add plus}]
- [es6_calc]
- [es6_default_hello :as es6hello]))
+ ["lodash/array" :as array :refer [slice] :rename {slice slc}]
+ [calculator :as vector :refer [add] :rename {add plus}]
+ [es6_calc]
+ [es6_default_hello :as es6hello]))
(def array #js [1 2 3])
diff --git a/src/test/cljs/cljs/ns_test.cljs b/src/test/cljs/cljs/ns_test.cljs
index da7c0c8c..d9bbf495 100644
--- a/src/test/cljs/cljs/ns_test.cljs
+++ b/src/test/cljs/cljs/ns_test.cljs
@@ -10,12 +10,12 @@
(:refer-clojure :exclude [+ for] :rename {mapv core-mapv})
(:require-macros [clojure.core :as lang :refer [when when-let] :rename {when always
when-let always-let}]
- [cljs.test :refer [deftest is]])
+ [cljs.test :refer [deftest is]])
(:require [goog :as goog-alias]
- [cljs.test]
- [cljs.ns-test.foo :refer [baz]]
- [clojure.set :as s :refer [intersection] :rename {intersection itsc}]
- [cljs.analyzer :as ana])
+ [cljs.test]
+ [cljs.ns-test.foo :refer [baz]]
+ [clojure.set :as s :refer [intersection] :rename {intersection itsc}]
+ [cljs.analyzer :as ana])
(:use [cljs.ns-test.bar :only [quux]]))
(def + -)
diff --git a/src/test/cljs/cljs/pprint_test.clj b/src/test/cljs/cljs/pprint_test.clj
index 5112562c..07646922 100644
--- a/src/test/cljs/cljs/pprint_test.clj
+++ b/src/test/cljs/cljs/pprint_test.clj
@@ -26,5 +26,5 @@
`[(clojure.string/split-lines
(with-out-str
(cljs.pprint/with-pprint-dispatch cljs.pprint/code-dispatch
- (cljs.pprint/pprint (cljs.reader/read-string ~block)))))
+ (cljs.pprint/pprint (cljs.reader/read-string ~block)))))
(clojure.string/split-lines ~block)]))))
diff --git a/src/test/cljs/cljs/pprint_test.cljs b/src/test/cljs/cljs/pprint_test.cljs
index a1832df7..ab34d239 100644
--- a/src/test/cljs/cljs/pprint_test.cljs
+++ b/src/test/cljs/cljs/pprint_test.cljs
@@ -9,15 +9,15 @@
(ns cljs.pprint-test
(:refer-clojure :exclude [prn])
(:require-macros
- [cljs.pprint-test :refer [simple-tests code-block]])
+ [cljs.pprint-test :refer [simple-tests code-block]])
(:require
- [cljs.test :as t :refer-macros [deftest is]]
- [cljs.pprint :refer [pprint cl-format get-pretty-writer prn print-table
- *print-pprint-dispatch* simple-dispatch
- *print-right-margin* *print-miser-width*
- write code-dispatch]
- :refer-macros [with-pprint-dispatch]]
- [cljs.reader :as reader])
+ [cljs.test :as t :refer-macros [deftest is]]
+ [cljs.pprint :refer [pprint cl-format get-pretty-writer prn print-table
+ *print-pprint-dispatch* simple-dispatch
+ *print-right-margin* *print-miser-width*
+ write code-dispatch]
+ :refer-macros [with-pprint-dispatch]]
+ [cljs.reader :as reader])
(:import [goog.string StringBuffer]))
@@ -36,7 +36,7 @@
(cl-format nil "(let ~:<~@{~:<~w ~_~w~:>~^ ~:_~}~:>~_ ...)~%"
'((x 4) (*print-length* nil) (z 2) (list nil))))
"(let ((x 4)\n (*print-length*\n nil)\n (z 2)\n (list nil))\n ...)\n"
-)
+ )
(simple-tests mandatory-fill-test
(cl-format nil
@@ -53,7 +53,7 @@ Usage: *hello*
*print-right-margin* 10, *print-miser-width* 10]
(cl-format nil "~<{~;LIST ~@_~W ~@_~W ~@_~W~;}~:>" '(first second third)))
"{LIST\n first\n second\n third}"
-)
+ )
(simple-tests pprint-test
(binding [*print-pprint-dispatch* simple-dispatch]
@@ -135,7 +135,7 @@ Usage: *hello*
*print-right-margin* 10, *print-miser-width* 8]
(cl-format nil "~:<LIST ~@_~W ~@_~W ~@_~W~:>" '(first second third)))
"(LIST first second third)"
-)
+ )
(code-block code-block-tests
"(defn cl-format
@@ -147,7 +147,7 @@ Usage: *hello*
navigator (init-navigator args)]
(execute-format stream compiled-format navigator)))"
- "(defn pprint-defn [writer alis]
+ "(defn pprint-defn [writer alis]
(if (next alis)
(let [[defn-sym defn-name & stuff] alis
[doc-str stuff] (if (string? (first stuff))
@@ -171,7 +171,7 @@ Usage: *hello*
(or doc-str attr-map))
:else (multi-defn stuff (or doc-str attr-map)))))
(pprint-simple-code-list writer alis)))"
-)
+ )
(simple-tests print-length-tests
(binding [*print-length* 1] (with-out-str (pprint '(a b c d e f))))
@@ -230,7 +230,7 @@ Usage: *hello*
(binding [cljs.pprint/*print-right-margin* 8]
(with-out-str (pprint (sorted-set 123 456 789))))
"#{123\n 456\n 789}\n"
-)
+ )
(simple-tests print-namespace-maps-tests
(binding [*print-namespace-maps* true] (with-out-str (pprint {:user/a 1})))
@@ -250,7 +250,7 @@ Usage: *hello*
(cl-format nil "~:D" 2000000) "2,000,000"
;(cl-format nil "~D" 1/2) "1/2" ;no ratio
(cl-format nil "~D" 'fred) "fred"
-)
+ )
(simple-tests cardinal-tests
(cl-format nil "~R" 0) "zero"
@@ -284,7 +284,7 @@ Usage: *hello*
(cl-format nil "~R = ~:*~:D" 200000200000)
"two hundred billion, two hundred thousand = 200,000,200,000"
-)
+ )
(simple-tests ordinal-tests
(cl-format nil "~:R" 0) "zeroth"
@@ -315,7 +315,7 @@ Usage: *hello*
(cl-format nil "~:R = ~:*~:D" 2e6)
"two millionth = 2,000,000"
-)
+ )
(simple-tests ordinal1-tests
(cl-format nil "~:R" 1) "first"
@@ -325,7 +325,7 @@ Usage: *hello*
(cl-format nil "~:R" 220) "two hundred twentieth"
(cl-format nil "~:R" 200) "two hundredth"
(cl-format nil "~:R" 999) "nine hundred ninety-ninth"
-)
+ )
(simple-tests roman-tests
(cl-format nil "~@R" 3) "III"
@@ -343,7 +343,7 @@ Usage: *hello*
(cl-format nil "~@R" 5000) "5,000"
(cl-format nil "~@R ~D" 5000 20) "5,000 20"
(cl-format nil "~@R" "the quick") "the quick"
-)
+ )
(simple-tests c-tests
(cl-format nil "~{~c~^, ~}~%" "hello") "h, e, l, l, o\n"
@@ -361,7 +361,7 @@ Usage: *hello*
(cl-format nil "~@C~%" (char 92)) "\\\\\n"
(cl-format nil "~@C~%" (char 3)) "\\\n"
-)
+ )
(simple-tests e-tests
(cl-format nil "*~E*" 0.0) "*0.0E+0*"
@@ -374,7 +374,7 @@ Usage: *hello*
(cl-format nil "*~10,2E*" 9.99999E99) "* 1.00E+100*"
(cl-format nil "*~10,2,2E*" 9.99999E99) "* 1.00E+100*"
(cl-format nil "*~10,2,2,,'?E*" 9.99999E99) "*??????????*"
-)
+ )
(simple-tests $-tests
(cl-format nil "~$" 22.3) "22.30"
@@ -409,7 +409,7 @@ Usage: *hello*
(cl-format nil "~1$" 0.1) "0.1"
(cl-format nil "~1$" 0.99) "1.0"
(cl-format nil "~1$" -0.99) "-1.0"
-)
+ )
(simple-tests f-tests
(cl-format nil "~,1f" -12.0) "-12.0"
@@ -505,7 +505,7 @@ Usage: *hello*
(cl-format nil "~13,10f" -1.23456789014) "-1.2345678901"
(cl-format nil "~13,10f" -1.23456789016) "-1.2345678902"
(cl-format nil "~1,1f" 0.1) ".1"
-)
+ )
(simple-tests ampersand-tests
(cl-format nil "The quick brown ~a jumped over ~d lazy dogs" 'elephant 5)
@@ -522,7 +522,7 @@ Usage: *hello*
"The quick brown elephant jumped over 5 lazy dogs\nThe quick brown fox jumped over 10 lazy dogs"
(cl-format nil "I ~[don't ~:;d~&o ~]have one~%" 0) "I don't have one\n"
(cl-format nil "I ~[don't ~:;d~&o ~]have one~%" 1) "I d\no have one\n"
-)
+ )
(simple-tests t-tests
(cl-format nil "~@{~&~A~8,4T~:*~A~}"
@@ -533,7 +533,7 @@ Usage: *hello*
"a a\naa aa\naaa aaa\naaaa aaaa\naaaaa aaaaa\naaaaaa aaaaaa\naaaaaaa aaaaaaa\naaaaaaaa aaaaaaaa\naaaaaaaaa aaaaaaaaa\naaaaaaaaaa aaaaaaaaaa"
(cl-format nil "~@{~&~A~2,6@T~:*~A~}" 'a 'aa 'aaa 'aaaa 'aaaaa 'aaaaaa 'aaaaaaa 'aaaaaaaa 'aaaaaaaaa 'aaaaaaaaaa)
"a a\naa aa\naaa aaa\naaaa aaaa\naaaaa aaaaa\naaaaaa aaaaaa\naaaaaaa aaaaaaa\naaaaaaaa aaaaaaaa\naaaaaaaaa aaaaaaaaa\naaaaaaaaaa aaaaaaaaaa"
-)
+ )
(simple-tests paren-tests
(cl-format nil "~(PLEASE SPEAK QUIETLY IN HERE~)") "please speak quietly in here"
@@ -551,7 +551,7 @@ Usage: *hello*
(cl-format nil "~:(~A~)" "pipe 13a, foo16c") "Pipe 13a, Foo16c"
(cl-format nil "~:(~A~)" nil) "Nil"
(cl-format nil "~:(~A~)" "") ""
-)
+ )
(simple-tests square-bracket-tests
;; Tests for format without modifiers
@@ -603,7 +603,7 @@ Usage: *hello*
"The answer is 7 out of 22."
(cl-format nil "The answer is ~#[nothing~;~D~;~D out of ~D~:;something crazy~]." 1 2 3 4)
"The answer is something crazy."
-)
+ )
(simple-tests curly-brace-plain-tests
;; Iteration from sublist
@@ -630,7 +630,7 @@ Usage: *hello*
(cl-format nil "Coordinates are~{~:}~%" " ~#[none~;<~D>~:;[~D,~D]~]" [ ])
"Coordinates are none\n"
-)
+ )
(simple-tests curly-brace-colon-tests
;; Iteration from list of sublists
@@ -660,7 +660,7 @@ Usage: *hello*
(cl-format nil "Coordinates are~:{~:}~%" " ~#[none~;<~D>~:;[~D,~D]~]" [ ])
"Coordinates are none\n"
-)
+ )
(simple-tests curly-brace-at-tests
;; Iteration from main list
@@ -687,7 +687,7 @@ Usage: *hello*
(cl-format nil "Coordinates are~@{~:}~%" " ~#[none~;<~D>~:;[~D,~D]~]")
"Coordinates are none\n"
-)
+ )
(simple-tests curly-brace-colon-at-tests
;; Iteration from sublists on the main arg list
@@ -717,7 +717,7 @@ Usage: *hello*
(cl-format nil "Coordinates are~@:{~:}~%" " ~#[none~;<~D>~:;[~D,~D]~]")
"Coordinates are none\n"
-)
+ )
;; TODO tests for ~^ in ~[ constructs and other brackets
;; TODO test ~:^ generates an error when used improperly
@@ -730,7 +730,7 @@ Usage: *hello*
(cl-format nil "~{~a~#,3^, ~}" aseq) "a, quick, brown, fox, jumped, over"
(cl-format nil "~{~a~v,3^, ~}" lseq) "a, quick, brown, fox"
(cl-format nil "~{~a~3,v,4^, ~}" lseq) "a, quick, brown, fox"
- ))
+ ))
(simple-tests angle-bracket-tests
(cl-format nil "~<foo~;bar~;baz~>") "foobarbaz"
@@ -747,13 +747,13 @@ Usage: *hello*
(cl-format nil "~20<~A~;~^~A~;~^~A~>" "foo" "bar") "foo bar"
(cl-format nil "~20@<~A~;~^~A~;~^~A~>" "foo") "foo "
(cl-format nil "~20:<~A~;~^~A~;~^~A~>" "foo") " foo"
-)
+ )
(simple-tests angle-bracket-max-column-tests
(cl-format nil "~%;; ~{~<~%;; ~1,50:; ~A~>~}.~%" (into [] (clojure.string/split "This function computes the circular thermodynamic coefficient of the thrombulator angle for use in determining the reaction distance" #"\s")))
"\n;; This function computes the circular\n;; thermodynamic coefficient of the thrombulator\n;; angle for use in determining the reaction\n;; distance.\n"
(cl-format true "~%;; ~{~<~%;; ~:; ~A~>~}.~%" (into [] (clojure.string/split "This function computes the circular thermodynamic coefficient of the thrombulator angle for use in determining the reaction distance." #"\s")))
-)
+ )
(defn list-to-table-stream [aseq column-width]
(let [sb (StringBuffer.)]
@@ -782,7 +782,7 @@ Usage: *hello*
(list-to-table-print (map #(vector % (* % %) (* % % %)) (range 1 21)) 8)
" 1 1 1 \n 2 4 8 \n 3 9 27 \n 4 16 64 \n 5 25 125 \n 6 36 216 \n 7 49 343 \n 8 64 512 \n 9 81 729 \n 10 100 1000 \n 11 121 1331 \n 12 144 1728 \n 13 169 2197 \n 14 196 2744 \n 15 225 3375 \n 16 256 4096 \n 17 289 4913 \n 18 324 5832 \n 19 361 6859 \n 20 400 8000 \n"
-)
+ )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The following tests are the various examples from the format
@@ -814,13 +814,13 @@ Usage: *hello*
;; This one was a nice idea, but nothing in the spec supports it working this way
;; (and SBCL doesn't work this way either)
;(format nil "~19,,' ,4:B" 0x1CE) "0000 0001 1100 1110")
-)
+ )
(simple-tests cltl-P-tests
(format nil "~D tr~:@P/~D win~:P" 7 1) "7 tries/1 win"
(format nil "~D tr~:@P/~D win~:P" 1 0) "1 try/0 wins"
(format nil "~D tr~:@P/~D win~:P" 1 3) "1 try/3 wins"
-)
+ )
(defn foo [x]
(format nil "~6,2F|~6,2,1,'*F|~6,2,,'?F|~6F|~,2F|~F"
@@ -839,16 +839,16 @@ Usage: *hello*
#_(cl-format false "~10,3f" 4/5)
#_" 0.800"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3f" big-pos-ratio))
+ (cl-format false "~10,3f" big-pos-ratio))
#_"239692417981642093333333333333333300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3f" big-neg-ratio))
+ (cl-format false "~10,3f" big-neg-ratio))
#_"-239692417981642093333333333333333300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3f" tiny-pos-ratio))
+ (cl-format false "~10,3f" tiny-pos-ratio))
#_" 0.000"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3f" tiny-neg-ratio))
+ (cl-format false "~10,3f" tiny-neg-ratio))
#_" -0.000"
(foo 3.14159) " 3.14| 31.42| 3.14|3.1416|3.14|3.14159"
#_(foo 314159/100000)
@@ -857,7 +857,7 @@ Usage: *hello*
(foo 100.0) "100.00|******|100.00| 100.0|100.00|100.0"
(foo 1234.0) "1234.00|******|??????|1234.0|1234.00|1234.0"
(foo 0.006) " 0.01| 0.06| 0.01| 0.006|0.01|0.006"
-)
+ )
(defn foo-e [x]
(format nil
@@ -869,16 +869,16 @@ Usage: *hello*
#_(cl-format false "~10,3e" 4/5)
#_" 8.000E-1"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3e" big-pos-ratio))
+ (cl-format false "~10,3e" big-pos-ratio))
#_"2.397E+308"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3e" big-neg-ratio))
+ (cl-format false "~10,3e" big-neg-ratio))
#_"-2.397E+308"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3e" tiny-pos-ratio))
+ (cl-format false "~10,3e" tiny-pos-ratio))
#_"1.000E-340"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3e" tiny-neg-ratio))
+ (cl-format false "~10,3e" tiny-neg-ratio))
#_"-1.000E-340"
(foo-e 0.0314159) " 3.14E-2| 31.42$-03|+.003E+01| 3.14E-2" ; Added this one
#_(foo-e 314159/10000000)
@@ -892,7 +892,7 @@ Usage: *hello*
(foo-e 1.1E120) "*********|??????????|%%%%%%%%%|1.10E+120"
; Clojure doesn't support real numbers this large
; (foo-e 1.1L1200) "*********|??????????|%%%%%%%%%|1.10L+1200"
-)
+ )
(simple-tests cltl-E-scale-tests
(map
@@ -900,18 +900,18 @@ Usage: *hello*
(- k 5) 3.14159)) ;Prints 13 lines
(range 13))
'("Scale factor -5: | 0.000003E+06|"
- "Scale factor -4: | 0.000031E+05|"
- "Scale factor -3: | 0.000314E+04|"
- "Scale factor -2: | 0.003142E+03|"
- "Scale factor -1: | 0.031416E+02|"
- "Scale factor 0: | 0.314159E+01|"
- "Scale factor 1: | 3.141590E+00|"
- "Scale factor 2: | 31.41590E-01|"
- "Scale factor 3: | 314.1590E-02|"
- "Scale factor 4: | 3141.590E-03|"
- "Scale factor 5: | 31415.90E-04|"
- "Scale factor 6: | 314159.0E-05|"
- "Scale factor 7: | 3141590.E-06|"))
+ "Scale factor -4: | 0.000031E+05|"
+ "Scale factor -3: | 0.000314E+04|"
+ "Scale factor -2: | 0.003142E+03|"
+ "Scale factor -1: | 0.031416E+02|"
+ "Scale factor 0: | 0.314159E+01|"
+ "Scale factor 1: | 3.141590E+00|"
+ "Scale factor 2: | 31.41590E-01|"
+ "Scale factor 3: | 314.1590E-02|"
+ "Scale factor 4: | 3141.590E-03|"
+ "Scale factor 5: | 31415.90E-04|"
+ "Scale factor 6: | 314159.0E-05|"
+ "Scale factor 7: | 3141590.E-06|"))
(defn foo-g [x]
(format nil
@@ -923,16 +923,16 @@ Usage: *hello*
#_(cl-format false "~10,3g" 4/5)
#_" 0.800 "
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3g" big-pos-ratio))
+ (cl-format false "~10,3g" big-pos-ratio))
#_"2.397E+308"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3g" big-neg-ratio))
+ (cl-format false "~10,3g" big-neg-ratio))
#_"-2.397E+308"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3g" tiny-pos-ratio))
+ (cl-format false "~10,3g" tiny-pos-ratio))
#_"1.000E-340"
#_(binding [*math-context* java.math.MathContext/DECIMAL128]
- (cl-format false "~10,3g" tiny-neg-ratio))
+ (cl-format false "~10,3g" tiny-neg-ratio))
#_"-1.000E-340"
(foo-g 0.0314159) " 3.14E-2|314.2$-04|0.314E-01| 3.14E-2"
#_(foo-g 314159/10000000)
@@ -947,7 +947,7 @@ Usage: *hello*
(foo-g 3.14E12) "*********|314.0$+10|0.314E+13| 3.14E+12"
(foo-g 3.14E120) "*********|?????????|%%%%%%%%%|3.14E+120"
; Clojure doesn't support real numbers this large
-)
+ )
(defn type-clash-error [fun nargs argnum right-type wrong-type]
(format nil ;; CLtL has this format string slightly wrong
@@ -961,14 +961,14 @@ Usage: *hello*
"Function aref requires its second argument to be of type integer,\nbut it was called with an argument of type vector.\n"
(type-clash-error 'car 1 1 'list 'short-float)
"Function car requires its argument to be of type list,\nbut it was called with an argument of type short-float.\n"
-)
+ )
(simple-tests cltl-?-tests
(format nil "~? ~D" "<~A ~D>" '("Foo" 5) 7) "<Foo 5> 7"
(format nil "~? ~D" "<~A ~D>" '("Foo" 5 14) 7) "<Foo 5> 7"
(format nil "~@? ~D" "<~A ~D>" "Foo" 5 7) "<Foo 5> 7"
(format nil "~@? ~D" "<~A ~D>" "Foo" 5 14 7) "<Foo 5> 14"
-)
+ )
(defn f [n] (format nil "~@(~R~) error~:P detected." n))
@@ -977,14 +977,14 @@ Usage: *hello*
(f 0) "Zero errors detected."
(f 1) "One error detected."
(f 23) "Twenty-three errors detected."
-)
+ )
(let [*print-level* nil *print-length* 5]
(simple-tests cltl-bracket-tests
(format nil "~@[ print level = ~D~]~@[ print length = ~D~]"
*print-level* *print-length*)
" print length = 5")
-)
+ )
(let [foo "Items:~#[ none~; ~S~; ~S and ~S~
~:;~@{~#[~; and~] ~
@@ -995,7 +995,7 @@ Usage: *hello*
(format nil foo 'foo 'bar) "Items: foo and bar."
(format nil foo 'foo 'bar 'baz) "Items: foo, bar, and baz."
(format nil foo 'foo 'bar 'baz 'quux) "Items: foo, bar, baz, and quux."
- ))
+ ))
(simple-tests cltl-curly-bracket-tests
(format nil
@@ -1014,7 +1014,7 @@ Usage: *hello*
(format nil "Pairs:~:@{ <~S,~S>~}." '(a 1) '(b 2) '(c 3))
"Pairs: <a,1> <b,2> <c,3>."
-)
+ )
(simple-tests cltl-angle-bracket-tests
(format nil "~10<foo~;bar~>") "foo bar"
@@ -1024,7 +1024,7 @@ Usage: *hello*
(format nil "~10:<foobar~>") " foobar"
(format nil "~10@<foobar~>") "foobar "
(format nil "~10:@<foobar~>") " foobar "
-)
+ )
(let [donestr "Done.~^ ~D warning~:P.~^ ~D error~:P."
tellstr "~@{~@(~@[~R~^ ~]~A~)~}."] ;; The CLtL example is a little wrong here
@@ -1042,7 +1042,7 @@ Usage: *hello*
"foo bar"
(format nil "~15<~S~;~^~S~;~^~S~>" 'foo 'bar 'baz)
"foo bar baz"
- ))
+ ))
(simple-tests cltl-up-x3j13-tests
(format nil
@@ -1058,7 +1058,7 @@ Usage: *hello*
"~:{/~S~#:^ ...~}" ;; This is wrong in CLtL
'((hot dog) (hamburger) (ice cream) (french fries)))
"/hot .../hamburger"
-)
+ )
(simple-tests pprint-table-tests
(with-out-str
diff --git a/src/test/cljs/cljs/primitives_test.cljs b/src/test/cljs/cljs/primitives_test.cljs
index 7656e5c7..05570a9e 100644
--- a/src/test/cljs/cljs/primitives_test.cljs
+++ b/src/test/cljs/cljs/primitives_test.cljs
@@ -9,9 +9,9 @@
(ns cljs.primitives-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is]]
- [clojure.string :as s]
- [clojure.set :as set]
- [goog.object :as gobject]))
+ [clojure.string :as s]
+ [clojure.set :as set]
+ [goog.object :as gobject]))
(deftest test-js-primitives
;; js primitives
diff --git a/src/test/cljs/cljs/printing_test.cljs b/src/test/cljs/cljs/printing_test.cljs
index c114893d..a7da64d9 100644
--- a/src/test/cljs/cljs/printing_test.cljs
+++ b/src/test/cljs/cljs/printing_test.cljs
@@ -9,8 +9,8 @@
(ns cljs.printing-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is]]
- [clojure.string :as s]
- [clojure.set :as set]))
+ [clojure.string :as s]
+ [clojure.set :as set]))
(deftest test-print-knobs
(testing "Testing printing knobs"
@@ -28,9 +28,9 @@
(is (= (binding [*print-length* 0] (str {:foo "bar" :baz "woz"}))
"{...}"))
(is (#{"{:foo \"bar\", ...}" "{:baz \"woz\", ...}"}
- (binding [*print-length* 1] (str {:foo "bar" :baz "woz"}))))
+ (binding [*print-length* 1] (str {:foo "bar" :baz "woz"}))))
(is (#{"{:foo \"bar\", :baz \"woz\"}" "{:baz \"woz\", :foo \"bar\"}"}
- (binding [*print-length* 10] (str {:foo "bar" :baz "woz"})))))
+ (binding [*print-length* 10] (str {:foo "bar" :baz "woz"})))))
)
(deftest test-print-with-opts
@@ -43,13 +43,13 @@
(is (#{"#{1 2 \u2026}" "#{1 3 \u2026}"
"#{2 1 \u2026}" "#{2 3 \u2026}"
"#{3 1 \u2026}" "#{3 2 \u2026}"}
- (pr-str-with-opts [#{1 2 3}] {:more-marker "\u2026" :print-length 2})))
+ (pr-str-with-opts [#{1 2 3}] {:more-marker "\u2026" :print-length 2})))
(is (= (pr-str-with-opts ['(1 2 3)] {:more-marker "\u2026" :print-length 2})
"(1 2 \u2026)"))
(is (#{"{:1 1, :2 2, \u2026}" "{:1 1, :3 3, \u2026}"
"{:2 2, :1 1, \u2026}" "{:2 2, :3 3, \u2026}"
"{:3 3, :1 1, \u2026}" "{:3 3, :2 2, \u2026}"}
- (pr-str-with-opts [{:1 1 :2 2 :3 3}] {:more-marker "\u2026" :print-length 2}))))
+ (pr-str-with-opts [{:1 1 :2 2 :3 3}] {:more-marker "\u2026" :print-length 2}))))
(testing "Testing printing with opts - :alt-impl"
; CLJS-1010
@@ -112,7 +112,7 @@
;; Different hash map order on self-host
(is (#{"[1 true {:a 2, :b \"x\\\"y\"} #js [3 4]]"
"[1 true {:b \"x\\\"y\", :a 2} #js [3 4]]"}
- (pr-str [1 true {:a 2 :b "x\"y"} (array 3 4)]))))
+ (pr-str [1 true {:a 2 :b "x\"y"} (array 3 4)]))))
(testing "Testing print-str"
(is (= (print-str "asdf") "asdf")))
(testing "Testing println-str"
@@ -123,7 +123,7 @@
;; Different hash map order on self-host
(is (#{"[1 true {:a 2, :b 42} #js [3 4]]\n"
"[1 true {:b 42, :a 2} #js [3 4]]\n"}
- (prn-str [1 true {:a 2 :b 42} (array 3 4)]))))
+ (prn-str [1 true {:a 2 :b 42} (array 3 4)]))))
(testing "Testing with-out-str"
(is (= "12" (with-out-str (print 1) (print 2))))
(is (= "12" (with-out-str (*print-fn* 1) (*print-fn* 2))))))
diff --git a/src/test/cljs/cljs/reader_test.cljs b/src/test/cljs/cljs/reader_test.cljs
index 9a8a9b43..1c132386 100644
--- a/src/test/cljs/cljs/reader_test.cljs
+++ b/src/test/cljs/cljs/reader_test.cljs
@@ -8,8 +8,8 @@
(ns cljs.reader-test
(:require [cljs.test :refer-macros [deftest testing is] :as test]
- [cljs.reader :as reader]
- [goog.object :as o]))
+ [cljs.reader :as reader]
+ [goog.object :as o]))
(deftype T [a b])
(defrecord R [a b])
@@ -35,7 +35,7 @@
(is (= \a (reader/read-string "\\a")))
(is (= {:tag 'String} (meta (reader/read-string "^String {:a 1}"))))
(is (= [:a 'b #{'c {:d [:e :f :g]}}]
- (reader/read-string "[:a b #{c {:d [:e :f :g]}}]")))
+ (reader/read-string "[:a b #{c {:d [:e :f :g]}}]")))
(is (= :foo/bar (reader/read-string ":foo/bar")))
(is (= nil (reader/read-string "nil")))
(is (= true (reader/read-string "true")))
@@ -51,11 +51,11 @@
(testing "Test reading queue literals"
(is (= cljs.core.PersistentQueue.EMPTY
- (reader/read-string "#queue []")))
+ (reader/read-string "#queue []")))
(is (= (-> cljs.core.PersistentQueue.EMPTY (conj 1))
- (reader/read-string "#queue [1]")))
+ (reader/read-string "#queue [1]")))
(is (= (into cljs.core.PersistentQueue.EMPTY [1 2])
- (reader/read-string "#queue [1 2]"))))
+ (reader/read-string "#queue [1 2]"))))
(testing "Test reading comments"
;; Another bad test found by switching to tools.reader - David
@@ -137,7 +137,7 @@
:cześć
:привет
- ;compound data
+ ;compound data
{:привет :ru "你好" :cn}
]]
(let [input (pr-str unicode)
@@ -162,7 +162,7 @@
:failed-to-throw
(catch js/Error e :ok))]
(is (= r :ok))))
-)
+ )
(deftest test-717
(testing "Testing reading, CLJS-717"
diff --git a/src/test/cljs/cljs/reducers_test.cljs b/src/test/cljs/cljs/reducers_test.cljs
index 06cdf8f1..ec355abd 100644
--- a/src/test/cljs/cljs/reducers_test.cljs
+++ b/src/test/cljs/cljs/reducers_test.cljs
@@ -8,7 +8,7 @@
(ns cljs.reducers-test
(:require [cljs.test :refer-macros [deftest is]]
- [clojure.core.reducers :as r]))
+ [clojure.core.reducers :as r]))
(deftest test-builtin-impls
(is (= 0 (r/fold + nil)))
@@ -18,19 +18,19 @@
(is (= 10 (r/reduce + (list 1 2 3 4))))
(is (= 11 (r/reduce + 1 (list 1 2 3 4))))
(is (= (r/fold + + [1 2 3])
- (r/fold + [1 2 3])
- (r/reduce + [1 2 3])
- 6))
+ (r/fold + [1 2 3])
+ (r/reduce + [1 2 3])
+ 6))
(is (= (r/fold + + (vec (range 2048)))
- (r/reduce + (vec (range 2048)))))
+ (r/reduce + (vec (range 2048)))))
(letfn [(f [[ks vs] k v]
- [(conj ks k) (conj vs v)])
+ [(conj ks k) (conj vs v)])
(g ([] [#{} #{}])
([[ks1 vs1] [ks2 vs2]]
[(into ks1 ks2) (into vs1 vs2)]))]
(is (= (r/reduce f (g) {:a 1 :b 2 :c 3})
- (r/fold g f {:a 1 :b 2 :c 3})
- [#{:a :b :c} #{1 2 3}]))
+ (r/fold g f {:a 1 :b 2 :c 3})
+ [#{:a :b :c} #{1 2 3}]))
(let [m (into {} (for [x (range 2048)] [x (- x)]))]
(is (= (r/reduce f (g) m) (r/fold g f m)))))
;; CLJS-792
diff --git a/src/test/cljs/cljs/seqs_test.cljs b/src/test/cljs/cljs/seqs_test.cljs
index 94ca0e20..5bff9063 100644
--- a/src/test/cljs/cljs/seqs_test.cljs
+++ b/src/test/cljs/cljs/seqs_test.cljs
@@ -9,8 +9,8 @@
(ns cljs.seqs-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is]]
- [clojure.string :as s]
- [clojure.set :as set]))
+ [clojure.string :as s]
+ [clojure.set :as set]))
(deftest test-sequential-equality
(testing "Testing ISequential equality"
diff --git a/src/test/cljs/cljs/set_equiv_test.cljs b/src/test/cljs/cljs/set_equiv_test.cljs
index 31b5d057..acaf64c2 100644
--- a/src/test/cljs/cljs/set_equiv_test.cljs
+++ b/src/test/cljs/cljs/set_equiv_test.cljs
@@ -1,8 +1,8 @@
(ns cljs.set-equiv-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is]]
- [clojure.string :as s]
- [clojure.set :as set]))
+ [clojure.string :as s]
+ [clojure.set :as set]))
(deftest test-set-equality
(testing "Testing set equality"
diff --git a/src/test/cljs/cljs/spec/test_test.cljs b/src/test/cljs/cljs/spec/test_test.cljs
index b1085aca..c5ff6559 100644
--- a/src/test/cljs/cljs/spec/test_test.cljs
+++ b/src/test/cljs/cljs/spec/test_test.cljs
@@ -2,10 +2,10 @@
(:require-macros [cljs.spec.test.test-macros])
(:require [cljs.test :as test :refer-macros [deftest testing
is are run-tests]]
- [cljs.spec.alpha :as s]
- [cljs.spec.test.alpha :as stest]
- [cljs.spec.test.test-ns1]
- [cljs.spec.test.test-ns2]))
+ [cljs.spec.alpha :as s]
+ [cljs.spec.test.alpha :as stest]
+ [cljs.spec.test.test-ns1]
+ [cljs.spec.test.test-ns2]))
(s/fdef clojure.core/symbol
:args (s/alt :separate (s/cat :ns string? :n string?)
diff --git a/src/test/cljs/cljs/spec_test.cljs b/src/test/cljs/cljs/spec_test.cljs
index c6d1ce2f..cb287d0a 100644
--- a/src/test/cljs/cljs/spec_test.cljs
+++ b/src/test/cljs/cljs/spec_test.cljs
@@ -8,10 +8,10 @@
(ns cljs.spec-test
(:require [cljs.spec.alpha :as s]
- [cljs.spec.test.alpha :as st]
- [cljs.test :as test :refer-macros [deftest is are run-tests]]
- [cljs.spec.gen.alpha :as gen]
- [clojure.test.check.generators]))
+ [cljs.spec.test.alpha :as st]
+ [cljs.test :as test :refer-macros [deftest is are run-tests]]
+ [cljs.spec.gen.alpha :as gen]
+ [clojure.test.check.generators]))
(s/def ::even? (s/and number? even?))
(s/def ::odd? (s/and number? odd?))
diff --git a/src/test/cljs/cljs/tagged_literals_test.cljs b/src/test/cljs/cljs/tagged_literals_test.cljs
index 1635381c..7f9538cc 100644
--- a/src/test/cljs/cljs/tagged_literals_test.cljs
+++ b/src/test/cljs/cljs/tagged_literals_test.cljs
@@ -8,7 +8,7 @@
(ns cljs.tagged-literals-test
(:require [cljs.test :refer-macros [deftest is]]
- [cljs.reader :as reader]))
+ [cljs.reader :as reader]))
(deftest test-identity-custom-literal
(is (= #cljs/tag [1 2 3] [1 2 3])))
diff --git a/src/test/cljs/cljs/test_test.cljs b/src/test/cljs/cljs/test_test.cljs
index f4b072be..7483b75a 100644
--- a/src/test/cljs/cljs/test_test.cljs
+++ b/src/test/cljs/cljs/test_test.cljs
@@ -1,7 +1,7 @@
(ns cljs.test-test
(:require [cljs.test :refer-macros [deftest testing is] :as ct]
- [clojure.string :as s]
- [clojure.set :as set]))
+ [clojure.string :as s]
+ [clojure.set :as set]))
(defn- nan?
[x]
diff --git a/src/test/cljs/cljs/walk_test.cljs b/src/test/cljs/cljs/walk_test.cljs
index 9f28ebf0..350584e6 100644
--- a/src/test/cljs/cljs/walk_test.cljs
+++ b/src/test/cljs/cljs/walk_test.cljs
@@ -8,7 +8,7 @@
(ns cljs.walk-test
(:require [cljs.test :refer-macros [deftest testing is]]
- [clojure.walk :as w]))
+ [clojure.walk :as w]))
(deftest t-prewalk-replace
(is (= (w/prewalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])
diff --git a/src/test/cljs/clojure/data_test.cljs b/src/test/cljs/clojure/data_test.cljs
index 0675a6a5..85e8eb2d 100644
--- a/src/test/cljs/clojure/data_test.cljs
+++ b/src/test/cljs/clojure/data_test.cljs
@@ -8,7 +8,7 @@
(ns clojure.data-test
(:require [cljs.test :refer-macros [deftest is]]
- [clojure.data :refer [diff]]))
+ [clojure.data :refer [diff]]))
(deftest test-data
(is (= [nil nil nil] (diff nil nil)))
@@ -26,6 +26,6 @@
(is (= [nil nil [1 2]] (diff [1 2] (into-array [1 2]))))
(is (= [nil nil [1 2]] (diff (into-array [1 2]) [1 2])))
(is (= [{:a {:c [1]}} {:a {:c [0]}} {:a {:c [nil 2] :b 1}}]
- (diff {:a {:b 1 :c [1 2]}} {:a {:b 1 :c [0 2]}})))
+ (diff {:a {:b 1 :c [1 2]}} {:a {:b 1 :c [0 2]}})))
(is (= [{:a nil} {:a false} {:b nil :c false}]
- (diff {:a nil :b nil :c false} {:a false :b nil :c false}))))
+ (diff {:a nil :b nil :c false} {:a false :b nil :c false}))))
diff --git a/src/test/cljs/clojure/datafy_test.cljs b/src/test/cljs/clojure/datafy_test.cljs
index ff108d0c..f5b2ef88 100644
--- a/src/test/cljs/clojure/datafy_test.cljs
+++ b/src/test/cljs/clojure/datafy_test.cljs
@@ -9,7 +9,7 @@
(ns clojure.datafy-test
(:require [cljs.test :as test
:refer-macros [deftest is testing]]
- [clojure.datafy :as d]))
+ [clojure.datafy :as d]))
(deftest datafy-test
(testing "Datafy works when datafied value is arbitrary JS objects"
diff --git a/src/test/cljs/clojure/string_test.cljs b/src/test/cljs/clojure/string_test.cljs
index 5837f806..58ddade3 100644
--- a/src/test/cljs/clojure/string_test.cljs
+++ b/src/test/cljs/clojure/string_test.cljs
@@ -9,11 +9,11 @@
(ns clojure.string-test
(:require [cljs.test :as test
:refer-macros [deftest is testing]]
- [clojure.test.check :as tc]
- [clojure.test.check.clojure-test :refer-macros [defspec]]
- [clojure.test.check.generators :as gen]
- [clojure.test.check.properties :as prop :include-macros true]
- [clojure.string :as s]))
+ [clojure.test.check :as tc]
+ [clojure.test.check.clojure-test :refer-macros [defspec]]
+ [clojure.test.check.generators :as gen]
+ [clojure.test.check.properties :as prop :include-macros true]
+ [clojure.string :as s]))
(deftest test-api
(testing "Testing string reverse"
@@ -77,11 +77,11 @@
(testing "Testing string escape"
(is (= "&lt;foo&amp;bar&gt;"
- (s/escape "<foo&bar>" {\& "&amp;" \< "&lt;" \> "&gt;"})))
+ (s/escape "<foo&bar>" {\& "&amp;" \< "&lt;" \> "&gt;"})))
(is (= " \\\"foo\\\" "
- (s/escape " \"foo\" " {\" "\\\""})))
+ (s/escape " \"foo\" " {\" "\\\""})))
(is (= "faabor"
- (s/escape "foobar" {\a \o, \o \a}))))
+ (s/escape "foobar" {\a \o, \o \a}))))
(testing "Testing string replace-first"
(is (= "barbarfoo" (s/replace-first "foobarfoo" "foo" "bar")))
@@ -112,18 +112,18 @@
(testing "Testing string index-of"
(let [sb "tacos"]
- (is (= 2 (s/index-of sb "c")))
- (is (= 2 (s/index-of sb \c)))
- (is (= 1 (s/index-of sb "ac")))
- (is (= 3 (s/index-of sb "o" 2)))
- (is (= 3 (s/index-of sb \o 2)))
- (is (= 3 (s/index-of sb "o" -100)))
- (is (= nil (s/index-of sb "z")))
- (is (= nil (s/index-of sb \z)))
- (is (= nil (s/index-of sb "z" 2)))
- (is (= nil (s/index-of sb \z 2)))
- (is (= nil (s/index-of sb "z" 100))
- (is (= nil (s/index-of sb "z" -10))))))
+ (is (= 2 (s/index-of sb "c")))
+ (is (= 2 (s/index-of sb \c)))
+ (is (= 1 (s/index-of sb "ac")))
+ (is (= 3 (s/index-of sb "o" 2)))
+ (is (= 3 (s/index-of sb \o 2)))
+ (is (= 3 (s/index-of sb "o" -100)))
+ (is (= nil (s/index-of sb "z")))
+ (is (= nil (s/index-of sb \z)))
+ (is (= nil (s/index-of sb "z" 2)))
+ (is (= nil (s/index-of sb \z 2)))
+ (is (= nil (s/index-of sb "z" 100))
+ (is (= nil (s/index-of sb "z" -10))))))
(testing "Testing string last-index-of"
(let [sb "banana"]
@@ -171,25 +171,25 @@
(comment
-(deftest char-sequence-handling
- (are [result f args] (let [[^CharSequence s & more] args]
- (= result (apply f (StringBuffer. s) more)))
- "paz" s/reverse ["zap"]
- "foo:bar" s/replace ["foo-bar" \- \:]
- "ABC" s/replace ["abc" #"\w" s/upper-case]
- "faa" s/replace ["foo" #"o" (StringBuffer. "a")]
- "baz::quux" s/replace-first ["baz--quux" #"--" "::"]
- "baz::quux" s/replace-first ["baz--quux" (StringBuffer. "--") (StringBuffer. "::")]
- "zim-zam" s/replace-first ["zim zam" #" " (StringBuffer. "-")]
- "Pow" s/capitalize ["POW"]
- "BOOM" s/upper-case ["boom"]
- "whimper" s/lower-case ["whimPER"]
- ["foo" "bar"] s/split ["foo-bar" #"-"]
- "calvino" s/trim [" calvino "]
- "calvino " s/triml [" calvino "]
- " calvino" s/trimr [" calvino "]
- "the end" s/trim-newline ["the end\r\n\r\r\n"]
- true s/blank? [" "]
- ["a" "b"] s/split-lines ["a\nb"]
- "fa la la" s/escape ["fo lo lo" {\o \a}]))
-)
+ (deftest char-sequence-handling
+ (are [result f args] (let [[^CharSequence s & more] args]
+ (= result (apply f (StringBuffer. s) more)))
+ "paz" s/reverse ["zap"]
+ "foo:bar" s/replace ["foo-bar" \- \:]
+ "ABC" s/replace ["abc" #"\w" s/upper-case]
+ "faa" s/replace ["foo" #"o" (StringBuffer. "a")]
+ "baz::quux" s/replace-first ["baz--quux" #"--" "::"]
+ "baz::quux" s/replace-first ["baz--quux" (StringBuffer. "--") (StringBuffer. "::")]
+ "zim-zam" s/replace-first ["zim zam" #" " (StringBuffer. "-")]
+ "Pow" s/capitalize ["POW"]
+ "BOOM" s/upper-case ["boom"]
+ "whimper" s/lower-case ["whimPER"]
+ ["foo" "bar"] s/split ["foo-bar" #"-"]
+ "calvino" s/trim [" calvino "]
+ "calvino " s/triml [" calvino "]
+ " calvino" s/trimr [" calvino "]
+ "the end" s/trim-newline ["the end\r\n\r\r\n"]
+ true s/blank? [" "]
+ ["a" "b"] s/split-lines ["a\nb"]
+ "fa la la" s/escape ["fo lo lo" {\o \a}]))
+ )
diff --git a/src/test/cljs/clojure/walk_test.cljs b/src/test/cljs/clojure/walk_test.cljs
index 11d41312..930279e7 100644
--- a/src/test/cljs/clojure/walk_test.cljs
+++ b/src/test/cljs/clojure/walk_test.cljs
@@ -9,7 +9,7 @@
(ns clojure.walk-test
(:require [cljs.test :as test
:refer-macros [deftest is testing]]
- [clojure.walk :as w]))
+ [clojure.walk :as w]))
(defrecord Rec1 [a])
diff --git a/src/test/cljs/foo/ns_shadow_test.cljs b/src/test/cljs/foo/ns_shadow_test.cljs
index 1d3d2200..2c7c6101 100644
--- a/src/test/cljs/foo/ns_shadow_test.cljs
+++ b/src/test/cljs/foo/ns_shadow_test.cljs
@@ -8,7 +8,7 @@
(ns foo.ns-shadow-test
(:require [cljs.test :refer-macros [deftest is]]
- baz))
+ baz))
(defn bar [] 1)
diff --git a/src/test/cljs/test_runner.cljs b/src/test/cljs/test_runner.cljs
index bd6a2873..26368051 100644
--- a/src/test/cljs/test_runner.cljs
+++ b/src/test/cljs/test_runner.cljs
@@ -8,49 +8,49 @@
(ns test-runner
(:require [cljs.test :refer-macros [run-tests]]
- [cljs.apply-test]
- [cljs.primitives-test]
- [cljs.destructuring-test]
- [cljs.new-new-test]
- [cljs.printing-test]
- [cljs.seqs-test]
- [cljs.collections-test]
- [cljs.hashing-test]
- [cljs.core-test :as core-test]
- [cljs.reader-test]
- [cljs.binding-test]
- [cljs.ns-test]
- [clojure.string-test]
- [clojure.data-test]
- [clojure.datafy-test]
- [clojure.walk-test]
- [cljs.macro-test]
- [cljs.letfn-test]
- [foo.ns-shadow-test]
- [cljs.top-level]
- [cljs.reducers-test]
- [cljs.keyword-test]
- [cljs.import-test]
- [cljs.ns-test.foo]
- [cljs.syntax-quote-test]
- [cljs.pprint]
- [cljs.pprint-test]
- [cljs.spec-test]
- [cljs.spec.test-test]
- [cljs.clojure-alias-test]
- [cljs.hash-map-test]
- [cljs.map-entry-test]
- [cljs.metadata-test]
- [cljs.npm-deps-test]
- [cljs.predicates-test]
- [cljs.tagged-literals-test]
- [cljs.test-test]
- [static.core-test]
- [cljs.recur-test]
- [cljs.array-access-test]
- [cljs.inference-test]
- [cljs.walk-test]
- [cljs.extend-to-native-test]))
+ [cljs.apply-test]
+ [cljs.primitives-test]
+ [cljs.destructuring-test]
+ [cljs.new-new-test]
+ [cljs.printing-test]
+ [cljs.seqs-test]
+ [cljs.collections-test]
+ [cljs.hashing-test]
+ [cljs.core-test :as core-test]
+ [cljs.reader-test]
+ [cljs.binding-test]
+ [cljs.ns-test]
+ [clojure.string-test]
+ [clojure.data-test]
+ [clojure.datafy-test]
+ [clojure.walk-test]
+ [cljs.macro-test]
+ [cljs.letfn-test]
+ [foo.ns-shadow-test]
+ [cljs.top-level]
+ [cljs.reducers-test]
+ [cljs.keyword-test]
+ [cljs.import-test]
+ [cljs.ns-test.foo]
+ [cljs.syntax-quote-test]
+ [cljs.pprint]
+ [cljs.pprint-test]
+ [cljs.spec-test]
+ [cljs.spec.test-test]
+ [cljs.clojure-alias-test]
+ [cljs.hash-map-test]
+ [cljs.map-entry-test]
+ [cljs.metadata-test]
+ [cljs.npm-deps-test]
+ [cljs.predicates-test]
+ [cljs.tagged-literals-test]
+ [cljs.test-test]
+ [static.core-test]
+ [cljs.recur-test]
+ [cljs.array-access-test]
+ [cljs.inference-test]
+ [cljs.walk-test]
+ [cljs.extend-to-native-test]))
(set! *print-newline* false)
(set-print-fn! js/print)
diff --git a/src/test/cljs_build/code-split/src/code/split/a.cljs b/src/test/cljs_build/code-split/src/code/split/a.cljs
index 3c159777..fe7c7a87 100644
--- a/src/test/cljs_build/code-split/src/code/split/a.cljs
+++ b/src/test/cljs_build/code-split/src/code/split/a.cljs
@@ -1,10 +1,10 @@
(ns code.split.a
(:require [cljs.loader :as loader]
- [clojure.pprint :refer [pprint]]
- [goog.dom :as gdom]
- [goog.events :as events])
+ [clojure.pprint :refer [pprint]]
+ [goog.dom :as gdom]
+ [goog.events :as events])
(:import [goog.debug Console]
- [goog.events EventType]))
+ [goog.events EventType]))
(def loader
"The module loader."
diff --git a/src/test/cljs_build/code-split/src/code/split/b.cljs b/src/test/cljs_build/code-split/src/code/split/b.cljs
index 800ca25e..15050d1f 100644
--- a/src/test/cljs_build/code-split/src/code/split/b.cljs
+++ b/src/test/cljs_build/code-split/src/code/split/b.cljs
@@ -1,6 +1,6 @@
(ns code.split.b
(:require [cljs.loader :as loader]
- [code.split.d :as d]))
+ [code.split.d :as d]))
(defn hello []
(println "Hello from code.split.b.")
diff --git a/src/test/cljs_build/code-split/src/code/split/c.cljs b/src/test/cljs_build/code-split/src/code/split/c.cljs
index e70cd5be..e35b1ff7 100644
--- a/src/test/cljs_build/code-split/src/code/split/c.cljs
+++ b/src/test/cljs_build/code-split/src/code/split/c.cljs
@@ -1,6 +1,6 @@
(ns code.split.c
(:require [cljs.loader :as loader]
- [code.split.d :as d]))
+ [code.split.d :as d]))
(enable-console-print!)
diff --git a/src/test/cljs_build/emit_global_requires_test/core.cljs b/src/test/cljs_build/emit_global_requires_test/core.cljs
index 86205f79..f571926d 100644
--- a/src/test/cljs_build/emit_global_requires_test/core.cljs
+++ b/src/test/cljs_build/emit_global_requires_test/core.cljs
@@ -1,8 +1,8 @@
(ns emit-global-requires-test.core
(:require [react :refer [createElement]]
- ["react-dom/server" :as ReactDOMServer]
- ["@material-ui/core/styles" :as mui-styles]
- ["@material-ui/core/styles/a" :as mui-styles-a]))
+ ["react-dom/server" :as ReactDOMServer]
+ ["@material-ui/core/styles" :as mui-styles]
+ ["@material-ui/core/styles/a" :as mui-styles-a]))
(enable-console-print!)
diff --git a/src/test/cljs_build/emit_node_requires_test/core.cljs b/src/test/cljs_build/emit_node_requires_test/core.cljs
index 98ca70ae..db4942e4 100644
--- a/src/test/cljs_build/emit_node_requires_test/core.cljs
+++ b/src/test/cljs_build/emit_node_requires_test/core.cljs
@@ -1,6 +1,6 @@
(ns emit-node-requires-test.core
(:require [react :refer [createElement]]
- ["react-dom/server" :as ReactDOMServer]))
+ ["react-dom/server" :as ReactDOMServer]))
(enable-console-print!)
diff --git a/src/test/cljs_build/hello-modules/src/foo/core.cljs b/src/test/cljs_build/hello-modules/src/foo/core.cljs
index cef2ffcb..1f8eb271 100644
--- a/src/test/cljs_build/hello-modules/src/foo/core.cljs
+++ b/src/test/cljs_build/hello-modules/src/foo/core.cljs
@@ -1,7 +1,7 @@
(ns foo.core
(:require [goog.dom :as gdom]
- [goog.events :as events]
- [cljs.loader :as loader])
+ [goog.events :as events]
+ [cljs.loader :as loader])
(:import [goog.events EventType]))
(enable-console-print!)
diff --git a/src/test/cljs_build/loader_test/foo.cljs b/src/test/cljs_build/loader_test/foo.cljs
index 232e8205..a0f04148 100644
--- a/src/test/cljs_build/loader_test/foo.cljs
+++ b/src/test/cljs_build/loader_test/foo.cljs
@@ -1,9 +1,9 @@
(ns loader-test.foo
(:require [goog.dom :as gdom]
- [goog.events :as events]
- [cljs.loader :as loader]
- [foreign.a]
- [foreign.b])
+ [goog.events :as events]
+ [cljs.loader :as loader]
+ [foreign.a]
+ [foreign.b])
(:import [goog.events EventType]))
(enable-console-print!)
diff --git a/src/test/cljs_build/npm_deps_test/string_requires.cljs b/src/test/cljs_build/npm_deps_test/string_requires.cljs
index b5836dff..c56cceb4 100644
--- a/src/test/cljs_build/npm_deps_test/string_requires.cljs
+++ b/src/test/cljs_build/npm_deps_test/string_requires.cljs
@@ -1,10 +1,10 @@
(ns npm-deps-test.string-requires
(:require [react :refer [createElement]]
- ["react-dom/server" :as ReactDOMServer]
- ["lodash-es/toArray" :refer [default] :rename {default toArray}]
- ["lodash-es/toFinite" :as toFinite]
- ["lodash-es/array" :as array]
- [npm-deps-test.string-requires-in-classpath]))
+ ["react-dom/server" :as ReactDOMServer]
+ ["lodash-es/toArray" :refer [default] :rename {default toArray}]
+ ["lodash-es/toFinite" :as toFinite]
+ ["lodash-es/array" :as array]
+ [npm-deps-test.string-requires-in-classpath]))
(enable-console-print!)
diff --git a/src/test/cljs_build/package_json_resolution_test/core.cljs b/src/test/cljs_build/package_json_resolution_test/core.cljs
index a232412e..775faac6 100644
--- a/src/test/cljs_build/package_json_resolution_test/core.cljs
+++ b/src/test/cljs_build/package_json_resolution_test/core.cljs
@@ -1,6 +1,6 @@
(ns package-json-resolution-test.core
(:require [iterall]
- [graphql]))
+ [graphql]))
(enable-console-print!)
diff --git a/src/test/clojure/cljs/analyzer_tests.clj b/src/test/clojure/cljs/analyzer_tests.clj
index 74653eb7..717e6eef 100644
--- a/src/test/clojure/cljs/analyzer_tests.clj
+++ b/src/test/clojure/cljs/analyzer_tests.clj
@@ -8,18 +8,18 @@
(ns cljs.analyzer-tests
(:require [clojure.java.io :as io]
- [cljs.util :as util]
- [clojure.set :as set]
- [cljs.env :as e]
- [cljs.env :as env]
- [cljs.analyzer :as a]
- [cljs.analyzer.api :as ana-api]
- [cljs.compiler :as comp]
- [cljs.closure :as closure]
- [cljs.externs :as externs]
- [cljs.analyzer :as ana]
- [clojure.string :as string]
- [cljs.test-util :refer [unsplit-lines]])
+ [cljs.util :as util]
+ [clojure.set :as set]
+ [cljs.env :as e]
+ [cljs.env :as env]
+ [cljs.analyzer :as a]
+ [cljs.analyzer.api :as ana-api]
+ [cljs.compiler :as comp]
+ [cljs.closure :as closure]
+ [cljs.externs :as externs]
+ [cljs.analyzer :as ana]
+ [clojure.string :as string]
+ [cljs.test-util :refer [unsplit-lines]])
(:use clojure.test))
(defn analyze
@@ -309,28 +309,28 @@
;; should always infer 'function as tag
(is (= 'function
(:tag
- (e/with-compiler-env test-cenv
- (analyze test-env
- '(fn ([a] 1) ([a b] "foo") ([a b & r] ())))))))
- (is (nil?
- (:ret-tag
(e/with-compiler-env test-cenv
(analyze test-env
- '(fn ([a] 1) ([a b] "foo") ([a b & r] ())))))) )
+ '(fn ([a] 1) ([a b] "foo") ([a b & r] ())))))))
+ (is (nil?
+ (:ret-tag
+ (e/with-compiler-env test-cenv
+ (analyze test-env
+ '(fn ([a] 1) ([a b] "foo") ([a b & r] ())))))) )
;; methods should have inferred types
(is (= '(number string cljs.core/IList)
(map :tag
(:methods
- (e/with-compiler-env test-cenv
- (analyze test-env
- '(fn ([a] 1) ([a b] "foo") ([a b & r] ())))))))))
+ (e/with-compiler-env test-cenv
+ (analyze test-env
+ '(fn ([a] 1) ([a b] "foo") ([a b & r] ())))))))))
(deftest fn-inference
(is (= 'number
- (e/with-compiler-env test-cenv
- (:tag (analyze test-env
- '(let [x (fn ([a] 1) ([a b] "foo") ([a b & r] ()))]
- (x :one)))))))
+ (e/with-compiler-env test-cenv
+ (:tag (analyze test-env
+ '(let [x (fn ([a] 1) ([a b] "foo") ([a b & r] ()))]
+ (x :one)))))))
(is (= 'string
(e/with-compiler-env test-cenv
(:tag (analyze test-env
@@ -361,45 +361,45 @@
(get-in @test-cenv [::a/namespaces 'test.cljs-2901 :defs 'foo :methods]))))
(is (= 'number
(:tag
- (e/with-compiler-env test-cenv
- (a/analyze-form-seq
- '[(ns test.cljs-2901)
- (defn foo
- ([a] 1)
- ([a b] "foo")
- ([a b & r] ()))
- (foo :one)]
- nil true)))))
+ (e/with-compiler-env test-cenv
+ (a/analyze-form-seq
+ '[(ns test.cljs-2901)
+ (defn foo
+ ([a] 1)
+ ([a b] "foo")
+ ([a b & r] ()))
+ (foo :one)]
+ nil true)))))
(is (= 'string
(:tag
- (e/with-compiler-env test-cenv
- (a/analyze-form-seq
- '[(ns test.cljs-2901)
- (defn foo
- ([a] 1)
- ([a b] "foo")
- ([a b & r] ()))
- (foo :one :two)]
- nil true)))))
+ (e/with-compiler-env test-cenv
+ (a/analyze-form-seq
+ '[(ns test.cljs-2901)
+ (defn foo
+ ([a] 1)
+ ([a b] "foo")
+ ([a b & r] ()))
+ (foo :one :two)]
+ nil true)))))
(is (= 'cljs.core/IList
(:tag
- (e/with-compiler-env test-cenv
- (a/analyze-form-seq
- '[(ns test.cljs-2901)
- (defn foo
- ([a] 1)
- ([a b] "foo")
- ([a b & r] ()))
- (foo :one :two :three)]
- nil true))))))
+ (e/with-compiler-env test-cenv
+ (a/analyze-form-seq
+ '[(ns test.cljs-2901)
+ (defn foo
+ ([a] 1)
+ ([a b] "foo")
+ ([a b & r] ()))
+ (foo :one :two :three)]
+ nil true))))))
(deftest variadic-fn-inference
(is (= '(cljs.core/IList)
(map :tag
(:methods
- (e/with-compiler-env test-cenv
- (analyze test-env
- '(fn ([a b & r] ()))))))))
+ (e/with-compiler-env test-cenv
+ (analyze test-env
+ '(fn ([a b & r] ()))))))))
(is (= 'cljs.core/IList
(e/with-compiler-env test-cenv
(:tag (analyze test-env
@@ -432,28 +432,28 @@
[::a/namespaces 'test.cljs-2901-b :defs 'foo :methods]))))
(is (= 'cljs.core/IList
(:tag
+ (e/with-compiler-env test-cenv
+ (a/analyze-form-seq
+ '[(ns test.cljs-2901-b)
+ (defn foo ([a b & r] ()))
+ (foo :one :two)]
+ nil true)))))
+ (is (= 'cljs.core/IList
+ (:tag
(e/with-compiler-env test-cenv
(a/analyze-form-seq
'[(ns test.cljs-2901-b)
(defn foo ([a b & r] ()))
- (foo :one :two)]
+ (foo :one :two :three)]
nil true)))))
(is (= 'cljs.core/IList
(:tag
- (e/with-compiler-env test-cenv
- (a/analyze-form-seq
- '[(ns test.cljs-2901-b)
- (defn foo ([a b & r] ()))
- (foo :one :two :three)]
- nil true)))))
- (is (= 'cljs.core/IList
- (:tag
- (e/with-compiler-env test-cenv
- (a/analyze-form-seq
- '[(ns test.cljs-2901-b)
- (defn foo ([a b & r] ()))
- (foo :one :two :three :four)]
- nil true))))))
+ (e/with-compiler-env test-cenv
+ (a/analyze-form-seq
+ '[(ns test.cljs-2901-b)
+ (defn foo ([a b & r] ()))
+ (foo :one :two :three :four)]
+ nil true))))))
(deftest lib-inference
(is (= (e/with-compiler-env test-cenv
@@ -561,11 +561,11 @@
(:require (clojure.spec.alpha :as s :refer [fdef]) :reload)))
'((:require-macros (bar :refer [quux]) :reload)
(:require (cljs.spec.alpha :as s :refer [fdef])
- (cljs.spec.alpha :as clojure.spec.alpha) :reload))))
+ (cljs.spec.alpha :as clojure.spec.alpha) :reload))))
(is (= (a/rewrite-cljs-aliases
'((:refer-clojure :exclude [first])
- (:require-macros (bar :refer [quux]) :reload)
- (:require (clojure.spec.alpha :as s) :reload)))
+ (:require-macros (bar :refer [quux]) :reload)
+ (:require (clojure.spec.alpha :as s) :reload)))
'((:refer-clojure :exclude [first])
(:require-macros (bar :refer [quux]) :reload)
(:require (cljs.spec.alpha :as s) (cljs.spec.alpha :as clojure.spec.alpha) :reload))))
@@ -626,7 +626,7 @@
;; Constants
(deftest test-constants
- (is (.startsWith
+ (is (.startsWith
(try
(analyze test-env '(do (def ^:const foo 123) (def foo 246)))
(catch Exception e
@@ -766,7 +766,7 @@
'#{union intersection})))
(let [test-env (a/empty-env)]
(is (= (-> (analyze test-env '(require '[clojure.set :as set]
- '[clojure.string :as str]))
+ '[clojure.string :as str]))
:requires vals set)
'#{clojure.set clojure.string})))
(let [test-env (a/empty-env)]
@@ -828,7 +828,7 @@
(are [analyzed] (thrown-with-cause-msg? Exception
#"Namespace declarations must appear at the top-level."
analyzed)
- (analyze test-env
+ (analyze test-env
'(def foo
(ns foo.core
(:require [clojure.set :as set]))))
@@ -901,7 +901,7 @@
(is (= (-> (ana ::a) juxt-op-val) [:const ::a]))
(is (= (-> (ana "abc") juxt-op-val) [:const "abc"]))
;variables
- ; FIXME deviates from tools.analyzer, :name is always unqualified
+ ; FIXME deviates from tools.analyzer, :name is always unqualified
(is (= [:var 'cljs.core 'cljs.core/inc 'inc] (-> (ana inc) ((juxt :op :ns :name :form)))))
(is (= [:var 'cljs.core 'cljs.core/inc 'cljs.core/inc] (-> (ana cljs.core/inc) ((juxt :op :ns :name :form)))))
;; dotted :var
@@ -1037,7 +1037,7 @@
(is (= :throw (-> (ana (case 1)) :body :ret :default :op)))
(is (= [:const 2] (-> (ana (case 1 2)) :body :ret :default juxt-op-val)))
;def
-;TODO :meta node
+ ;TODO :meta node
(is (= :def (-> (ana (def a)) :op)))
(is (= [:var] (-> (ana (def a)) :children)))
(is (= [:var :init] (-> (ana (def a 1)) :children)))
@@ -1055,7 +1055,7 @@
(is (= [:body] (-> (ana (deftype A [])) :statements first :children)))
; :body
(is (= :do (-> (ana (deftype A [a] Object (toString [this] a))) :statements first :body :op)))
- ; field reference
+ ; field reference
(is (= [:local :field]
(-> (ana (deftype A [a] Object (toString [this] a)))
:statements first :body :ret :val :methods
@@ -1073,29 +1073,29 @@
; :local
(is (-> (ana (fn [])) (contains? :local) false?))
(is (=
- [:binding 'b :fn]
- (-> (ana (fn b [& a]))
- :local
- ((juxt :op :name :local)))))
+ [:binding 'b :fn]
+ (-> (ana (fn b [& a]))
+ :local
+ ((juxt :op :name :local)))))
(is (=
- [:local 'b :fn]
- (-> (ana (fn b [] b))
- :methods
- first
- :body
- :ret
- ((juxt :op :name :local)))))
+ [:local 'b :fn]
+ (-> (ana (fn b [] b))
+ :methods
+ first
+ :body
+ :ret
+ ((juxt :op :name :local)))))
(is (=
- [:binding 'b :fn]
- (-> (ana (fn b [] b))
- :methods
- first
- :body
- :ret
- :env
- :locals
- (get 'b)
- ((juxt :op :name :local)))))
+ [:binding 'b :fn]
+ (-> (ana (fn b [] b))
+ :methods
+ first
+ :body
+ :ret
+ :env
+ :locals
+ (get 'b)
+ ((juxt :op :name :local)))))
; :variadic?
(is (true? (-> (ana (fn [& a])) :variadic?)))
(is (false? (-> (ana (fn [])) :variadic?)))
@@ -1117,9 +1117,9 @@
(is (= [:const 1] (-> (ana (fn [] 1)) :methods first :body :ret juxt-op-val)))
; :params
(is (vector?
- (-> (ana (fn [])) :methods first :params)))
+ (-> (ana (fn [])) :methods first :params)))
(is (vector?
- (-> (ana (fn [a b])) :methods first :params)))
+ (-> (ana (fn [a b])) :methods first :params)))
(is (= [:binding 'a :arg]
(-> (ana (fn [a b])) :methods first :params
first ((juxt :op :name :local)))))
@@ -1159,7 +1159,7 @@
(is (= [:const :a] (-> (prs-ana "#js [:a]") :items first juxt-op-val)))
;js-object
(is (= :js-object (-> (prs-ana "#js {:a 1}]") :op)))
-;; FIXME :keys should be an expression too
+ ;; FIXME :keys should be an expression too
(is (= [:vals] (-> (prs-ana "#js {:a 1}") :children)))
(is (vector? (-> (prs-ana "#js {:a 1}") :vals)))
(is (= :a (-> (prs-ana "#js {:a 1}") :keys first)))
@@ -1170,7 +1170,7 @@
(is (= [:args] (-> (ana (js* "~{}" 'food)) :children)))
(is (vector? (-> (ana (js* "~{}" 'food)) :args)))
(is (= [:const 'food] (-> (ana (js* "~{}" 'food)) :args first :expr juxt-op-val)))
-;; FIXME why not a vector?
+ ;; FIXME why not a vector?
;(is (vector? (-> (ana (js* "~{} / ~{}" 1 2)) :segs)))
(is (= ["" " / " ""] (-> (ana (js* "~{} / ~{}" 1 2)) :segs)))
;letfn
@@ -1184,13 +1184,13 @@
:children)))
; :bindings
(is (vector?
- (-> (ana (letfn [(my-inc [a] (inc a))]
- (my-inc 1)))
- :bindings)))
+ (-> (ana (letfn [(my-inc [a] (inc a))]
+ (my-inc 1)))
+ :bindings)))
(is (vector?
- (-> (ana (letfn [(my-inc [a] (inc a))]
- (my-inc 1)))
- :bindings)))
+ (-> (ana (letfn [(my-inc [a] (inc a))]
+ (my-inc 1)))
+ :bindings)))
(is (= :binding
(-> (ana (letfn [(my-inc [a] (inc a))]
(my-inc 1)))
@@ -1252,9 +1252,9 @@
((juxt :op :ns :name)))))
; :args
(is ((every-pred vector? empty?)
- (-> (ana (do (deftype Noarg []) (Noarg.)))
- :ret
- :args)))
+ (-> (ana (do (deftype Noarg []) (Noarg.)))
+ :ret
+ :args)))
(is (= [:const 1]
(-> (ana (do (deftype Person [a]) (Person. 1)))
:ret
@@ -1304,28 +1304,28 @@
(run!
(fn [[k v]]
; ensure entries map to sane things
- (case (:val k)
- :name (is (= '+ (-> v :expr :val)))
- :tag (is (= 'number (-> v :expr :val)))
- :arglists (is (= :quote (:op v)))
- ;:row (is (= :quote (:op v)))
- (:line :column :end-line :end-column) (number? (:val v))
- :ns (is (symbol? (-> v :expr :val)))
- :file (is (string? (-> v :expr :val)))
- :doc (is (string? (-> v :expr :val)))
- :test (is (= :if (:op v)))
- :top-fn (do (is (= :const (:op (:expr v))))
- (is (map? (:val (:expr v)))))
- ;default
- nil))
+ (case (:val k)
+ :name (is (= '+ (-> v :expr :val)))
+ :tag (is (= 'number (-> v :expr :val)))
+ :arglists (is (= :quote (:op v)))
+ ;:row (is (= :quote (:op v)))
+ (:line :column :end-line :end-column) (number? (:val v))
+ :ns (is (symbol? (-> v :expr :val)))
+ :file (is (string? (-> v :expr :val)))
+ :doc (is (string? (-> v :expr :val)))
+ :test (is (= :if (:op v)))
+ :top-fn (do (is (= :const (:op (:expr v))))
+ (is (map? (:val (:expr v)))))
+ ;default
+ nil))
(apply zipmap (-> (ana #'+) :meta ((juxt :keys :vals)))))
;throw
(is (= :throw (-> (ana (throw (js/Error. "bad"))) :op)))
(is (= [:exception] (-> (ana (throw (js/Error. "bad"))) :children)))
; :exception
(is (= [:js-var 'js 'js/Error] (-> (ana (throw (js/Error. "bad"))) :exception
- :class
- ((juxt :op :ns :name)))))
+ :class
+ ((juxt :op :ns :name)))))
;vector
(is (= :vector (-> (ana [1]) :op)))
(is (= [:items] (-> (ana [1]) :children)))
@@ -1380,50 +1380,50 @@
(is (map? (-> (ana js/console) :env)))
(is (= 'js/-Infinity (-> (ana js/-Infinity) :form)))
;; TODO dotted :js-var (?)
-#_
+ #_
(is (= [:js-var 'js/console 'js]
(-> (ana js/console) ((juxt :op :name :ns)))))
;munging
(is (=
- [false 'a]
- (->
- (ana (let [a (println 1)
- b (println 2)]
- [a b]))
- :bindings first
- ((juxt #(contains? % :ns) :name)))))
+ [false 'a]
+ (->
+ (ana (let [a (println 1)
+ b (println 2)]
+ [a b]))
+ :bindings first
+ ((juxt #(contains? % :ns) :name)))))
;shadowing
(is (=
- 'a
- (->
- (ana (let [a (println 1)
- a (println 2)]
- [a a]))
- :bindings second
- :shadow
- :name)))
+ 'a
+ (->
+ (ana (let [a (println 1)
+ a (println 2)]
+ [a a]))
+ :bindings second
+ :shadow
+ :name)))
(is (=
- 'a
- (->
- (ana (let [a (println 1)
- a (println 2)
- a (println 3)
- ]
- [a a a]))
- :bindings (nth 2)
- :shadow
- :shadow
- :name)))
+ 'a
+ (->
+ (ana (let [a (println 1)
+ a (println 2)
+ a (println 3)
+ ]
+ [a a a]))
+ :bindings (nth 2)
+ :shadow
+ :shadow
+ :name)))
;ns
(is
(binding [a/*analyze-deps* false]
- (binding [a/*cljs-ns* 'cljs.user]
- (ana
- (ns my.ns.foo
- (:require [clojure.repl]
- [clojure.string]
- [goog.string])
- (:import [goog.string StringBuffer]))))))
+ (binding [a/*cljs-ns* 'cljs.user]
+ (ana
+ (ns my.ns.foo
+ (:require [clojure.repl]
+ [clojure.string]
+ [goog.string])
+ (:import [goog.string StringBuffer]))))))
;nested metadata
(is (= :baz
(-> (ana ''#{^{:foo :baz} a})
@@ -1530,10 +1530,10 @@
(analyze (a/empty-env) '(def foo (js/woz)))))
:tag)))
(is (= 'js
- (-> (binding [a/*cljs-ns* a/*cljs-ns*]
- (e/with-compiler-env externs-cenv
- (analyze (a/empty-env) '(def foo js/boz))))
- :tag)))
+ (-> (binding [a/*cljs-ns* a/*cljs-ns*]
+ (e/with-compiler-env externs-cenv
+ (analyze (a/empty-env) '(def foo js/boz))))
+ :tag)))
(is (nil? (-> (binding [a/*cljs-ns* a/*cljs-ns*]
(a/no-warn
(e/with-compiler-env externs-cenv
@@ -1639,16 +1639,16 @@
a/*analyze-deps* false]
(is (thrown-with-cause-msg? Exception #"Alias str already exists in namespace cljs.user, aliasing clojure.string"
(analyze test-env '(do
- (require '[clojure.string :as str])
- (require '[clojure.set :as str])))))
+ (require '[clojure.string :as str])
+ (require '[clojure.set :as str])))))
(is (thrown-with-cause-msg? Exception #"Alias str already exists in namespace cljs.user, aliasing clojure.string"
(analyze test-env '(do
- (require-macros '[clojure.string :as str])
- (require-macros '[clojure.set :as str])))))
+ (require-macros '[clojure.string :as str])
+ (require-macros '[clojure.set :as str])))))
(is (analyze test-env '(do
- (require '[clojure.string :as str])
- (require '[clojure.string :as str])
- (require 'clojure.string)))))))
+ (require '[clojure.string :as str])
+ (require '[clojure.string :as str])
+ (require 'clojure.string)))))))
(deftest test-cljs-2182
(let [cenv (atom @test-cenv)]
@@ -1797,7 +1797,7 @@
(let [ws (atom [])
res (infer-test-helper
{:forms '[(defn baz [^js/Foo a]
- (.gozMethod a))]
+ (.gozMethod a))]
:externs ["src/test/externs/test.js"]
:warnings ws})]
(is (= (unsplit-lines ["Foo.prototype.gozMethod;"]) res))
@@ -1888,7 +1888,7 @@
res (infer-test-helper
{:forms '[(ns cjls-1918.core
(:require [cljs.nodejs]
- [cljs.nodejscli]))]
+ [cljs.nodejscli]))]
:warnings ws
:with-core? true
:opts {:target :nodejs}})]
diff --git a/src/test/clojure/cljs/build_api_tests.clj b/src/test/clojure/cljs/build_api_tests.clj
index a76efc68..53b33b96 100644
--- a/src/test/clojure/cljs/build_api_tests.clj
+++ b/src/test/clojure/cljs/build_api_tests.clj
@@ -10,17 +10,17 @@
(:refer-clojure :exclude [compile])
(:import java.io.File)
(:require [cljs.analyzer :as ana]
- [cljs.build.api :as build]
- [cljs.closure :as closure]
- [cljs.env :as env]
- [cljs.test-util :as test]
- [cljs.util :as util]
- [clojure.data.json :as json]
- [clojure.edn :as edn]
- [clojure.java.io :as io]
- [clojure.java.shell :as sh]
- [clojure.test :refer [deftest is testing]]
- [clojure.string :as string]))
+ [cljs.build.api :as build]
+ [cljs.closure :as closure]
+ [cljs.env :as env]
+ [cljs.test-util :as test]
+ [cljs.util :as util]
+ [clojure.data.json :as json]
+ [clojure.edn :as edn]
+ [clojure.java.io :as io]
+ [clojure.java.shell :as sh]
+ [clojure.test :refer [deftest is testing]]
+ [clojure.string :as string]))
(deftest test-target-file-for-cljs-ns
(is (= (.getPath (build/target-file-for-cljs-ns 'example.core-lib nil))
@@ -31,21 +31,21 @@
(deftest test-cljs-dependents-for-macro-namespaces
(env/with-compiler-env (env/default-compiler-env)
(swap! env/*compiler* assoc :cljs.analyzer/namespaces
- { 'example.core
- {:require-macros {'example.macros 'example.macros
- 'mac 'example.macros}
- :name 'example.core}
- 'example.util
- {:require-macros {'example.macros 'example.macros
- 'mac 'example.macros}
- :name 'example.util}
- 'example.helpers
- {:require-macros {'example.macros-again 'example.macros-again
- 'mac 'example.macros-again}
- :name 'example.helpers }
- 'example.fun
- {:require-macros nil
- :name 'example.fun }})
+ { 'example.core
+ {:require-macros {'example.macros 'example.macros
+ 'mac 'example.macros}
+ :name 'example.core}
+ 'example.util
+ {:require-macros {'example.macros 'example.macros
+ 'mac 'example.macros}
+ :name 'example.util}
+ 'example.helpers
+ {:require-macros {'example.macros-again 'example.macros-again
+ 'mac 'example.macros-again}
+ :name 'example.helpers }
+ 'example.fun
+ {:require-macros nil
+ :name 'example.fun }})
(is (= (set (build/cljs-dependents-for-macro-namespaces ['example.macros]))
#{'example.core 'example.util}))
(is (= (set (build/cljs-dependents-for-macro-namespaces ['example.macros-again]))
@@ -117,7 +117,7 @@
(ana/analyze test-env
'(ns graph.baz.core
(:require [graph.foo.core :as foo]
- [graph.bar.core :as bar]))))))
+ [graph.bar.core :as bar]))))))
(deftest cljs-1469
(let [out (.getPath (io/file (test/tmp-dir) "loader-test-out"))
@@ -677,5 +677,5 @@
(when-not (= :cljs-base name)
(let [f (io/file (get mf output-to))
sha (string/lower-case (util/content-sha (slurp (io/file f)) 7))]
- (is (true? (.exists f)))
- (is (string/includes? (.getPath f) sha))))))))
+ (is (true? (.exists f)))
+ (is (string/includes? (.getPath f) sha))))))))
diff --git a/src/test/clojure/cljs/closure_tests.clj b/src/test/clojure/cljs/closure_tests.clj
index 8e90870d..bf7b27a1 100644
--- a/src/test/clojure/cljs/closure_tests.clj
+++ b/src/test/clojure/cljs/closure_tests.clj
@@ -10,16 +10,16 @@
(:refer-clojure :exclude [compile])
(:use cljs.closure clojure.test)
(:require [cljs.build.api :as build]
- [clojure.data.json :as json]
- [clojure.java.shell :as sh]
- [cljs.closure :as closure]
- [cljs.js-deps :as deps]
- [cljs.util :as util]
- [cljs.test-util :as test]
- [clojure.java.io :as io]
- [clojure.string :as string])
+ [clojure.data.json :as json]
+ [clojure.java.shell :as sh]
+ [cljs.closure :as closure]
+ [cljs.js-deps :as deps]
+ [cljs.util :as util]
+ [cljs.test-util :as test]
+ [clojure.java.io :as io]
+ [clojure.string :as string])
(:import [java.io File]
- [com.google.javascript.jscomp JSModule]))
+ [com.google.javascript.jscomp JSModule]))
(deftest test-make-preamble
(testing "no options"
diff --git a/src/test/clojure/cljs/compiler_tests.clj b/src/test/clojure/cljs/compiler_tests.clj
index 59857b9f..38b1bdd5 100644
--- a/src/test/clojure/cljs/compiler_tests.clj
+++ b/src/test/clojure/cljs/compiler_tests.clj
@@ -9,13 +9,13 @@
(ns cljs.compiler-tests
(:use clojure.test)
(:require [cljs.analyzer :as ana]
- [cljs.compiler :as comp]
- [cljs.compiler.api :as comp-api]
- [cljs.env :as env]
- [cljs.util :as util]
- [cljs.tagged-literals :as tags]
- [clojure.java.io :as io]
- [clojure.string :as str])
+ [cljs.compiler :as comp]
+ [cljs.compiler.api :as comp-api]
+ [cljs.env :as env]
+ [cljs.util :as util]
+ [cljs.tagged-literals :as tags]
+ [clojure.java.io :as io]
+ [clojure.string :as str])
(:import [java.io File]))
(defn analyze
@@ -33,19 +33,19 @@
(def cenv (env/default-compiler-env))
#_(deftest should-recompile
- (let [src (File. "test/hello.cljs")
- dst (File/createTempFile "compilertest" ".cljs")
- 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)))))))
+ (let [src (File. "test/hello.cljs")
+ dst (File/createTempFile "compilertest" ".cljs")
+ 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
@@ -61,7 +61,7 @@
'(defn foo []
(fn bar [])))
[:init :methods 0 :body :ret :local]))
- 'cljs$user$foo_$_bar))
+ 'cljs$user$foo_$_bar))
(is (= (comp/munge
(get-in
(analyze aenv
@@ -74,14 +74,14 @@
(is (= (with-out-str
(emit
(analyze (assoc aenv :context :expr) 'js/-Infinity)))
- "-Infinity")))
+ "-Infinity")))
(deftest test-cljs-2352
(are [form result]
- (= (with-out-str
- (emit
- (analyze (assoc aenv :context :expr) form)))
- result)
+ (= (with-out-str
+ (emit
+ (analyze (assoc aenv :context :expr) form)))
+ result)
Double/NaN "NaN"
Double/POSITIVE_INFINITY "Infinity"
Double/NEGATIVE_INFINITY "-Infinity"))
@@ -163,11 +163,11 @@
(binding [ana/*cljs-static-fns* true]
(are [form]
(empty?
- (capture-warnings
- (env/with-compiler-env (atom cenv-with-foo)
- (with-out-str
- (emit
- (analyze aenv-with-foo form))))))
+ (capture-warnings
+ (env/with-compiler-env (atom cenv-with-foo)
+ (with-out-str
+ (emit
+ (analyze aenv-with-foo form))))))
'(cljs.user/foo nil)
'(cljs.user/foo 0)
diff --git a/src/test/clojure/cljs/module_graph_tests.clj b/src/test/clojure/cljs/module_graph_tests.clj
index 3ce70375..b133de4e 100644
--- a/src/test/clojure/cljs/module_graph_tests.clj
+++ b/src/test/clojure/cljs/module_graph_tests.clj
@@ -8,9 +8,9 @@
(ns cljs.module-graph-tests
(:require [clojure.test :as test :refer [deftest is testing]]
- [cljs.closure :as closure]
- [cljs.util :as util]
- [cljs.module-graph :as module-graph])
+ [cljs.closure :as closure]
+ [cljs.util :as util]
+ [cljs.module-graph :as module-graph])
(:import [clojure.lang ExceptionInfo]))
(def opts {:output-dir "out"})
@@ -135,7 +135,7 @@
(module-graph/validate-modules modules' index)
(catch Throwable t
:caught))
- :caught))))
+ :caught))))
(deftest test-module->module-uris
(is (= (module-graph/modules->module-uris (modules opts) (inputs opts)
diff --git a/src/test/clojure/cljs/module_processing_tests.clj b/src/test/clojure/cljs/module_processing_tests.clj
index 533d47b2..f34a98dd 100644
--- a/src/test/clojure/cljs/module_processing_tests.clj
+++ b/src/test/clojure/cljs/module_processing_tests.clj
@@ -1,14 +1,14 @@
(ns cljs.module-processing-tests
(:require [clojure.java.io :as io]
- [cljs.closure :as closure]
- [clojure.string :as string]
- [clojure.test :refer [deftest is]]
- [cljs.env :as env]
- [cljs.analyzer :as ana]
- [cljs.compiler :as comp]
- [cljs.js-deps :as deps]
- [cljs.util :as util]
- [cljs.test-util :as test])
+ [cljs.closure :as closure]
+ [clojure.string :as string]
+ [clojure.test :refer [deftest is]]
+ [cljs.env :as env]
+ [cljs.analyzer :as ana]
+ [cljs.compiler :as comp]
+ [cljs.js-deps :as deps]
+ [cljs.util :as util]
+ [cljs.test-util :as test])
(:import [java.io File]))
;; Hard coded JSX transform for the test case
diff --git a/src/test/clojure/cljs/profile.clj b/src/test/clojure/cljs/profile.clj
index b168c02b..87463fd0 100644
--- a/src/test/clojure/cljs/profile.clj
+++ b/src/test/clojure/cljs/profile.clj
@@ -1,8 +1,8 @@
(ns cljs.profile
(:require [clojure.java.io :as io]
- [cljs.env :as env]
- [cljs.analyzer :as ana]
- [cljs.compiler :as comp]))
+ [cljs.env :as env]
+ [cljs.analyzer :as ana]
+ [cljs.compiler :as comp]))
(comment
diff --git a/src/test/clojure/cljs/repl_tests.clj b/src/test/clojure/cljs/repl_tests.clj
index dda28e38..22f05f60 100644
--- a/src/test/clojure/cljs/repl_tests.clj
+++ b/src/test/clojure/cljs/repl_tests.clj
@@ -8,13 +8,13 @@
(ns cljs.repl-tests
(:require [clojure.java.io :as io]
- [cljs.analyzer :as ana]
- [cljs.analyzer.api :as ana-api]
- [cljs.env :as env]
- [cljs.repl :as repl]
- [cljs.repl.rhino :as rhino]
- [cljs.compiler :as comp])
- (:use clojure.test))
+ [cljs.analyzer :as ana]
+ [cljs.analyzer.api :as ana-api]
+ [cljs.env :as env]
+ [cljs.repl :as repl]
+ [cljs.repl.rhino :as rhino]
+ [cljs.compiler :as comp])
+ (:use clojure.test))
(def st (env/default-compiler-env))
@@ -27,20 +27,20 @@
(is (string? (:doc (ana-api/resolve {} '->))))))
#_(deftest file-info
- (let [repl-env (rhino/repl-env)
- compiler-env (env/default-compiler-env)
- repl-env (assoc repl-env ::env/compiler compiler-env)]
- (env/with-compiler-env compiler-env
- (binding [ana/*cljs-ns* 'cljs.user]
- (repl/-setup repl-env)))
- (let [assoc-info (get-in @compiler-env [:cljs.analyzer/namespaces 'cljs.core :defs 'assoc])
- {:keys [file line]} assoc-info]
+ (let [repl-env (rhino/repl-env)
+ compiler-env (env/default-compiler-env)
+ repl-env (assoc repl-env ::env/compiler compiler-env)]
+ (env/with-compiler-env compiler-env
+ (binding [ana/*cljs-ns* 'cljs.user]
+ (repl/-setup repl-env)))
+ (let [assoc-info (get-in @compiler-env [:cljs.analyzer/namespaces 'cljs.core :defs 'assoc])
+ {:keys [file line]} assoc-info]
- (is assoc-info)
- (is (number? line))
- (is file)
- (and file
- (is (io/resource file))))))
+ (is assoc-info)
+ (is (number? line))
+ (is file)
+ (and file
+ (is (io/resource file))))))
(deftest test-bytes-to-base64-str
(is (= "YWJj" (#'repl/bytes-to-base64-str (.getBytes "abc")))))
diff --git a/src/test/clojure/cljs/test_util.clj b/src/test/clojure/cljs/test_util.clj
index c1afc436..e20ed15a 100644
--- a/src/test/clojure/cljs/test_util.clj
+++ b/src/test/clojure/cljs/test_util.clj
@@ -8,7 +8,7 @@
(ns cljs.test-util
(:require [clojure.java.io :as io]
- [clojure.string :as string])
+ [clojure.string :as string])
(:import [java.io File]))
(defn delete-out-files
diff --git a/src/test/clojure/cljs/util_tests.clj b/src/test/clojure/cljs/util_tests.clj
index f5bf0bac..23d98b69 100644
--- a/src/test/clojure/cljs/util_tests.clj
+++ b/src/test/clojure/cljs/util_tests.clj
@@ -8,7 +8,7 @@
(ns cljs.util-tests
(:require [cljs.util :as util]
- [clojure.java.io :as io])
+ [clojure.java.io :as io])
(:use clojure.test))
(deftest test-levenshtein-distance
diff --git a/src/test/self/self_host/test.cljs b/src/test/self/self_host/test.cljs
index 96139c86..ef821105 100644
--- a/src/test/self/self_host/test.cljs
+++ b/src/test/self/self_host/test.cljs
@@ -9,11 +9,11 @@
(ns self-host.test
(:require [cljs.test :as test
:refer-macros [run-tests deftest testing is async]]
- [cljs.js :as cljs]
- [cljs.analyzer :as ana]
- [clojure.string :as string]
- [cljs.stacktrace :as st]
- [cljs.nodejs :as nodejs]))
+ [cljs.js :as cljs]
+ [cljs.analyzer :as ana]
+ [clojure.string :as string]
+ [cljs.stacktrace :as st]
+ [cljs.nodejs :as nodejs]))
(set! (.-user js/cljs) #js {})
@@ -253,13 +253,13 @@
(is (== 3 value))
(inc! l)))
(cljs/eval-str st "(ns foo.bar)" nil
- {:eval node-eval
- :context :expr
- :def-emits-var true}
- (fn [{:keys [error value]}]
- (is (nil? error))
- (is (not (nil? js/foo.bar)))
- (inc! l)))
+ {:eval node-eval
+ :context :expr
+ :def-emits-var true}
+ (fn [{:keys [error value]}]
+ (is (nil? error))
+ (is (not (nil? js/foo.bar)))
+ (inc! l)))
(cljs/eval-str st "(defn foo [a b] (+ a b))" nil
{:eval node-eval
:context :expr
@@ -1187,7 +1187,7 @@
"@material-ui/core/styles/a" {:global-exports {"@material-ui/core/styles/a" "X.a"}}})
(cljs/eval-str
(atom @st)
-"(ns foo.core
+ "(ns foo.core
(:require [\"@material-ui/core/styles\" :as mui-styles]
[\"@material-ui/core/styles/a\" :as mui-styles-a]))
@@ -1421,11 +1421,11 @@
:line 2
:column 7}]
(st/mapped-stacktrace
- [{:file "foo/bar.js"
- :function "broken-first"
- :line 2
- :column 0}]
- sms)))
+ [{:file "foo/bar.js"
+ :function "broken-first"
+ :line 2
+ :column 0}]
+ sms)))
(inc! l)))))))))
(deftest test-mapping-stacktrace-with-underscore
@@ -1452,11 +1452,11 @@
:line 2
:column 7}]
(st/mapped-stacktrace
- [{:file "foo/with_underscore.js"
- :function "broken-first"
- :line 2
- :column 0}]
- sms)))
+ [{:file "foo/with_underscore.js"
+ :function "broken-first"
+ :line 2
+ :column 0}]
+ sms)))
(inc! l)))))))))
(deftest test-append-source-map-with-nil-name
diff --git a/src/test/self/self_parity/auxiliary.cljs b/src/test/self/self_parity/auxiliary.cljs
index ec8e2e3a..946d7b1d 100644
--- a/src/test/self/self_parity/auxiliary.cljs
+++ b/src/test/self/self_parity/auxiliary.cljs
@@ -13,140 +13,140 @@
the compiler tests in bootstrap mode."}
self-parity.auxiliary
(:require
- goog.Delay
- goog.Disposable
- goog.Promise
- goog.Throttle
- goog.Timer
- goog.Uri
- goog.color
- goog.color.Hsl
- goog.color.Hsv
- goog.color.Rgb
- goog.color.alpha
- goog.color.names
- goog.crypt
- goog.crypt.Aes
- goog.crypt.Arc4
- goog.crypt.BlobHasher
- goog.crypt.Cbc
- goog.crypt.Hash
- goog.crypt.Hmac
- goog.crypt.Md5
- goog.crypt.Sha1
- goog.crypt.Sha2
- goog.crypt.Sha224
- goog.crypt.Sha256
- goog.crypt.Sha2_64bit
- goog.crypt.Sha512
- goog.crypt.Sha512_256
- goog.crypt.base64
- goog.crypt.baseN
- goog.crypt.hash32
- goog.crypt.hashTester
- goog.crypt.pbkdf2
- goog.date.Date
- goog.date.DateLike
- goog.date.DateRange
- goog.date.DateTime
- goog.date.Interval
- goog.date.UtcDateTime
- goog.date.duration
- goog.date.month
- goog.date.relative.TimeDeltaFormatter
- goog.date.relative.Unit
- goog.date.relativeWithPlurals
- goog.date.weekDay
- goog.format
- goog.format.EmailAddress
- goog.format.HtmlPrettyPrinter
- goog.format.InternationalizedEmailAddress
- goog.format.JsonPrettyPrinter
- goog.i18n.BidiFormatter
- goog.i18n.CharListDecompressor
- goog.i18n.CharPickerData
- goog.i18n.DateTimeFormat
- goog.i18n.DateTimeParse
- goog.i18n.GraphemeBreak
- goog.i18n.MessageFormat
- goog.i18n.NumberFormat
- goog.i18n.TimeZone
- goog.i18n.bidi
- goog.i18n.bidi.Dir
- goog.i18n.bidi.Format
- goog.i18n.collation
- goog.i18n.currency
- goog.i18n.mime
- goog.i18n.ordinalRules
- goog.i18n.pluralRules
- goog.i18n.uChar
- goog.i18n.uChar.LocalNameFetcher
- goog.i18n.uChar.RemoteNameFetcher
- goog.i18n.uCharNames
- goog.iter
- goog.iter.Iterable
- goog.iter.Iterator
- goog.json
- goog.json.NativeJsonProcessor
- goog.json.Replacer
- goog.json.Reviver
- goog.json.Serializer
- goog.json.hybrid
- goog.locale
- goog.locale.TimeZoneFingerprint
- goog.locale.defaultLocaleNameConstants
- goog.locale.genericFontNames
- goog.locale.timeZoneDetection
- goog.math
- goog.math.AffineTransform
- goog.math.Bezier
- goog.math.Box
- goog.math.Coordinate
- goog.math.Coordinate3
- goog.math.ExponentialBackoff
- goog.math.Integer
- goog.math.Line
- goog.math.Long
- goog.math.Matrix
- goog.math.Path
- goog.math.Path.Segment
- goog.math.Range
- goog.math.RangeSet
- goog.math.Rect
- goog.math.Size
- goog.math.Vec2
- goog.math.Vec3
- goog.math.interpolator.Linear1
- goog.math.interpolator.Pchip1
- goog.math.interpolator.Spline1
- goog.math.paths
- goog.math.tdma
- goog.spell.SpellCheck
- goog.string
- goog.string.Const
- goog.string.StringBuffer
- goog.string.Unicode
- goog.string.format
- goog.string.newlines
- goog.string.newlines.Line
- goog.structs
- goog.structs.AvlTree
- goog.structs.CircularBuffer
- goog.structs.Heap
- goog.structs.InversionMap
- goog.structs.LinkedMap
- goog.structs.Map
- goog.structs.Node
- goog.structs.Pool
- goog.structs.PriorityPool
- goog.structs.PriorityQueue
- goog.structs.QuadTree
- goog.structs.QuadTree.Node
- goog.structs.QuadTree.Point
- goog.structs.Queue
- goog.structs.Set
- goog.structs.SimplePool
- goog.structs.StringSet
- goog.structs.TreeNode
- goog.structs.Trie
- goog.text.LoremIpsum))
+ goog.Delay
+ goog.Disposable
+ goog.Promise
+ goog.Throttle
+ goog.Timer
+ goog.Uri
+ goog.color
+ goog.color.Hsl
+ goog.color.Hsv
+ goog.color.Rgb
+ goog.color.alpha
+ goog.color.names
+ goog.crypt
+ goog.crypt.Aes
+ goog.crypt.Arc4
+ goog.crypt.BlobHasher
+ goog.crypt.Cbc
+ goog.crypt.Hash
+ goog.crypt.Hmac
+ goog.crypt.Md5
+ goog.crypt.Sha1
+ goog.crypt.Sha2
+ goog.crypt.Sha224
+ goog.crypt.Sha256
+ goog.crypt.Sha2_64bit
+ goog.crypt.Sha512
+ goog.crypt.Sha512_256
+ goog.crypt.base64
+ goog.crypt.baseN
+ goog.crypt.hash32
+ goog.crypt.hashTester
+ goog.crypt.pbkdf2
+ goog.date.Date
+ goog.date.DateLike
+ goog.date.DateRange
+ goog.date.DateTime
+ goog.date.Interval
+ goog.date.UtcDateTime
+ goog.date.duration
+ goog.date.month
+ goog.date.relative.TimeDeltaFormatter
+ goog.date.relative.Unit
+ goog.date.relativeWithPlurals
+ goog.date.weekDay
+ goog.format
+ goog.format.EmailAddress
+ goog.format.HtmlPrettyPrinter
+ goog.format.InternationalizedEmailAddress
+ goog.format.JsonPrettyPrinter
+ goog.i18n.BidiFormatter
+ goog.i18n.CharListDecompressor
+ goog.i18n.CharPickerData
+ goog.i18n.DateTimeFormat
+ goog.i18n.DateTimeParse
+ goog.i18n.GraphemeBreak
+ goog.i18n.MessageFormat
+ goog.i18n.NumberFormat
+ goog.i18n.TimeZone
+ goog.i18n.bidi
+ goog.i18n.bidi.Dir
+ goog.i18n.bidi.Format
+ goog.i18n.collation
+ goog.i18n.currency
+ goog.i18n.mime
+ goog.i18n.ordinalRules
+ goog.i18n.pluralRules
+ goog.i18n.uChar
+ goog.i18n.uChar.LocalNameFetcher
+ goog.i18n.uChar.RemoteNameFetcher
+ goog.i18n.uCharNames
+ goog.iter
+ goog.iter.Iterable
+ goog.iter.Iterator
+ goog.json
+ goog.json.NativeJsonProcessor
+ goog.json.Replacer
+ goog.json.Reviver
+ goog.json.Serializer
+ goog.json.hybrid
+ goog.locale
+ goog.locale.TimeZoneFingerprint
+ goog.locale.defaultLocaleNameConstants
+ goog.locale.genericFontNames
+ goog.locale.timeZoneDetection
+ goog.math
+ goog.math.AffineTransform
+ goog.math.Bezier
+ goog.math.Box
+ goog.math.Coordinate
+ goog.math.Coordinate3
+ goog.math.ExponentialBackoff
+ goog.math.Integer
+ goog.math.Line
+ goog.math.Long
+ goog.math.Matrix
+ goog.math.Path
+ goog.math.Path.Segment
+ goog.math.Range
+ goog.math.RangeSet
+ goog.math.Rect
+ goog.math.Size
+ goog.math.Vec2
+ goog.math.Vec3
+ goog.math.interpolator.Linear1
+ goog.math.interpolator.Pchip1
+ goog.math.interpolator.Spline1
+ goog.math.paths
+ goog.math.tdma
+ goog.spell.SpellCheck
+ goog.string
+ goog.string.Const
+ goog.string.StringBuffer
+ goog.string.Unicode
+ goog.string.format
+ goog.string.newlines
+ goog.string.newlines.Line
+ goog.structs
+ goog.structs.AvlTree
+ goog.structs.CircularBuffer
+ goog.structs.Heap
+ goog.structs.InversionMap
+ goog.structs.LinkedMap
+ goog.structs.Map
+ goog.structs.Node
+ goog.structs.Pool
+ goog.structs.PriorityPool
+ goog.structs.PriorityQueue
+ goog.structs.QuadTree
+ goog.structs.QuadTree.Node
+ goog.structs.QuadTree.Point
+ goog.structs.Queue
+ goog.structs.Set
+ goog.structs.SimplePool
+ goog.structs.StringSet
+ goog.structs.TreeNode
+ goog.structs.Trie
+ goog.text.LoremIpsum))
diff --git a/src/test/self/self_parity/test.cljs b/src/test/self/self_parity/test.cljs
index 81665904..dff0b5f8 100644
--- a/src/test/self/self_parity/test.cljs
+++ b/src/test/self/self_parity/test.cljs
@@ -16,12 +16,12 @@
ClojureScript compiler, and also running the resulting tests."}
self-parity.test
(:require [clojure.string :as string]
- [cljs.compiler :as comp]
- [cljs.nodejs :as nodejs]
- [cljs.js :as cljs]
- [cljs.tools.reader :as reader]
- [cljs.stacktrace :as st]
- [goog.object :as gobj]))
+ [cljs.compiler :as comp]
+ [cljs.nodejs :as nodejs]
+ [cljs.js :as cljs]
+ [cljs.tools.reader :as reader]
+ [cljs.stacktrace :as st]
+ [goog.object :as gobj]))
(def out-dir "builds/out-self-parity")
@@ -274,46 +274,46 @@
(eval-form st 'cljs.user
'(ns parity.core
(:require [cljs.test :refer-macros [run-tests]]
- [cljs.eval-test]
- [cljs.primitives-test]
- [cljs.destructuring-test]
- [cljs.new-new-test]
- [cljs.printing-test]
- [cljs.seqs-test]
- [cljs.collections-test]
- [cljs.hashing-test]
- [cljs.core-test :as core-test]
- [cljs.reader-test]
- [cljs.binding-test]
- #_[cljs.ns-test]
- [clojure.string-test]
- [clojure.data-test]
- [clojure.walk-test]
- [cljs.macro-test]
- [cljs.letfn-test]
- [foo.ns-shadow-test]
- [cljs.top-level]
- [cljs.reducers-test]
- [cljs.keyword-test]
- [cljs.import-test]
- [cljs.ns-test.foo]
- [cljs.pprint]
- [cljs.pprint-test]
- [cljs.spec-test]
- [cljs.spec.test-test]
- [cljs.clojure-alias-test]
- [cljs.hash-map-test]
- [cljs.map-entry-test]
- [cljs.set-equiv-test]
- [cljs.syntax-quote-test]
- [cljs.predicates-test]
- [cljs.test-test]
- [static.core-test]
- [cljs.recur-test]
- [cljs.array-access-test]
- [cljs.inference-test]
- [cljs.walk-test]
- [cljs.extend-to-native-test]))
+ [cljs.eval-test]
+ [cljs.primitives-test]
+ [cljs.destructuring-test]
+ [cljs.new-new-test]
+ [cljs.printing-test]
+ [cljs.seqs-test]
+ [cljs.collections-test]
+ [cljs.hashing-test]
+ [cljs.core-test :as core-test]
+ [cljs.reader-test]
+ [cljs.binding-test]
+ #_[cljs.ns-test]
+ [clojure.string-test]
+ [clojure.data-test]
+ [clojure.walk-test]
+ [cljs.macro-test]
+ [cljs.letfn-test]
+ [foo.ns-shadow-test]
+ [cljs.top-level]
+ [cljs.reducers-test]
+ [cljs.keyword-test]
+ [cljs.import-test]
+ [cljs.ns-test.foo]
+ [cljs.pprint]
+ [cljs.pprint-test]
+ [cljs.spec-test]
+ [cljs.spec.test-test]
+ [cljs.clojure-alias-test]
+ [cljs.hash-map-test]
+ [cljs.map-entry-test]
+ [cljs.set-equiv-test]
+ [cljs.syntax-quote-test]
+ [cljs.predicates-test]
+ [cljs.test-test]
+ [static.core-test]
+ [cljs.recur-test]
+ [cljs.array-access-test]
+ [cljs.inference-test]
+ [cljs.walk-test]
+ [cljs.extend-to-native-test]))
(fn [{:keys [value error]}]
(if error
(handle-error error (:source-maps @st))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment