Skip to content

Commit

Permalink
Code cleanup, consistent ns usage, whitespace etc
Browse files Browse the repository at this point in the history
  • Loading branch information
senior committed May 22, 2012
1 parent 755647b commit 10c8f49
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/main/clojure/clojure/data/xml.clj
Expand Up @@ -73,7 +73,7 @@
(Comment. content))

;=== Parse-related functions ===
(defn- seq-tree
(defn seq-tree
"Takes a seq of events that logically represents
a tree by each event being one of: enter-sub-tree event,
exit-sub-tree event, or node event.
Expand Down Expand Up @@ -320,5 +320,5 @@
[e]
(let [^java.io.StringWriter sw (java.io.StringWriter.)]
(indent e sw)
(.toString sw)) )
(.toString sw)))

22 changes: 11 additions & 11 deletions src/test/clojure/clojure/data/xml/test_emit.clj
Expand Up @@ -8,9 +8,9 @@

(ns ^{:doc "Tests for emit to print XML text."
:author "Chris Houser"}
clojure.data.xml.test-emit
(:use [clojure.test :only [deftest is are]]
[clojure.data.xml :as xml :only [element cdata xml-comment]]
clojure.data.xml.test-emit
(:use clojure.test
clojure.data.xml
[clojure.data.xml.test-utils :only (test-stream lazy-parse*)]))

(def deep-tree
Expand All @@ -33,13 +33,13 @@
" t8<f>t10</f>t11</e>"
" t12<g>t13</g>t14"
"</a>")]
(is (= expect (xml/emit-str deep-tree)))))
(is (= expect (emit-str deep-tree)))))

(deftest mixed-quotes
(is (= (str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<mixed double=\"&quot;double&quot;quotes&quot;here&quot;\""
" single=\"'single'quotes'here\"></mixed>")
(xml/emit-str (element :mixed
(emit-str (element :mixed
{:single "'single'quotes'here"
:double "\"double\"quotes\"here\""})))))

Expand All @@ -49,7 +49,7 @@
(defn emit-char-seq [xml-tree encoding]
(with-open [bos (java.io.ByteArrayOutputStream.)
stream (java.io.OutputStreamWriter. bos encoding)]
(xml/emit xml-tree stream :encoding encoding)
(emit xml-tree stream :encoding encoding)
(.flush stream)
(map #(if (pos? %) (char %) %) (.toByteArray bos))))

Expand All @@ -67,18 +67,18 @@
(is (thrown? Exception
(let [stream (java.io.ByteArrayOutputStream.)]
(binding [*out* (java.io.OutputStreamWriter. stream "UTF-8")]
(xml/emit (element :foo) *out* :encoding "ISO-8859-1"))))))
(emit (element :foo) *out* :encoding "ISO-8859-1"))))))

(deftest emitting-cdata
(is (= (str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<cdata-stuff><![CDATA[<goes><here>]]></cdata-stuff>")
(xml/emit-str (element :cdata-stuff {}
(emit-str (element :cdata-stuff {}
(cdata "<goes><here>"))))) )

(deftest emitting-comment
(is (= (str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<comment-stuff>comment <!-- goes here --> not here</comment-stuff>")
(xml/emit-str (element :comment-stuff {}
(emit-str (element :comment-stuff {}
"comment "
(xml-comment " goes here ")
" not here")))) )
Expand All @@ -88,11 +88,11 @@
expect (str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a>\n "
"<b>\n <c>\n <d>foo</d>\n </c>\n </b>\n</a>\n")
sw (java.io.StringWriter.)]
(xml/indent nested-xml sw)
(indent nested-xml sw)
(is (= expect (.toString sw)))))

(deftest test-indent-str
(let [nested-xml (lazy-parse* (str "<a><b><c><d>foo</d></c></b></a>"))
expect (str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a>\n "
"<b>\n <c>\n <d>foo</d>\n </c>\n </b>\n</a>\n")]
(is (= expect (xml/indent-str nested-xml)))))
(is (= expect (indent-str nested-xml)))))
4 changes: 2 additions & 2 deletions src/test/clojure/clojure/data/xml/test_parse.clj
Expand Up @@ -9,8 +9,8 @@
(ns ^{:doc "Tests for XML parsing functions."
:author "Chris Houser"}
clojure.data.xml.test-parse
(:use [clojure.test :only [deftest is are]]
[clojure.data.xml :as xml :only [element cdata parse-str]]
(:use clojure.test
clojure.data.xml
[clojure.data.xml.test-utils :only [test-stream lazy-parse*]]))

(deftest simple
Expand Down
6 changes: 3 additions & 3 deletions src/test/clojure/clojure/data/xml/test_seq_tree.clj
Expand Up @@ -9,12 +9,12 @@
(ns ^{:doc "Tests for seq-tree, building a lazy tree from lazy seq."
:author "Chris Houser"}
clojure.data.xml.test-seq-tree
(:use [clojure.test :only [deftest is are]]
[clojure.data.xml :as xml :only []])
(:use clojure.test
clojure.data.xml)
(:import (java.lang.ref WeakReference)))

(def tt
(partial #'xml/seq-tree #(when (= %1 :<) (vector %2)) #{:>} str))
(partial #'seq-tree #(when (= %1 :<) (vector %2)) #{:>} str))

(deftest example
(is (= '(("1" "2" [("3" [("4")])] "5") 6)
Expand Down
6 changes: 3 additions & 3 deletions src/test/clojure/clojure/data/xml/test_sexp.clj
Expand Up @@ -9,10 +9,10 @@
(ns ^{:doc "Tests for reading [:tag {:attr 'value} body*] as XML."
:author "Alan Malloy"}
clojure.data.xml.test-sexp
(:use [clojure.test :only [deftest is are]]
[clojure.data.xml :as xml :only [sexp-as-element
sexps-as-fragment element]]
(:use clojure.test
clojure.data.xml
[clojure.data.xml.test-utils :only (test-stream lazy-parse*)]))

(deftest as-element
(let [xml-input "<tag attr=\"value\"><body /></tag>"
sexp-input [:tag {:attr "value"} :body]]
Expand Down

0 comments on commit 10c8f49

Please sign in to comment.