Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heredoc body contains a tab that gets incorrectly converted to spaces #6456

Open
p6rt opened this issue Aug 18, 2017 · 2 comments
Open

heredoc body contains a tab that gets incorrectly converted to spaces #6456

p6rt opened this issue Aug 18, 2017 · 2 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 18, 2017

Migrated from rt.perl.org#131927 (status was 'new')

Searchable as RT131927$

@p6rt
Copy link
Author

p6rt commented Aug 18, 2017

From @molecules

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 (Raku/roast#295). I will merge it once I get an RT number.

@p6rt
Copy link
Author

p6rt commented Aug 18, 2017

From @molecules

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';
}

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant