Implement +slit. Tests both the success and error cases.

This commit is contained in:
Elliot Glaysher 2018-05-02 14:47:24 -07:00
parent 943b7152d2
commit 1694f95eee
2 changed files with 130 additions and 2 deletions

View File

@ -28,6 +28,8 @@
test-live-triangle
test-live-and-pinned-triangle
test-slim
test-slit
test-slit-error
test-ride
test-ride-scry-succeed
test-ride-scry-fail
@ -1045,6 +1047,110 @@
(expect-ford-empty ford ~nul)
==
::
++ test-slit
~& %test-slit
::
=/ gate=vase (ride %noun '|=(a=@ud ["one" a])')
=/ sample=vase !>(42)
::
=/ ford *ford-turbo
=^ results1 ford
%- test-ford-call-with-comparator :*
ford
now=~1234.5.6
scry=scry-is-forbidden
::
call-args=[duct=~[/slit] type=~ %make ~nul [%slit gate sample]]
::
^= comparator
|= moves=(list move:ford-turbo)
^- tang
::
?> =(1 (lent moves))
?> ?=(^ moves)
?> ?=([* %give %made @da %complete %success %slit *] i.moves)
:: we are expecting a type, and all we can do is ensure it nests in
:: the right type
::
=/ expected-type=type -:!>([*tape *@ud])
=/ actual-type=type |7:i.moves
%- expect-eq !>
:- (~(nest ut actual-type) | expected-type)
&
==
::
=^ results2 ford
%- test-ford-call :*
ford
now=~1234.5.7
scry=scry-is-forbidden
::
call-args=[duct=~[/slit] type=~ %kill ~nul]
::
moves=~
==
::
;: weld
results1
results2
(expect-ford-empty ford ~nul)
==
::
++ test-slit-error
~& %test-slit-error
::
=/ gate=vase (ride %noun '|=(a=@ud ["one" a])')
=/ sample=vase !>("a tape instead of @ud")
::
=/ ford *ford-turbo
=^ results1 ford
%- test-ford-call-with-comparator :*
ford
now=~1234.5.6
scry=scry-is-forbidden
::
call-args=[duct=~[/slit] type=~ %make ~nul [%slit gate sample]]
::
^= comparator
|= moves=(list move:ford-turbo)
^- tang
::
?> =(1 (lent moves))
?> ?=(^ moves)
?> ?=([* %give %made @da %complete %error *] i.moves)
:: ignore last message; contains source positions in the stack trace
::
=/ messages=tang (scag 4 `tang`|6:i.moves)
::
%- expect-eq !>
:_ messages
:~ [%palm ["." "-" "" ""] [%leaf "have"] [%leaf "\"\""] ~]
:~ %palm ["." "-" "" ""]
[%leaf "want"]
[%palm ["/" "" "" ""] [%leaf "a"] [%leaf "@ud"] ~]
==
[%leaf "%slit failed: "]
[%leaf "nest-fail"]
==
==
::
=^ results2 ford
%- test-ford-call :*
ford
now=~1234.5.7
scry=scry-is-forbidden
::
call-args=[duct=~[/slit] type=~ %kill ~nul]
::
moves=~
==
::
;: weld
results1
results2
(expect-ford-empty ford ~nul)
==
::
++ test-ride
~& %test-ride
::

View File

@ -2470,9 +2470,9 @@
%reef !!
%ride (ride [formula subject]:schematic.build)
%same (same schematic.schematic.build)
%slit !!
%slim (slim [subject-type formula]:schematic.build)
%scry (scry resource.schematic.build)
%slim (slim [subject-type formula]:schematic.build)
%slit (slit [gate sample]:schematic.build)
%vale !!
%volt !!
==
@ -2717,6 +2717,28 @@
accessed-builds
|
==
::
++ slit
|= [gate=vase sample=vase]
^- build-receipt
::
=/ product=(each type tang)
(mule |.((^slit p.gate p.sample)))
::
:* build
?- -.product
%| :* %build-result %error
:* (~(dunk ut p.sample) %have)
(~(dunk ut (~(peek ut p.gate) %free 6)) %want)
leaf+"%slit failed: "
p.product
==
==
%& [%build-result %success %slit p.product]
==
accessed-builds
|
==
:: |utilities:make: helper arms
::
::+| utilities