ruby-changes:15590
From: nobu <ko1@a...>
Date: Mon, 26 Apr 2010 10:56:01 +0900 (JST)
Subject: [ruby-changes:15590] Ruby:r27496 (trunk): * test/bigdecimal/testbase.rb (teardown): should reset all modes.
nobu 2010-04-26 10:55:51 +0900 (Mon, 26 Apr 2010) New Revision: 27496 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27496 Log: * test/bigdecimal/testbase.rb (teardown): should reset all modes. Added files: trunk/test/bigdecimal/testbase.rb Modified files: trunk/test/bigdecimal/test_bigdecimal.rb trunk/test/bigdecimal/test_bigmath.rb Index: test/bigdecimal/test_bigdecimal.rb =================================================================== --- test/bigdecimal/test_bigdecimal.rb (revision 27495) +++ test/bigdecimal/test_bigdecimal.rb (revision 27496) @@ -1,14 +1,7 @@ -require "test/unit" -require "bigdecimal" +require_relative "testbase" class TestBigDecimal < Test::Unit::TestCase - def setup - BigDecimal.mode(BigDecimal::EXCEPTION_ALL, true) - BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true) - BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true) - BigDecimal.mode(BigDecimal::ROUND_MODE, BigDecimal::ROUND_HALF_UP) - BigDecimal.limit(0) - end + include TestBigDecimalBase def test_version assert_equal("1.0.1", BigDecimal.ver) Index: test/bigdecimal/test_bigmath.rb =================================================================== --- test/bigdecimal/test_bigmath.rb (revision 27495) +++ test/bigdecimal/test_bigmath.rb (revision 27496) @@ -1,8 +1,8 @@ -require "test/unit" -require "bigdecimal" +require_relative "testbase" require "bigdecimal/math" class TestBigMath < Test::Unit::TestCase + include TestBigDecimalBase include BigMath N = 20 PINF = BigDecimal("+Infinity") Index: test/bigdecimal/testbase.rb =================================================================== --- test/bigdecimal/testbase.rb (revision 0) +++ test/bigdecimal/testbase.rb (revision 27496) @@ -0,0 +1,20 @@ +require "test/unit" +require "bigdecimal" + +module TestBigDecimalBase + def setup + @mode = BigDecimal.mode(BigDecimal::EXCEPTION_ALL) + BigDecimal.mode(BigDecimal::EXCEPTION_ALL, true) + BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true) + BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true) + BigDecimal.mode(BigDecimal::ROUND_MODE, BigDecimal::ROUND_HALF_UP) + BigDecimal.limit(0) + end + + def teardown + [BigDecimal::EXCEPTION_INFINITY, BigDecimal::EXCEPTION_NaN, + BigDecimal::EXCEPTION_UNDERFLOW, BigDecimal::EXCEPTION_OVERFLOW].each do |mode| + BigDecimal.mode(mode, !(@mode & mode).zero?) + end + end +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/