Skip to content

Commit

Permalink
More Heredoc/indent tabbification tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skids committed Oct 11, 2015
1 parent 7f9a23f commit 552fa60
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
18 changes: 17 additions & 1 deletion S02-literals/heredocs.t
@@ -1,5 +1,5 @@
use Test;
plan 22;
plan 23;

my $foo = "FOO";
my $bar = "BAR";
Expand Down Expand Up @@ -208,4 +208,20 @@ END
MAKEFILE4
"foo: bar\n\techo 'AGAIN';\nbar:\n\techo 'OHAI';\n"),
"Heredoc tab explosion makefile use case is usesul.";
}

# RT #125543
{
is qq:to<FOO>,
line1\n line1
line2\r line2
line3\f line3
line4\x0b line4
line5\x85 line5
line6\x2028 line6
line7\x2029 line7
FOO
"line1\n line1\nline2\r line2\nline3\f line3\nline4\x0b line4\nline5\x85 line5\nline6\x2028 line6\nline7\x2029 line7\n",
"Backslashes for line ending characters are indent-transparent";
}
20 changes: 17 additions & 3 deletions S32-str/indent.t
Expand Up @@ -4,7 +4,7 @@ use Test;

# L<S32::Str/Str/"=item indent">

plan 62;
plan 67;

# TODO: Rakudo doesn't have full support for constants, so we have to assume a
# hardcoded 8 instead of $?TABSTOP for now.
Expand Down Expand Up @@ -98,8 +98,17 @@ is "\t\t!".indent(-1),
"\t" ~ ' ' x ($tab - 1) ~ '!',
'Test that tabs explode from the right';

ok ([eq] ((' ' Xx 0..$tab - 1) X~ "\t".indent(-4)),
'Check that varying amounts of space before a tabstop explode in a visually consistent way';
ok ([eq] ((' ' Xx 0..^$tab) X~ "\t".indent(-Int(floor(($tab + 1) div 2)))),
"Sweep 0..{$tab-1} spaces before a tabstop explode in a visually consistent way";

ok ([eq] ((' ' Xx $tab..^$tab * 2) X~ "\t".indent(-Int(floor(($tab + 1) div 2)))),
"Sweep {$tab}..{$tab*2-1} spaces before tab (non-explosion) visual consistency";

ok ([eq] ((' ' Xx $tab..^$tab * 2 - 1) X~ "\x2002\t".indent(-Int(floor(($tab + 1) div 2)))),
"Sweep {$tab}..{$tab*2-2} spaces + mixed space visual consistency";

is " \x2000\x2001\t\x2002".indent(-1), " \x2000\x2001\t\x2002 ",
'Tabs later in mixed line notched back by removing from front';

is " \t!".indent(-1),
' ' x ($tab - 1) ~ '!',
Expand All @@ -125,6 +134,11 @@ is "\tquack\nmeow".indent($tab),
"\t\tquack\n{' ' x $tab}meow",
'Multiline $?TABSTOP-width indent with an unindented line and a tab-indented line';

is " \r \f \x0b \x85 \x2028 \x2029".indent(1), " \r \f \x0b \x85 \x2028 \x2029",
'All specced \v characters in multiline indent';

is " \r \f \x0b \x85 \x2028 \x2029".indent(-1), "\r\f\x0b\x85\x2028\x2029",
'All specced \v characters in multiline outdent';

# Misc
is "\ta\n b".indent(0),
Expand Down

0 comments on commit 552fa60

Please sign in to comment.