From 1694f95eee8b7bf7081986c1ae9621a3c5c8de86 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 2 May 2018 14:47:24 -0700 Subject: [PATCH] Implement +slit. Tests both the success and error cases. --- gen/ford-turbo.hoon | 106 ++++++++++++++++++++++++++++++++++++++++++++ lib/ford-turbo.hoon | 26 ++++++++++- 2 files changed, 130 insertions(+), 2 deletions(-) diff --git a/gen/ford-turbo.hoon b/gen/ford-turbo.hoon index a85c66574..fc422bb5a 100644 --- a/gen/ford-turbo.hoon +++ b/gen/ford-turbo.hoon @@ -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 :: diff --git a/lib/ford-turbo.hoon b/lib/ford-turbo.hoon index 94eddc5be..7c024f048 100644 --- a/lib/ford-turbo.hoon +++ b/lib/ford-turbo.hoon @@ -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