summaryrefslogtreecommitdiff
path: root/test/bigdecimal/test_bigdecimal.rb
diff options
context:
space:
mode:
authorKenta Murata <mrkn@users.noreply.github.com>2020-07-12 17:30:29 +0900
committerGitHub <noreply@github.com>2020-07-12 17:30:29 +0900
commit9b433d34da90b0e706a388fe67cdfc386a8c2212 (patch)
tree1bacc3d768d20495728a4cfa2e983d1fbdcdbfd0 /test/bigdecimal/test_bigdecimal.rb
parent3b96ad9b54455aef66edd758fa1ef931fa748ce5 (diff)
bidecimal: improve tests' independence (#3297)
Tests depending on the rounding mode must specify the appropriate rounding mode and restore to the original mode at the end.
Notes
Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
Diffstat (limited to 'test/bigdecimal/test_bigdecimal.rb')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 4d53575..11174ad 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -334,6 +334,8 @@ class TestBigDecimal < Test::Unit::TestCase
end
def test_save_rounding_mode
+ saved_mode = BigDecimal.mode(BigDecimal::ROUND_MODE)
+
BigDecimal.mode(BigDecimal::ROUND_MODE, BigDecimal::ROUND_FLOOR)
BigDecimal.save_rounding_mode do
BigDecimal.mode(BigDecimal::ROUND_MODE, BigDecimal::ROUND_HALF_EVEN)
@@ -341,6 +343,8 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(BigDecimal::ROUND_FLOOR, BigDecimal.mode(BigDecimal::ROUND_MODE))
assert_equal(42, BigDecimal.save_rounding_mode { 42 })
+ ensure
+ BigDecimal.mode(BigDecimal::ROUND_MODE, saved_mode)
end
def test_save_limit