Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 49401) +++ ext/bigdecimal/bigdecimal.c (working copy) @@ -124,8 +124,9 @@ * 1.0.0: Ruby 1.8.0 * 1.0.1: Ruby 1.8.1 * 1.1.0: Ruby 1.9.3 + * 1.2.0: Ruby 2.3.0 */ - return rb_str_new2("1.1.0"); + return rb_str_new2("1.2.0"); } /* @@ -3259,6 +3260,15 @@ arg = rb_str_new2("NaN"); /* 'Not a Number' value. */ rb_define_const(rb_cBigDecimal, "NAN", BigDecimal_global_new(1, &arg, rb_cBigDecimal)); + arg = rb_str_new2("0"); + /* Singleton instance of BigDecimal.new('0'). */ + rb_define_const(rb_cBigDecimal, "ZERO", BigDecimal_global_new(1, &arg, rb_cBigDecimal)); + arg = rb_str_new2("1"); + /* Singleton instance of BigDecimal.new('1'). */ + rb_define_const(rb_cBigDecimal, "ONE", BigDecimal_global_new(1, &arg, rb_cBigDecimal)); + arg = rb_str_new2("10"); + /* Singleton instance of BigDecimal.new('10'). */ + rb_define_const(rb_cBigDecimal, "TEN", BigDecimal_global_new(1, &arg, rb_cBigDecimal)); /* instance methods */ Index: ext/bigdecimal/bigdecimal.h =================================================================== --- ext/bigdecimal/bigdecimal.h (revision 49401) +++ ext/bigdecimal/bigdecimal.h (working copy) @@ -114,6 +114,7 @@ #define SZ_PINF "+Infinity" #define SZ_NINF "-Infinity" + /* * #define VP_EXPORT other than static to let VP_ routines * be called from outside of this module. Index: test/bigdecimal/test_bigdecimal.rb =================================================================== --- test/bigdecimal/test_bigdecimal.rb (revision 49401) +++ test/bigdecimal/test_bigdecimal.rb (working copy) @@ -1552,4 +1552,25 @@ Thread.current.keys.to_s EOS end + + def test_zero_const + assert_equal(BigDecimal::ZERO, BigDecimal.new('0')) + assert_equal(BigDecimal::ZERO.object_id, BigDecimal::ZERO.object_id) + assert_equal((-BigDecimal::ZERO), BigDecimal.new('-0')) + assert_equal((-BigDecimal::ZERO).object_id, (-BigDecimal::ZERO).object_id) + end + + def test_one_const + assert_equal(BigDecimal::ONE, BigDecimal.new('1')) + assert_equal(BigDecimal::ONE.object_id, BigDecimal::ONE.object_id) + assert_equal((-BigDecimal::ONE), BigDecimal.new('-1')) + assert_equal((-BigDecimal::ONE).object_id, (-BigDecimal::ONE).object_id) + end + + def test_ten_const + assert_equal(BigDecimal::TEN, BigDecimal.new('10')) + assert_equal(BigDecimal::TEN.object_id, BigDecimal::TEN.object_id) + assert_equal((-BigDecimal::TEN), BigDecimal.new('-10')) + assert_equal((-BigDecimal::TEN).object_id, (-BigDecimal::TEN).object_id) + end end