mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
75f1ad8cb3
commit
687ab5dcad
1 changed files with 15 additions and 4 deletions
|
@ -31,6 +31,8 @@ module TestIRB
|
||||||
[:CYAN] => "#{CYAN}#{text}#{CLEAR}",
|
[:CYAN] => "#{CYAN}#{text}#{CLEAR}",
|
||||||
}.each do |seq, result|
|
}.each do |seq, result|
|
||||||
assert_equal_with_term(result, text, seq: seq)
|
assert_equal_with_term(result, text, seq: seq)
|
||||||
|
|
||||||
|
assert_equal_with_term(text, text, seq: seq, tty: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,6 +126,9 @@ module TestIRB
|
||||||
if colorize_code_supported?
|
if colorize_code_supported?
|
||||||
assert_equal_with_term(result, code, complete: true)
|
assert_equal_with_term(result, code, complete: true)
|
||||||
assert_equal_with_term(result, code, complete: false)
|
assert_equal_with_term(result, code, complete: false)
|
||||||
|
|
||||||
|
assert_equal_with_term(code, code, complete: true, tty: false)
|
||||||
|
assert_equal_with_term(code, code, complete: false, tty: false)
|
||||||
else
|
else
|
||||||
assert_equal_with_term(code, code)
|
assert_equal_with_term(code, code)
|
||||||
end
|
end
|
||||||
|
@ -141,6 +146,8 @@ module TestIRB
|
||||||
"('foo" => "(#{RED}#{BOLD}'#{CLEAR}#{RED}#{REVERSE}foo#{CLEAR}",
|
"('foo" => "(#{RED}#{BOLD}'#{CLEAR}#{RED}#{REVERSE}foo#{CLEAR}",
|
||||||
}.each do |code, result|
|
}.each do |code, result|
|
||||||
assert_equal_with_term(result, code, complete: true)
|
assert_equal_with_term(result, code, complete: true)
|
||||||
|
|
||||||
|
assert_equal_with_term(code, code, complete: true, tty: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -153,8 +160,12 @@ module TestIRB
|
||||||
if colorize_code_supported?
|
if colorize_code_supported?
|
||||||
assert_equal_with_term(result, code, complete: false)
|
assert_equal_with_term(result, code, complete: false)
|
||||||
|
|
||||||
|
assert_equal_with_term(code, code, complete: false, tty: false)
|
||||||
|
|
||||||
unless complete_option_supported?
|
unless complete_option_supported?
|
||||||
assert_equal_with_term(result, code, complete: true)
|
assert_equal_with_term(result, code, complete: true)
|
||||||
|
|
||||||
|
assert_equal_with_term(code, code, complete: true, tty: false)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
assert_equal_with_term(code, code)
|
assert_equal_with_term(code, code)
|
||||||
|
@ -194,10 +205,10 @@ module TestIRB
|
||||||
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
|
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_term
|
def with_term(tty: true)
|
||||||
stdout = $stdout
|
stdout = $stdout
|
||||||
io = StringIO.new
|
io = StringIO.new
|
||||||
def io.tty?; true; end
|
def io.tty?; true; end if tty
|
||||||
$stdout = io
|
$stdout = io
|
||||||
|
|
||||||
env = ENV.to_h.dup
|
env = ENV.to_h.dup
|
||||||
|
@ -209,8 +220,8 @@ module TestIRB
|
||||||
ENV.replace(env) if env
|
ENV.replace(env) if env
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_equal_with_term(result, code, seq: nil, **opts)
|
def assert_equal_with_term(result, code, seq: nil, tty: true, **opts)
|
||||||
actual = with_term do
|
actual = with_term(tty: tty) do
|
||||||
if seq
|
if seq
|
||||||
IRB::Color.colorize(code, seq, **opts)
|
IRB::Color.colorize(code, seq, **opts)
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue