From 039679f1af32af9c285ce1fff2d9e8fd52af51eb Mon Sep 17 00:00:00 2001 From: Beoran Date: Thu, 22 Nov 2012 11:02:17 +0100 Subject: Keep stack depth and allocation better under control and fix crash on infinite recursion. --- test/t/exception.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test') diff --git a/test/t/exception.rb b/test/t/exception.rb index aa707c1b1..a2e6acc07 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -290,3 +290,26 @@ end assert('Exception#inspect without message') do Exception.new.inspect end + +# very deeply recursive function that stil returns albeit very deeply so +$test_infinite_recursion = 0 +TEST_INFINITE_RECURSION_MAX = 100000 +def test_infinite_recursion + $test_infinite_recursion += 1 + if $test_infinite_recursion > TEST_INFINITE_RECURSION_MAX + return $test_infinite_recursion + end + test_infinite_recursion +end + +assert('Infinite recursion should result in an exception being raised') do + a = begin + test_infinite_recursion + rescue + :ok + end + # OK if an exception was caught, otherwise a number will be stored in a + a == :ok +end + + -- cgit v1.2.3