oj 3.13.23 → 3.16.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +81 -0
 - data/README.md +2 -2
 - data/ext/oj/buf.h +7 -6
 - data/ext/oj/cache.c +29 -26
 - data/ext/oj/cache.h +3 -2
 - data/ext/oj/cache8.c +10 -9
 - data/ext/oj/circarray.c +7 -5
 - data/ext/oj/circarray.h +2 -2
 - data/ext/oj/code.c +5 -12
 - data/ext/oj/code.h +2 -2
 - data/ext/oj/compat.c +20 -60
 - data/ext/oj/custom.c +26 -59
 - data/ext/oj/debug.c +3 -9
 - data/ext/oj/dump.c +103 -53
 - data/ext/oj/dump.h +1 -4
 - data/ext/oj/dump_compat.c +557 -592
 - data/ext/oj/dump_leaf.c +3 -5
 - data/ext/oj/dump_object.c +42 -48
 - data/ext/oj/dump_strict.c +10 -22
 - data/ext/oj/encoder.c +1 -1
 - data/ext/oj/err.c +2 -13
 - data/ext/oj/err.h +9 -12
 - data/ext/oj/extconf.rb +16 -7
 - data/ext/oj/fast.c +60 -92
 - data/ext/oj/intern.c +62 -47
 - data/ext/oj/intern.h +3 -7
 - data/ext/oj/mem.c +318 -0
 - data/ext/oj/mem.h +53 -0
 - data/ext/oj/mimic_json.c +51 -32
 - data/ext/oj/object.c +33 -43
 - data/ext/oj/odd.c +8 -6
 - data/ext/oj/odd.h +4 -4
 - data/ext/oj/oj.c +243 -212
 - data/ext/oj/oj.h +83 -81
 - data/ext/oj/parse.c +94 -148
 - data/ext/oj/parse.h +21 -24
 - data/ext/oj/parser.c +80 -67
 - data/ext/oj/parser.h +7 -8
 - data/ext/oj/rails.c +70 -92
 - data/ext/oj/reader.c +9 -14
 - data/ext/oj/reader.h +4 -2
 - data/ext/oj/resolve.c +3 -4
 - data/ext/oj/rxclass.c +6 -5
 - data/ext/oj/rxclass.h +1 -1
 - data/ext/oj/saj.c +10 -9
 - data/ext/oj/saj2.c +37 -49
 - data/ext/oj/saj2.h +1 -1
 - data/ext/oj/scp.c +3 -14
 - data/ext/oj/sparse.c +22 -70
 - data/ext/oj/stream_writer.c +45 -41
 - data/ext/oj/strict.c +20 -52
 - data/ext/oj/string_writer.c +64 -38
 - data/ext/oj/trace.h +31 -4
 - data/ext/oj/usual.c +125 -114
 - data/ext/oj/usual.h +7 -6
 - data/ext/oj/util.h +1 -1
 - data/ext/oj/val_stack.c +13 -2
 - data/ext/oj/val_stack.h +8 -7
 - data/ext/oj/wab.c +25 -57
 - data/lib/oj/active_support_helper.rb +1 -3
 - data/lib/oj/bag.rb +7 -1
 - data/lib/oj/easy_hash.rb +4 -5
 - data/lib/oj/error.rb +0 -1
 - data/lib/oj/json.rb +162 -150
 - data/lib/oj/mimic.rb +7 -7
 - data/lib/oj/schandler.rb +5 -4
 - data/lib/oj/state.rb +8 -5
 - data/lib/oj/version.rb +1 -2
 - data/lib/oj.rb +2 -0
 - data/pages/InstallOptions.md +20 -0
 - data/pages/Options.md +4 -0
 - data/test/_test_active.rb +8 -9
 - data/test/_test_active_mimic.rb +7 -8
 - data/test/_test_mimic_rails.rb +17 -20
 - data/test/activerecord/result_test.rb +5 -6
 - data/test/activesupport6/encoding_test.rb +63 -28
 - data/test/activesupport7/abstract_unit.rb +4 -1
 - data/test/activesupport7/encoding_test.rb +72 -22
 - data/test/files.rb +15 -15
 - data/test/foo.rb +18 -69
 - data/test/helper.rb +5 -8
 - data/test/isolated/shared.rb +3 -2
 - data/test/json_gem/json_addition_test.rb +2 -2
 - data/test/json_gem/json_common_interface_test.rb +8 -6
 - data/test/json_gem/json_encoding_test.rb +0 -0
 - data/test/json_gem/json_ext_parser_test.rb +1 -0
 - data/test/json_gem/json_fixtures_test.rb +3 -2
 - data/test/json_gem/json_generator_test.rb +50 -33
 - data/test/json_gem/json_generic_object_test.rb +11 -11
 - data/test/json_gem/json_parser_test.rb +46 -46
 - data/test/json_gem/json_string_matching_test.rb +9 -9
 - data/test/mem.rb +13 -12
 - data/test/perf.rb +21 -26
 - data/test/perf_compat.rb +31 -33
 - data/test/perf_dump.rb +28 -28
 - data/test/perf_fast.rb +80 -82
 - data/test/perf_file.rb +27 -29
 - data/test/perf_object.rb +65 -69
 - data/test/perf_once.rb +12 -11
 - data/test/perf_parser.rb +42 -48
 - data/test/perf_saj.rb +46 -54
 - data/test/perf_scp.rb +57 -69
 - data/test/perf_simple.rb +41 -39
 - data/test/perf_strict.rb +68 -70
 - data/test/perf_wab.rb +67 -69
 - data/test/prec.rb +5 -5
 - data/test/sample/change.rb +0 -1
 - data/test/sample/dir.rb +0 -1
 - data/test/sample/doc.rb +0 -1
 - data/test/sample/file.rb +0 -1
 - data/test/sample/group.rb +0 -1
 - data/test/sample/hasprops.rb +0 -1
 - data/test/sample/layer.rb +0 -1
 - data/test/sample/rect.rb +0 -1
 - data/test/sample/shape.rb +0 -1
 - data/test/sample/text.rb +0 -1
 - data/test/sample.rb +16 -16
 - data/test/sample_json.rb +8 -8
 - data/test/test_compat.rb +81 -54
 - data/test/test_custom.rb +63 -52
 - data/test/test_debian.rb +7 -10
 - data/test/test_fast.rb +86 -90
 - data/test/test_file.rb +24 -29
 - data/test/test_gc.rb +5 -5
 - data/test/test_generate.rb +5 -5
 - data/test/test_hash.rb +4 -4
 - data/test/test_integer_range.rb +9 -9
 - data/test/test_null.rb +20 -20
 - data/test/test_object.rb +92 -87
 - data/test/test_parser.rb +4 -4
 - data/test/test_parser_debug.rb +5 -5
 - data/test/test_parser_saj.rb +27 -25
 - data/test/test_parser_usual.rb +44 -6
 - data/test/test_rails.rb +2 -2
 - data/test/test_saj.rb +10 -8
 - data/test/test_scp.rb +35 -35
 - data/test/test_strict.rb +38 -32
 - data/test/test_various.rb +146 -97
 - data/test/test_wab.rb +46 -44
 - data/test/test_writer.rb +63 -47
 - data/test/tests.rb +7 -7
 - data/test/tests_mimic.rb +6 -6
 - data/test/tests_mimic_addition.rb +6 -6
 - metadata +46 -26
 - data/test/activesupport4/decoding_test.rb +0 -108
 - data/test/activesupport4/encoding_test.rb +0 -531
 - data/test/activesupport4/test_helper.rb +0 -41
 - data/test/activesupport5/abstract_unit.rb +0 -45
 - data/test/activesupport5/decoding_test.rb +0 -133
 - data/test/activesupport5/encoding_test.rb +0 -500
 - data/test/activesupport5/encoding_test_cases.rb +0 -98
 - data/test/activesupport5/test_helper.rb +0 -72
 - data/test/activesupport5/time_zone_test_helpers.rb +0 -39
 - data/test/bar.rb +0 -11
 - data/test/baz.rb +0 -16
 - data/test/bug.rb +0 -16
 - data/test/zoo.rb +0 -13
 
    
        data/test/test_fast.rb
    CHANGED
    
    | 
         @@ -1,8 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby
         
     | 
