flop spur just right. cleaned up tests and +to-wire

This commit is contained in:
Ted Blackman 2018-03-23 11:53:38 -07:00
parent 9ec17b469c
commit f744352f4c
2 changed files with 82 additions and 108 deletions

View File

@ -81,10 +81,7 @@
~& %test-literal ~& %test-literal
=^ moves ford =^ moves ford
%- call:ford %- call:ford
:* duct=~ :* duct=~ type=~ %make ~nul
type=~
%make
~nul
plan=[%$ %noun !>(**)] plan=[%$ %noun !>(**)]
date=`~1234.5.6 date=`~1234.5.6
== ==
@ -101,10 +98,7 @@
~& %test-autocons-same ~& %test-autocons-same
=^ moves ford =^ moves ford
%- call:ford %- call:ford
:* duct=~ :* duct=~ type=~ %make ~nul
type=~
%make
~nul
plan=[[%$ %noun !>(**)] [%$ %noun !>(**)]] plan=[[%$ %noun !>(**)] [%$ %noun !>(**)]]
date=`~1234.5.6 date=`~1234.5.6
== ==
@ -125,10 +119,7 @@
~& %test-autocons-different ~& %test-autocons-different
=^ moves ford =^ moves ford
%- call:ford %- call:ford
:* duct=~ :* duct=~ type=~ %make ~nul
type=~
%make
~nul
plan=[[%$ %noun !>(42)] [%$ %noun !>(43)]] plan=[[%$ %noun !>(42)] [%$ %noun !>(43)]]
date=`~1234.5.6 date=`~1234.5.6
== ==
@ -147,23 +138,13 @@
:: ::
++ test-scry-clay-succeed ++ test-scry-clay-succeed
~& %test-scry-clay-succeed ~& %test-scry-clay-succeed
=/ scry =/ scry (scry-succeed ~1234.5.6 [%noun !>(42)])
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
::
?> =(term %cx)
?> =(beam [[~nul %desk %da ~1234.5.6] /foo/bar])
::
[~ ~ %noun !>(42)]
:: ::
=. ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry) =. ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry)
=^ moves ford =^ moves ford
%- call:ford %- call:ford
:* duct=~ :* duct=~ type=~ %make ~nul
type=~ plan=[%scry %clay-once ren=%x bem=[[~nul %desk %da ~1234.5.6] /bar/foo]]
%make
~nul
plan=[%scry %clay-once ren=%x bem=[[~nul %desk %da ~1234.5.6] /foo/bar]]
date=`~1234.5.6 date=`~1234.5.6
== ==
%+ welp %+ welp
@ -179,22 +160,12 @@
:: ::
++ test-scry-clay-fail ++ test-scry-clay-fail
~& %test-scry-clay-fail ~& %test-scry-clay-fail
=/ scry =/ scry (scry-fail ~1234.5.6)
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
::
?> =(term %cx)
?> =(beam [[~nul %desk %da ~1234.5.6] /bar/foo])
::
[~ ~]
:: ::
=. ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry) =. ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry)
=^ moves ford =^ moves ford
%- call:ford %- call:ford
:* duct=~ :* duct=~ type=~ %make ~nul
type=~
%make
~nul
plan=[%scry %clay-once ren=%x bem=[[~nul %desk %da ~1234.5.6] /bar/foo]] plan=[%scry %clay-once ren=%x bem=[[~nul %desk %da ~1234.5.6] /bar/foo]]
date=`~1234.5.6 date=`~1234.5.6
== ==
@ -212,31 +183,12 @@
:: ::
++ test-scry-clay-block ++ test-scry-clay-block
~& %test-scry-clay-block ~& %test-scry-clay-block
=/ scry-block =/ scry-blocked (scry-block ~1234.5.6)
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
:: ::
?> =(term %cx) =. ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry-blocked)
?> =(beam [[~nul %desk %da ~1234.5.6] /bar/foo])
::
~
:: scry-is-forbidden: makes sure ford does not attempt to scry
::
=/ scry-is-forbidden
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
::
~| term+term
~| beam+beam
!!
::
=. ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry-block)
=^ moves ford =^ moves ford
%- call:ford %- call:ford
:* duct=~ :* duct=~ type=~ %make ~nul
type=~
%make
~nul
plan=[%scry %clay-once ren=%x bem=[[~nul %desk %da ~1234.5.6] /bar/foo]] plan=[%scry %clay-once ren=%x bem=[[~nul %desk %da ~1234.5.6] /bar/foo]]
date=`~1234.5.6 date=`~1234.5.6
== ==
@ -271,34 +223,14 @@
:: ::
++ test-scry-clay-live ++ test-scry-clay-live
~& %test-scry-clay-live ~& %test-scry-clay-live
=/ scry-42 =/ scry-42 (scry-succeed ~1234.5.6 [%noun !>(42)])
|= [* (unit (set monk)) =term =beam] =/ scry-43 (scry-succeed ~1234.5.7 [%noun !>(43)])
^- (unit (unit cage))
::
?> =(term %cx)
?> =(beam [[~nul %desk %da ~1234.5.6] /foo/bar])
~& %scry-42
::
[~ ~ %noun !>(42)]
::
=/ scry-43
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
::
?> =(term %cx)
?> =(beam [[~nul %desk %da ~1234.5.7] /foo/bar])
~& %scry-43
::
[~ ~ %noun !>(43)]
:: ::
=. ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry-42) =. ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry-42)
=^ moves ford =^ moves ford
%- call:ford %- call:ford
:* duct=~ :* duct=~ type=~ %make ~nul
type=~ plan=[%scry %clay-live care=%x bel=[[~nul %desk] /bar/foo]]
%make
~nul
plan=[%scry %clay-live care=%x bel=[[~nul %desk] /foo/bar]]
date=~ date=~
== ==
%+ welp %+ welp
@ -330,4 +262,53 @@
== == == ==
:::- state-by-ship.+>+<.ford :::- state-by-ship.+>+<.ford
::(my [~nul *ford-state:ford-turbo]~) ::(my [~nul *ford-state:ford-turbo]~)
::
:: |utilities: helper arms
::
::+| utilities
::
:: +scry-succeed: produces a scry function with a known request and answer
::
++ scry-succeed
|= [date=@da result=cage] ^- sley
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
::
~| scry-succeed+[beam+beam term+term]
?> =(term %cx)
?> =(beam [[~nul %desk %da date] /bar/foo])
::
[~ ~ result]
:: +scry-fail: produces a scry function with a known request and failed answer
::
++ scry-fail
|= date=@da ^- sley
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
::
~| scry-fail+[beam+beam term+term]
?> =(term %cx)
?> =(beam [[~nul %desk %da date] /bar/foo])
::
[~ ~]
:: +scry-block: produces a scry function with known request and blocked answer
::
++ scry-block
|= date=@da ^- sley
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
::
~| scry-block+[beam+beam term+term]
?> =(term %cx)
?> =(beam [[~nul %desk %da date] /bar/foo])
::
~
:: +scry-is-forbidden: makes sure ford does not attempt to scry
::
++ scry-is-forbidden ^- sley
|= [* (unit (set monk)) =term =beam]
^- (unit (unit cage))
::
~| scry-is-forbidden+[beam+beam term+term]
!!
-- --

