tests: test galls can now load %sub and %pub agents

This commit is contained in:
Ted Blackman 2022-08-19 02:46:04 +03:00
parent c48c2f4b6a
commit 317f03e337
4 changed files with 121 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/+ *test
/+ *test, test-pub, test-sub
/= ames /sys/vane/ames
/= gall-raw /sys/vane/gall
::
@ -8,12 +8,16 @@
++ gall-gate _(make-gall ~zod)
++ nec-bud
=/ a ames-nec-bud
:* nec=[ames=nec.a gall=(make-gall ~nec)]
bud=[ames=bud.a gall=(make-gall ~bud)]
=/ gall-nec (make-gall ~nec)
=. gall-nec (load-agent ~nec gall-nec %sub test-sub)
=/ gall-bud (make-gall ~bud)
=. gall-bud (load-agent ~bud gall-bud %pub test-pub)
:* nec=[ames=nec.a gall=gall-nec]
bud=[ames=bud.a gall=gall-bud]
==
:: +gall-call: have %gall run a +task and assert it produces expected-moves
:: +gall-check-call: run gall task, assert produces expected-moves
::
++ gall-call
++ gall-check-call
|= $: =gall-gate
now=@da
scry=roof
@ -34,6 +38,16 @@
::
[output +.res]
::
++ gall-call
|= [=gall-gate =duct task=(hobo task:gall) =roof]
%. [duct dud=~ task]
call:(gall-gate now=~1111.1.1 eny=`@`0xdead.beef roof)
::
++ gall-take
|= [=gall-gate =wire =duct =sign-arvo =roof]
%. [wire duct dud=~ sign-arvo]
take:(gall-gate now=~1111.1.1 eny=`@`0xdead.beef roof)
::
++ ames-nec-bud
:: create ~nec
::
@ -100,4 +114,21 @@
=/ gall-core (gall-pupa now=~1111.1.1 eny=`@`0xdead.beef scry=*roof)
=+ [out adult]=(call:gall-core duct=~[/init] dud=~ task=[%init ~])
adult
::
++ load-agent
|= [=ship =gall-gate =dude:gall =agent:gall]
=^ * gall-gate
(gall-call gall-gate ~[/jolt] [%jolt %base dude] *roof)
=^ * gall-gate
=/ =sign-arvo
:+ %clay %writ
`[[%a da+~1111.1.1 %base] /app/[dude]/hoon vase+!>(!>(agent))]
%: gall-take
gall-gate
/sys/cor/[dude]/(scot %p ship)/base/(scot %da ~1111.1.1)
~[/jolt]
sign-arvo
*roof
==
gall-gate
--

View File

@ -0,0 +1,38 @@
/+ default-agent, verb, dbug
::
=| state=~
%- agent:dbug
%+ verb &
^- agent:gall
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
::
++ on-poke
|= [=mark =vase]
(on-poke:def +<)
::
++ on-watch
|= =path
~& pub-watch+path
(on-watch:def +<)
::
++ on-agent
|= [=wire =sign:agent:gall]
(on-agent:def +<)
::
++ on-fail
|= [=term =tang]
(mean ':pub +on-fail' term tang)
::
++ on-leave
|= =path
~& pub-leave+path
`this
::
++ on-init `this
++ on-save !>(state)
++ on-load |=(old=vase `this(state !<(_state old)))
++ on-arvo on-arvo:def
++ on-peek on-peek:def
--

View File

@ -0,0 +1,46 @@
/+ default-agent, verb, dbug
::
=| state=~
%- agent:dbug
%+ verb &
^- agent:gall
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
::
++ on-poke
|= [=mark =vase]
?+ mark !!
%leave [[%pass /sub %agent [our.bowl %pub] %leave ~]~ this]
%watch [[%pass /sub %agent [our.bowl %pub] %watch /foo]~ this]
==
::
++ on-watch
|= =path
(on-watch:def +<)
::
++ on-agent
|= [=wire =sign:agent:gall]
?. =(/foo wire)
~| wire+wire !!
~& sub+-.sign
?+ -.sign !!
%kick [[%pass /sub %agent [our.bowl %pub] %watch /foo]~ this]
%fact `this
%watch-ack `this
==
::
++ on-fail
|= [=term =tang]
(mean ':sub +on-fail' term tang)
::
++ on-leave
|= =path
`this
::
++ on-init ~& %sub-on-init `this
++ on-save !>(state)
++ on-load |=(old=vase `this(state !<(_state old)))
++ on-arvo on-arvo:def
++ on-peek on-peek:def
--

View File

@ -2,7 +2,7 @@
::
/+ *test, vane-test
|%
++ test-nec-bud
++ test-setup-nec-bud
=+ nec-bud:vane-test
;: weld
%+ expect-eq