6 use Test::More no_plan => 1;
9 use_ok('Moose::Autobox');
10 use_ok('Moose::Autobox::Undef');
13 use autobox UNDEF => 'Moose::Autobox::Undef';
18 ok(!$s->defined, '... got a undefined value');
21 ok($s->defined, '... got a defined value');
26 ok($f1->defined, '... created function');
28 my $f2 = eval { $f1->curry(1, 2, 3) };
29 ok($f2->defined, '... created curried function');
31 my $f3 = eval { $f1->rcurry(1, 2, 3) };
32 ok($f3->defined, '... created right-curried function');
37 '... got the right return value from the curried function');
42 '... got the right return value from the r-curried function');
44 ok((sub { 1 })->disjoin(sub { 0 })->(), '... disjoins properly');
45 ok(!(sub { 1 })->conjoin(sub { 0 })->(), '... conjoins properly');
47 #my $compose = (sub { 1, @_ })->compose(sub { 2, @_ });
52 #'... got the right return value for compose');
57 my $a = [ 4, 2, 6, 78, 101, 2, 3 ];
59 is($a->length, 7, '... got the right length');
60 ok($a->defined, '... got the right defined value');
63 $a->map(sub { $_ + 2 }),
64 [ map { $_ + 2 } (4, 2, 6, 78, 101, 2, 3) ],
65 '... got the right return value for map');
67 is_deeply($a, [ 4, 2, 6, 78, 101, 2, 3 ], '... original value is unchanged');
71 [ 3, 2, 101, 78, 6, 2, 4 ],
72 '... got the right return value for reverse');
74 is_deeply($a, [ 4, 2, 6, 78, 101, 2, 3 ], '... original value is unchanged');
77 $a->grep(sub { $_ < 50 }),
78 [ grep { $_ < 50 } (4, 2, 6, 78, 101, 2, 3) ],
79 '... got the right return value grep');
81 is_deeply($a, [ 4, 2, 6, 78, 101, 2, 3 ], '... original value is unchanged');
83 is($a->join(', '), '4, 2, 6, 78, 101, 2, 3', '... got the right joined string');
84 ok($a->exists(0), '... exists works');
85 ok(!$a->exists(10), '... exists works');
87 is($a->pop(), 3, '... got the right pop-ed value');
88 is_deeply($a, [ 4, 2, 6, 78, 101, 2 ], '... original value is now changed');
90 is($a->shift(), 4, '... got the right unshift-ed value');
91 is_deeply($a, [ 2, 6, 78, 101, 2 ], '... original value is now changed');
95 [ 10, 2, 6, 78, 101, 2 ],
96 '... got the correct unshifted value');
99 $a->unshift(15, 20, 30),
100 [ 15, 20, 30, 10, 2, 6, 78, 101, 2 ],
101 '... got the correct unshifted value (multiple values)');
105 [ 15, 20, 30, 10, 2, 6, 78, 101, 2, 10 ],
106 '... got the correct pushed value');
109 $a->push(15, 20, 30),
110 [ 15, 20, 30, 10, 2, 6, 78, 101, 2, 10, 15, 20, 30 ],
111 '... got the correct pushed value (multiple values)');
114 $a->sort(sub { $_[0] <=> $_[1] }),
115 [ 2, 2, 6, 10, 10, 15, 15, 20, 20, 30, 30, 78, 101 ],
116 '... got the correct sorted value');
120 [ 15, 20, 30, 10, 2, 6, 78, 101, 2, 10, 15, 20, 30 ],
121 '... the original values are unchanged');
124 []->push(10, 20, 30)->map(sub { ($_, $_ + 5) })->reverse,
125 [ 35, 30, 25, 20, 15, 10 ],
126 '... got the correct chained value');
130 my $h = { one => 1, two => 2, three => 3 };
132 ok($h->defined, '... got the right defined value');