Commit | Line | Data |
9256ec21 |
1 | use strict; |
2 | use warnings FATAL => 'all'; |
3 | use Test::More; |
4 | |
5 | BEGIN { |
6 | package MyRole; |
7 | use Role::Tiny; |
8 | |
9 | sub as_string { "welp" } |
10 | sub as_num { 219 } |
11 | use overload |
12 | '""' => \&as_string, |
13 | '0+' => 'as_num', |
14 | bool => sub(){1}, |
15 | fallback => 1; |
16 | } |
17 | |
18 | BEGIN { |
19 | package MyClass; |
20 | use Role::Tiny::With; |
21 | with 'MyRole'; |
22 | sub new { bless {}, shift } |
23 | } |
24 | |
25 | my $o = MyClass->new; |
26 | is "$o", 'welp', 'subref overload'; |
27 | is 0+$o, 219, 'method name overload'; |
28 | ok !!$o, 'anon subref overload'; |
29 | |
30 | done_testing; |