Permalink
Browse files

Return scheme as keyword.

  • Loading branch information...
1 parent a637fe3 commit 253f1523bb7064752825e70dd93dcc3f743d2674 @r0man committed Apr 12, 2013
Showing with 36 additions and 37 deletions.
  1. +3 −3 project.clj
  2. +5 −6 runners/phantomjs.js
  3. +1 −1 src/inflections/util.clj
  4. +1 −1 src/inflections/util.cljs
  5. +3 −3 test/inflections/test/util.clj
  6. +23 −23 test/inflections/test/util.cljs
View
@@ -5,12 +5,12 @@
:min-lein-version "2.0.0"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
- :dependencies [[org.clojure/clojure "1.5.0"]]
- :profiles {:dev {:dependencies [[com.cemerick/clojurescript.test "0.0.1"]]}}
+ :dependencies [[org.clojure/clojure "1.5.1"]]
+ :profiles {:dev {:dependencies [[com.cemerick/clojurescript.test "0.0.3"]]}}
:plugins [[lein-cljsbuild "0.3.0"]]
:hooks [leiningen.cljsbuild]
:cljsbuild {:builds [{:compiler {:output-to "target/inflections-test.js"
- :optimizations :whitespace
+ :optimizations :advanced
:pretty-print true}
:source-paths ["test"]}
{:compiler {:output-to "target/inflections-debug.js"
View
@@ -8,16 +8,15 @@ p.injectJs(require('system').args[1]);
p.onConsoleMessage = function (x) { console.log(x); };
p.evaluate(function () {
- // can't just assign console.log directly?
- cljs.core._STAR_print_fn_STAR_ = function (x) {
- x = x.replace(/\n/g, "");
- console.log(x);
- };
+ cemerick.cljs.test.set_print_fn_BANG_(function(x) {
+ x = x.replace(/\n/g, "");
+ console.log(x);
+ });
});
var success = p.evaluate(function () {
var results = cemerick.cljs.test.run_all_tests();
- cljs.core.println(results);
+ console.log(results);
return cemerick.cljs.test.successful_QMARK_(results);
});
View
@@ -62,7 +62,7 @@
"Parse `s` as a url and return a Ring compatible map."
[s]
(if-let [matches (re-matches #"([^:]+)://(([^:]+):([^@]+)@)?(([^:/]+)(:([0-9]+))?((/[^?]*)(\?(.*))?)?)" s)]
- {:scheme (nth matches 1)
+ {:scheme (keyword (nth matches 1))
:user (nth matches 3)
:password (nth matches 4)
:server-name (nth matches 6)
@@ -69,7 +69,7 @@
"Parse `s` as a url and return a Ring compatible map."
[s]
(if-let [matches (re-matches #"([^:]+)://(([^:]+):([^@]+)@)?(([^:/]+)(:([0-9]+))?((/[^?]*)(\?(.*))?)?)" s)]
- {:scheme (nth matches 1)
+ {:scheme (keyword (nth matches 1))
:user (nth matches 3)
:password (nth matches 4)
:server-name (nth matches 6)
@@ -68,11 +68,11 @@
(deftest test-parse-url
(let [spec (parse-url "postgresql://localhost/example")]
- (is (= "postgresql" (:scheme spec)))
+ (is (= :postgresql (:scheme spec)))
(is (= "localhost" (:server-name spec)))
(is (= "/example" (:uri spec))))
(let [spec (parse-url "postgresql://tiger:scotch@localhost:5432/example?a=1&b=2")]
- (is (= "postgresql" (:scheme spec)))
+ (is (= :postgresql (:scheme spec)))
(is (= "tiger" (:user spec)))
(is (= "scotch" (:password spec)))
(is (= "localhost" (:server-name spec)))
@@ -81,7 +81,7 @@
(is (= "a=1&b=2" (:query-string spec)))
(is (= {:a "1", :b "2"} (:params spec))))
(let [spec (parse-url "rabbitmq://tiger:scotch@localhost:5672")]
- (is (= "rabbitmq" (:scheme spec)))
+ (is (= :rabbitmq (:scheme spec)))
(is (= "tiger" (:user spec)))
(is (= "scotch" (:password spec)))
(is (= "localhost" (:server-name spec)))
@@ -67,26 +67,26 @@
;; (is (= {:latitude 1.0 :longitude -2.0} (parse-location "1.0,-2.0")))
;; (is (= {:latitude 1.0 :longitude -2.0} (parse-location "1.0 -2.0"))))
-;; (deftest test-parse-url
-;; (let [spec (parse-url "postgresql://localhost/example")]
-;; (is (= "postgresql" (:scheme spec)))
-;; (is (= "localhost" (:server-name spec)))
-;; (is (= "/example" (:uri spec))))
-;; (let [spec (parse-url "postgresql://tiger:scotch@localhost:5432/example?a=1&b=2")]
-;; (is (= "postgresql" (:scheme spec)))
-;; (is (= "tiger" (:user spec)))
-;; (is (= "scotch" (:password spec)))
-;; (is (= "localhost" (:server-name spec)))
-;; (is (= 5432 (:server-port spec)))
-;; (is (= "/example" (:uri spec)))
-;; (is (= "a=1&b=2" (:query-string spec)))
-;; (is (= {:a "1", :b "2"} (:params spec))))
-;; (let [spec (parse-url "rabbitmq://tiger:scotch@localhost:5672")]
-;; (is (= "rabbitmq" (:scheme spec)))
-;; (is (= "tiger" (:user spec)))
-;; (is (= "scotch" (:password spec)))
-;; (is (= "localhost" (:server-name spec)))
-;; (is (= 5672 (:server-port spec)))
-;; (is (nil? (:uri spec)))
-;; (is (nil? (:params spec)))
-;; (is (nil? (:query-string spec)))))
+(deftest test-parse-url
+ (let [spec (parse-url "postgresql://localhost/example")]
+ (is (= :postgresql (:scheme spec)))
+ (is (= "localhost" (:server-name spec)))
+ (is (= "/example" (:uri spec))))
+ (let [spec (parse-url "postgresql://tiger:scotch@localhost:5432/example?a=1&b=2")]
+ (is (= :postgresql (:scheme spec)))
+ (is (= "tiger" (:user spec)))
+ (is (= "scotch" (:password spec)))
+ (is (= "localhost" (:server-name spec)))
+ (is (= 5432 (:server-port spec)))
+ (is (= "/example" (:uri spec)))
+ (is (= "a=1&b=2" (:query-string spec)))
+ (is (= {:a "1", :b "2"} (:params spec))))
+ (let [spec (parse-url "rabbitmq://tiger:scotch@localhost:5672")]
+ (is (= :rabbitmq (:scheme spec)))
+ (is (= "tiger" (:user spec)))
+ (is (= "scotch" (:password spec)))
+ (is (= "localhost" (:server-name spec)))
+ (is (= 5672 (:server-port spec)))
+ (is (nil? (:uri spec)))
+ (is (nil? (:params spec)))
+ (is (nil? (:query-string spec)))))

0 comments on commit 253f152

Please sign in to comment.