summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--ext/bigdecimal/bigdecimal.c2
-rw-r--r--test/bigdecimal/test_bigdecimal.rb4
3 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 3d9569c..0b9feb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Wed Sep 29 13:26:30 2010 Kenta Murata <mrkn@mrkn.jp>
+
+ * ext/bigdecimal/bigdecimal.c (BigDecimal_save_rounding_mode):
+ return the result of a block.
+
+ * test/bigdecimal/test_bigdecimal.rb (test_save_rounding_mode):
+ add a test for the above change.
+
+ * test/bigdecimal/test_bigdecimal.rb (test_save_exception_mode):
+ add a test for the return value of BigDecimal.save_exception_mode.
+
Wed Sep 29 12:45:30 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/bigdecimal/bigdecimal.c (BigDecimal_div2, BigDecimal_add2,
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 9781e4e..f5885eb 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -1864,7 +1864,7 @@ BigDecimal_save_rounding_mode(VALUE self)
VALUE ret = rb_protect(rb_yield, Qnil, &state);
VpSetRoundMode(round_mode);
if (state) rb_jump_tag(state);
- return Qnil;
+ return ret;
}
/* call-seq:
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 9f66a79..e8fed16 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -112,6 +112,8 @@ class TestBigDecimal < Test::Unit::TestCase
BigDecimal.mode(BigDecimal::ROUND_MODE, BigDecimal::ROUND_HALF_EVEN)
end
assert_equal(BigDecimal::ROUND_HALF_EVEN, BigDecimal.mode(BigDecimal::ROUND_MODE))
+
+ assert_equal(42, BigDecimal.save_exception_mode { 42 })
end
def test_save_rounding_mode
@@ -120,6 +122,8 @@ class TestBigDecimal < Test::Unit::TestCase
BigDecimal.mode(BigDecimal::ROUND_MODE, BigDecimal::ROUND_HALF_EVEN)
end
assert_equal(BigDecimal::ROUND_FLOOR, BigDecimal.mode(BigDecimal::ROUND_MODE))
+
+ assert_equal(42, BigDecimal.save_rounding_mode { 42 })
end
def test_save_limit