Skip to content

Commit

Permalink
[ruby/irb] Add East Asian Ambiguous Width to irb_info command
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta authored and matzbot committed Dec 20, 2021
1 parent 145f7c0 commit b96ef76
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
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
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 b96ef76

Please sign in to comment.