urbit/lib/ph.hoon

94 lines
1.9 KiB
Plaintext
Raw Normal View History

2019-02-06 05:21:41 +03:00
::
:::: /hoon/ph/lib
::
/- aquarium
=, aquarium
|%
:: Defines a complete integration test.
::
:: Perhaps route should take a unix-effect rather than a sign.
:: Similarly, perhaps ++abet should produce a list of
:: unix-events. Also, perhaps we should support state.
::
:: Perhaps closer to this:
:: ++ test-core
:: $_ ^?
:: |%
:: ++ start ^?(..abet)
:: ++ route |~([wire unix-effect] ^?(..abet))
:: ++ abet *(list unix-event)
:: --
::
++ test-core
$_ ^?
|%
2019-02-09 00:34:24 +03:00
++ start *(trel (list ship) (list ph-event) _^?(..start))
2019-02-08 05:03:46 +03:00
++ route |~([ship unix-effect] *(list ph-event))
2019-02-06 05:21:41 +03:00
--
::
++ ph-event
$% [%test-done p=?]
aqua-event
==
::
++ send-events-to
|= [who=ship what=(list unix-event)]
^- (list ph-event)
%+ turn what
|= ovo=unix-event
[%event who ovo]
::
++ init
|= who=ship
^- (list ph-event)
[%init-ship who]~
::
:: factor out send-events-to
::
++ dojo
|= [who=ship what=tape]
^- (list ph-event)
%+ send-events-to who
^- (list unix-event)
:~
[//term/1 %belt %ctl `@c`%e]
[//term/1 %belt %ctl `@c`%u]
[//term/1 %belt %txt ((list @c) what)]
[//term/1 %belt %ret ~]
==
::
2019-02-09 02:21:40 +03:00
++ insert-file
|= [who=ship pax=path]
^- (list ph-event)
?> ?=([@ @ @ *] pax)
=/ file [/text/plain (as-octs:mimes:html .^(@ %cx pax))]
%+ send-events-to who
:~
[//sync/0v1n.2m9vh %into i.t.pax | [t.t.t.pax `file]~]
==
::
2019-02-09 06:18:38 +03:00
++ on-dojo-output
|= [who=ship her=ship ovo=unix-effect what=tape fun=$-($~ (list ph-event))]
2019-02-06 05:21:41 +03:00
^- (list ph-event)
2019-02-08 05:03:46 +03:00
?. =(who her)
2019-02-06 05:21:41 +03:00
~
2019-02-08 05:03:46 +03:00
?. ?=(%blit -.q.ovo)
~
?. %+ lien p.q.ovo
2019-02-06 05:21:41 +03:00
|= =blit:dill
?. ?=(%lin -.blit)
|
!=(~ (find what p.blit))
~
2019-02-09 06:18:38 +03:00
(fun)
::
++ expect-dojo-output
|= [who=ship her=ship ovo=unix-effect what=tape]
^- (list ph-event)
%- on-dojo-output
:^ who her ovo
:- what
|= ~
2019-02-06 05:21:41 +03:00
[%test-done &]~
--