diff options
Diffstat (limited to 'test/irb/test_context.rb')
-rw-r--r-- | test/irb/test_context.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index b3d1884309..49495027c1 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 |