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 06:25:29 +03:00
|
|
|
%- expect-eq !>
|
|
|
|
:- "right"
|
|
|
|
%^ apply `(either @u tape)`[%| "one"]
|
|
|
|
|=(a/@u "left")
|
|
|
|
|=(b/tape "right")
|
2017-11-27 02:41:49 +03:00
|
|
|
::
|
|
|
|
++ test-firsts
|
2018-03-10 06:25:29 +03:00
|
|
|
%- expect-eq !>
|
|
|
|
:- [1 2 ~]
|
|
|
|
(firsts data)
|
2017-11-27 02:41:49 +03:00
|
|
|
::
|
|
|
|
++ test-seconds
|
2018-03-10 06:25:29 +03:00
|
|
|
%- expect-eq !>
|
|
|
|
:- ["one" "two" ~]
|
|
|
|
(seconds data)
|
2017-11-27 02:41:49 +03:00
|
|
|
::
|
|
|
|
++ test-partition
|
2018-03-10 06:25:29 +03:00
|
|
|
%- expect-eq !>
|
|
|
|
:- [[1 2 ~] ["one" "two" ~]]
|
|
|
|
(partition data)
|
2017-11-27 02:41:49 +03:00
|
|
|
--
|