Fix order of expected and actual
This commit is contained in:
parent
fb53f6aa05
commit
5518ead174
3 changed files with 59 additions and 62 deletions
|
@ -7,69 +7,68 @@
|
||||||
#:create-element))
|
#:create-element))
|
||||||
(in-package #:hsx-test/defhsx)
|
(in-package #:hsx-test/defhsx)
|
||||||
|
|
||||||
|
|
||||||
(def-suite defhsx-test)
|
(def-suite defhsx-test)
|
||||||
(in-suite defhsx-test)
|
(in-suite defhsx-test)
|
||||||
|
|
||||||
(test empty-hsx
|
(test empty-hsx
|
||||||
(is (equal (macroexpand-1
|
(is (equal '(create-element
|
||||||
'(div))
|
|
||||||
'(create-element
|
|
||||||
:div
|
:div
|
||||||
(list)))))
|
(list))
|
||||||
|
(macroexpand-1
|
||||||
|
'(div)))))
|
||||||
|
|
||||||
(test hsx-with-props
|
(test hsx-with-props
|
||||||
(is (equal (macroexpand-1
|
(is (equal '(create-element
|
||||||
'(div :prop1 "value1" :prop2 "value2"))
|
|
||||||
'(create-element
|
|
||||||
:div
|
:div
|
||||||
(list :prop1 "value1" :prop2 "value2")))))
|
(list :prop1 "value1" :prop2 "value2"))
|
||||||
|
(macroexpand-1
|
||||||
|
'(div :prop1 "value1" :prop2 "value2")))))
|
||||||
|
|
||||||
(test hsx-with-children
|
(test hsx-with-children
|
||||||
(is (equal (macroexpand-1
|
(is (equal '(create-element
|
||||||
'(div
|
|
||||||
"child1"
|
|
||||||
"child2"))
|
|
||||||
'(create-element
|
|
||||||
:div
|
:div
|
||||||
(list)
|
(list)
|
||||||
"child1"
|
"child1"
|
||||||
"child2"))))
|
"child2")
|
||||||
|
(macroexpand-1
|
||||||
|
'(div
|
||||||
|
"child1"
|
||||||
|
"child2")))))
|
||||||
|
|
||||||
(test hsx-with-props-and-children
|
(test hsx-with-props-and-children
|
||||||
(is (equal (macroexpand-1
|
(is (equal '(create-element
|
||||||
'(div :prop1 "value1" :prop2 "value2"
|
|
||||||
"child1"
|
|
||||||
"child2"))
|
|
||||||
'(create-element
|
|
||||||
:div
|
:div
|
||||||
(list :prop1 "value1" :prop2 "value2")
|
(list :prop1 "value1" :prop2 "value2")
|
||||||
"child1"
|
"child1"
|
||||||
"child2"))))
|
"child2")
|
||||||
|
(macroexpand-1
|
||||||
|
'(div :prop1 "value1" :prop2 "value2"
|
||||||
|
"child1"
|
||||||
|
"child2")))))
|
||||||
|
|
||||||
(deftag custom)
|
(deftag custom)
|
||||||
|
|
||||||
(test hsx-for-custom-tag
|
(test hsx-for-custom-tag
|
||||||
(is (equal (macroexpand-1
|
(is (equal '(create-element
|
||||||
'(custom :prop1 "value1" :prop2 "value2"
|
|
||||||
"child1"
|
|
||||||
"child2"))
|
|
||||||
'(create-element
|
|
||||||
:custom
|
:custom
|
||||||
(list :prop1 "value1" :prop2 "value2")
|
(list :prop1 "value1" :prop2 "value2")
|
||||||
"child1"
|
"child1"
|
||||||
"child2"))))
|
"child2")
|
||||||
|
(macroexpand-1
|
||||||
|
'(custom :prop1 "value1" :prop2 "value2"
|
||||||
|
"child1"
|
||||||
|
"child2")))))
|
||||||
|
|
||||||
(defcomp comp (&key prop1 prop2 children)
|
(defcomp comp (&key prop1 prop2 children)
|
||||||
(declare (ignore prop1 prop2 children)))
|
(declare (ignore prop1 prop2 children)))
|
||||||
|
|
||||||
(test hsx-for-component
|
(test hsx-for-component
|
||||||
(is (equal (macroexpand-1
|
(is (equal '(create-element
|
||||||
'(comp :prop1 "value1" :prop2 "value2"
|
|
||||||
"child1"
|
|
||||||
"child2"))
|
|
||||||
'(create-element
|
|
||||||
(fdefinition '%comp)
|
(fdefinition '%comp)
|
||||||
(list :prop1 "value1" :prop2 "value2")
|
(list :prop1 "value1" :prop2 "value2")
|
||||||
"child1"
|
"child1"
|
||||||
"child2"))))
|
"child2")
|
||||||
|
(macroexpand-1
|
||||||
|
'(comp :prop1 "value1" :prop2 "value2"
|
||||||
|
"child1"
|
||||||
|
"child2")))))
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#:hsx/element))
|
#:hsx/element))
|
||||||
(in-package #:hsx-test/element)
|
(in-package #:hsx-test/element)
|
||||||
|
|
||||||
|
|
||||||
(def-suite element-test)
|
(def-suite element-test)
|
||||||
(in-suite element-test)
|
(in-suite element-test)
|
||||||
|
|
||||||
|
@ -13,9 +12,9 @@
|
||||||
'(:class "red")
|
'(:class "red")
|
||||||
"Hello,"
|
"Hello,"
|
||||||
"World")))
|
"World")))
|
||||||
(is (eq (element-type elm) :p))
|
(is (eq :p (element-type elm)))
|
||||||
(is (equal (element-props elm) '(:class "red")))
|
(is (equal '(:class "red") (element-props elm)))
|
||||||
(is (equal (element-children elm) (list "Hello," "World")))))
|
(is (equal (list "Hello," "World") (element-children elm)))))
|
||||||
|
|
||||||
(test flatten-children
|
(test flatten-children
|
||||||
(let* ((elm (create-element :p
|
(let* ((elm (create-element :p
|
||||||
|
@ -24,7 +23,7 @@
|
||||||
nil
|
nil
|
||||||
(list "b" (list nil "c"))
|
(list "b" (list nil "c"))
|
||||||
(cons "d" "e"))))
|
(cons "d" "e"))))
|
||||||
(is (equal (element-children elm) (list "a" "b" "c" "d" "e")))))
|
(is (equal (list "a" "b" "c" "d" "e") (element-children elm)))))
|
||||||
|
|
||||||
(defun comp1 (&key title children)
|
(defun comp1 (&key title children)
|
||||||
(create-element :div
|
(create-element :div
|
||||||
|
@ -37,11 +36,11 @@
|
||||||
'(:title "foo")
|
'(:title "foo")
|
||||||
"bar"))
|
"bar"))
|
||||||
(expanded (expand-component elm)))
|
(expanded (expand-component elm)))
|
||||||
(is (eq (element-type elm) #'comp1))
|
(is (eq #'comp1 (element-type elm)))
|
||||||
(is (equal (element-props elm) '(:title "foo")))
|
(is (equal '(:title "foo") (element-props elm)))
|
||||||
(is (equal (element-children elm) (list "bar")))
|
(is (equal (list "bar") (element-children elm)))
|
||||||
(is (eq (element-type expanded) :div))
|
(is (eq :div (element-type expanded)))
|
||||||
(is (equal (element-children expanded) (list "foo" "bar")))))
|
(is (equal (list "foo" "bar") (element-children expanded)))))
|
||||||
|
|
||||||
(defun comp2 (&rest props)
|
(defun comp2 (&rest props)
|
||||||
(create-element :div
|
(create-element :div
|
||||||
|
@ -54,11 +53,11 @@
|
||||||
'(:title "foo")
|
'(:title "foo")
|
||||||
"bar"))
|
"bar"))
|
||||||
(expanded (expand-component elm)))
|
(expanded (expand-component elm)))
|
||||||
(is (eq (element-type elm) #'comp2))
|
(is (eq #'comp2 (element-type elm)))
|
||||||
(is (equal (element-props elm) '(:title "foo")))
|
(is (equal '(:title "foo") (element-props elm)))
|
||||||
(is (equal (element-children elm) (list "bar")))
|
(is (equal (list "bar") (element-children elm)))
|
||||||
(is (eq (element-type expanded) :div))
|
(is (eq :div (element-type expanded)))
|
||||||
(is (equal (element-children expanded) (list "foo" "bar")))))
|
(is (equal (list "foo" "bar") (element-children expanded)))))
|
||||||
|
|
||||||
(defun comp3 (&rest props &key title children &allow-other-keys)
|
(defun comp3 (&rest props &key title children &allow-other-keys)
|
||||||
(create-element :div
|
(create-element :div
|
||||||
|
@ -72,8 +71,8 @@
|
||||||
'(:title "foo" :other-key "baz")
|
'(:title "foo" :other-key "baz")
|
||||||
"bar"))
|
"bar"))
|
||||||
(expanded (expand-component elm)))
|
(expanded (expand-component elm)))
|
||||||
(is (eq (element-type elm) #'comp3))
|
(is (eq #'comp3 (element-type elm)))
|
||||||
(is (equal (element-props elm) '(:title "foo" :other-key "baz")))
|
(is (equal '(:title "foo" :other-key "baz") (element-props elm)))
|
||||||
(is (equal (element-children elm) (list "bar")))
|
(is (equal (list "bar") (element-children elm)))
|
||||||
(is (eq (element-type expanded) :div))
|
(is (eq :div (element-type expanded)))
|
||||||
(is (equal (element-children expanded) (list "foo" "bar" "baz")))))
|
(is (equal (list "foo" "bar" "baz") (element-children expanded)))))
|
||||||
|
|
|
@ -5,21 +5,20 @@
|
||||||
(:import-from #:hsx/builtin))
|
(:import-from #:hsx/builtin))
|
||||||
(in-package #:hsx-test/hsx)
|
(in-package #:hsx-test/hsx)
|
||||||
|
|
||||||
|
|
||||||
(def-suite hsx-test)
|
(def-suite hsx-test)
|
||||||
(in-suite hsx-test)
|
(in-suite hsx-test)
|
||||||
|
|
||||||
(test find-symbols
|
(test find-symbols
|
||||||
(is (equal (macroexpand-1
|
(is (equal '(hsx/builtin:div
|
||||||
|
div
|
||||||
|
(hsx/builtin:div
|
||||||
|
div
|
||||||
|
(hsx/builtin:div))
|
||||||
|
div)
|
||||||
|
(macroexpand-1
|
||||||
'(hsx (div
|
'(hsx (div
|
||||||
div
|
div
|
||||||
(div
|
(div
|
||||||
div
|
div
|
||||||
(div))
|
(div))
|
||||||
div)))
|
div))))))
|
||||||
'(hsx/builtin:div
|
|
||||||
div
|
|
||||||
(hsx/builtin:div
|
|
||||||
div
|
|
||||||
(hsx/builtin:div))
|
|
||||||
div))))
|
|
||||||
|
|
Loading…
Reference in a new issue