%ride scry-succeed and scry-block tests pass

This commit is contained in:
Ted Blackman 2018-04-05 14:12:57 -07:00
parent cfc460d5b3
commit e58986fc73
2 changed files with 150 additions and 10 deletions

View File

@ -23,6 +23,8 @@
test-live-and-once
test-slim
test-ride
test-ride-scry-succeed
test-ride-scry-block
==
++ test-is-schematic-live
~& %test-is-schematic-live
@ -546,7 +548,7 @@
[%result [%slim (~(mint ut subject-type) [%noun formula])]]
== ==
::
++ test-ride !:
++ test-ride
~& %test-ride
::
=/ ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry-is-forbidden)
@ -578,10 +580,109 @@
==
::
%- expect-eq !>
~& [%here-goes &8:i.moves]
:- (~(nest ut &8:i.moves) | -:!>(*@))
&
::
++ test-ride-scry-succeed
~& %test-ride-scry-succeed
::
=/ scry-42 (scry-succeed ~1234.5.6 [%noun !>(42)])
=/ ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry-42)
::
=/ formula=hoon (ream '!: .^(* %cx /~nul/desk/~1234.5.6/foo/bar)')
=/ subject-schematic=schematic:ford [%$ %noun !>(.)]
::
=^ moves ford
%- call:ford
:* duct=~[/dead] type=~ %make ~nul
[%ride formula subject-schematic]
==
::
?> =(1 (lent moves))
?> ?=(^ moves)
?> ?=([* %give %made @da %complete %result %ride *] i.moves)
::
%+ welp
%- expect-eq !>
:: compare the move to the expected move, omitting type checking on vase
::
:: Types can't be compared using simple equality, so normalize the type
:: to check the rest of the move.
::
:- i.moves(&8 *type)
:* duct=~[/dead] %give %made ~1234.5.6 %complete
[%result [%ride *type 42]]
==
::
%- expect-eq !>
:- (~(nest ut &8:i.moves) | -:!>(*@))
&
::
++ test-ride-scry-block
~& %test-ride-scry-block
::
=/ scry-blocked (scry-block ~1234.5.6)
=/ ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry-blocked)
::
=/ formula=hoon (ream '!: .^(* %cx /~nul/desk/~1234.5.6/foo/bar)')
=/ subject-schematic=schematic:ford [%$ %noun !>(.)]
::
=^ moves ford
%- call:ford
:* duct=~[/live] type=~ %make ~nul
[%ride formula subject-schematic]
==
%+ welp
%- expect-eq !>
:- moves
:~ :* duct=~ %pass
wire=/~nul/dependency/cx/~nul/desk/0/foo/bar
%c %warp [~nul ~nul] %desk
~ %sing %x [%da ~1234.5.6] /bar/foo
== ==
::
=. ford (ford now=~1234.5.7 eny=0xbeef.dead scry=scry-blocked)
::
=^ moves2 ford
%- take:ford
:* wire=/~nul/dependency/cx/~nul/desk/0/foo/bar duct=~
^= wrapped-sign ^- (hypo sign:ford) :- *type :: ^- sign:ford
[%c %writ ~ [%x [%da ~1234.5.6] %desk] /bar/foo %noun !>(42)]
==
::
?> =(1 (lent moves2))
?> ?=(^ moves2)
?> ?=([* %give %made @da %complete %result %ride *] i.moves2)
::
%+ welp
%- expect-eq !>
:: compare the move to the expected move, omitting type checking on vase
::
:: Types can't be compared using simple equality, so normalize the type
:: to check the rest of the move.
::
:- i.moves2(&8 *type)
:* duct=~[/live] %give %made ~1234.5.6 %complete
[%result [%ride *type 42]]
==
::
%+ welp
%- expect-eq !>
:- (~(nest ut &8:i.moves2) | -:!>(*@))
&
::
=. ford (ford now=~1234.5.8 eny=0xbeef.dead scry=scry-is-forbidden)
=^ moves3 ford
(call:ford [duct=~[/live] type=~ %kill ~nul])
::
%+ welp
%- expect-eq !>
[moves3 ~]
::
%- expect-eq !>
:- state-by-ship.+>+<.ford
(my [~nul *ford-state:ford-turbo]~)
::
:: |utilities: helper arms
::
::+| utilities

View File

@ -901,6 +901,25 @@
--
=, format
|%
:: +build-to-tank: convert :build to a printable format
::
++ build-to-tank
|= =build
^- tank
::
=+ [date schematic]=build
::
:- %leaf
%+ weld (trip (scot %da date))
%+ weld " "
::
%- trip
?+ -.schematic
-.schematic
::
%$ %literal
^ %autocons
==
:: +unify-jugs: make a new jug, unifying sets for all keys
::
++ unify-jugs
@ -1753,7 +1772,7 @@
?> ?=([%result %slim *] u.slim-result)
::
=/ val
(mock [q.q.subject-cage nock.u.slim-result] (sloy ^scry))
(mock [q.q.subject-cage nock.u.slim-result] intercepted-scry)
:: val is a toon, which might be a list of blocks.
::
?- -.val
@ -1762,7 +1781,7 @@
[[%build-result %result %ride [type.u.slim-result p.val]] this]
::
%1
=/ blocked-paths=(list path) ((hard (list path)) +.p.val)
=/ blocked-paths=(list path) ((hard (list path)) p.val)
::
=/ blocks-or-failures=(list (each ^build tank))
%+ turn blocked-paths
@ -1810,6 +1829,12 @@
::
p.block
::
=. state
%+ roll blocks
|= [block=^build accumulator=_state]
=. state accumulator
+:(depend-on schematic.block)
::
[[%blocks blocks] this]
::
%2
@ -1965,13 +1990,15 @@
:: +intercepted-scry: use local results as a scry facade
::
++ intercepted-scry
::%- sloy ^- slyd
|= [[hoon-version=@ type=*] (unit (set monk)) =term =beam]
%- sloy ^- slyd
|= [ref=* (unit (set monk)) =term =beam]
^- (unit (unit (cask)))
:: TODO: is %151 ok?
?> ?=([@ *] ref)
=/ hoon-version=@ud -.ref
=/ type=type ((hard type) +.ref)
::
~| hoon-version=hoon-version
?> ?=(%143 hoon-version)
?> ?=(?(%143 %151) hoon-version)
::
=/ vane=(unit ?(%c %g)) ((soft ?(%c %g)) (end 3 1 term))
?~ vane
@ -1982,8 +2009,20 @@
::
=/ dependency=dependency
[u.vane u.care rail=[[p.beam q.beam] s.beam]]
:: TODO: handle other kinds of +case
::
=/ build=build [now %scry dependency]
=/ date=@da
~| bad-case+r.beam
?> ?=(%da -.r.beam)
p.r.beam
::
=/ build=build [date %scry dependency]
:: if the actual scry produces a value, use that value; otherwise use local
::
=/ scry-response (scry +<.$)
::
?^ scry-response
scry-response
:: look up the scry result from our permanent state
::
:: Note: we can't freshen this cache entry because we can't modify
@ -2002,7 +2041,7 @@
~& [%scry-nest-fail term=term beam=beam]
[~ ~]
::
``local-cage
[~ ~ `(cask)`local-cage]
:: +send-mades: send one %made move for :build per listener in :listeners
::
++ send-mades