-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1702564
commit ed8e7f7
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(ns dev.onionpancakes.chassis.tests.test-compiler | ||
(:require [dev.onionpancakes.chassis.core :as c] | ||
[dev.onionpancakes.chassis.compiler :as cc] | ||
[clojure.test :refer [deftest are is]])) | ||
|
||
(def example-deref | ||
(delay "foobar")) | ||
|
||
(defn example-fn [] | ||
"foobar") | ||
|
||
(def example-attrs | ||
{:foo "bar"}) | ||
|
||
(defn example-elem-fn | ||
[arg] | ||
[:p arg]) | ||
|
||
(defmacro example-elem-macro | ||
[arg] | ||
[:p arg]) | ||
|
||
(defmethod c/resolve-alias ::Foo | ||
[_ _ attrs content] | ||
[:p.alias attrs content]) | ||
|
||
(deftest test-compile | ||
(are [node] (= (c/html (cc/compile node)) (c/html node)) | ||
nil | ||
0 | ||
0.0 | ||
"" | ||
"foobar" | ||
{} | ||
#{} | ||
'() | ||
[] | ||
[:div] | ||
[:div "foo"] | ||
[:div#foo "foo"] | ||
[:div.123 "foo"] | ||
[:div#foo.123 "foo"] | ||
[:div [:p 123] [:p 456]] | ||
[:div example-deref] | ||
[:div example-fn] | ||
[:div nil] | ||
[:div {:foo "bar"}] | ||
[:div {:foo "bar"} "baz"] | ||
[:div example-attrs] | ||
[:div (example-elem-fn "foo")] | ||
[:div (example-elem-macro "foo")] | ||
[:div (for [i (range 4)] | ||
[:p i])] | ||
(map inc (range 5)) | ||
[:div (map inc (range 5))] | ||
[:div nil (map inc (range 5))] | ||
[::Foo] | ||
[::Foo nil] | ||
[::Foo nil "foobar"] | ||
[::Foo nil "foo" [::Foo "bar"]])) |