| 
       2 
     | 
    
         
            -
            # coding: utf-8
         
     | 
| 
       3 
2 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       4 
3 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
            $LOAD_PATH << __dir__
         
     | 
| 
       6 
5 
     | 
    
         | 
| 
       7 
6 
     | 
    
         
             
            require 'helper'
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
         @@ -52,7 +51,7 @@ class DocTest < Minitest::Test 
     | 
|
| 
       52 
51 
     | 
    
         
             
                json = %{true}
         
     | 
| 
       53 
52 
     | 
    
         
             
                Oj::Doc.open(json) do |doc|
         
     | 
| 
       54 
53 
     | 
    
         
             
                  assert_equal(TrueClass, doc.type)
         
     | 
| 
       55 
     | 
    
         
            -
                   
     | 
| 
      
 54 
     | 
    
         
            +
                  assert(doc.fetch())
         
     | 
| 
       56 
55 
     | 
    
         
             
                end
         
     | 
| 
       57 
56 
     | 
    
         
             
              end
         
     | 
| 
       58 
57 
     | 
    
         | 
| 
         @@ -60,7 +59,7 @@ class DocTest < Minitest::Test 
     | 
|
| 
       60 
59 
     | 
    
         
             
                json = %{false}
         
     | 
| 
       61 
60 
     | 
    
         
             
                Oj::Doc.open(json) do |doc|
         
     | 
| 
       62 
61 
     | 
    
         
             
                  assert_equal(FalseClass, doc.type)
         
     | 
| 
       63 
     | 
    
         
            -
                   
     | 
| 
      
 62 
     | 
    
         
            +
                  refute(doc.fetch())
         
     | 
| 
       64 
63 
     | 
    
         
             
                end
         
     | 
| 
       65 
64 
     | 
    
         
             
              end
         
     | 
| 
       66 
65 
     | 
    
         | 
| 
         @@ -76,7 +75,7 @@ class DocTest < Minitest::Test 
     | 
|
| 
       76 
75 
     | 
    
         
             
                json = %{"ぴーたー"}
         
     | 
| 
       77 
76 
     | 
    
         
             
                Oj::Doc.open(json) do |doc|
         
     | 
| 
       78 
77 
     | 
    
         
             
                  assert_equal(String, doc.type)
         
     | 
