From c870705df4b76913c4e335ca5e4a92e5f833f940 Mon Sep 17 00:00:00 2001 From: yugui Date: Mon, 20 Dec 2010 13:23:02 +0000 Subject: merges r29885 from trunk into ruby_1_9_2. -- * vm.c (rb_thread_mark): should mark self in conrol frames. [ruby-core:33289] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_optimization.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test') diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index 8e8311e6ef..b581b7dfd3 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -137,4 +137,27 @@ class TestRubyOptimization < Test::Unit::TestCase assert_equal true, MyObj.new == nil end + def test_tailcall + bug4082 = '[ruby-core:33289]' + + option = { + tailcall_optimization: true, + trace_instruction: false, + } + iseq = RubyVM::InstructionSequence.new(<<-EOF, bug4082, __FILE__, __LINE__+1, option).eval + class #{self.class}::Tailcall + def fact_helper(n, res) + if n == 1 + res + else + fact_helper(n - 1, n * res) + end + end + def fact(n) + fact_helper(n, 1) + end + end + EOF + assert_equal(9131, Tailcall.new.fact(3000).to_s.size, bug4082) + end end -- cgit v1.2.3