2017-11-27 02:41:49 +03:00
|
|
|
:: tests for the either core.
|
|
|
|
/+ new-hoon, tester
|
|
|
|
=, thr:new-hoon
|
|
|
|
=/ data/(list (either @u tape)) [[%& 1] [%| "one"] [%& 2] [%| "two"] ~]
|
2018-03-10 04:31:44 +03:00
|
|
|
|_ _tester:tester
|
2017-11-27 02:41:49 +03:00
|
|
|
++ test-apply
|
2018-03-10 04:27:45 +03:00
|
|
|
%+ expect-eq
|
|
|
|
%^ apply `(either @u tape)`[%| "one"]
|
|
|
|
|=(a/@u "left")
|
2017-11-27 02:41:49 +03:00
|
|
|
|=(b/tape "right")
|
|
|
|
"right"
|
|
|
|
::
|
|
|
|
++ test-firsts
|
2018-03-10 04:27:45 +03:00
|
|
|
%+ expect-eq
|
|
|
|
(firsts data)
|
2017-11-27 02:41:49 +03:00
|
|
|
[1 2 ~]
|
|
|
|
::
|
|
|
|
++ test-seconds
|
2018-03-10 04:27:45 +03:00
|
|
|
%+ expect-eq
|
|
|
|
(seconds data)
|
2017-11-27 02:41:49 +03:00
|
|
|
["one" "two" ~]
|
|
|
|
::
|
|
|
|
++ test-partition
|
2018-03-10 04:27:45 +03:00
|
|
|
%+ expect-eq
|
|
|
|
(partition data)
|
2017-11-27 02:41:49 +03:00
|
|
|
[[1 2 ~] ["one" "two" ~]]
|
|
|
|
--
|