6 use Test::More tests => 22;
11 my $VAR1; # for eval of dumps
13 is('Hello World'->lc, 'hello world', '... $str->lc');
14 is('Hello World'->uc, 'HELLO WORLD', '... $str->uc');
16 is('foo'->ucfirst, 'Foo', '... $str->ucfirst');
17 is('Foo'->lcfirst, 'foo', '... $str->lcfirst');
19 dies_ok { ('Hello')->chop } '... cannot modify a read-only';
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');
26 dies_ok { "Hello\n"->chomp } '... cannot modify a read-only';
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');
33 is('reverse'->reverse, 'esrever', '... got the string reversal');
34 is('length'->length, 6, '... got the string length');
36 is('Hello World'->index('World'), 6, '... got the correct index');
38 is('Hello World, Hello'->index('Hello'), 0, '... got the correct index');
40 is('Hello World, Hello'->index('Hello', 6), 13, '... got the correct index');
42 is('Hello World, Hello'->rindex('Hello'), 13, '... got the correct right index');
44 is('Hello World, Hello'->rindex('Hello', 6), 0, '... got the correct right index');
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');
50 eval 'Hello World, Hello'->dump;
51 is($VAR1, 'Hello World, Hello' , '... eval of &dump works');
53 eval 'Hello World, Hello'->perl;
54 is($VAR1, 'Hello World, Hello' , '... eval of &perl works');