[ruby/irb] Properly reset USE_COLORIZE after changing it in tests
Some context tests assigns USE_COLORIZE to false and never change it back. This can potentially affect other tests' result as the default should be nil (activated) instead. https://github.com/ruby/irb/commit/986eb16ece
This commit is contained in:
parent
69337a65b2
commit
a415a3de05
@ -279,7 +279,6 @@ module TestIRB
|
||||
end
|
||||
|
||||
def test_omit_on_assignment
|
||||
IRB.conf[:USE_COLORIZE] = false
|
||||
input = TestInputMethod.new([
|
||||
"a = [1] * 100\n",
|
||||
"a\n",
|
||||
@ -343,7 +342,7 @@ module TestIRB
|
||||
end
|
||||
|
||||
def test_omit_multiline_on_assignment
|
||||
IRB.conf[:USE_COLORIZE] = false
|
||||
without_colorize do
|
||||
input = TestInputMethod.new([
|
||||
"class A; def inspect; ([?* * 1000] * 3).join(%{\\n}); end; end; a = A.new\n",
|
||||
"a\n"
|
||||
@ -412,12 +411,13 @@ module TestIRB
|
||||
assert_equal("", out)
|
||||
irb.context.evaluate('A.remove_method(:inspect)', 0)
|
||||
end
|
||||
end
|
||||
|
||||
def test_echo_on_assignment_conf
|
||||
# Default
|
||||
IRB.conf[:ECHO] = nil
|
||||
IRB.conf[:ECHO_ON_ASSIGNMENT] = nil
|
||||
IRB.conf[:USE_COLORIZE] = false
|
||||
without_colorize do
|
||||
input = TestInputMethod.new()
|
||||
irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
|
||||
|
||||
@ -439,13 +439,15 @@ module TestIRB
|
||||
assert(irb.context.echo?, "echo? should be true by default")
|
||||
refute(irb.context.echo_on_assignment?, "echo_on_assignment? should be false when IRB.conf[:ECHO_ON_ASSIGNMENT] is set to false")
|
||||
end
|
||||
end
|
||||
|
||||
def test_multiline_output_on_default_inspector
|
||||
main = Object.new
|
||||
def main.inspect
|
||||
"abc\ndef"
|
||||
end
|
||||
IRB.conf[:USE_COLORIZE] = false
|
||||
|
||||
without_colorize do
|
||||
input = TestInputMethod.new([
|
||||
"self"
|
||||
])
|
||||
@ -468,8 +470,8 @@ module TestIRB
|
||||
irb.eval_input
|
||||
end
|
||||
assert_empty err
|
||||
assert_equal("=> abc\ndef\n",
|
||||
out)
|
||||
assert_equal("=> abc\ndef\n", out)
|
||||
end
|
||||
end
|
||||
|
||||
def test_default_return_format
|
||||
@ -642,5 +644,15 @@ module TestIRB
|
||||
:*, /\b6\n/,
|
||||
], out)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def without_colorize
|
||||
original_value = IRB.conf[:USE_COLORIZE]
|
||||
IRB.conf[:USE_COLORIZE] = false
|
||||
yield
|
||||
ensure
|
||||
IRB.conf[:USE_COLORIZE] = original_value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user