diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ripper/test_parser_events.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 35264868b9..348e87696a 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -1765,4 +1765,26 @@ class TestRipper::ParserEvents < Test::Unit::TestCase end end; end + + def test_return_out_of_warn_no_memory_leak + assert_no_memory_leak(%w(-rripper), "#{<<~'begin;'}", "#{<<~'end;'}", rss: true) + class MyRipper < Ripper + def initialize(src, &blk) + super(src) + @blk = blk + end + + def warn(msg, *args) = @blk.call(msg) + end + + def call_parse = MyRipper.new("{ a: 1, a: 2 }") { |msg| return msg }.parse + + # Check that call_parse does warn + raise "call_parse should warn" unless call_parse + begin; + 500_000.times do + call_parse + end + end; + end end if ripper_test |