%vale schematic

This commit is contained in:
Ted Blackman 2018-05-21 14:54:58 -07:00
parent 566422f7db
commit 4cbb057600
2 changed files with 177 additions and 1 deletions

View File

@ -96,6 +96,8 @@
test-core-fscm
test-bunt
test-volt
test-vale
test-vale-error
==
++ test-tear
:- `tank`leaf+"test-tear"
@ -4808,6 +4810,114 @@
(expect-ford-empty ford ~nul)
==
::
++ test-vale
:- `tank`leaf+"test-vale"
::
=/ ford *ford-gate
::
=/ hoon-src=@ta
'''
|_ cell=^
++ grab
|%
++ noun ^
--
--
'''
::
=/ scry-results=(map [term beam] cage)
%- my :~
:- [%cx [[~nul %home %da ~1234.5.6] /hoon/foo/mar]]
[%hoon !>(hoon-src)]
==
::
=^ results1 ford
%- test-ford-call-with-comparator :*
ford
now=~1234.5.6
scry=(scry-with-results scry-results)
::
^= call-args
:* duct=~[/path] type=~ %make ~nul
%pin ~1234.5.6
[%vale [~nul %home] %foo [12 13]]
==
::
^= comparator
|= moves=(list move:ford-gate)
::
?> =(1 (lent moves))
?> ?=(^ moves)
?> ?=([* %give %made @da %complete %success %pin *] i.moves)
=/ result result.p.card.i.moves
=/ pin-result build-result.result
?> ?=([%success %vale *] build-result.pin-result)
::
=/ =vase q.cage.build-result.pin-result
::
%+ weld
%- expect-eq !>
:- [12 13]
q.vase
::
%- expect-eq !>
:- &
(~(nest ut p.vase) | -:!>(*^))
==
::
;: weld
results1
(expect-ford-empty ford ~nul)
==
::
++ test-vale-error
:- `tank`leaf+"test-vale-error"
::
=/ ford *ford-gate
::
=/ hoon-src=@ta
'''
|_ cell=^
++ grab
|%
++ noun ^
--
--
'''
::
=/ scry-results=(map [term beam] cage)
%- my :~
:- [%cx [[~nul %home %da ~1234.5.6] /hoon/foo/mar]]
[%hoon !>(hoon-src)]
==
::
=^ results1 ford
%- test-ford-call :*
ford
now=~1234.5.6
scry=(scry-with-results scry-results)
::
^= call-args
:* duct=~[/path] type=~ %make ~nul
%pin ~1234.5.6
[%vale [~nul %home] %foo 42]
==
::
^= moves
:~ :* duct=~[/path] %give %made ~1234.5.6 %complete %success
%pin ~1234.5.6 %error
:- %leaf
%+ weld
"ford: %vale failed: invalid input for mark: "
"/~nul/home/~1234.5.6/mar/foo/hoon"
~
== == ==
::
;: weld
results1
(expect-ford-empty ford ~nul)
==
::
::
:: |utilities: helper arms
::

View File

@ -2709,7 +2709,7 @@
%scry (make-scry resource)
%slim (make-slim subject-type formula)
%slit (make-slit gate sample)
%vale !!
%vale (make-vale disc mark input)
%volt (make-volt disc mark input)
==
:: |schematic-handlers:make: implementation of the schematics
@ -3705,6 +3705,72 @@
[%success %volt [mark p.q.cage.u.bunt-result input]]
::
[build [%build-result build-result] accessed-builds]
::
++ make-vale
:: TODO: better docs
::
|= [=disc mark=term input=*]
^- build-receipt
:: don't validate for the %noun mark
::
?: =(%noun mark)
=/ =build-result [%success %vale [%noun %noun input]]
::
[build [%build-result build-result] accessed-builds]
::
=/ path-build [date.build [%path disc %mar mark]]
::
=^ path-result accessed-builds (depend-on path-build)
?~ path-result
[build [%blocks [path-build]~ ~] accessed-builds]
::
?. ?=([~ %success %path *] path-result)
(wrap-error path-result)
::
=/ bunt-build=^build [date.build [%bunt disc mark]]
::
=^ bunt-result accessed-builds (depend-on bunt-build)
?~ bunt-result
[build [%blocks [bunt-build]~ ~] accessed-builds]
::
?. ?=([~ %success %bunt *] bunt-result)
(wrap-error bunt-result)
::
=/ mark-sample=vase q.cage.u.bunt-result
::
=/ call-build=^build
:^ date.build
%call
^= gate
:* %ride
:: (ream 'noun:grab')
formula=`hoon`[%tsgl [%wing ~[%noun]] [%wing ~[%grab]]]
subject=`schematic`[%core rail.u.path-result]
==
sample=[%$ %noun %noun input]
::
=^ call-result accessed-builds (depend-on call-build)
?~ call-result
[build [%blocks [call-build]~ ~] accessed-builds]
::
?. ?=([~ %success %call *] call-result)
(wrap-error call-result)
::
=/ product=vase vase.u.call-result
:: TODO: why do we check nesting here?
::
?> (~(nest ut p.mark-sample) | p.product)
:: check mold idempotence; if different, nest fail
::
?: =(q.product input)
=/ =build-result
[%success %vale [mark p.mark-sample q.product]]
::
[build [%build-result build-result] accessed-builds]
::
%- return-error
=/ =beam [[ship.disc desk.disc %da date.build] spur.rail.u.path-result]
[leaf+"ford: %vale failed: invalid input for mark: {<(en-beam beam)>}"]~
:: |utilities:make: helper arms
::
::+| utilities