Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pass 62-subst.t.
  • Loading branch information
jnthn committed Feb 17, 2013
1 parent 1a5005a commit cf179ce
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions t/nqp/62-subst.t
@@ -0,0 +1,20 @@
#! nqp

plan(7);

my $str := 'hello';

ok(subst($str, /h/, 'f') eq 'fello', 'We can use subst');
ok($str eq 'hello', '.. withouth side effect');

ok(subst($str, /l/, 'r', :global) eq 'herro', 'We can use subst to replace all matches');

my $i := 0;
ok(subst($str, /l/, -> $m {$i++}) eq 'he0lo', 'We can have a closure as replacement');
ok($i == 1, '.. and $i updated');

ok(subst($str, /FOO/, 'BAR') eq 'hello', "Non-existing string doesn't clobber string");
ok(subst($str, /FOO/, 'BAR', :global) eq 'hello', "Non-existing string doesn't clobber string globally");

# vim: ft=perl6

0 comments on commit cf179ce

Please sign in to comment.