Project

General

Profile

Actions

Misc #17662

open

The heredoc pattern used in tests does not syntax highlight correctly in many editors

Added by Eregon (Benoit Daloze) 4 months ago. Updated about 15 hours ago.

Status:
Assigned
Priority:
Normal
[ruby-core:102639]

Description

This heredoc pattern

    assert_ruby_status([], "#{<<-"begin;"}\n#{<<-'end;'}", bug)
    begin;
      exit("1" == Thread.start(1, &:to_s).value)
    end;

completely breaks syntax highlighting in at least:

  • GitHub: there are many examples
  • Atom
  • RubyMine (and IntelliJ)
  • Likely many more editors based on TextMate grammars

Could another pattern be used in tests inside the ruby/ruby repository (at least for test/ruby)?

Due to this issue, it is very annoying and inconvenient to look at/read/investigate many tests.

I think this pattern is also very complicated to understand (and using ; is quite weird for this).
I suggest to replace it with this obvious and simple pattern many people use:

    assert_ruby_status([], <<~'RUBY', bug)
      exit("1" == Thread.start(1, &:to_s).value)
    RUBY

This syntax highlights correctly in most (all?) editors, and as an added bonus the code inside the heredoc is also highlighted in some editors (due to the label being RUBY).

Actions

Also available in: Atom PDF