summaryrefslogtreecommitdiff
path: root/test/irb/test_context.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/irb/test_context.rb')
-rw-r--r--test/irb/test_context.rb76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb
index 3a4c987..fa628bb 100644
--- a/test/irb/test_context.rb
+++ b/test/irb/test_context.rb
@@ -286,6 +286,82 @@ module TestIRB
assert_equal("", out)
end
+ def test_omit_multiline_on_assignment
+ input = TestInputMethod.new([
+ "class A; def inspect; ([?* * 1000] * 3).join(%{\\n}); end; end; a = A.new\n",
+ "a\n"
+ ])
+ value = ([?* * 1000] * 3).join(%{\n})
+ value_first_line = (?* * 1000).to_s
+ irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
+ irb.context.return_format = "=> %s\n"
+
+ irb.context.echo = true
+ irb.context.echo_on_assignment = false
+ irb.context.omit_on_assignment = true
+ out, err = capture_io do
+ irb.eval_input
+ end
+ assert_empty err
+ assert_equal("=> \n#{value}\n", out)
+ irb.context.evaluate('A.remove_method(:inspect)', 0)
+
+ input.reset
+ irb.context.echo = true
+ irb.context.echo_on_assignment = true
+ irb.context.omit_on_assignment = true
+ out, err = capture_io do
+ irb.eval_input
+ end
+ assert_empty err
+ assert_equal("=> #{value_first_line[0..(input.winsize.last - 9)]}...\e[0m\n=> \n#{value}\n", out)
+ irb.context.evaluate('A.remove_method(:inspect)', 0)
+
+ input.reset
+ irb.context.echo = true
+ irb.context.echo_on_assignment = true
+ irb.context.omit_on_assignment = false
+ out, err = capture_io do
+ irb.eval_input
+ end
+ assert_empty err
+ assert_equal("=> \n#{value}\n=> \n#{value}\n", out)
+ irb.context.evaluate('A.remove_method(:inspect)', 0)
+
+ input.reset
+ irb.context.echo = false
+ irb.context.echo_on_assignment = false
+ irb.context.omit_on_assignment = true
+ out, err = capture_io do
+ irb.eval_input
+ end
+ assert_empty err
+ assert_equal("", out)
+ irb.context.evaluate('A.remove_method(:inspect)', 0)
+
+ input.reset
+ irb.context.echo = false
+ irb.context.echo_on_assignment = true
+ irb.context.omit_on_assignment = true
+ out, err = capture_io do
+ irb.eval_input
+ end
+ assert_empty err
+ assert_equal("", out)
+ irb.context.evaluate('A.remove_method(:inspect)', 0)
+
+ input.reset
+ irb.context.echo = false
+ irb.context.echo_on_assignment = true
+ irb.context.omit_on_assignment = false
+ out, err = capture_io do
+ irb.eval_input
+ end
+ assert_empty err
+ assert_equal("", out)
+ irb.context.evaluate('A.remove_method(:inspect)', 0)
+ end
+
def test_echo_on_assignment_conf
# Default
IRB.conf[:ECHO] = nil