| 
       79 
     | 
    
         
            -
                  assert_equal( 
     | 
| 
      
 78 
     | 
    
         
            +
                  assert_equal('ぴーたー', doc.fetch())
         
     | 
| 
       80 
79 
     | 
    
         
             
                end
         
     | 
| 
       81 
80 
     | 
    
         
             
              end
         
     | 
| 
       82 
81 
     | 
    
         | 
| 
         @@ -84,19 +83,15 @@ class DocTest < Minitest::Test 
     | 
|
| 
       84 
83 
     | 
    
         
             
                json = %{"\\u3074\\u30fc\\u305f\\u30fc"}
         
     | 
| 
       85 
84 
     | 
    
         
             
                Oj::Doc.open(json) do |doc|
         
     | 
| 
       86 
85 
     | 
    
         
             
                  assert_equal(String, doc.type)
         
     | 
| 
       87 
     | 
    
         
            -
                  assert_equal( 
     | 
| 
      
 86 
     | 
    
         
            +
                  assert_equal('ぴーたー', doc.fetch())
         
     | 
| 
       88 
87 
     | 
    
         
             
                end
         
     | 
| 
       89 
88 
     | 
    
         
             
              end
         
     | 
| 
       90 
89 
     | 
    
         | 
| 
       91 
90 
     | 
    
         
             
              def test_fixnum
         
     | 
| 
       92 
91 
     | 
    
         
             
                json = %{12345}
         
     | 
| 
       93 
92 
     | 
    
         
             
                Oj::Doc.open(json) do |doc|
         
     | 
| 
       94 
     | 
    
         
            -
                   
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                  else
         
     | 
| 
       97 
     | 
    
         
            -
                    assert_equal(Fixnum, doc.type)
         
     | 
| 
       98 
     | 
    
         
            -
                  end
         
     | 
| 
       99 
     | 
    
         
            -
                  assert_equal(12345, doc.fetch())
         
     | 
| 
      
 93 
     | 
    
         
            +
                  assert_equal(Integer, doc.type)
         
     | 
| 
      
 94 
     | 
    
         
            +
                  assert_equal(12_345, doc.fetch())
         
     | 
| 
       100 
95 
     | 
    
         
             
                end
         
     | 
| 
       101 
96 
     | 
    
         
             
              end
         
     | 
| 
       102 
97 
     | 
    
         | 
| 
         @@ -104,7 +99,7 @@ class DocTest < Minitest::Test 
     | 
|
| 
       104 
99 
     | 
    
         
             
                json = %{12345.6789}
         
     | 
| 
       105 
100 
     | 
    
         
             
                Oj::Doc.open(json) do |doc|
         
     | 
| 
       106 
101 
     | 
    
         
             
                  assert_equal(Float, doc.type)
         
     | 
| 
       107 
     | 
    
         
            -
                   
     | 
| 
      
 102 
     | 
    
         
            +
                  assert_in_delta(12_345.6789, doc.fetch())
         
     | 
| 
       108 
103 
     | 
    
         
             
                end
         
     | 
| 
       109 
104 
     | 
    
         
             
              end
         
     | 
| 
       110 
105 
     | 
    
         | 
| 
         @@ -112,8 +107,8 @@ class DocTest < Minitest::Test 
     | 
|
| 
       112 
107 
     | 
    
         
             
                json = %{12345.6789e7}
         
     | 
| 
       113 
108 
     | 
    
         
             
                Oj::Doc.open(json) do |doc|
         
     | 
| 
       114 
109 
     | 
    
         
             
                  assert_equal(Float, doc.type)
         
     | 
| 
       115 
     | 
    
         
            -
                  #assert_equal(12345.6789e7, doc.fetch())
         
     | 
| 
       116 
     | 
    
         
            -
                  assert_equal( 
     | 
| 
      
 110 
     | 
    
         
            +
                  # assert_equal(12345.6789e7, doc.fetch())
         
     | 
| 
      
 111 
     | 
    
         
            +
                  assert_equal(12_345.6789e7.to_i, doc.fetch().to_i)
         
     | 
| 
       117 
112 
     | 
    
         
             
                end
         
     | 
| 
       118 
113 
     | 
    
         
             
              end
         
     | 
| 
       119 
114 
     | 
    
         | 
| 
         @@ -121,7 +116,7 @@ class DocTest < Minitest::Test 
     | 
|
| 
       121 
116 
     | 
    
         
             
                json = %{[]}
         
     | 
| 
       122 
117 
     | 
    
         
             
                Oj::Doc.open(json) do |doc|
         
     | 
| 
       123 
118 
     | 
    
         
             
                  assert_equal(Array, doc.type)
         
     | 
| 
       124 
     | 
    
         
            -
                   
     | 
| 
      
 119 
     | 
    
         
            +
                  assert_empty(doc.fetch())
         
     | 
| 
       125 
120 
     | 
    
         
             
                end
         
     | 
| 
       126 
121 
     | 
    
         
             
              end
         
     | 
| 
       127 
122 
     | 
    
         | 
| 
         @@ -137,7 +132,7 @@ class DocTest < Minitest::Test 
     | 
|
| 
       137 
132 
     | 
    
         
             
                json = %{{}}
         
     | 
| 
       138 
133 
     | 
    
         
             
                Oj::Doc.open(json) do |doc|
         
     | 
| 
       139 
134 
     | 
    
         
             
                  assert_equal(Hash, doc.type)
         
     | 
| 
       140 
     | 
    
         
            -
                   
     | 
| 
      
 135 
     | 
    
         
            +
                  assert_empty(doc.fetch())
         
     | 
| 
       141 
136 
     | 
    
         
             
                end
         
     | 
| 
       142 
137 
     | 
    
         
             
              end
         
     | 
| 
       143 
138 
     | 
    
         | 
| 
         @@ -172,7 +167,8 @@ class DocTest < Minitest::Test 
     | 
|
| 
       172 
167 
     | 
    
         | 
| 
       173 
168 
     | 
    
         
             
              def test_move
         
     | 
| 
       174 
169 
     | 
    
         
             
                Oj::Doc.open(@json1) do |doc|
         
     | 
| 
       175 
     | 
    
         
            -
                  [ 
     | 
| 
      
 170 
     | 
    
         
            +
                  [
         
     | 
| 
      
 171 
     | 
    
         
            +
                    '/',
         
     | 
| 
       176 
172 
     | 
    
         
             
                    '/array',
         
     | 
| 
       177 
173 
     | 
    
         
             
                    '/boolean',
         
     | 
| 
       178 
174 
     | 
    
         
             
                    '/array/1/hash/h2/a/3',
         
     | 
| 
         @@ -205,13 +201,14 @@ class DocTest < Minitest::Test 
     | 
|
| 
       205 
201 
     | 
    
         | 
| 
       206 
202 
     | 
    
         
             
              def test_move_relative
         
     | 
| 
       207 
203 
     | 
    
         
             
                Oj::Doc.open(@json1) do |doc|
         
     | 
| 
       208 
     | 
    
         
            -
                  [ 
     | 
| 
       209 
     | 
    
         
            -
             
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
     | 
    
         
            -
             
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
      
 204 
     | 
    
         
            +
                  [
         
     | 
| 
      
 205 
     | 
    
         
            +
                    ['/', 'array', '/array'],
         
     | 
| 
      
 206 
     | 
    
         
            +
                    ['/array', '1/num', '/array/1/num'],
         
     | 
| 
      
 207 
     | 
    
         
            +
                    ['/array/1/hash', 'h2/a', '/array/1/hash/h2/a'],
         
     | 
| 
      
 208 
     | 
    
         
            +
                    ['/array/1', 'hash/h2/a/2', '/array/1/hash/h2/a/2'],
         
     | 
| 
      
 209 
     | 
    
         
            +
                    ['/array/1/hash', '../string', '/array/1/string'],
         
     | 
| 
      
 210 
     | 
    
         
            +
                    ['/array/1/hash', '..', '/array/1'],
         
     | 
| 
      
 211 
     | 
    
         
            +
                  ].each do |start, path, where|
         
     | 
| 
       215 
212 
     | 
    
         
             
                    doc.move(start)
         
     | 
| 
       216 
213 
     | 
    
         
             
                    doc.move(path)
         
     | 
| 
       217 
214 
     | 
    
         
             
                    assert_equal(where, doc.where?)
         
     | 
| 
         @@ -220,21 +217,17 @@ class DocTest < Minitest::Test 
     | 
|
| 
       220 
217 
     | 
    
         
             
              end
         
     | 
| 
       221 
218 
     | 
    
         | 
| 
       222 
219 
     | 
    
         
             
              def test_type
         
     | 
| 
       223 
     | 
    
         
            -
                if '2.4.0' <= RUBY_VERSION
         
     | 
| 
       224 
     | 
    
         
            -
                  num_class = Integer
         
     | 
| 
       225 
     | 
    
         
            -
                else
         
     | 
| 
       226 
     | 
    
         
            -
                  num_class = Fixnum
         
     | 
| 
       227 
     | 
    
         
            -
                end
         
     | 
| 
       228 
220 
     | 
    
         
             
                Oj::Doc.open(@json1) do |doc|
         
     | 
| 
       229 
     | 
    
         
            -
                  [ 
     | 
| 
       230 
     | 
    
         
            -
             
     | 
| 
       231 
     | 
    
         
            -
             
     | 
| 
       232 
     | 
    
         
            -
             
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
       234 
     | 
    
         
            -
             
     | 
| 
       235 
     | 
    
         
            -
             
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
       237 
     | 
    
         
            -
             
     | 
| 
      
 221 
     | 
    
         
            +
                  [
         
     | 
| 
      
 222 
     | 
    
         
            +
                    ['/', Hash],
         
     | 
| 
      
 223 
     | 
    
         
            +
                    ['/array', Array],
         
     | 
| 
      
 224 
     | 
    
         
            +
                    ['/array/1', Hash],
         
     | 
| 
      
 225 
     | 
    
         
            +
                    ['/array/1/num', Integer],
         
     | 
| 
      
 226 
     | 
    
         
            +
                    ['/array/1/string', String],
         
     | 
| 
      
 227 
     | 
    
         
            +
                    ['/array/1/hash/h2/a', Array],
         
     | 
| 
      
 228 
     | 
    
         
            +
                    ['/array/1/hash/../num', Integer],
         
     | 
| 
      
 229 
     | 
    
         
            +
                    ['/array/1/hash/../..', Array],
         
     | 
| 
      
 230 
     | 
    
         
            +
                  ].each do |path, type|
         
     | 
| 
       238 
231 
     | 
    
         
             
                    assert_equal(type, doc.type(path))
         
     | 
| 
       239 
232 
     | 
    
         
             
                  end
         
     | 
| 
       240 
233 
     | 
    
         
             
                end
         
     | 
| 
         @@ -242,16 +235,17 @@ class DocTest < Minitest::Test 
     | 
|
| 
       242 
235 
     | 
    
         | 
| 
       243 
236 
     | 
    
         
             
              def test_local_key
         
     | 
| 
       244 
237 
     | 
    
         
             
                Oj::Doc.open(@json1) do |doc|
         
     | 
| 
       245 
     | 
    
         
            -
                  [ 
     | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
       248 
     | 
    
         
            -
             
     | 
| 
       249 
     | 
    
         
            -
             
     | 
| 
       250 
     | 
    
         
            -
             
     | 
| 
       251 
     | 
    
         
            -
             
     | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
             
     | 
| 
      
 238 
     | 
    
         
            +
                  [
         
     | 
| 
      
 239 
     | 
    
         
            +
                    ['/', nil],
         
     | 
| 
      
 240 
     | 
    
         
            +
                    ['/array', 'array'],
         
     | 
| 
      
 241 
     | 
    
         
            +
                    ['/array/1', 1],
         
     | 
| 
      
 242 
     | 
    
         
            +
                    ['/array/1/num', 'num'],
         
     | 
| 
      
 243 
     | 
    
         
            +
                    ['/array/1/string', 'string'],
         
     | 
| 
      
 244 
     | 
    
         
            +
                    ['/array/1/hash/h2/a', 'a'],
         
     | 
| 
      
 245 
     | 
    
         
            +
                    ['/array/1/hash/../num', 'num'],
         
     | 
| 
      
 246 
     | 
    
         
            +
                    ['/array/1/hash/..', 1],
         
     | 
| 
      
 247 
     | 
    
         
            +
                    ['/array/1/hash/../..', 'array'],
         
     | 
| 
      
 248 
     | 
    
         
            +
                  ].each do |path, key|
         
     | 
| 
       255 
249 
     | 
    
         
             
                    doc.move(path)
         
     | 
| 
       256 
250 
     | 
    
         
             
                    if key.nil?
         
     | 
| 
       257 
251 
     | 
    
         
             
                      assert_nil(doc.local_key())
         
     | 
| 
         @@ -264,16 +258,17 @@ class DocTest < Minitest::Test 
     | 
|
| 
       264 
258 
     | 
    
         | 
| 
       265 
259 
     | 
    
         
             
              def test_fetch_move
         
     | 
| 
       266 
260 
     | 
    
         
             
                Oj::Doc.open(@json1) do |doc|
         
     | 
| 
       267 
     | 
    
         
            -
                  [ 
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
             
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
       273 
     | 
    
         
            -
             
     | 
| 
       274 
     | 
    
         
            -
             
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
      
 261 
     | 
    
         
            +
                  [
         
     | 
| 
      
 262 
     | 
    
         
            +
                    ['/array/1/num', 3],
         
     | 
| 
      
 263 
     | 
    
         
            +
                    ['/array/1/string', 'message'],
         
     | 
| 
      
 264 
     | 
    
         
            +
                    ['/array/1/hash/h2/a', [1, 2, 3]],
         
     | 
| 
      
 265 
     | 
    
         
            +
                    ['/array/1/hash/../num', 3],
         
     | 
| 
      
 266 
     | 
    
         
            +
                    ['/array/1/hash/..', {'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}],
         
     | 
| 
      
 267 
     | 
    
         
            +
                    ['/array/1/hash/../..', [{'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}]],
         
     | 
| 
      
 268 
     | 
    
         
            +
                    ['/array/1', {'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}],
         
     | 
| 
      
 269 
     | 
    
         
            +
                    ['/array', [{'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}]],
         
     | 
| 
      
 270 
     | 
    
         
            +
                    ['/', {'array' => [{'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}], 'boolean' => true}],
         
     | 
| 
      
 271 
     | 
    
         
            +
                  ].each do |path, val|
         
     | 
| 
       277 
272 
     | 
    
         
             
                    doc.move(path)
         
     | 
| 
       278 
273 
     | 
    
         
             
                    assert_equal(val, doc.fetch())
         
     | 
| 
       279 
274 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -282,18 +277,19 @@ class DocTest < Minitest::Test 
     | 
|
| 
       282 
277 
     | 
    
         | 
| 
       283 
278 
     | 
    
         
             
              def test_fetch_path
         
     | 
| 
       284 
279 
     | 
    
         
             
                Oj::Doc.open(@json1) do |doc|
         
     | 
| 
       285 
     | 
    
         
            -
                  [ 
     | 
| 
       286 
     | 
    
         
            -
             
     | 
| 
       287 
     | 
    
         
            -
             
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
             
     | 
| 
       290 
     | 
    
         
            -
             
     | 
| 
       291 
     | 
    
         
            -
             
     | 
| 
       292 
     | 
    
         
            -
             
     | 
| 
       293 
     | 
    
         
            -
             
     | 
| 
       294 
     | 
    
         
            -
             
     | 
| 
       295 
     | 
    
         
            -
             
     | 
| 
       296 
     | 
    
         
            -
             
     | 
| 
      
 280 
     | 
    
         
            +
                  [
         
     | 
| 
      
 281 
     | 
    
         
            +
                    ['/array/1/num', 3],
         
     | 
| 
      
 282 
     | 
    
         
            +
                    ['/array/1/string', 'message'],
         
     | 
| 
      
 283 
     | 
    
         
            +
                    ['/array/1/hash/h2/a', [1, 2, 3]],
         
     | 
| 
      
 284 
     | 
    
         
            +
                    ['/array/1/hash/../num', 3],
         
     | 
| 
      
 285 
     | 
    
         
            +
                    ['/array/1/hash/..', {'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}],
         
     | 
| 
      
 286 
     | 
    
         
            +
                    ['/array/1/hash/../..', [{'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}]],
         
     | 
| 
      
 287 
     | 
    
         
            +
                    ['/array/1', {'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}],
         
     | 
| 
      
 288 
     | 
    
         
            +
                    ['/array', [{'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}]],
         
     | 
| 
      
 289 
     | 
    
         
            +
                    ['/', {'array' => [{'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}], 'boolean' => true}],
         
     | 
| 
      
 290 
     | 
    
         
            +
                    ['/nothing', nil],
         
     | 
| 
      
 291 
     | 
    
         
            +
                    ['/array/10', nil],
         
     | 
| 
      
 292 
     | 
    
         
            +
                  ].each do |path, val|
         
     | 
| 
       297 
293 
     | 
    
         
             
                    if val.nil?
         
     | 
| 
       298 
294 
     | 
    
         
             
                      assert_nil(doc.fetch(path))
         
     | 
| 
       299 
295 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -310,15 +306,15 @@ class DocTest < Minitest::Test 
     | 
|
| 
       310 
306 
     | 
    
         
             
                  assert_nil(doc.fetch('/x'))
         
     | 
| 
       311 
307 
     | 
    
         
             
                  assert_nil(doc.fetch('/0'))
         
     | 
| 
       312 
308 
     | 
    
         
             
                end
         
     | 
| 
       313 
     | 
    
         
            -
             
     | 
| 
       314 
309 
     | 
    
         
             
              end
         
     | 
| 
       315 
310 
     | 
    
         | 
| 
       316 
311 
     | 
    
         
             
              def test_move_fetch_path
         
     | 
| 
       317 
312 
     | 
    
         
             
                Oj::Doc.open(@json1) do |doc|
         
     | 
| 
       318 
     | 
    
         
            -
                  [ 
     | 
| 
       319 
     | 
    
         
            -
             
     | 
| 
       320 
     | 
    
         
            -
             
     | 
| 
       321 
     | 
    
         
            -
             
     | 
| 
      
 313 
     | 
    
         
            +
                  [
         
     | 
| 
      
 314 
     | 
    
         
            +
                    ['/array/1', 'num', 3],
         
     | 
| 
      
 315 
     | 
    
         
            +
                    ['/array/1', 'string', 'message'],
         
     | 
| 
      
 316 
     | 
    
         
            +
                    ['/array/1/hash', 'h2/a', [1, 2, 3]],
         
     | 
| 
      
 317 
     | 
    
         
            +
                  ].each do |path, fetch_path, val|
         
     | 
| 
       322 
318 
     | 
    
         
             
                    doc.move(path)
         
     | 
| 
       323 
319 
     | 
    
         
             
                    assert_equal(val, doc.fetch(fetch_path))
         
     | 
| 
       324 
320 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -327,13 +323,14 @@ class DocTest < Minitest::Test 
     | 
|
| 
       327 
323 
     | 
    
         | 
| 
       328 
324 
     | 
    
         
             
              def test_exists
         
     | 
| 
       329 
325 
     | 
    
         
             
                Oj::Doc.open(@json1) do |doc|
         
     | 
| 
       330 
     | 
    
         
            -
                  [ 
     | 
| 
       331 
     | 
    
         
            -
             
     | 
| 
       332 
     | 
    
         
            -
             
     | 
| 
       333 
     | 
    
         
            -
             
     | 
| 
       334 
     | 
    
         
            -
             
     | 
| 
       335 
     | 
    
         
            -
             
     | 
| 
       336 
     | 
    
         
            -
             
     | 
| 
      
 326 
     | 
    
         
            +
                  [
         
     | 
| 
      
 327 
     | 
    
         
            +
                    ['/array/1', true],
         
     | 
| 
      
 328 
     | 
    
         
            +
                    ['/array/1', true],
         
     | 
| 
      
 329 
     | 
    
         
            +
                    ['/array/1/hash', true],
         
     | 
| 
      
 330 
     | 
    
         
            +
                    ['/array/1/dash', false],
         
     | 
| 
      
 331 
     | 
    
         
            +
                    ['/array/3', false],
         
     | 
| 
      
 332 
     | 
    
         
            +
                    ['/nothing', false],
         
     | 
| 
      
 333 
     | 
    
         
            +
                  ].each do |path, val|
         
     | 
| 
       337 
334 
     | 
    
         
             
                    assert_equal(val, doc.exists?(path), "failed for #{path.inspect}")
         
     | 
| 
       338 
335 
     | 
    
         
             
                  end
         
     | 
| 
       339 
336 
     | 
    
         
             
                end
         
     | 
| 
         @@ -406,7 +403,7 @@ class DocTest < Minitest::Test 
     | 
|
| 
       406 
403 
     | 
    
         
             
                    end
         
     | 
| 
       407 
404 
     | 
    
         
             
                  end
         
     | 
| 
       408 
405 
     | 
    
         
             
                end
         
     | 
| 
       409 
     | 
    
         
            -
                assert_equal({ 
     | 
| 
      
 406 
     | 
    
         
            +
                assert_equal({'/a'=>1, '/c'=>[2], '/c/1'=>2, '/d'=>3}, h)
         
     | 
| 
       410 
407 
     | 
    
         
             
              end
         
     | 
| 
       411 
408 
     | 
    
         | 
| 
       412 
409 
     | 
    
         
             
              def test_size
         
     | 
| 
         @@ -419,8 +416,8 @@ class DocTest < Minitest::Test 
     | 
|
| 
       419 
416 
     | 
    
         
             
              end
         
     | 
| 
       420 
417 
     | 
    
         | 
| 
       421 
418 
     | 
    
         
             
              def test_open_file
         
     | 
| 
       422 
     | 
    
         
            -
                filename = File.join( 
     | 
| 
       423 
     | 
    
         
            -
                File. 
     | 
| 
      
 419 
     | 
    
         
            +
                filename = File.join(__dir__, 'open_file_test.json')
         
     | 
| 
      
 420 
     | 
    
         
            +
                File.write(filename, '{"a":[1,2,3]}')
         
     | 
| 
       424 
421 
     | 
    
         
             
                Oj::Doc.open_file(filename) do |doc|
         
     | 
| 
       425 
422 
     | 
    
         
             
                  assert_equal(5, doc.size)
         
     | 
| 
       426 
423 
     | 
    
         
             
                end
         
     | 
| 
         @@ -445,8 +442,8 @@ class DocTest < Minitest::Test 
     | 
|
| 
       445 
442 
     | 
    
         
             
              end
         
     | 
| 
       446 
443 
     | 
    
         | 
| 
       447 
444 
     | 
    
         
             
              def test_file_open_close
         
     | 
| 
       448 
     | 
    
         
            -
                filename = File.join( 
     | 
| 
       449 
     | 
    
         
            -
                File. 
     | 
| 
      
 445 
     | 
    
         
            +
                filename = File.join(__dir__, 'open_file_test.json')
         
     | 
| 
      
 446 
     | 
    
         
            +
                File.write(filename, '{"a":[1,2,3]}')
         
     | 
| 
       450 
447 
     | 
    
         
             
                doc = Oj::Doc.open_file(filename)
         
     | 
| 
       451 
448 
     | 
    
         
             
                assert_equal(Oj::Doc, doc.class)
         
     | 
| 
       452 
449 
     | 
    
         
             
                assert_equal(5, doc.size)
         
     | 
| 
         @@ -473,7 +470,6 @@ class DocTest < Minitest::Test 
     | 
|
| 
       473 
470 
     | 
    
         
             
                doc.home()
         
     | 
| 
       474 
471 
     | 
    
         
             
                assert_equal(2, doc.fetch('/a/2'))
         
     | 
| 
       475 
472 
     | 
    
         
             
                assert_equal(2, doc.fetch('a/2'))
         
     | 
| 
       476 
     | 
    
         
            -
                doc = nil
         
     | 
| 
       477 
473 
     | 
    
         
             
                GC.start
         
     | 
| 
       478 
474 
     | 
    
         
             
                # a print statement confirms close is called
         
     | 
| 
       479 
475 
     | 
    
         
             
              end
         
     | 
| 
         @@ -506,7 +502,7 @@ class DocTest < Minitest::Test 
     | 
|
| 
       506 
502 
     | 
    
         
             
              end
         
     | 
| 
       507 
503 
     | 
    
         | 
| 
       508 
504 
     | 
    
         
             
              def test_doc_empty
         
     | 
| 
       509 
     | 
    
         
            -
                result = Oj::Doc.open( 
     | 
| 
      
 505 
     | 
    
         
            +
                result = Oj::Doc.open('') { |doc| doc.each_child {} }
         
     | 
| 
       510 
506 
     | 
    
         
             
                assert_nil(result)
         
     | 
| 
       511 
507 
     | 
    
         
             
              end
         
     | 
| 
       512 
508 
     | 
    
         | 
    
        data/test/test_file.rb
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby
         
     | 
| 
       2 
     | 
    
         
            -
            #  
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
            $LOAD_PATH << __dir__
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            require 'helper'
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
         @@ -19,35 +19,29 @@ class FileJuice < Minitest::Test 
     | 
|
| 
       19 
19 
     | 
    
         
             
                end
         
     | 
| 
       20 
20 
     | 
    
         
             
                alias == eql?
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
              end# Jam
         
     | 
| 
      
 22 
     | 
    
         
            +
              end # Jam
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
              class Jeez < Jam
         
     | 
| 
       25 
     | 
    
         
            -
                def initialize(x, y)
         
     | 
| 
       26 
     | 
    
         
            -
                  super
         
     | 
| 
       27 
     | 
    
         
            -
                end
         
     | 
| 
       28 
25 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                def to_json()
         
     | 
| 
      
 26 
     | 
    
         
            +
                def to_json(*_args)
         
     | 
| 
       30 
27 
     | 
    
         
             
                  %{{"json_class":"#{self.class}","x":#{@x},"y":#{@y}}}
         
     | 
| 
       31 
28 
     | 
    
         
             
                end
         
     | 
| 
       32 
29 
     | 
    
         | 
| 
       33 
30 
     | 
    
         
             
                def self.json_create(h)
         
     | 
| 
       34 
     | 
    
         
            -
                   
     | 
| 
      
 31 
     | 
    
         
            +
                  new(h['x'], h['y'])
         
     | 
| 
       35 
32 
     | 
    
         
             
                end
         
     | 
| 
       36 
     | 
    
         
            -
              end# Jeez
         
     | 
| 
      
 33 
     | 
    
         
            +
              end # Jeez
         
     | 
| 
       37 
34 
     | 
    
         | 
| 
       38 
35 
     | 
    
         
             
              class Orange < Jam
         
     | 
| 
       39 
     | 
    
         
            -
                def initialize(x, y)
         
     | 
| 
       40 
     | 
    
         
            -
                  super
         
     | 
| 
       41 
     | 
    
         
            -
                end
         
     | 
| 
       42 
36 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                def as_json 
     | 
| 
      
 37 
     | 
    
         
            +
                def as_json
         
     | 
| 
       44 
38 
     | 
    
         
             
                  { :json_class => self.class,
         
     | 
| 
       45 
39 
     | 
    
         
             
                    :x => @x,
         
     | 
| 
       46 
40 
     | 
    
         
             
                    :y => @y }
         
     | 
| 
       47 
41 
     | 
    
         
             
                end
         
     | 
| 
       48 
42 
     | 
    
         | 
| 
       49 
43 
     | 
    
         
             
                def self.json_create(h)
         
     | 
| 
       50 
     | 
    
         
            -
                   
     | 
| 
      
 44 
     | 
    
         
            +
                  new(h['x'], h['y'])
         
     | 
| 
       51 
45 
     | 
    
         
             
                end
         
     | 
| 
       52 
46 
     | 
    
         
             
              end
         
     | 
| 
       53 
47 
     | 
    
         | 
| 
         @@ -73,8 +67,8 @@ class FileJuice < Minitest::Test 
     | 
|
| 
       73 
67 
     | 
    
         | 
| 
       74 
68 
     | 
    
         
             
              def test_fixnum
         
     | 
| 
       75 
69 
     | 
    
         
             
                dump_and_load(0, false)
         
     | 
| 
       76 
     | 
    
         
            -
                dump_and_load( 
     | 
| 
       77 
     | 
    
         
            -
                dump_and_load(- 
     | 
| 
      
 70 
     | 
    
         
            +
                dump_and_load(12_345, false)
         
     | 
| 
      
 71 
     | 
    
         
            +
                dump_and_load(-54_321, false)
         
     | 
| 
       78 
72 
     | 
    
         
             
                dump_and_load(1, false)
         
     | 
| 
       79 
73 
     | 
    
         
             
              end
         
     | 
| 
       80 
74 
     | 
    
         | 
| 
         @@ -82,9 +76,9 @@ class FileJuice < Minitest::Test 
     | 
|
| 
       82 
76 
     | 
    
         
             
                mode = Oj.default_options()[:mode]
         
     | 
| 
       83 
77 
     | 
    
         
             
                Oj.default_options = {:mode => :object}
         
     | 
| 
       84 
78 
     | 
    
         
             
                dump_and_load(0.0, false)
         
     | 
| 
       85 
     | 
    
         
            -
                dump_and_load( 
     | 
| 
      
 79 
     | 
    
         
            +
                dump_and_load(12_345.6789, false)
         
     | 
| 
       86 
80 
     | 
    
         
             
                dump_and_load(70.35, false)
         
     | 
| 
       87 
     | 
    
         
            -
                dump_and_load(- 
     | 
| 
      
 81 
     | 
    
         
            +
                dump_and_load(-54_321.012, false)
         
     | 
| 
       88 
82 
     | 
    
         
             
                dump_and_load(1.7775, false)
         
     | 
| 
       89 
83 
     | 
    
         
             
                dump_and_load(2.5024, false)
         
     | 
| 
       90 
84 
     | 
    
         
             
                dump_and_load(2.48e16, false)
         
     | 
| 
         @@ -118,9 +112,9 @@ class FileJuice < Minitest::Test 
     | 
|
| 
       118 
112 
     | 
    
         
             
              # Symbol
         
     | 
| 
       119 
113 
     | 
    
         
             
              def test_symbol_object
         
     | 
| 
       120 
114 
     | 
    
         
             
                Oj.default_options = { :mode => :object }
         
     | 
| 
       121 
     | 
    
         
            -
                #dump_and_load(''.to_sym, false)
         
     | 
| 
      
 115 
     | 
    
         
            +
                # dump_and_load(''.to_sym, false)
         
     | 
| 
       122 
116 
     | 
    
         
             
                dump_and_load(:abc, false)
         
     | 
| 
       123 
     | 
    
         
            -
                dump_and_load( 
     | 
| 
      
 117 
     | 
    
         
            +
                dump_and_load(:":xyz", false)
         
     | 
| 
       124 
118 
     | 
    
         
             
              end
         
     | 
| 
       125 
119 
     | 
    
         | 
| 
       126 
120 
     | 
    
         
             
              # Time
         
     | 
| 
         @@ -129,10 +123,11 @@ class FileJuice < Minitest::Test 
     | 
|
| 
       129 
123 
     | 
    
         
             
                Oj.default_options = { :mode => :object, :time_format => :unix_zone }
         
     | 
| 
       130 
124 
     | 
    
         
             
                dump_and_load(t, false)
         
     | 
| 
       131 
125 
     | 
    
         
             
              end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
       132 
127 
     | 
    
         
             
              def test_time_object_early
         
     | 
| 
       133 
128 
     | 
    
         
             
                skip 'Windows does not support dates before 1970.' if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
         
     | 
| 
       134 
129 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
                t = Time.xmlschema( 
     | 
| 
      
 130 
     | 
    
         
            +
                t = Time.xmlschema('1954-01-05T00:00:00.123456')
         
     | 
| 
       136 
131 
     | 
    
         
             
                Oj.default_options = { :mode => :object, :time_format => :unix_zone }
         
     | 
| 
       137 
132 
     | 
    
         
             
                dump_and_load(t, false)
         
     | 
| 
       138 
133 
     | 
    
         
             
              end
         
     | 
| 
         @@ -165,7 +160,7 @@ class FileJuice < Minitest::Test 
     | 
|
| 
       165 
160 
     | 
    
         
             
                if $ruby == 'ruby'
         
     | 
| 
       166 
161 
     | 
    
         
             
                  assert_equal(%{{"^u":["Range",1,7,false]}}, json)
         
     | 
| 
       167 
162 
     | 
    
         
             
                else
         
     | 
| 
       168 
     | 
    
         
            -
                   
     | 
| 
      
 163 
     | 
    
         
            +
                  assert_equal(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}}, json)
         
     | 
| 
       169 
164 
     | 
    
         
             
                end
         
     | 
| 
       170 
165 
     | 
    
         
             
                dump_and_load(1..7, false)
         
     | 
| 
       171 
166 
     | 
    
         
             
                dump_and_load(1..1, false)
         
     | 
| 
         @@ -212,11 +207,11 @@ class FileJuice < Minitest::Test 
     | 
|
| 
       212 
207 
     | 
    
         | 
| 
       213 
208 
     | 
    
         
             
              def test_load_unicode_path
         
     | 
| 
       214 
209 
     | 
    
         
             
                json =<<~JSON
         
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
             
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
      
 210 
     | 
    
         
            +
                  {
         
     | 
| 
      
 211 
     | 
    
         
            +
                    "x":true,
         
     | 
| 
      
 212 
     | 
    
         
            +
                    "y":58,
         
     | 
| 
      
 213 
     | 
    
         
            +
                    "z": [1,2,3]
         
     | 
| 
      
 214 
     | 
    
         
            +
                  }
         
     | 
| 
       220 
215 
     | 
    
         
             
                JSON
         
     | 
| 
       221 
216 
     | 
    
         | 
| 
       222 
217 
     | 
    
         
             
                Tempfile.create('file_test_conceição1.json') do |f|
         
     | 
| 
         @@ -229,8 +224,8 @@ class FileJuice < Minitest::Test 
     | 
|
| 
       229 
224 
     | 
    
         
             
              end
         
     | 
| 
       230 
225 
     | 
    
         | 
| 
       231 
226 
     | 
    
         
             
              def dump_and_load(obj, trace=false)
         
     | 
| 
       232 
     | 
    
         
            -
                filename = File.join( 
     | 
| 
       233 
     | 
    
         
            -
                File.open(filename,  
     | 
| 
      
 227 
     | 
    
         
            +
                filename = File.join(__dir__, 'file_test.json')
         
     | 
| 
      
 228 
     | 
    
         
            +
                File.open(filename, 'w') { |f|
         
     | 
| 
       234 
229 
     | 
    
         
             
                  Oj.to_stream(f, obj, :indent => 2)
         
     | 
| 
       235 
230 
     | 
    
         
             
                }
         
     | 
| 
       236 
231 
     | 
    
         
             
                puts "\n*** file: '#{File.read(filename)}'" if trace
         
     | 
    
        data/test/test_gc.rb
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby
         
     | 
| 
       2 
     | 
    
         
            -
            #  
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
            $LOAD_PATH << __dir__
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            require 'helper'
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
         @@ -14,13 +14,13 @@ class GCTest < Minitest::Test 
     | 
|
| 
       14 
14 
     | 
    
         
             
                  @child = child
         
     | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                def to_hash 
     | 
| 
       18 
     | 
    
         
            -
                  { 'json_class' =>  
     | 
| 
      
 17 
     | 
    
         
            +
                def to_hash
         
     | 
| 
      
 18 
     | 
    
         
            +
                  { 'json_class' => self.class.to_s, 'x' => x, 'child' => child }
         
     | 
| 
       19 
19 
     | 
    
         
             
                end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                def self.json_create(h)
         
     | 
| 
       22 
22 
     | 
    
         
             
                  GC.start
         
     | 
| 
       23 
     | 
    
         
            -
                   
     | 
| 
      
 23 
     | 
    
         
            +
                  new(h['x'], h['child'])
         
     | 
| 
       24 
24 
     | 
    
         
             
                end
         
     | 
| 
       25 
25 
     | 
    
         
             
              end # Goo
         
     | 
| 
       26 
26 
     | 
    
         | 
    
        data/test/test_generate.rb
    CHANGED
    
    | 
         @@ -1,10 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby
         
     | 
| 
       2 
     | 
    
         
            -
            #  
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
            $LOAD_PATH << __dir__
         
     | 
| 
      
 5 
     | 
    
         
            +
            @oj_dir = File.dirname(File.expand_path(__dir__))
         
     | 
| 
       6 
6 
     | 
    
         
             
            %w(lib ext).each do |dir|
         
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
      
 7 
     | 
    
         
            +
              $LOAD_PATH << File.join(@oj_dir, dir)
         
     | 
| 
       8 
8 
     | 
    
         
             
            end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            require 'minitest'
         
     | 
| 
         @@ -15,7 +15,7 @@ class Generator < Minitest::Test 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              def test_before
         
     | 
| 
       17 
17 
     | 
    
         
             
                json = Oj.generate({})
         
     | 
| 
       18 
     | 
    
         
            -
                assert_equal( 
     | 
| 
      
 18 
     | 
    
         
            +
                assert_equal('{}', json)
         
     | 
| 
       19 
19 
     | 
    
         
             
              end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            end
         
     | 
    
        data/test/test_hash.rb
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby
         
     | 
| 
       2 
     | 
    
         
            -
            #  
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
            $LOAD_PATH << __dir__
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            require 'helper'
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
         @@ -19,7 +19,7 @@ class HashTest < Minitest::Test 
     | 
|
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              def test_load
         
     | 
| 
       21 
21 
     | 
    
         
             
                obj = Oj.load(%|{"abc":3}|, :mode => :compat, :hash_class => Oj::EasyHash)
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       23 
23 
     | 
    
         
             
                assert_equal(Oj::EasyHash, obj.class)
         
     | 
| 
       24 
24 
     | 
    
         
             
                assert_equal(3, obj['abc'])
         
     | 
| 
       25 
25 
     | 
    
         
             
                assert_equal(3, obj[:abc])
         
     | 
| 
         @@ -35,5 +35,5 @@ class HashTest < Minitest::Test 
     | 
|
| 
       35 
35 
     | 
    
         
             
                assert_equal(Oj::EasyHash, obj.class)
         
     | 
| 
       36 
36 
     | 
    
         
             
                assert_equal(3, obj[:abc])
         
     | 
| 
       37 
37 
     | 
    
         
             
              end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       39 
39 
     | 
    
         
             
            end # HashTest
         
     | 
    
        data/test/test_integer_range.rb
    CHANGED
    
    | 
         @@ -1,10 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby
         
     | 
| 
       2 
     | 
    
         
            -
            #  
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
            $LOAD_PATH << __dir__
         
     | 
| 
      
 5 
     | 
    
         
            +
            @oj_dir = File.dirname(File.expand_path(__dir__))
         
     | 
| 
       6 
6 
     | 
    
         
             
            %w(lib ext).each do |dir|
         
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
      
 7 
     | 
    
         
            +
              $LOAD_PATH << File.join(@oj_dir, dir)
         
     | 
| 
       8 
8 
     | 
    
         
             
            end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            require 'minitest'
         
     | 
| 
         @@ -23,19 +23,19 @@ class IntegerRangeTest < Minitest::Test 
     | 
|
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
              def test_range
         
     | 
| 
       26 
     | 
    
         
            -
                test = {s: 0, s2: -1, s3: 1, u: -2, u2: 2, u3:  
     | 
| 
      
 26 
     | 
    
         
            +
                test = {s: 0, s2: -1, s3: 1, u: -2, u2: 2, u3: 9_007_199_254_740_993}
         
     | 
| 
       27 
27 
     | 
    
         
             
                exp = '{"s":0,"s2":-1,"s3":1,"u":"-2","u2":"2","u3":"9007199254740993"}'
         
     | 
| 
       28 
28 
     | 
    
         
             
                assert_equal(exp, Oj.dump(test, integer_range: (-1..1)))
         
     | 
| 
       29 
29 
     | 
    
         
             
              end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
              def test_bignum
         
     | 
| 
       32 
     | 
    
         
            -
                test = {u: - 
     | 
| 
      
 32 
     | 
    
         
            +
                test = {u: -10_000_000_000_000_000_000, u2: 10_000_000_000_000_000_000}
         
     | 
| 
       33 
33 
     | 
    
         
             
                exp = '{"u":"-10000000000000000000","u2":"10000000000000000000"}'
         
     | 
| 
       34 
34 
     | 
    
         
             
                assert_equal(exp, Oj.dump(test, integer_range: (-1..1)))
         
     | 
| 
       35 
35 
     | 
    
         
             
              end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
              def test_valid_modes
         
     | 
| 
       38 
     | 
    
         
            -
                test = {safe: 0, unsafe:  
     | 
| 
      
 38 
     | 
    
         
            +
                test = {safe: 0, unsafe: 9_007_199_254_740_993}
         
     | 
| 
       39 
39 
     | 
    
         
             
                exp  = '{"safe":0,"unsafe":"9007199254740993"}'
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                [:strict, :null, :compat, :rails, :custom].each do |mode|
         
     | 
| 
         @@ -49,7 +49,7 @@ class IntegerRangeTest < Minitest::Test 
     | 
|
| 
       49 
49 
     | 
    
         
             
              end
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
51 
     | 
    
         
             
              def test_modes_without_opt
         
     | 
| 
       52 
     | 
    
         
            -
                test = {safe:0, unsafe:  
     | 
| 
      
 52 
     | 
    
         
            +
                test = {safe: 0, unsafe: 10_000_000_000_000_000_000}
         
     | 
| 
       53 
53 
     | 
    
         
             
                exp = '{"safe":0,"unsafe":10000000000000000000}'
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
                [:strict, :null, :compat, :rails, :custom].each do |mode|
         
     | 
| 
         @@ -63,7 +63,7 @@ class IntegerRangeTest < Minitest::Test 
     | 
|
| 
       63 
63 
     | 
    
         
             
              end
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
       65 
65 
     | 
    
         
             
              def test_accept_nil_and_false
         
     | 
| 
       66 
     | 
    
         
            -
                test = {safe:0, unsafe:  
     | 
| 
      
 66 
     | 
    
         
            +
                test = {safe: 0, unsafe: 10_000_000_000_000_000_000}
         
     | 
| 
       67 
67 
     | 
    
         
             
                exp = '{"safe":0,"unsafe":10000000000000000000}'
         
     | 
| 
       68 
68 
     | 
    
         | 
| 
       69 
69 
     | 
    
         
             
                assert_equal(exp, Oj.dump(test, integer_range: nil))
         
     |