1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
use strict;
use warnings;
use Test::More tests => 3;
use PerlX::Maybe ':all';
is_deeply(
[
provided_deref 0, { foo => 1 }, 6,
provided_deref 1, { bar => 2 }, 7,
provided_deref 0, { baz => 3 }, 8,
provided_deref undef, { quux => 4 }, 9,
provided_deref [], { quuux => 5 }, 10,
provided_deref 1, { quuux => undef }, 11,
],
[
6,
bar => 2, 7,
8,
9,
quuux => 5, 10,
quuux => undef, 11,
]
);
is_deeply(
[
provided_deref 0, [ 'foo' , 1 ], 6,
provided_deref 1, [ 'bar' , 2 ], 7,
provided_deref 0, [ 'baz' , 3 ], 8,
provided_deref undef, [ 'quux' , 4 ], 9,
provided_deref [], [ 'quuux', 5 ], 10,
provided_deref 1, [ 'quuux', undef ], 11,
],
[
6,
bar => 2, 7,
8,
9,
quuux => 5, 10,
quuux => undef, 11,
]
);
is_deeply(
[
## provided_deref 1, \"scalar value", 1,
provided_deref 1, ["foo", "bar"], 2,
provided_deref 1, {"baz", "qux"}, 3,
provided_deref 1, sub { die("nope") if @_; return blah => "quux" }, 4,
provided_deref 1, PerlX::Maybe::Test::Hash->new( foo => 'bar' ), 5,
provided_deref 1, PerlX::Maybe::Test::Hash->new( _baz => 'qux' ), 6,
provided_deref 1, PerlX::Maybe::Test::Hash->new( fuz => undef ), 7
],
[
## "scalar value", 1,
"foo", "bar", 2,
"baz", "qux", 3,
"blah", "quux", 4,
"foo", "bar", 5,
"_baz", "qux", 6,
"fuz", undef, 7,
],
"does do dereferencing"
);
package PerlX::Maybe::Test::Hash;
sub new {
my $class = shift;
my %data = @_;
bless \%data, $class;
}
|