Skip to content

Commit

Permalink
Add East Asian Ambiguous Width to irb_info command
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Dec 20, 2021
1 parent 09c8db2 commit 4cade4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/irb/cmd/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def inspect
str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty?
str += "East Asian Ambiguous Width: #{Reline.ambiguous_width.inspect}\n"
if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
codepage = `chcp`.sub(/.*: (\d+)\n/, '\1')
str += "Code page: #{codepage}\n"
Expand Down
5 changes: 5 additions & 0 deletions test/irb/test_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def test_irb_info_multiline
InputMethod:\sAbstract\sInputMethod\n
\.irbrc\spath:\s.+\n
RUBY_PLATFORM:\s.+\n
East\sAsian\sAmbiguous\sWidth:\s\d\n
#{@is_win ? 'Code\spage:\s\d+\n' : ''}
}x
assert_match expected, irb.context.main.irb_info.to_s
Expand All @@ -107,6 +108,7 @@ def test_irb_info_singleline
InputMethod:\sAbstract\sInputMethod\n
\.irbrc\spath:\s.+\n
RUBY_PLATFORM:\s.+\n
East\sAsian\sAmbiguous\sWidth:\s\d\n
#{@is_win ? 'Code\spage:\s\d+\n' : ''}
}x
assert_match expected, irb.context.main.irb_info.to_s
Expand Down Expand Up @@ -135,6 +137,7 @@ def test_irb_info_multiline_without_rc_files
IRB\sversion:\sirb\s.+\n
InputMethod:\sAbstract\sInputMethod\n
RUBY_PLATFORM:\s.+\n
East\sAsian\sAmbiguous\sWidth:\s\d\n
#{@is_win ? 'Code\spage:\s\d+\n' : ''}
\z
}x
Expand Down Expand Up @@ -167,6 +170,7 @@ def test_irb_info_singleline_without_rc_files
IRB\sversion:\sirb\s.+\n
InputMethod:\sAbstract\sInputMethod\n
RUBY_PLATFORM:\s.+\n
East\sAsian\sAmbiguous\sWidth:\s\d\n
#{@is_win ? 'Code\spage:\s\d+\n' : ''}
\z
}x
Expand Down Expand Up @@ -201,6 +205,7 @@ def test_irb_info_lang
RUBY_PLATFORM: .+\n
LANG\senv:\sja_JP\.UTF-8\n
LC_ALL\s env:\sen_US\.UTF-8\n
East\sAsian\sAmbiguous\sWidth:\s\d\n
}x
assert_match expected, irb.context.main.irb_info.to_s
ensure
Expand Down

0 comments on commit 4cade4b

Please sign in to comment.