Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test substr coerces from/to/from-to endpoitns to Ints
  • Loading branch information
zoffixznet committed Apr 9, 2018
1 parent bf28c77 commit 399ca73
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion S32-str/substr.t
Expand Up @@ -3,7 +3,7 @@ use lib $?FILE.IO.parent(2).add("packages");
use Test;
use Test::Util;

plan 57;
plan 58;

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

Expand Down Expand Up @@ -124,4 +124,21 @@ subtest '.substr fails when start is beyond end of string' => {
# RT #122789
lives-ok { BEGIN "a".subst: /a/, "b" }, '.subst in BEGIN does not die';

subtest 'substr coerces from/to to Ints' => {
plan 2;
for '1234567890', 'Str', 1234567890, 'Cool' -> \v, $type {
subtest $type => {
plan 2*6;
for v.^lookup('substr'), &substr -> &SUBSTR {
is SUBSTR(v, 6.1..8.8 ), '789', 'Range(Rat, Rat)';
is SUBSTR(v, 6.1 ), '7890', 'Rat';
is SUBSTR(v, 6.1, 3.8 ), '789', 'Rat, Rat';
is SUBSTR(v, {6.1}, 3.8 ), '789', 'Callable, Rat';
is SUBSTR(v, {6.1} ), '7890', 'Callable';
is SUBSTR(v, 6.1, {3.8}), '789', 'Callable';
}
}
}
}

# vim: ft=perl6

0 comments on commit 399ca73

Please sign in to comment.