Skip to content

Commit 35ad08e

Browse files
lxsameerswannodette
authored andcommitted
CLJS-2166: Add uri? predicate
Clojure introduced a `uri?` predicate in 1.9. This commit adds support for `uri` to Clojurescript under `cljs.core/uri?`. It returns true if the given argument is an instance of `goog.Uri`, false otherwise.
1 parent 62e78a8 commit 35ad08e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
goog.math.Integer
1212
[goog.string :as gstring]
1313
[goog.object :as gobject]
14-
[goog.array :as garray])
14+
[goog.array :as garray]
15+
[goog.Uri])
1516
(:import [goog.string StringBuffer]))
1617

1718
;; next line is auto-generated by the build-script - Do not edit!
@@ -11166,3 +11167,9 @@ reduces them without incurring seq initialization"
1116611167
Bootstrap only."
1116711168
[ns-obj]
1116811169
(.-name ns-obj))
11170+
11171+
(defn uri?
11172+
"Returns true X is a goog.Uri instance."
11173+
{:added "1.9"}
11174+
[x]
11175+
(instance? goog.Uri x))

src/test/cljs/cljs/core_test.cljs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,3 +1492,13 @@
14921492
;; (assert (= (:arglists var-meta) '([a b]))))
14931493

14941494
)
1495+
1496+
(deftest uri-predicate
1497+
(testing "Testing uri?"
1498+
(is (not (uri? "http://clojurescript.org")))
1499+
(is (not (uri? 42)))
1500+
(is (not (uri? [])))
1501+
(is (not (uri? {})))
1502+
(is (uri? (goog.Uri. "")))
1503+
(is (uri? (goog.Uri. "http://clojurescript.org")))
1504+
(is (uri? (goog.Uri. "some string")))))

0 commit comments

Comments
 (0)