Implement and test +slim.

This commit is contained in:
Elliot Glaysher 2018-04-02 16:17:27 -07:00
parent c02d374b88
commit 6dfecacb59
2 changed files with 64 additions and 4 deletions

View File

@ -21,6 +21,7 @@
test-pinned-in-live
test-live-build-that-blocks
test-live-and-once
test-slim
==
++ test-is-schematic-live
~& %test-is-schematic-live
@ -524,6 +525,26 @@
:- state-by-ship.+>+<.ford
(my [~nul *ford-state:ford-turbo]~)
::
++ test-slim
~& %test-slim
::
=/ formula=hoon (ream '(add 2 2)')
=/ subject-type=type -:!>(.)
::
=/ ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry-is-forbidden)
::
=^ moves ford
%- call:ford
:* duct=~[/dead] type=~ %make ~nul
[%slim subject-type formula]
==
::
%- expect-eq !>
:- moves
:~ :* duct=~[/dead] %give %made ~1234.5.6 %complete
[%result [%slim (~(mint ut subject-type) [%noun formula])]]
== ==
::
:: |utilities: helper arms
::
::+| utilities

View File

@ -1590,11 +1590,11 @@
::
|^ ?- -.schematic.build
::
^ (autocons head.schematic.build tail.schematic.build)
^ (autocons [head tail]:schematic.build)
::
%$ (literal literal.schematic.build)
::
%pin (pin date.schematic.build schematic.schematic.build)
%pin (pin [date schematic]:schematic.build)
%alts !!
%bake !!
%bunt !!
@ -1612,10 +1612,10 @@
%path !!
%plan !!
%reef !!
%ride !!
%ride (ride [formula subject]:schematic.build)
%same (same schematic.schematic.build)
%slit !!
%slim !!
%slim (slim [subject-type formula]:schematic.build)
%scry (scry dependency.schematic.build)
%vale !!
%volt !!
@ -1660,6 +1660,34 @@
[[%blocks [date schematic]~] this]
[[%build-result %result %pin date u.result] this]
::
++ ride
|= [formula=hoon =schematic]
::
=^ result state (depend-on schematic)
?~ result
[[%blocks [date.build schematic]~] this]
::
!!
:: =* subject u.result
:: =* subject-cage (result-to-cage subject)
:: =^ slim-result state (depend-on [%slim p.q.subject-cage formula])
:: ?> ?=(^ slim-result)
:: :: val is a toon, which might be a list of blocks.
:: ::
:: :: TODO: We need an intercepted scry to figure out the dependencies,
:: :: which also knows about the results of previous runs so we can feeed
:: :: the results back in.
:: ::
:: :: TODO: Implement slim. It's sort of a prerequisite to getting this
:: :: working.
:: ::
:: :: TODO: +result-to-cage? +result-to-vase?
:: ::
:: :: TODO: test cases
:: ::
:: =+ val=(mock [q.q.subject-cage u.slim-result] (sloy ^scry))
:: [[%build-result %result %ride vase] this]
::
++ same
|= =schematic
::
@ -1751,6 +1779,17 @@
:: scry succeeded
::
[[%build-result %result %scry u.u.scry-response] this]
::
++ slim
|= [subject-type=type formula=hoon]
::
=/ compiled=(each (pair type nock) tang)
(mule |.((~(mint ut subject-type) [%noun formula])))
::
?- -.compiled
%| [[%build-result %error [leaf+"%slim failed: " p.compiled]] this]
%& [[%build-result %result %slim p.compiled] this]
==
:: |utilities:make: helper arms
::
::+| utilities