summaryrefslogtreecommitdiff
path: root/test/irb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-01-08 04:51:28 +0900
committeraycabta <aycabta@gmail.com>2021-01-08 13:25:18 +0900
commit111fddd5437c0d2d6755f8aa474da4b54f89bc44 (patch)
tree1f0bc6b821f4e1489a628559347fa7249ff202c9 /test/irb
parent917050220a1fd41bdb3e50ea54a200b0c285bcd4 (diff)
[ruby/irb] Fix BACK_TRACE_LIMIT logic
https://github.com/ruby/irb/commit/30dc5d43fe
Diffstat (limited to 'test/irb')
-rw-r--r--test/irb/test_context.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb
index b3d1884..4949502 100644
--- a/test/irb/test_context.rb
+++ b/test/irb/test_context.rb
@@ -476,5 +476,71 @@ module TestIRB
ensure
$VERBOSE = verbose
end
+
+ def test_eval_input_with_long_exception
+ skip if RUBY_ENGINE == 'truffleruby'
+ verbose, $VERBOSE = $VERBOSE, nil
+ nesting = 20
+ generated_code = ''
+ nesting.times do |i|
+ generated_code << "def a#{i}() a#{i + 1}; end; "
+ end
+ generated_code << "def a#{nesting}() raise; end; a0\n"
+ input = TestInputMethod.new([
+ generated_code
+ ])
+ irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
+ out, err = capture_output do
+ irb.eval_input
+ end
+ assert_empty err
+ if '2.5.0' <= RUBY_VERSION && RUBY_VERSION < '3.0.0'
+ expected = [
+ :*, /Traceback \(most recent call last\):\n/,
+ :*, /\t... 5 levels...\n/,
+ :*, /\t16: from \(irb\):1:in `a4'\n/,
+ :*, /\t15: from \(irb\):1:in `a5'\n/,
+ :*, /\t14: from \(irb\):1:in `a6'\n/,
+ :*, /\t13: from \(irb\):1:in `a7'\n/,
+ :*, /\t12: from \(irb\):1:in `a8'\n/,
+ :*, /\t11: from \(irb\):1:in `a9'\n/,
+ :*, /\t10: from \(irb\):1:in `a10'\n/,
+ :*, /\t 9: from \(irb\):1:in `a11'\n/,
+ :*, /\t 8: from \(irb\):1:in `a12'\n/,
+ :*, /\t 7: from \(irb\):1:in `a13'\n/,
+ :*, /\t 6: from \(irb\):1:in `a14'\n/,
+ :*, /\t 5: from \(irb\):1:in `a15'\n/,
+ :*, /\t 4: from \(irb\):1:in `a16'\n/,
+ :*, /\t 3: from \(irb\):1:in `a17'\n/,
+ :*, /\t 2: from \(irb\):1:in `a18'\n/,
+ :*, /\t 1: from \(irb\):1:in `a19'\n/,
+ :*, /\(irb\):1:in `a20': unhandled exception\n/,
+ ]
+ else
+ expected = [
+ :*, /\(irb\):1:in `a20': unhandled exception\n/,
+ :*, /\tfrom \(irb\):1:in `a19'\n/,
+ :*, /\tfrom \(irb\):1:in `a18'\n/,
+ :*, /\tfrom \(irb\):1:in `a17'\n/,
+ :*, /\tfrom \(irb\):1:in `a16'\n/,
+ :*, /\tfrom \(irb\):1:in `a15'\n/,
+ :*, /\tfrom \(irb\):1:in `a14'\n/,
+ :*, /\tfrom \(irb\):1:in `a13'\n/,
+ :*, /\tfrom \(irb\):1:in `a12'\n/,
+ :*, /\tfrom \(irb\):1:in `a11'\n/,
+ :*, /\tfrom \(irb\):1:in `a10'\n/,
+ :*, /\tfrom \(irb\):1:in `a9'\n/,
+ :*, /\tfrom \(irb\):1:in `a8'\n/,
+ :*, /\tfrom \(irb\):1:in `a7'\n/,
+ :*, /\tfrom \(irb\):1:in `a6'\n/,
+ :*, /\tfrom \(irb\):1:in `a5'\n/,
+ :*, /\tfrom \(irb\):1:in `a4'\n/,
+ :*, /\t... 5 levels...\n/,
+ ]
+ end
+ assert_pattern_list(expected, out)
+ ensure
+ $VERBOSE = verbose
+ end
end
end