Skip to content

Commit

Permalink
update existing and add more substr(Range) tests
Browse files Browse the repository at this point in the history
  • Loading branch information
perlpilot committed Jun 25, 2015
1 parent ce42e09 commit 93edb02
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
18 changes: 14 additions & 4 deletions S32-str/substr-rw.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 36;
plan 39;

{
my $str = "gorch ding";
Expand Down Expand Up @@ -120,11 +120,21 @@ plan 36;
{ # ranges

my $str = 'foo';
substr-rw($str, 2..3) = 'x';
substr-rw($str, 2..2) = 'x';
is($str, 'fox', 'substr-rw with a Range should work');

substr-rw($str, 1..2) = 'a';
is($str, 'fax', 'Str.substr-rw with a Range should work');
substr-rw($str, 1..2) = 'at';
is($str, 'fat', 'Str.substr-rw with a Range should work');

substr-rw($str, 0..^1) = 'h';
is($str, 'hat', 'Str.substr-rw with a Range should work');

substr-rw($str, 0^..1) = 'o';
is($str, 'hot', 'Str.substr-rw with a Range should work');

substr-rw($str, 0^..^1) = 'o';
is($str, 'hoot', 'Str.substr-rw with a Range should work');

}

# RT #114526
Expand Down
15 changes: 12 additions & 3 deletions S32-str/substr.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 49;
plan 55;

# L<S32::Str/Str/=item substr>

Expand Down Expand Up @@ -78,8 +78,17 @@ plan 49;

my $str = "hello foo and bar";

is(substr($str, 6..9), "foo", "substr (substr(Range)).");
is($str.substr(6..9), "foo", "substr (substr(Range)).");
is(substr($str, 6..8), "foo", "substr (substr(Range)).");
is($str.substr(6..8), "foo", "substr (substr(Range)).");

is(substr($str, 6^..8), "oo", "substr (substr(Range)).");
is($str.substr(6^..8), "oo", "substr (substr(Range)).");

is(substr($str, 6..^8), "fo", "substr (substr(Range)).");
is($str.substr(6..^8), "fo", "substr (substr(Range)).");

is(substr($str, 6^..^8), "o", "substr (substr(Range)).");
is($str.substr(6^..^8), "o", "substr (substr(Range)).");
}

#?niecza todo
Expand Down

0 comments on commit 93edb02

Please sign in to comment.