diff options
| author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-07-18 11:36:21 +0900 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-07-18 12:25:55 +0900 |
| commit | 56c8dab46891bb21b637ec64903bb0a38bb5d2a3 (patch) | |
| tree | ff4c37499293e11320c6ea8fc8f96f865ca99420 /test/json | |
| parent | 9f51810f340afca45257043cf1a5955da0379836 (diff) | |
[flori/json] Skip BigDecimal tests when it's missing to load
https://github.com/flori/json/commit/3dd36c6077
Diffstat (limited to 'test/json')
| -rw-r--r-- | test/json/json_addition_test.rb | 2 | ||||
| -rw-r--r-- | test/json/json_parser_test.rb | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/test/json/json_addition_test.rb b/test/json/json_addition_test.rb index 614c735567..d5dab78fed 100644 --- a/test/json/json_addition_test.rb +++ b/test/json/json_addition_test.rb @@ -183,7 +183,7 @@ class JSONAdditionTest < Test::Unit::TestCase def test_bigdecimal assert_equal BigDecimal('3.141', 23), JSON(JSON(BigDecimal('3.141', 23)), :create_additions => true) assert_equal BigDecimal('3.141', 666), JSON(JSON(BigDecimal('3.141', 666)), :create_additions => true) - end + end if defined?(::BigDecimal) def test_ostruct o = OpenStruct.new diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb index 146ff7c047..802408b2cb 100644 --- a/test/json/json_parser_test.rb +++ b/test/json/json_parser_test.rb @@ -4,7 +4,10 @@ require 'test_helper' require 'stringio' require 'tempfile' require 'ostruct' -require 'bigdecimal' +begin + require 'bigdecimal' +rescue LoadError +end class JSONParserTest < Test::Unit::TestCase include JSON @@ -113,7 +116,7 @@ class JSONParserTest < Test::Unit::TestCase def test_parse_bigdecimals assert_equal(BigDecimal, JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"].class) assert_equal(BigDecimal("0.901234567890123456789E1"),JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] ) - end + end if defined?(::BigDecimal) def test_parse_string_mixed_unicode assert_equal(["éé"], JSON.parse("[\"\\u00e9é\"]")) |
