8000 irb: add more syntax errors colorizing support (#3967) · aycabta/ruby@74c743a · GitHub
[go: up one dir, main page]

Skip to content

Commit 74c743a

Browse files
no6vaycabta
authored andcommitted
irb: add more syntax errors colorizing support (ruby#3967)
1 parent 779334d commit 74c743a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/irb/color.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ module Color
6060
on_words_beg: [[RED, BOLD], ALL],
6161
on_parse_error: [[RED, REVERSE], ALL],
6262
compile_error: [[RED, REVERSE], ALL],
63+
on_assign_error: [[RED, REVERSE], ALL],
64+
on_alias_error: [[RED, REVERSE], ALL],
65+
on_class_name_error:[[RED, REVERSE], ALL],
66+
on_param_error: [[RED, REVERSE], ALL],
6367
}
6468
rescue NameError
6569
# Give up highlighting Ripper-incompatible older Ruby

test/irb/test_color.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,23 @@ def test_colorize_code
8282
tests.merge!({
8383
"[1]]]\u0013" => "[#{BLUE}#{BOLD}1#{CLEAR}]#{RED}#{REVERSE}]#{CLEAR}#{RED}#{REVERSE}]#{CLEAR}#{RED}#{REVERSE}^S#{CLEAR}",
8484
})
85+
tests.merge!({
86+
"def req(true) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}true#{CLEAR}) #{RED}#{REVERSE}end#{CLEAR}",
87+
"nil = 1" => "#{RED}#{REVERSE}nil#{CLEAR} = #{BLUE}#{BOLD}1#{CLEAR}",
88+
"alias $x $1" => "#{GREEN}alias#{CLEAR} #{GREEN}#{BOLD}$x#{CLEAR} #{RED}#{REVERSE}$1#{CLEAR}",
89+
"class bad; end" => "#{GREEN}class#{CLEAR} #{RED}#{REVERSE}bad#{CLEAR}; #{GREEN}end#{CLEAR}",
90+
"def req(@a) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}@a#{CLEAR}) #{GREEN}end#{CLEAR}",
91+
})
8592
else
8693
tests.merge!({
8794
"[1]]]\u0013" => "[1]]]^S",
95+
})
96+
tests.merge!({
97+
"def req(true) end" => "def req(true) end",
98+
"nil = 1" => "#{CYAN}#{BOLD}nil#{CLEAR} = #{BLUE}#{BOLD}1#{CLEAR}",
99+
"alias $x $1" => "#{GREEN}alias#{CLEAR} #{GREEN}#{BOLD}$x#{CLEAR} $1",
100+
"class bad; end" => "#{GREEN}class#{CLEAR} bad; #{GREEN}end#{CLEAR}",
101+
"def req(@a) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(@a) #{GREEN}end#{CLEAR}",
88102
})
89103
end
90104

0 commit comments

Comments
 (0)
0