shrub/lib/test/ford.hoon

268 lines
7.3 KiB
Plaintext
Raw Normal View History

2018-08-30 01:54:54 +03:00
/+ *test
2018-08-30 00:56:54 +03:00
=, ford
|%
2018-08-30 01:00:40 +03:00
:: +expect-schematic: assert a +schematic:ford is what we expect
::
:: Since Ford requests contain types, we can't do simple
:: equality checking. This function handles all the different
:: kinds of +schematic:ford, dealing with types as necessary.
::
2018-08-30 00:56:54 +03:00
++ expect-schematic
|= [expected=schematic actual=schematic]
2018-08-30 00:56:54 +03:00
^- tang
::
?^ -.expected
?. ?=(^ -.actual)
[%leaf "expected autocons, but got {<-.actual>}"]~
2018-08-30 00:56:54 +03:00
::
%+ weld
$(expected head.expected, actual head.actual)
$(expected tail.expected, actual tail.actual)
2018-08-30 00:56:54 +03:00
::
?- -.expected
%$
?. ?=(%$ -.actual)
[%leaf "expected %$, but got {<-.actual>}"]~
2018-08-30 00:56:54 +03:00
::
%+ weld
(expect-eq !>(p.literal.expected) !>(p.literal.actual))
(expect-eq q.literal.expected q.literal.actual)
2018-08-30 00:56:54 +03:00
::
%pin
::
?. ?=(%pin -.actual)
[%leaf "expected %pin, but got {<-.actual>}"]~
2018-08-30 00:56:54 +03:00
::
%+ weld
(expect-eq !>(date.expected) !>(date.actual))
$(expected schematic.expected, actual schematic.actual)
2018-08-30 00:56:54 +03:00
::
%alts
::
?. ?=(%alts -.actual)
[%leaf "expected %alts, but got {<-.actual>}"]~
::
|- ^- tang
2018-08-30 00:56:54 +03:00
?~ choices.expected
:: make sure there aren't any extra :choices in :actual
::
?~ choices.actual
~
[%leaf "actual had more choices than expected"]~
2018-08-30 00:56:54 +03:00
:: :expected isn't empty yet; make sure :actual isn't either
::
?~ choices.actual
[%leaf "expected had more choices than actual"]~
2018-08-30 00:56:54 +03:00
:: recurse on the first sub-schematic
::
%+ weld
^$(expected i.choices.expected, actual i.choices.actual)
$(choices.expected t.choices.expected, choices.actual t.choices.actual)
2018-08-30 00:56:54 +03:00
::
%bake
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
::
%bunt
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
::
%call
::
?. ?=(%call -.actual)
[%leaf "expected %call, but got {<-.actual>}"]~
::
2018-08-30 00:56:54 +03:00
%+ weld
$(expected gate.expected, actual gate.actual)
$(expected sample.expected, actual sample.actual)
2018-08-30 00:56:54 +03:00
::
%cast
::
?. ?=(%cast -.actual)
[%leaf "expected %cast, but got {<-.actual>}"]~
2018-08-30 00:56:54 +03:00
::
;: weld
(expect-eq !>(disc.expected) !>(disc.actual))
(expect-eq !>(mark.expected) !>(mark.actual))
$(expected input.expected, actual input.actual)
2018-08-30 00:56:54 +03:00
==
::
%core
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
::
%diff
::
?. ?=(%diff -.actual)
[%leaf "expected %diff, but got {<-.actual>}"]~
::
;: weld
(expect-eq !>(disc.expected) !>(disc.actual))
$(expected start.expected, actual start.actual)
$(expected end.expected, actual end.actual)
==
2018-08-30 00:56:54 +03:00
::
%dude
::
?. ?=(%dude -.actual)
[%leaf "expected %dude, but got {<-.actual>}"]~
::
%+ weld
2019-02-05 03:58:22 +03:00
(expect-eq !>(error.expected) !>(error.actual))
$(expected attempt.expected, actual attempt.actual)
2018-08-30 00:56:54 +03:00
::
%hood
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
::
%join
::
?. ?=(%join -.actual)
[%leaf "expected %join, but got {<-.actual>}"]~
2018-08-30 00:56:54 +03:00
::
;: weld
(expect-eq !>(disc.expected) !>(disc.actual))
(expect-eq !>(mark.expected) !>(mark.actual))
$(expected first.expected, actual first.actual)
$(expected second.expected, actual second.actual)
==
2018-08-30 00:56:54 +03:00
::
%list
::
?. ?=(%list -.actual)
[%leaf "expected %list, but got {<-.actual>}"]~
2018-08-30 00:56:54 +03:00
::
|- ^- tang
?~ schematics.expected
:: make sure there aren't any extra :schematics in :actual
2018-08-30 00:56:54 +03:00
::
?~ schematics.actual
~
[%leaf "actual had more schematics than expected"]~
2018-08-30 00:56:54 +03:00
:: :expected isn't empty yet; make sure :actual isn't either
::
?~ schematics.actual
[%leaf "expected had more schematics than actual"]~
2018-08-30 00:56:54 +03:00
::
%+ weld
^$(expected i.schematics.expected, actual i.schematics.actual)
2018-08-30 00:56:54 +03:00
::
%_ $
schematics.expected t.schematics.expected
schematics.actual t.schematics.actual
==
2018-08-30 00:56:54 +03:00
::
%mash
::
?. ?=(%mash -.actual)
[%leaf "expected %mash, but got {<-.actual>}"]~
2018-08-30 00:56:54 +03:00
::
;: weld
(expect-eq !>(disc.expected) !>(disc.actual))
(expect-eq !>(mark.expected) !>(mark.actual))
(expect-eq !>(disc.first.expected) !>(disc.first.actual))
(expect-eq !>(mark.first.expected) !>(mark.first.actual))
(expect-eq !>(disc.second.expected) !>(disc.second.actual))
(expect-eq !>(mark.second.expected) !>(mark.second.actual))
$(expected schematic.first.expected, actual schematic.first.actual)
$(expected schematic.second.expected, actual schematic.second.actual)
2018-08-30 00:56:54 +03:00
==
::
%mute
::
?. ?=(%mute -.actual)
[%leaf "expected %mute, but got {<-.actual>}"]~
2018-08-30 00:56:54 +03:00
::
%+ weld $(expected subject.expected, actual subject.actual)
::
|- ^- tang
?~ mutations.expected
:: make sure there aren't any extra :mutations in :actual
2018-08-30 00:56:54 +03:00
::
?~ mutations.actual
~
[%leaf "actual had more mutations than expected"]~
2018-08-30 00:56:54 +03:00
:: :expected isn't empty yet; make sure :actual isn't either
::
?~ mutations.actual
[%leaf "expected had more mutations than actual"]~
2018-08-30 00:56:54 +03:00
::
;: weld
(expect-eq !>(p.i.mutations.expected) !>(p.i.mutations.actual))
^$(expected q.i.mutations.expected, actual q.i.mutations.actual)
%_ $
mutations.expected t.mutations.expected
mutations.actual t.mutations.actual
==
==
2018-08-30 00:56:54 +03:00
::
%pact
::
?. ?=(%pact -.actual)
[%leaf "expected %pact, but got {<-.actual>}"]~
::
;: weld
(expect-eq !>(disc.expected) !>(disc.actual))
$(expected start.expected, actual start.actual)
$(expected diff.expected, actual diff.actual)
==
2018-08-30 00:56:54 +03:00
::
%path
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
::
%plan
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
::
%reef
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
::
%ride
::
?. ?=(%ride -.actual)
[%leaf "expected %ride, but got {<-.actual>}"]~
::
%+ weld
(expect-eq !>(formula.expected) !>(formula.actual))
$(expected subject.expected, actual subject.actual)
2018-08-30 00:56:54 +03:00
::
%same
::
?. ?=(%same -.actual)
[%leaf "expected %same, but got {<-.actual>}"]~
::
$(expected schematic.expected, actual schematic.actual)
2018-08-30 00:56:54 +03:00
::
%scry
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
::
%slim
::
?. ?=(%slim -.actual)
[%leaf "expected %slim, but got {<-.actual>}"]~
::
2018-08-30 00:56:54 +03:00
%+ weld
(expect-eq !>(formula.expected) !>(formula.actual))
2018-08-30 00:56:54 +03:00
::
%+ expect-eq
!>(`?`%.y)
^- vase
:- -:!>(*?)
^- ?
(~(nest ut subject-type.expected) | subject-type.actual)
2018-08-30 00:56:54 +03:00
::
%slit
::
?. ?=(%slit -.actual)
[%leaf "expected %slit, but got {<-.actual>}"]~
2018-08-30 00:56:54 +03:00
::
%+ weld
(expect-eq gate.expected gate.actual)
(expect-eq sample.expected sample.actual)
::
?(%vale %volt)
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
::
%walk
(expect-eq [schematic-type expected] [schematic-type actual])
2018-08-30 00:56:54 +03:00
==
:: +schematic-type: the +type for +schematic:ford
2018-08-30 00:56:54 +03:00
::
++ schematic-type ^~ `type`-:!>(*schematic:ford)
2018-08-30 00:56:54 +03:00
--