### ----------------------------------------------------
### -- Monad-Result
### -- Licenses: MIT
### -- Authors: Rawley Fowler
### -- File: t/01-test-result.rakutest
### ----------------------------------------------------
use v6;

my ($ok, $plan) = do { use Test; (&ok, &plan) };

use Monad::Result :subs;

$plan(9);

my $result = ok('Bob');

$ok($result.is-ok, 'Is result OK?');
$ok(!$result.is-error, 'Is result not Error?');
$ok($result.unwrap eq 'Bob', 'Is unwrap correct?');

my $binded_result = $result >>=: -> $prev { ok('Tim') };

$ok($binded_result.is-ok, 'Is bind result OK?');
$ok(!$binded_result.is-error, 'Is bind result not Error?');
$ok($binded_result.unwrap eq 'Tim', 'Is binded unwrap correct?');

my $mapped_result = ($result >>=? -> $val { "$val is my friend" });

$ok($mapped_result.is-ok, 'Is mapped result OK?');
$ok(!$mapped_result.is-error, 'Is mapped result not Error?');
$ok($mapped_result.unwrap eq 'Bob is my friend', 'Is mapped result correct?');
# vim: expandtab shiftwidth=4


