# New Ticket Created by  Christopher Bottoms 
# Please include the string:  [perl #131927]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131927 >


When heredoc bodies are preceded by spaces, but the body itself contains a tab, 
sometimes the tab in the resulting heredoc gets converted to spaces. The 
attached test file demonstrates 5 failing cases (with a total of 10 tests) and 
one passing case (with one test). I've already submitted a pull request to 
roast (https://github.com/perl6/roast/pull/295). I will merge it once I get an 
RT number.
use v6;
use Test;
plan 11;

sub no-r(Str $in) { $in.subst("\r\n", "\n", :g) }

#?rakudo skip 'RT not yet assigned'
{
    # Don't change the space in front of any of these, or you'll change the 
test!

    # 4 spaces are present between the beginning of the line and the heredoc 
body
    my @q1 = q:to/END/;
    line one
        line two
    END
    is   no-r(@q1[0]), "line one\n\tline two\n",   'trim 4 spaces, leave 
leading tab in line two';
    isnt no-r(@q1[0]), "line one\n    line two\n", 'should not contain 4 
leading spaces at line two.';

    # Same exact heredoc body, except it is moved to the right one space
    # 5 spaces are present between the beginning of the line and the heredoc 
body
    my @q2 = q:to/END/;
     line one
        line two
     END
     is no-r(@q2[0]),   "line one\n\tline two\n",  'trim 5 spaces, leave 
leading tab in line two';
     isnt no-r(@q2[0]), "line one\n   line two\n", 'should not contain 3 
leading spaces in line two.';

    # Same heredoc body as the first, except moved to the right two spaces
    # 6 spaces are present between the beginning of the line and the heredoc 
body
    my @q3 = q:to/END/;
      line one
        line two
      END
    is no-r(@q3[0]),   "line one\n\tline two\n", 'trim 6 spaces, leave leading 
tab in line two';
    isnt no-r(@q3[0]), "line one\n  line two\n", 'should not contain 2 leading 
spaces in line two';

    # Same heredoc body as the first, except moved to the right three spaces
    # 7 spaces are present between the beginning of the line and the heredoc 
body
    my @q4 = q:to/END/;
       line one
        line two
       END
    is no-r(@q4[0]),   "line one\n\tline two\n", 'trim 7 leading spaces, leave 
leading tab in line two';
    isnt no-r(@q4[0]), "line one\n line two\n",  'should not contain 1 leading 
space in line two';

    # ONLY TEST THAT PASSES
    # Same heredoc body as the first, except moved to the right four spaces
    # 8 spaces are present between the beginning of the line and the heredoc 
body
    my @q5 = q:to/END/;
        line one
                line two
        END
    is no-r(@q5[0]),   "line one\n\tline two\n", 'trim 8 leading spaces, leave 
leading tab in line two';

    # Same heredoc body as the first, except moved to the right five spaces
    # 9 spaces are present between the beginning of the line and the heredoc 
body
    my @q6 = q:to/END/;
         line one
                line two
         END
    is   no-r(@q6[0]), "line one\n\tline two\n",      'trim 9 leading spaces, 
leave leading tab in line two';
    isnt no-r(@q6[0]), "line one\n       line two\n", 'should not contain 7 
leading spaces in line two';
}

Reply via email to