From ecfc868bdb5e43cdb585767006e9df2de575eed2 Mon Sep 17 00:00:00 2001 From: mrkn Date: Wed, 29 Sep 2010 08:55:11 +0000 Subject: [PATCH] * ext/bigdecimal/bigdecimal.c (BigDecimal_save_limit): return the result of a block. * test/bigdecimal/test_bigdecimal.rb (test_save_limit): add a test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/bigdecimal/bigdecimal.c | 2 +- test/bigdecimal/test_bigdecimal.rb | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4eb868a61e..6a5628e677 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Sep 29 17:41:34 2010 Kenta Murata + + * ext/bigdecimal/bigdecimal.c (BigDecimal_save_limit): + return the result of a block. + + * test/bigdecimal/test_bigdecimal.rb (test_save_limit): + add a test for the above change. + Wed Sep 29 16:18:03 2010 NAKAMURA Usaku * vm_dump.c (dump_thread): remove ununsed optional arguments. diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index f5885ebbbd..9ed8a562a3 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -1878,7 +1878,7 @@ BigDecimal_save_limit(VALUE self) VALUE ret = rb_protect(rb_yield, Qnil, &state); VpSetPrecLimit(limit); if (state) rb_jump_tag(state); - return Qnil; + return ret; } /* Document-class: BigDecimal diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index e8fed1661b..810630549b 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -137,6 +137,8 @@ class TestBigDecimal < Test::Unit::TestCase ensure BigDecimal.limit(old) end + + assert_equal(42, BigDecimal.save_limit { 42 }) end def test_exception_nan