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