Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
RT #116224 test for $/
  • Loading branch information
FROGGS committed Jan 21, 2013
1 parent 53c8fe6 commit 7c6bc80
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion S05-substitution/subst.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 126;
plan 136;

# L<S05/Substitution/>

Expand All @@ -26,6 +26,27 @@ is 'a'.subst(/(.)/,"$1$0"), '', '.. and it can not access captures from st
is 'a'.subst(/(.)/,{$0~$0}),'aa', '.. you must wrap it in a closure';
is '12'.subst(/(.)(.)/,{$()*2}),'24', '.. and do nifty things in closures';

# RT #116224
{
$/ = '-';
is 'a'.subst("a","b"), 'b', '"a".subst("a", "b") is "b"';
is $/, '-', '$/ is left untouched';

is 'a'.subst(/a/,"b"), 'b', '"a".subst(/a/, "b") is "b"';
is $/, 'a', '$/ matched "a"';

is 'a'.subst(/x/,"y"), 'a', '"a".subst(/x/, "y") is "a"';
nok $/, '$/ is a falsey';

$_ = 'a';
is s/a/b/, 'b', '$_ = "a"; s/a/b/ is "b"';
is $/, 'a', '$/ matched "a"';

$_ = 'a';
is s/x/y/, 'a', '$_ = "a"; s/x/y/ is "a"';
nok $/, '$/ is a falsey';
}

{
is 'a b c d'.subst(/\w/, 'x', :g), 'x x x x', '.subst and :g';
is 'a b c d'.subst(/\w/, 'x', :global), 'x x x x', '.subst and :global';
Expand Down

0 comments on commit 7c6bc80

Please sign in to comment.