shrub/pkg/arvo/tests/lib/dprint.hoon

384 lines
7.9 KiB
Plaintext
Raw Normal View History

2022-05-09 21:57:43 +03:00
:: This library contains unit tests for doccords.
::
/+ *test, *dprint
::
2022-05-09 23:01:32 +03:00
=> =>
:: This core is for testing core and chapter docs.
:> core-summary
:>
:> core-description
|% %core-test
2022-05-09 23:45:16 +03:00
:> chapter-summary
:>
:> chapter-description
+| %chapter-test
2022-05-09 23:01:32 +03:00
++ empty ~
--
::
2022-05-09 21:57:43 +03:00
:> arms used for testing arm documentation
|% %test-arms
2022-05-09 21:57:43 +03:00
+| %types
+$ arm-dox [tape what what what]
2022-05-09 23:01:32 +03:00
+$ core-dox [tape what]
2022-05-09 23:45:16 +03:00
+$ chapter-dox [tape what]
2022-05-09 21:57:43 +03:00
::
+| %helper-functions
++ get-item
|= a=(list term)
^- item
+:(find-item-in-type a -:!>(.) %.y)
::
++ get-arm-dox
|= a=(list term)
^- arm-dox
=/ itm=item (get-item a)
?> ?=([%arm *] itm)
[name adoc pdoc cdoc]:itm
::
2022-05-09 23:01:32 +03:00
++ get-core-dox
|= a=(list term)
^- core-dox
=/ itm=item (get-item a)
?> ?=([%core *] itm)
[name docs]:itm
::
2022-05-09 23:45:16 +03:00
++ get-chapter-dox
|= a=(list term)
^- chapter-dox
=/ itm=item (get-item a)
?> ?=([%chapter *] itm)
[name docs]:itm
::
2022-05-09 21:57:43 +03:00
+| %docs-for-arms
++ no-doc ~
::
:> arm-doc
++ arm-adoc-pre ~
::
++ arm-adoc-post :< arm-doc
~
::
++ arm-pdoc-pre
:> product-doc
'foo'
++ arm-pdoc-post
'foo' :< product-doc
::
++ arm-cdoc-pre
|%
:> core-doc
++ $ ~
--
::
++ arm-cdoc-post
|%
++ $ :< core-doc
~
--
::
:> arm-doc
++ arm-adoc-pdoc-pre-pre
:> product-doc
'foo'
::
++ arm-adoc-pdoc-post-pre :< arm-doc
:> product-doc
'foo'
::
++ arm-adoc-pdoc-post-post :< arm-doc
'foo' :< product-doc
::
:> arm-doc
++ arm-adoc-cdoc-pre-pre
|%
:> core-doc
++ $ ~
--
::
++ arm-adoc-cdoc-post-pre :< arm-doc
|%
:> core-doc
++ $ ~
--
::
++ arm-adoc-cdoc-post-post :< arm-doc
|%
++ $ :< core-doc
~
--
::
++ arm-pdoc-cdoc-pre-pre
:> product-doc
|%
:> core-doc
++ $ ~
--
++ arm-pdoc-cdoc-post-pre
|%
:> core-doc
++ $ ~
-- :< product-doc
::
++ arm-pdoc-cdoc-post-post
|%
++ $ :< core-doc
~
-- :< product-doc
::
:> arm-doc
++ arm-adoc-pdoc-cdoc-pre-pre-pre
:> product-doc
|%
:> core-doc
++ $ ~
--
::
++ arm-adoc-pdoc-cdoc-post-pre-pre :< arm-doc
:> product-doc
|%
:> core-doc
++ $ ~
--
::
:> arm-doc
++ arm-adoc-pdoc-cdoc-pre-post-pre
|%
:> core-doc
++ $ ~
-- :< product-doc
::
:> arm-doc
++ arm-adoc-pdoc-cdoc-pre-pre-post
:> product-doc
|%
++ $ :< core-doc
~
--
::
++ arm-adoc-pdoc-cdoc-post-post-pre :< arm-doc
|%
:> core-doc
++ $ ~
-- :< product-doc
::
++ arm-adoc-pdoc-cdoc-post-pre-post :< arm-doc
:> product-doc
|%
++ $ :< core-doc
~
--
::
:> arm-doc
++ arm-adoc-pdoc-cdoc-pre-post-post
|%
++ $ :< core-doc
~
-- :< product-doc
::
++ arm-adoc-pdoc-cdoc-post-post-post :< arm-doc
|%
++ $ :< core-doc
~
-- :< product-doc
::
--
::
:> contains the actual tests to be run by -test
|% %dprint-tests
2022-05-09 21:57:43 +03:00
++ test-no-doc
%+ expect-eq
!> ^- arm-dox
["no-doc" *what *what *what]
::
!> (get-arm-dox ~[%no-doc])
2022-05-09 21:57:43 +03:00
::
++ test-adoc
;: weld
%+ expect-eq
!> ^- arm-dox
["arm-adoc-pre" `['arm-doc' ~] *what *what]
::
!> (get-arm-dox ~[%arm-adoc-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
["arm-adoc-post" `['arm-doc' ~] *what *what]
::
!> (get-arm-dox ~[%arm-adoc-post])
2022-05-09 21:57:43 +03:00
==
::
++ test-pdoc
;: weld
%+ expect-eq
!> ^- arm-dox
["arm-pdoc-pre" *what `['product-doc' ~] *what]
::
!> (get-arm-dox ~[%arm-pdoc-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
["arm-pdoc-post" *what `['product-doc' ~] *what]
::
!> (get-arm-dox ~[%arm-pdoc-post])
2022-05-09 21:57:43 +03:00
==
::
++ test-cdoc
;: weld
%+ expect-eq
!> ^- arm-dox
["arm-cdoc-pre" *what *what `['core-doc' ~]]
::
!> (get-arm-dox ~[%arm-cdoc-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
["arm-cdoc-post" *what *what `['core-doc' ~]]
::
!> (get-arm-dox ~[%arm-cdoc-post])
2022-05-09 21:57:43 +03:00
==
::
++ test-adoc-pdoc
;: weld
%+ expect-eq
!> ^- arm-dox
["arm-adoc-pdoc-pre-pre" `['arm-doc' ~] `['product-doc' ~] *what]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-pre-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
["arm-adoc-pdoc-post-pre" `['arm-doc' ~] `['product-doc' ~] *what]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-post-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
["arm-adoc-pdoc-post-post" `['arm-doc' ~] `['product-doc' ~] *what]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-post-post])
2022-05-09 21:57:43 +03:00
==
::
++ test-adoc-cdoc
;: weld
%+ expect-eq
!> ^- arm-dox
["arm-adoc-cdoc-pre-pre" `['arm-doc' ~] *what `['core-doc' ~]]
::
!> (get-arm-dox ~[%arm-adoc-cdoc-pre-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
["arm-adoc-cdoc-post-pre" `['arm-doc' ~] *what `['core-doc' ~]]
::
!> (get-arm-dox ~[%arm-adoc-cdoc-post-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
["arm-adoc-cdoc-post-post" `['arm-doc' ~] *what `['core-doc' ~]]
::
!> (get-arm-dox ~[%arm-adoc-cdoc-post-post])
2022-05-09 21:57:43 +03:00
==
::
++ test-pdoc-cdoc
;: weld
%+ expect-eq
!> ^- arm-dox
["arm-pdoc-cdoc-pre-pre" *what `['product-doc' ~] `['core-doc' ~]]
::
!> (get-arm-dox ~[%arm-pdoc-cdoc-pre-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
["arm-pdoc-cdoc-post-pre" *what `['product-doc' ~] `['core-doc' ~]]
::
!> (get-arm-dox ~[%arm-pdoc-cdoc-post-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
["arm-pdoc-cdoc-post-post" *what `['product-doc' ~] `['core-doc' ~]]
::
!> (get-arm-dox ~[%arm-pdoc-cdoc-post-post])
2022-05-09 21:57:43 +03:00
==
::
++ test-adoc-pdoc-cdoc
;: weld
%+ expect-eq
!> ^- arm-dox
:^ "arm-adoc-pdoc-cdoc-pre-pre-pre"
`['arm-doc' ~]
`['product-doc' ~]
`['core-doc' ~]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-cdoc-pre-pre-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
:^ "arm-adoc-pdoc-cdoc-post-pre-pre"
`['arm-doc' ~]
`['product-doc' ~]
`['core-doc' ~]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-cdoc-post-pre-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
:^ "arm-adoc-pdoc-cdoc-pre-post-pre"
`['arm-doc' ~]
`['product-doc' ~]
`['core-doc' ~]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-cdoc-pre-post-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
:^ "arm-adoc-pdoc-cdoc-pre-pre-post"
`['arm-doc' ~]
`['product-doc' ~]
`['core-doc' ~]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-cdoc-pre-pre-post])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
:^ "arm-adoc-pdoc-cdoc-post-post-pre"
`['arm-doc' ~]
`['product-doc' ~]
`['core-doc' ~]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-cdoc-post-post-pre])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
:^ "arm-adoc-pdoc-cdoc-post-pre-post"
`['arm-doc' ~]
`['product-doc' ~]
`['core-doc' ~]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-cdoc-post-pre-post])
2022-05-09 21:57:43 +03:00
::
%+ expect-eq
2022-05-09 21:57:43 +03:00
!> ^- arm-dox
:^ "arm-adoc-pdoc-cdoc-pre-post-post"
`['arm-doc' ~]
`['product-doc' ~]
`['core-doc' ~]
::
!> (get-arm-dox ~[%arm-adoc-pdoc-cdoc-pre-post-post])
2022-05-09 21:57:43 +03:00
==
2022-05-09 23:01:32 +03:00
::
++ test-core
%+ expect-eq
!> ^- core-dox
2022-05-09 23:45:16 +03:00
["core-test" `['core-summary' ~[~[[%.y 'core-description']]]]]
::
!> (get-core-dox ~[%core-test])
2022-05-09 23:45:16 +03:00
::
++ test-chapter
%+ expect-eq
!> ^- chapter-dox
["chapter-test" `['chapter-summary' ~[~[[%.y 'chapter-description']]]]]
::
!> (get-chapter-dox ~[%core-test %chapter-test])
2022-05-09 23:45:16 +03:00
::
2022-05-09 21:57:43 +03:00
--