View File

@ -910,36 +910,29 @@
++ to-wire ++ to-wire
|= =dependency |= =dependency
^- wire ^- wire
::
=/ beam=beam
?- -.dependency
?(%clay-once %gall-once) beam.dependency
?(%clay-live %gall-live)
::
=, bel.dependency
[[ship=p.p desk=q.p case=[%ud 0]] spur=q]
==
::
|^ ?- -.dependency |^ ?- -.dependency
:: %clay-live (encode %c &)
%clay-live %clay-once (encode %c |)
:: %gall-live (encode %g &)
=/ beam=beam %gall-once (encode %g |)
[[ship=p.p.bel desk=q.p.bel case=[%ud 0]] spur=q.bel]:dependency
::
(encode %c care.dependency & beam)
::
%clay-once
::
(encode %c care.dependency | beam.dependency)
::
%gall-live
=/ beam=beam
[[ship=p.p.bel desk=q.p.bel case=[%ud 0]] spur=q.bel]:dependency
::
(encode %g care.dependency & beam)
::
%gall-once
::
(encode %g care.dependency | beam.dependency)
== ==
:: +encode:to-wire: encode :vane, :care, :live, and :beam into a +wire :: +encode:to-wire: encode :vane, :care, :live, and :beam into a +wire
:: ::
++ encode ++ encode
|= [vane=?(%c %g) care=care:clay live=? =beam] |= [vane=?(%c %g) live=?]
^- wire ^- wire
:: ::
[vane care (scot %f live) (en-beam beam)] [vane care.dependency (scot %f live) (en-beam beam)]
-- --
:: +from-wire: decode a +dependency from a +wire :: +from-wire: decode a +dependency from a +wire
:: ::
@ -1098,7 +1091,7 @@
%+ roll ~(tap in care-paths) %+ roll ~(tap in care-paths)
|= [[care=care:clay =path] dependency-updates=_dependency-updates.state] |= [[care=care:clay =path] dependency-updates=_dependency-updates.state]
:: ::
=/ dependency=dependency [%clay-live care bel=[disc spur=path]] =/ dependency=dependency [%clay-live care bel=[disc spur=(flop path)]]
:: ::
=- (~(put by dependency-updates) date -) =- (~(put by dependency-updates) date -)
=- (~(put ju -) disc dependency) =- (~(put ju -) disc dependency)
@ -1801,7 +1794,7 @@
|= =dependency ^- (unit [care:clay path]) |= =dependency ^- (unit [care:clay path])
?: ?=(?(%gall-live %gall-once) -.dependency) ?: ?=(?(%gall-live %gall-once) -.dependency)
~ ~
=- `[care.dependency -] =- `[care.dependency (flop `path`-)]
?- -.dependency ?- -.dependency
%clay-live spur=q.bel.dependency %clay-live spur=q.bel.dependency
%clay-once spur=s.beam.dependency %clay-once spur=s.beam.dependency