Skip to content

Commit

Permalink
Code reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
luontola committed Dec 3, 2023
1 parent 8fe1b26 commit 71ed868
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
39 changes: 26 additions & 13 deletions test/hiccup2/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,17 @@

(deftest runtime-attributes-vs-content-detection-for-void-elements
(testing "runtime attributes present"
(is (= (str (html {:mode :xhtml} [:br (identity {:id 1})])) "<br id=\"1\" />"))
(is (= (str (html {:mode :html} [:br (identity {:id 1})])) "<br id=\"1\">"))
(is (= (str (html {:mode :xml} [:br (identity {:id 1})])) "<br id=\"1\" />"))
(is (= (str (html {:mode :sgml} [:br (identity {:id 1})])) "<br id=\"1\">")))
(is (= (str (html {:mode :xhtml} [:br (identity {:id 1})]))
"<br id=\"1\" />"))
(is (= (str (html {:mode :html} [:br (identity {:id 1})]))
"<br id=\"1\">"))
(is (= (str (html {:mode :xml} [:br (identity {:id 1})]))
"<br id=\"1\" />"))
(is (= (str (html {:mode :sgml} [:br (identity {:id 1})]))
"<br id=\"1\">")))
(testing "runtime content present"
;; it's not valid HTML to have content inside void elements, but Hiccup should still obey what the user told it to do
;; It's not valid HTML to have content inside void elements,
;; but Hiccup should still obey what the user told it to do.
(is (= (str (html {:mode :xhtml} [:br (identity "x")])) "<br>x</br>"))
(is (= (str (html {:mode :html} [:br (identity "x")])) "<br>x</br>"))
(is (= (str (html {:mode :xml} [:br (identity "x")])) "<br>x</br>"))
Expand Down Expand Up @@ -250,12 +255,20 @@
(is (= (str (html {:mode :xml} [(identity :br)])) "<br />"))
(is (= (str (html {:mode :sgml} [(identity :br)])) "<br>")))
(testing "runtime tag and content"
(is (= (str (html {:mode :xhtml} [(identity :p) (identity "x")])) "<p>x</p>"))
(is (= (str (html {:mode :html} [(identity :p) (identity "x")])) "<p>x</p>"))
(is (= (str (html {:mode :xml} [(identity :p) (identity "x")])) "<p>x</p>"))
(is (= (str (html {:mode :sgml} [(identity :p) (identity "x")])) "<p>x</p>")))
(is (= (str (html {:mode :xhtml} [(identity :p) (identity "x")]))
"<p>x</p>"))
(is (= (str (html {:mode :html} [(identity :p) (identity "x")]))
"<p>x</p>"))
(is (= (str (html {:mode :xml} [(identity :p) (identity "x")]))
"<p>x</p>"))
(is (= (str (html {:mode :sgml} [(identity :p) (identity "x")]))
"<p>x</p>")))
(testing "runtime tag and attributes"
(is (= (str (html {:mode :xhtml} [(identity :p) (identity {:id 1})])) "<p id=\"1\"></p>"))
(is (= (str (html {:mode :html} [(identity :p) (identity {:id 1})])) "<p id=\"1\"></p>"))
(is (= (str (html {:mode :xml} [(identity :p) (identity {:id 1})])) "<p id=\"1\" />"))
(is (= (str (html {:mode :sgml} [(identity :p) (identity {:id 1})])) "<p id=\"1\">"))))
(is (= (str (html {:mode :xhtml} [(identity :p) (identity {:id 1})]))
"<p id=\"1\"></p>"))
(is (= (str (html {:mode :html} [(identity :p) (identity {:id 1})]))
"<p id=\"1\"></p>"))
(is (= (str (html {:mode :xml} [(identity :p) (identity {:id 1})]))
"<p id=\"1\" />"))
(is (= (str (html {:mode :sgml} [(identity :p) (identity {:id 1})]))
"<p id=\"1\">"))))
9 changes: 5 additions & 4 deletions test/hiccup2/optimizations_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
(count (filter seq? (tree-seq coll? seq data))))

(deftest method-code-size
;; With Hiccup 2.0.0-RC2, it was easy to cause the hiccup2.core/html macro to generate so much bytecode
;; that it would go over the 64KB limit of how much bytecode one Java method may contain. It would crash
;; the Clojure compiler with a "Method code too large!" exception. These are a regression tests for that.
;; See https://github.com/weavejester/hiccup/issues/205
;; With Hiccup 2.0.0-RC2, it was easy to cause the hiccup2.core/html macro to
;; generate so much bytecode that it would go over the 64KB limit of how much
;; bytecode one Java method may contain. It would crash the Clojure compiler
;; with a "Method code too large!" exception. These are a regression tests for
;; that. See https://github.com/weavejester/hiccup/issues/205

(testing "static elements should be concatenated to one string, also when they have dynamic sibling elements"
(let [baseline (walk/macroexpand-all
Expand Down

0 comments on commit 71ed868

Please sign in to comment.