mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
colorize_code must return escaped text
This was needed before 0c459af7c2
but it
could be actually useless now. But I added this anyway just in case.
This commit is contained in:
parent
6498c733da
commit
de541fe196
2 changed files with 6 additions and 3 deletions
|
@ -123,7 +123,9 @@ module IRB # :nodoc:
|
|||
end
|
||||
|
||||
# give up colorizing incomplete Ripper tokens
|
||||
return code if length != code.bytesize
|
||||
if length != code.bytesize
|
||||
return Reline::Unicode.escape_for_print(code)
|
||||
end
|
||||
|
||||
colored
|
||||
end
|
||||
|
|
|
@ -69,6 +69,7 @@ module TestIRB
|
|||
"\t" => "\t", # not ^I
|
||||
"foo(*%W(bar))" => "foo(*#{RED}%W(#{CLEAR}#{RED}bar#{CLEAR}#{RED})#{CLEAR})",
|
||||
"$stdout" => "#{GREEN}#{BOLD}$stdout#{CLEAR}",
|
||||
"\u0013" => "#{RED}#{REVERSE}^S#{CLEAR}",
|
||||
}.each do |code, result|
|
||||
actual = with_term { IRB::Color.colorize_code(code, complete: true) }
|
||||
assert_equal(result, actual, "Case: colorize_code(#{code.dump}, complete: true)\nResult: #{humanized_literal(actual)}")
|
||||
|
@ -79,7 +80,7 @@ module TestIRB
|
|||
end
|
||||
|
||||
def test_colorize_code_complete_true
|
||||
# `complete: true` behaviors. Warn end-of-file.
|
||||
# `complete: true` behaviors. Warn compile_error.
|
||||
{
|
||||
"'foo' + 'bar" => "#{RED}'#{CLEAR}#{RED}foo#{CLEAR}#{RED}'#{CLEAR} + #{RED}'#{CLEAR}#{RED}#{REVERSE}bar#{CLEAR}",
|
||||
}.each do |code, result|
|
||||
|
@ -89,7 +90,7 @@ module TestIRB
|
|||
end
|
||||
|
||||
def test_colorize_code_complete_false
|
||||
# `complete: false` behaviors. Do not warn end-of-file
|
||||
# `complete: false` behaviors. Do not warn compile_error.
|
||||
{
|
||||
"'foo' + 'bar" => "#{RED}'#{CLEAR}#{RED}foo#{CLEAR}#{RED}'#{CLEAR} + #{RED}'#{CLEAR}#{RED}bar#{CLEAR}",
|
||||
}.each do |code, result|
|
||||
|
|
Loading…
Add table
Reference in a new issue