From 6b9a8b5e6f5cbb839fdfc87f8328b568a99453c3 Mon Sep 17 00:00:00 2001 From: Stuart Sierra Date: Tue, 15 Jun 2010 09:46:07 -0400 Subject: Implement :connect-timeout and :read-timeout in http.agent --- src/main/clojure/clojure/contrib/http/agent.clj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/clojure/clojure/contrib/http/agent.clj b/src/main/clojure/clojure/contrib/http/agent.clj index edae6f96..937aadc0 100644 --- a/src/main/clojure/clojure/contrib/http/agent.clj +++ b/src/main/clojure/clojure/contrib/http/agent.clj @@ -79,6 +79,10 @@ "Sets the instance method, redirect behavior, and request headers of the HttpURLConnection." [#^HttpURLConnection conn options] + (when-let [t (:connect-timeout options)] + (.setConnectTimeout conn t)) + (when-let [t (:read-timeout options)] + (.setReadTimeout conn t)) (.setRequestMethod conn (:method options)) (.setInstanceFollowRedirects conn (:follow-redirects options)) (doseq [[name value] (:headers options)] -- cgit v1.2.3-18-g5258 From aaa2f33f451953de58ade056bda5c8e40d5b6459 Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Tue, 15 Jun 2010 10:52:23 -0400 Subject: move tests into range of long --- src/test/clojure/clojure/contrib/test_math.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/clojure/clojure/contrib/test_math.clj b/src/test/clojure/clojure/contrib/test_math.clj index d7c6eaea..3b2f4e8a 100644 --- a/src/test/clojure/clojure/contrib/test_math.clj +++ b/src/test/clojure/clojure/contrib/test_math.clj @@ -5,7 +5,7 @@ (deftest test-expt (are [x y] (= x y) (expt 2 3) 8 - (expt (expt 2 32) 2) (expt 2 64) + (expt (expt 2 16) 2) (expt 2 32) (expt 4/3 2) 16/9 (expt 2 -10) 1/1024 (expt 0.5M 2) 0.25M @@ -114,5 +114,5 @@ (deftest test-exact-integer-sqrt (are [x y] (= x y) (exact-integer-sqrt 15) [3 6] - (exact-integer-sqrt (inc (expt 2 64))) [(expt 2 32) 1] + (exact-integer-sqrt (inc (expt 2 32))) [(expt 2 16) 1] (exact-integer-sqrt 1000000000000) [1000000 0])) -- cgit v1.2.3-18-g5258 From 1068a8045a6d75bb589fee885cc3a86f8d977c0c Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Tue, 15 Jun 2010 22:51:09 -0400 Subject: change from prim coercion to boxed coercion in order to see particular boxed type --- src/test/clojure/clojure/contrib/test_jmx.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/clojure/clojure/contrib/test_jmx.clj b/src/test/clojure/clojure/contrib/test_jmx.clj index dcfc9321..ee34916a 100644 --- a/src/test/clojure/clojure/contrib/test_jmx.clj +++ b/src/test/clojure/clojure/contrib/test_jmx.clj @@ -175,4 +175,4 @@ "int" 10 "boolean" false "java.lang.String" "foo" - "long" (long 10))) + "long" (Long/valueOf 10))) -- cgit v1.2.3-18-g5258 From 9f9b78ab6d536dbba4ae40eb0d6c5cdbfe843c5d Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Tue, 15 Jun 2010 22:58:11 -0400 Subject: prefer quot over unchecked-divide --- src/main/clojure/clojure/contrib/http/agent.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/clojure/clojure/contrib/http/agent.clj b/src/main/clojure/clojure/contrib/http/agent.clj index 937aadc0..cd257bb7 100644 --- a/src/main/clojure/clojure/contrib/http/agent.clj +++ b/src/main/clojure/clojure/contrib/http/agent.clj @@ -99,7 +99,7 @@ (defn- connection-success? [#^HttpURLConnection conn] "Returns true if the HttpURLConnection response code is in the 2xx range." - (= 2 (unchecked-divide (.getResponseCode conn) 100))) + (= 2 (quot (.getResponseCode conn) 100))) (defn- open-response "Agent action that opens the response body stream on the HTTP @@ -137,7 +137,7 @@ "Returns true if the response status of the HTTP agent begins with digit, an Integer." [digit http-agnt] - (= digit (unchecked-divide (.getResponseCode + (= digit (quot (.getResponseCode #^HttpURLConnection (::connection @http-agnt)) 100))) -- cgit v1.2.3-18-g5258 From 48c1e45a7d950fc7ac33c5b6843f291717a1b8ae Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Thu, 17 Jun 2010 09:58:15 -0400 Subject: fix for num compat --- src/main/clojure/clojure/contrib/pprint/cl_format.clj | 6 +++--- src/test/clojure/clojure/contrib/test_complex_numbers.clj | 2 +- src/test/clojure/clojure/contrib/test_math.clj | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/clojure/clojure/contrib/pprint/cl_format.clj b/src/main/clojure/clojure/contrib/pprint/cl_format.clj index 292f7f86..f6e988ca 100644 --- a/src/main/clojure/clojure/contrib/pprint/cl_format.clj +++ b/src/main/clojure/clojure/contrib/pprint/cl_format.clj @@ -423,9 +423,9 @@ Note this should only be used for the last one in the sequence" not-teens (or (< 11 low-two-digits) (> 19 low-two-digits)) low-digit (rem low-two-digits 10)] (print (cond - (and (= low-digit 1) not-teens) "st" - (and (= low-digit 2) not-teens) "nd" - (and (= low-digit 3) not-teens) "rd" + (and (== low-digit 1) not-teens) "st" + (and (== low-digit 2) not-teens) "nd" + (and (== low-digit 3) not-teens) "rd" :else "th"))))))) navigator)) diff --git a/src/test/clojure/clojure/contrib/test_complex_numbers.clj b/src/test/clojure/clojure/contrib/test_complex_numbers.clj index 4b0173fe..008e6ec7 100644 --- a/src/test/clojure/clojure/contrib/test_complex_numbers.clj +++ b/src/test/clojure/clojure/contrib/test_complex_numbers.clj @@ -237,7 +237,7 @@ (is (= (/ (complex 1 2) 3) (complex 1/3 2/3))) (is (= (/ 3 (complex -3 -7)) (complex -9/58 21/58))) (is (= (/ (complex -3 -7) 3) (complex -1 -7/3))) - (is (= (/ 3 (imaginary -2)) (imaginary 1.5))) + #_(is (= (/ 3 (imaginary -2)) (imaginary 1.5))) (is (= (/ (imaginary -2) 3) (imaginary -2/3))) (is (= (/ 3 (imaginary 5)) (imaginary -3/5))) (is (= (/ (imaginary 5) 3) (imaginary 5/3))) diff --git a/src/test/clojure/clojure/contrib/test_math.clj b/src/test/clojure/clojure/contrib/test_math.clj index 3b2f4e8a..4b58d807 100644 --- a/src/test/clojure/clojure/contrib/test_math.clj +++ b/src/test/clojure/clojure/contrib/test_math.clj @@ -54,7 +54,7 @@ (is (thrown? IllegalArgumentException (lcm 7.0 0)))) (deftest test-floor - (are [x y] (= x y) + (are [x y] (== x y) (floor 6) 6 (floor -6) -6 (floor 123456789123456789) 123456789123456789 @@ -67,7 +67,7 @@ (floor -4.3) -5.0)) (deftest test-ceil - (are [x y] (= x y) + (are [x y] (== x y) (ceil 6) 6 (ceil -6) -6 (ceil 123456789123456789) 123456789123456789 @@ -80,7 +80,7 @@ (ceil -4.3) -4.0)) (deftest test-round - (are [x y] (= x y) + (are [x y] (== x y) (round 6) 6 (round -6) -6 (round 123456789123456789) 123456789123456789 -- cgit v1.2.3-18-g5258 From d971ab4977e6c5a3cd565c2f68bfffa33439a961 Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Fri, 18 Jun 2010 12:17:09 -0400 Subject: added needed cast for jmx test --- src/test/clojure/clojure/contrib/test_jmx.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/clojure/clojure/contrib/test_jmx.clj b/src/test/clojure/clojure/contrib/test_jmx.clj index ee34916a..894fe158 100644 --- a/src/test/clojure/clojure/contrib/test_jmx.clj +++ b/src/test/clojure/clojure/contrib/test_jmx.clj @@ -175,4 +175,4 @@ "int" 10 "boolean" false "java.lang.String" "foo" - "long" (Long/valueOf 10))) + "long" (Long/valueOf (long 10)))) -- cgit v1.2.3-18-g5258 From b71e3d733b8c590eb3b0b9e8d555de4f1311a9ad Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Fri, 18 Jun 2010 22:42:11 -0400 Subject: make loop/recur match for num compat --- src/main/clojure/clojure/contrib/math.clj | 2 +- src/main/clojure/clojure/contrib/pprint/cl_format.clj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/clojure/clojure/contrib/math.clj b/src/main/clojure/clojure/contrib/math.clj index cef32bf2..56007c71 100644 --- a/src/main/clojure/clojure/contrib/math.clj +++ b/src/main/clojure/clojure/contrib/math.clj @@ -104,7 +104,7 @@ Returns an exact number if the base is an exact number and the power is an integ expt (fn [x y] [(class x) (class y)])) (defn- expt-int [base pow] - (loop [n pow, y 1, z base] + (loop [n pow, y (num 1), z base] (let [t (bit-and n 1), n (bit-shift-right n 1)] (cond (zero? t) (recur n y (* z z)) diff --git a/src/main/clojure/clojure/contrib/pprint/cl_format.clj b/src/main/clojure/clojure/contrib/pprint/cl_format.clj index f6e988ca..a7aeca30 100644 --- a/src/main/clojure/clojure/contrib/pprint/cl_format.clj +++ b/src/main/clojure/clojure/contrib/pprint/cl_format.clj @@ -834,7 +834,7 @@ Note this should only be used for the last one in the sequence" args (init-navigator arg-list)] (loop [count 0 args args - last-pos -1] + last-pos (num -1)] (if (and (not max-count) (= (:pos args) last-pos) (> count 1)) ;; TODO get the offset in here and call format exception (throw (RuntimeException. "%{ construct not consuming any arguments: Infinite loop!"))) @@ -880,7 +880,7 @@ Note this should only be used for the last one in the sequence" [param-clause navigator])] (loop [count 0 navigator navigator - last-pos -1] + last-pos (num -1)] (if (and (not max-count) (= (:pos navigator) last-pos) (> count 1)) ;; TODO get the offset in here and call format exception (throw (RuntimeException. "%@{ construct not consuming any arguments: Infinite loop!"))) -- cgit v1.2.3-18-g5258 From bb711051c1c5aaa8d034fc10ec7eb41d04e797ad Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Wed, 23 Jun 2010 20:07:42 -0400 Subject: fixes for equiv compat --- src/main/clojure/clojure/contrib/pprint/column_writer.clj | 2 ++ src/main/clojure/clojure/contrib/pprint/pretty_writer.clj | 2 ++ src/test/clojure/clojure/contrib/test_jmx.clj | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/clojure/clojure/contrib/pprint/column_writer.clj b/src/main/clojure/clojure/contrib/pprint/column_writer.clj index 65b94904..63718e29 100644 --- a/src/main/clojure/clojure/contrib/pprint/column_writer.clj +++ b/src/main/clojure/clojure/contrib/pprint/column_writer.clj @@ -75,4 +75,6 @@ (.write #^Writer (get-field this :base) s)) Integer + (write-char this x) + Long (write-char this x)))))))) diff --git a/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj b/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj index ba9c78de..91a1bcca 100644 --- a/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj +++ b/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj @@ -402,6 +402,8 @@ (add-to-buffer this (make-buffer-blob s white-space oldpos newpos)))))) Integer + (write-char this x) + Long (write-char this x)))) (flush [] diff --git a/src/test/clojure/clojure/contrib/test_jmx.clj b/src/test/clojure/clojure/contrib/test_jmx.clj index 894fe158..7420316a 100644 --- a/src/test/clojure/clojure/contrib/test_jmx.clj +++ b/src/test/clojure/clojure/contrib/test_jmx.clj @@ -61,12 +61,12 @@ (are [a b] (= a b) false (jmx/raw-read mem :Verbose)) (are [type attr] (instance? type attr) - Integer (jmx/raw-read mem :ObjectPendingFinalizationCount))))) + Number (jmx/raw-read mem :ObjectPendingFinalizationCount))))) (deftest reading-attributes (testing "simple scalar attributes" (are [type attr] (instance? type attr) - Integer (jmx/read "java.lang:type=Memory" :ObjectPendingFinalizationCount))) + Number (jmx/read "java.lang:type=Memory" :ObjectPendingFinalizationCount))) (testing "composite attributes" (are [ks attr] (=set ks (keys attr)) [:used :max :init :committed] (jmx/read "java.lang:type=Memory" :HeapMemoryUsage))) @@ -172,7 +172,7 @@ (deftest test-guess-attribute-typename (are [x y] (= x (jmx/guess-attribute-typename y)) - "int" 10 +; "long" 10 "boolean" false "java.lang.String" "foo" "long" (Long/valueOf (long 10)))) -- cgit v1.2.3-18-g5258 From 29b42bdfec1726976d5c1125d10ee0d811d197ff Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Fri, 25 Jun 2010 13:03:30 -0400 Subject: fixes for equiv compat --- src/main/clojure/clojure/contrib/pprint/cl_format.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/clojure/clojure/contrib/pprint/cl_format.clj b/src/main/clojure/clojure/contrib/pprint/cl_format.clj index a7aeca30..b93d535a 100644 --- a/src/main/clojure/clojure/contrib/pprint/cl_format.clj +++ b/src/main/clojure/clojure/contrib/pprint/cl_format.clj @@ -245,7 +245,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm for improved performance" [base val] (let [format-str (get java-base-formats base)] - (if (and format-str (integer? val)) + (if (and format-str (integer? val) (-> val class .getName (.startsWith "java."))) (clojure.core/format format-str val) (base-str base val)))) -- cgit v1.2.3-18-g5258