Commit | Line | Data |
6cf5bcf2 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
260cc81f |
6 | use Test::More tests => 16; |
6cf5bcf2 |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
10 | use_ok('Moose::Autobox'); |
11 | } |
12 | |
13 | use autobox; |
14 | |
15 | is('Hello World'->lc, 'hello world', '... $str->lc'); |
16 | is('Hello World'->uc, 'HELLO WORLD', '... $str->uc'); |
17 | |
18 | is('foo'->ucfirst, 'Foo', '... $str->ucfirst'); |
19 | is('Foo'->lcfirst, 'foo', '... $str->lcfirst'); |
20 | |
21 | dies_ok { ('Hello')->chop } '... cannot modify a read-only'; |
22 | { |
23 | my $greeting = 'Hello'; |
24 | is($greeting->chop, 'o', '... got the chopped off portion of the string'); |
25 | is($greeting, 'Hell', '... and are left with the rest of the string'); |
26 | } |
27 | |
28 | dies_ok { "Hello\n"->chomp } '... cannot modify a read-only'; |
29 | { |
30 | my $greeting = "Hello\n"; |
31 | is($greeting->chomp, '1', '... got the chopped off portion of the string'); |
32 | is($greeting, 'Hello', '... and are left with the rest of the string'); |
33 | } |
34 | |
35 | is('reverse'->reverse, 'esrever', '... got the string reversal'); |
36 | is('length'->length, 6, '... got the string length'); |
37 | |
38 | is('Hello World'->index('World'), 6, '... got the correct index'); |
39 | |
40 | is('Hello World, Hello'->index('Hello'), 0, '... got the correct index'); |
41 | |
260cc81f |
42 | is('Hello World, Hello'->index('Hello', 6), 13, '... got the correct index'); |
43 | |
6cf5bcf2 |
44 | #is('Hello World, Hello'->rindex('World'), 13, '... got the correct right index'); |
45 | #diag CORE::rindex('Hello World, Hello', 'Hello'); |