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