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

use Monad::Result;

plan(9);

my $result = Monad::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 { Monad::Result.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


