Commits

Meikel Brandmeyer committed aabeed6

Use integer? for number dispatch upon writing

  • Participants
  • Parent commits eeb2c8f
  • Branches next

Comments (0)

Files changed (2)

File src/main/clojure/clojure/tools/nrepl/bencode.clj

     (cond
       (instance? (RT/classForName "[B") thing) :bytes
       (instance? InputStream thing) :input-stream
-      (string? thing) :string
-      (map? thing)    :map
+      (integer? thing) :integer
+      (string? thing)  :string
+      (map? thing)     :map
       ;; Check for various sequency things. Yes. This is tedious. But as long
       ;; as we don't have a Seqable protocol, we can't do much about it.
       (or (vector? thing)
           (list? thing)
           (seq? thing)
           (.isArray (class thing)))
-      :list
-      ;; Similar for the numbers.
-      (or (instance? Byte thing)
-          (instance? Short thing)
-          (instance? Integer thing)
-          (instance? Long thing))
-      :integer)))
+      :list)))
 
 ;; The following methods should be pretty straight-forward.
 ;;

File src/test/clojure/clojure/tools/nrepl/bencode_test.clj

     -42 "i-42e"
 
     ; Works for all integral types.
+    ; Note: BigInts (42N) not tested, since they are not
+    ; supported in 1.2.
     (Byte. "42")    "i42e"
     (Short. "42")   "i42e"
     (Integer. "42") "i42e"