oj 3.14.1 → 3.14.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +0 -1
  4. data/ext/oj/buf.h +7 -6
  5. data/ext/oj/cache.c +25 -24
  6. data/ext/oj/cache8.c +10 -9
  7. data/ext/oj/circarray.c +7 -5
  8. data/ext/oj/circarray.h +2 -2
  9. data/ext/oj/code.c +2 -2
  10. data/ext/oj/code.h +2 -2
  11. data/ext/oj/compat.c +7 -14
  12. data/ext/oj/custom.c +3 -2
  13. data/ext/oj/debug.c +3 -9
  14. data/ext/oj/dump.c +18 -17
  15. data/ext/oj/dump_compat.c +551 -576
  16. data/ext/oj/dump_leaf.c +3 -5
  17. data/ext/oj/dump_object.c +37 -37
  18. data/ext/oj/dump_strict.c +2 -4
  19. data/ext/oj/encoder.c +1 -1
  20. data/ext/oj/err.c +2 -13
  21. data/ext/oj/err.h +9 -12
  22. data/ext/oj/extconf.rb +1 -1
  23. data/ext/oj/fast.c +33 -46
  24. data/ext/oj/intern.c +44 -46
  25. data/ext/oj/intern.h +3 -7
  26. data/ext/oj/mem.c +318 -0
  27. data/ext/oj/mem.h +53 -0
  28. data/ext/oj/mimic_json.c +20 -25
  29. data/ext/oj/object.c +7 -7
  30. data/ext/oj/odd.c +8 -6
  31. data/ext/oj/odd.h +4 -4
  32. data/ext/oj/oj.c +71 -85
  33. data/ext/oj/oj.h +53 -54
  34. data/ext/oj/parse.c +67 -128
  35. data/ext/oj/parse.h +5 -10
  36. data/ext/oj/parser.c +13 -14
  37. data/ext/oj/parser.h +7 -8
  38. data/ext/oj/rails.c +36 -66
  39. data/ext/oj/reader.c +8 -11
  40. data/ext/oj/reader.h +4 -2
  41. data/ext/oj/resolve.c +3 -4
  42. data/ext/oj/rxclass.c +6 -5
  43. data/ext/oj/rxclass.h +1 -1
  44. data/ext/oj/saj.c +9 -8
  45. data/ext/oj/saj2.c +36 -52
  46. data/ext/oj/saj2.h +1 -1
  47. data/ext/oj/scp.c +3 -14
  48. data/ext/oj/sparse.c +22 -70
  49. data/ext/oj/stream_writer.c +9 -21
  50. data/ext/oj/strict.c +7 -13
  51. data/ext/oj/string_writer.c +11 -18
  52. data/ext/oj/trace.h +27 -16
  53. data/ext/oj/usual.c +89 -87
  54. data/ext/oj/usual.h +6 -6
  55. data/ext/oj/util.h +1 -1
  56. data/ext/oj/val_stack.h +8 -7
  57. data/ext/oj/wab.c +7 -9
  58. data/lib/oj/active_support_helper.rb +0 -1
  59. data/lib/oj/bag.rb +7 -1
  60. data/lib/oj/easy_hash.rb +4 -5
  61. data/lib/oj/error.rb +0 -1
  62. data/lib/oj/json.rb +4 -2
  63. data/lib/oj/mimic.rb +4 -2
  64. data/lib/oj/state.rb +8 -5
  65. data/lib/oj/version.rb +1 -2
  66. data/lib/oj.rb +0 -1
  67. data/test/_test_active.rb +0 -1
  68. data/test/_test_active_mimic.rb +0 -1
  69. data/test/_test_mimic_rails.rb +0 -1
  70. data/test/activerecord/result_test.rb +5 -6
  71. data/test/bar.rb +3 -3
  72. data/test/files.rb +1 -1
  73. data/test/foo.rb +5 -3
  74. data/test/helper.rb +1 -4
  75. data/test/isolated/shared.rb +3 -2
  76. data/test/json_gem/json_addition_test.rb +2 -2
  77. data/test/json_gem/json_common_interface_test.rb +4 -4
  78. data/test/json_gem/json_encoding_test.rb +0 -0
  79. data/test/json_gem/json_ext_parser_test.rb +1 -0
  80. data/test/json_gem/json_fixtures_test.rb +3 -2
  81. data/test/json_gem/json_generator_test.rb +43 -32
  82. data/test/json_gem/json_generic_object_test.rb +11 -11
  83. data/test/json_gem/json_parser_test.rb +46 -46
  84. data/test/json_gem/json_string_matching_test.rb +9 -9
  85. data/test/mem.rb +7 -7
  86. data/test/perf.rb +2 -2
  87. data/test/perf_compat.rb +1 -1
  88. data/test/perf_fast.rb +1 -1
  89. data/test/perf_file.rb +2 -2
  90. data/test/perf_object.rb +1 -2
  91. data/test/perf_once.rb +4 -4
  92. data/test/perf_parser.rb +2 -2
  93. data/test/perf_saj.rb +1 -2
  94. data/test/perf_scp.rb +1 -1
  95. data/test/perf_simple.rb +3 -3
  96. data/test/perf_strict.rb +1 -1
  97. data/test/perf_wab.rb +1 -1
  98. data/test/sample/change.rb +0 -1
  99. data/test/sample/dir.rb +0 -1
  100. data/test/sample/doc.rb +0 -1
  101. data/test/sample/file.rb +0 -1
  102. data/test/sample/group.rb +0 -1
  103. data/test/sample/hasprops.rb +0 -1
  104. data/test/sample/layer.rb +0 -1
  105. data/test/sample/rect.rb +0 -1
  106. data/test/sample/shape.rb +0 -1
  107. data/test/sample/text.rb +0 -1
  108. data/test/sample.rb +2 -3
  109. data/test/sample_json.rb +0 -1
  110. data/test/test_compat.rb +11 -9
  111. data/test/test_custom.rb +5 -9
  112. data/test/test_debian.rb +1 -1
  113. data/test/test_fast.rb +10 -20
  114. data/test/test_file.rb +8 -8
  115. data/test/test_integer_range.rb +2 -2
  116. data/test/test_null.rb +5 -3
  117. data/test/test_object.rb +6 -5
  118. data/test/test_parser_saj.rb +23 -21
  119. data/test/test_parser_usual.rb +3 -3
  120. data/test/test_saj.rb +2 -0
  121. data/test/test_scp.rb +6 -6
  122. data/test/test_strict.rb +6 -4
  123. data/test/test_various.rb +21 -24
  124. data/test/test_wab.rb +6 -5
  125. data/test/test_writer.rb +1 -1
  126. metadata +20 -27
  127. data/test/activesupport4/decoding_test.rb +0 -108
  128. data/test/activesupport4/encoding_test.rb +0 -531
  129. data/test/activesupport4/test_helper.rb +0 -41
  130. data/test/activesupport5/abstract_unit.rb +0 -45
  131. data/test/activesupport5/decoding_test.rb +0 -133
  132. data/test/activesupport5/encoding_test.rb +0 -500
  133. data/test/activesupport5/encoding_test_cases.rb +0 -98
  134. data/test/activesupport5/test_helper.rb +0 -72
  135. data/test/activesupport5/time_zone_test_helpers.rb +0 -39
data/test/test_fast.rb CHANGED
@@ -91,11 +91,7 @@ class DocTest < Minitest::Test
91
91
  def test_fixnum
92
92
  json = %{12345}
93
93
  Oj::Doc.open(json) do |doc|
94
- if '2.4.0' <= RUBY_VERSION
95
- assert_equal(Integer, doc.type)
96
- else
97
- assert_equal(Fixnum, doc.type)
98
- end
94
+ assert_equal(Integer, doc.type)
99
95
  assert_equal(12345, doc.fetch())
100
96
  end
101
97
  end
@@ -211,7 +207,7 @@ class DocTest < Minitest::Test
211
207
  ['/array/1', 'hash/h2/a/2', '/array/1/hash/h2/a/2'],
212
208
  ['/array/1/hash', '../string', '/array/1/string'],
213
209
  ['/array/1/hash', '..', '/array/1'],
214
- ].each do |start,path,where|
210
+ ].each do |start, path, where|
215
211
  doc.move(start)
216
212
  doc.move(path)
217
213
  assert_equal(where, doc.where?)
@@ -220,21 +216,16 @@ class DocTest < Minitest::Test
220
216
  end
221
217
 
222
218
  def test_type
223
- if '2.4.0' <= RUBY_VERSION
224
- num_class = Integer
225
- else
226
- num_class = Fixnum
227
- end
228
219
  Oj::Doc.open(@json1) do |doc|
229
220
  [['/', Hash],
230
221
  ['/array', Array],
231
222
  ['/array/1', Hash],
232
- ['/array/1/num', num_class],
223
+ ['/array/1/num', Integer],
233
224
  ['/array/1/string', String],
234
225
  ['/array/1/hash/h2/a', Array],
235
- ['/array/1/hash/../num', num_class],
226
+ ['/array/1/hash/../num', Integer],
236
227
  ['/array/1/hash/../..', Array],
237
- ].each do |path,type|
228
+ ].each do |path, type|
238
229
  assert_equal(type, doc.type(path))
239
230
  end
240
231
  end
@@ -251,7 +242,7 @@ class DocTest < Minitest::Test
251
242
  ['/array/1/hash/../num', 'num'],
252
243
  ['/array/1/hash/..', 1],
253
244
  ['/array/1/hash/../..', 'array'],
254
- ].each do |path,key|
245
+ ].each do |path, key|
255
246
  doc.move(path)
256
247
  if key.nil?
257
248
  assert_nil(doc.local_key())
@@ -273,7 +264,7 @@ class DocTest < Minitest::Test
273
264
  ['/array/1', {'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}],
274
265
  ['/array', [{'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}]],
275
266
  ['/', {'array' => [{'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}], 'boolean' => true}],
276
- ].each do |path,val|
267
+ ].each do |path, val|
277
268
  doc.move(path)
278
269
  assert_equal(val, doc.fetch())
279
270
  end
@@ -293,7 +284,7 @@ class DocTest < Minitest::Test
293
284
  ['/', {'array' => [{'num' => 3, 'string' => 'message', 'hash' => {'h2' => {'a' => [1, 2, 3]}}}], 'boolean' => true}],
294
285
  ['/nothing', nil],
295
286
  ['/array/10', nil],
296
- ].each do |path,val|
287
+ ].each do |path, val|
297
288
  if val.nil?
298
289
  assert_nil(doc.fetch(path))
299
290
  else
@@ -310,7 +301,6 @@ class DocTest < Minitest::Test
310
301
  assert_nil(doc.fetch('/x'))
311
302
  assert_nil(doc.fetch('/0'))
312
303
  end
313
-
314
304
  end
315
305
 
316
306
  def test_move_fetch_path
@@ -318,7 +308,7 @@ class DocTest < Minitest::Test
318
308
  [['/array/1', 'num', 3],
319
309
  ['/array/1', 'string', 'message'],
320
310
  ['/array/1/hash', 'h2/a', [1, 2, 3]],
321
- ].each do |path,fetch_path,val|
311
+ ].each do |path, fetch_path, val|
322
312
  doc.move(path)
323
313
  assert_equal(val, doc.fetch(fetch_path))
324
314
  end
@@ -333,7 +323,7 @@ class DocTest < Minitest::Test
333
323
  ['/array/1/dash', false],
334
324
  ['/array/3', false],
335
325
  ['/nothing', false],
336
- ].each do |path,val|
326
+ ].each do |path, val|
337
327
  assert_equal(val, doc.exists?(path), "failed for #{path.inspect}")
338
328
  end
339
329
  end
data/test/test_file.rb CHANGED
@@ -19,21 +19,21 @@ 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
25
  def initialize(x, y)
26
26
  super
27
27
  end
28
28
 
29
- def to_json()
29
+ def to_json(*_args)
30
30
  %{{"json_class":"#{self.class}","x":#{@x},"y":#{@y}}}
31
31
  end
32
32
 
33
33
  def self.json_create(h)
34
34
  self.new(h['x'], h['y'])
35
35
  end
36
- end# Jeez
36
+ end # Jeez
37
37
 
38
38
  class Orange < Jam
39
39
  def initialize(x, y)
@@ -212,11 +212,11 @@ class FileJuice < Minitest::Test
212
212
 
213
213
  def test_load_unicode_path
214
214
  json =<<~JSON
215
- {
216
- "x":true,
217
- "y":58,
218
- "z": [1,2,3]
219
- }
215
+ {
216
+ "x":true,
217
+ "y":58,
218
+ "z": [1,2,3]
219
+ }
220
220
  JSON
221
221
 
222
222
  Tempfile.create('file_test_conceição1.json') do |f|
@@ -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: 10000000000000000000}
52
+ test = {safe: 0, unsafe: 10000000000000000000}
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: 10000000000000000000}
66
+ test = {safe: 0, unsafe: 10000000000000000000}
67
67
  exp = '{"safe":0,"unsafe":10000000000000000000}'
68
68
 
69
69
  assert_equal(exp, Oj.dump(test, integer_range: nil))
data/test/test_null.rb CHANGED
@@ -152,7 +152,7 @@ class NullJuice < Minitest::Test
152
152
  end
153
153
 
154
154
  def test_array_deep
155
- dump_and_load([1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20]]]]]]]]]]]]]]]]]]]], false)
155
+ dump_and_load([1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]]], false)
156
156
  end
157
157
 
158
158
  # Hash
@@ -245,12 +245,14 @@ class NullJuice < Minitest::Test
245
245
 
246
246
  def test_io_file
247
247
  filename = File.join(File.dirname(__FILE__), 'open_file_test.json')
248
- File.open(filename, 'w') { |f| f.write(%{{
248
+ File.open(filename, 'w') { |f|
249
+ f.write(%{{
249
250
  "x":true,
250
251
  "y":58,
251
252
  "z": [1,2,3]
252
253
  }
253
- }) }
254
+ })
255
+ }
254
256
  f = File.new(filename)
255
257
  obj = Oj.strict_load(f)
256
258
  f.close()
data/test/test_object.rb CHANGED
@@ -301,7 +301,7 @@ class ObjectJuice < Minitest::Test
301
301
  end
302
302
 
303
303
  def test_array_deep
304
- dump_and_load([1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20]]]]]]]]]]]]]]]]]]]], false)
304
+ dump_and_load([1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]]], false)
305
305
  end
306
306
 
307
307
  # Hash
@@ -377,12 +377,14 @@ class ObjectJuice < Minitest::Test
377
377
 
378
378
  def test_io_file
379
379
  filename = File.join(File.dirname(__FILE__), 'open_file_test.json')
380
- File.open(filename, 'w') { |f| f.write(%{{
380
+ File.open(filename, 'w') { |f|
381
+ f.write(%{{
381
382
  "x":true,
382
383
  "y":58,
383
384
  "z": [1,2,3]
384
385
  }
385
- }) }
386
+ })
387
+ }
386
388
  f = File.new(filename)
387
389
  obj = Oj.object_load(f)
388
390
  f.close()
@@ -651,7 +653,7 @@ class ObjectJuice < Minitest::Test
651
653
 
652
654
  json = %{{"~#x":[1,2]}}
653
655
  h = Oj.object_load(json)
654
- assert_equal({'~#x' => [1,2]}, h);
656
+ assert_equal({'~#x' => [1, 2]}, h);
655
657
  end
656
658
 
657
659
  def test_json_struct
@@ -839,7 +841,6 @@ class ObjectJuice < Minitest::Test
839
841
  assert_equal(h2['b'].__id__, h2.__id__)
840
842
  end
841
843
 
842
-
843
844
  def test_json_object_missing_fields
844
845
  json = %{{ "^u": [ "ObjectJuice::Stuck",1]}}
845
846
 
@@ -25,6 +25,8 @@ class AllSaj < Oj::Saj
25
25
 
26
26
  def initialize()
27
27
  @calls = []
28
+
29
+ super
28
30
  end
29
31
 
30
32
  def hash_start(key)
@@ -260,13 +262,13 @@ class SajTest < Minitest::Test
260
262
  p.handler = handler
261
263
  p.parse(json)
262
264
  assert_equal([
263
- [:array_start, nil],
264
- [:add_value, true, nil],
265
- [:array_end, nil],
266
- [:array_start, nil],
267
- [:add_value, false, nil],
268
- [:array_end, nil],
269
- ], handler.calls)
265
+ [:array_start, nil],
266
+ [:add_value, true, nil],
267
+ [:array_end, nil],
268
+ [:array_start, nil],
269
+ [:add_value, false, nil],
270
+ [:array_end, nil],
271
+ ], handler.calls)
270
272
  end
271
273
 
272
274
  def test_io
@@ -276,11 +278,11 @@ class SajTest < Minitest::Test
276
278
  p.handler = handler
277
279
  p.load(StringIO.new(json))
278
280
  assert_equal([
279
- [:array_start, nil],
280
- [:add_value, true, nil],
281
- [:add_value, false, nil],
282
- [:array_end, nil],
283
- ], handler.calls)
281
+ [:array_start, nil],
282
+ [:add_value, true, nil],
283
+ [:add_value, false, nil],
284
+ [:array_end, nil],
285
+ ], handler.calls)
284
286
  end
285
287
 
286
288
  def test_file
@@ -289,11 +291,11 @@ class SajTest < Minitest::Test
289
291
  p.handler = handler
290
292
  p.file('saj_test.json')
291
293
  assert_equal([
292
- [:array_start, nil],
293
- [:add_value, true, nil],
294
- [:add_value, false, nil],
295
- [:array_end, nil],
296
- ], handler.calls)
294
+ [:array_start, nil],
295
+ [:add_value, true, nil],
296
+ [:add_value, false, nil],
297
+ [:array_end, nil],
298
+ ], handler.calls)
297
299
  end
298
300
 
299
301
  def test_default
@@ -302,10 +304,10 @@ class SajTest < Minitest::Test
302
304
  Oj::Parser.saj.handler = handler
303
305
  Oj::Parser.saj.parse(json)
304
306
  assert_equal([
305
- [:array_start, nil],
306
- [:add_value, true, nil],
307
- [:array_end, nil],
308
- ], handler.calls)
307
+ [:array_start, nil],
308
+ [:add_value, true, nil],
309
+ [:array_end, nil],
310
+ ], handler.calls)
309
311
  end
310
312
 
311
313
  def test_loc
@@ -40,10 +40,10 @@ class UsualTest < Minitest::Test
40
40
  [
41
41
  ['[]', []],
42
42
  ['[false]', [false]],
43
- ['[true,false]', [true,false]],
43
+ ['[true,false]', [true, false]],
44
44
  ['[[]]', [[]]],
45
- ['[true,[],false]', [true,[],false]],
46
- ['[true,[true],false]', [true,[true],false]],
45
+ ['[true,[],false]', [true, [], false]],
46
+ ['[true,[true],false]', [true, [true], false]],
47
47
  ].each { |x|
48
48
  doc = p.parse(x[0])
49
49
  assert_equal(x[1], doc)
data/test/test_saj.rb CHANGED
@@ -25,6 +25,8 @@ class AllSaj < Oj::Saj
25
25
 
26
26
  def initialize()
27
27
  @calls = []
28
+
29
+ super
28
30
  end
29
31
 
30
32
  def hash_start(key)
data/test/test_scp.rb CHANGED
@@ -47,6 +47,7 @@ class AllHandler < Oj::ScHandler
47
47
  @calls << [:hash_key, key]
48
48
  return 'too' if 'two' == key
49
49
  return :symbol if 'symbol' == key
50
+
50
51
  key
51
52
  end
52
53
 
@@ -346,12 +347,10 @@ class ScpTest < Minitest::Test
346
347
  end
347
348
 
348
349
  def test_bad_bignum
349
- if '2.4.0' < RUBY_VERSION
350
- handler = AllHandler.new()
351
- json = %|{"big":-e123456789}|
352
- assert_raises Exception do # Can be either Oj::ParseError or ArgumentError depending on Ruby version
353
- Oj.sc_parse(handler, json)
354
- end
350
+ handler = AllHandler.new()
351
+ json = %|{"big":-e123456789}|
352
+ assert_raises Exception do # Can be either Oj::ParseError or ArgumentError depending on Ruby version
353
+ Oj.sc_parse(handler, json)
355
354
  end
356
355
  end
357
356
 
@@ -402,6 +401,7 @@ class ScpTest < Minitest::Test
402
401
  c.puts json[0..11]
403
402
  10.times {
404
403
  break if c.closed?
404
+
405
405
  sleep(0.1)
406
406
  }
407
407
  unless c.closed?
data/test/test_strict.rb CHANGED
@@ -152,7 +152,7 @@ class StrictJuice < Minitest::Test
152
152
  end
153
153
 
154
154
  def test_array_deep
155
- dump_and_load([1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20]]]]]]]]]]]]]]]]]]]], false)
155
+ dump_and_load([1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]]], false)
156
156
  end
157
157
 
158
158
  def test_deep_nest
@@ -160,7 +160,7 @@ class StrictJuice < Minitest::Test
160
160
 
161
161
  begin
162
162
  n = 10000
163
- Oj.strict_load('[' * n + ']' * n)
163
+ Oj.strict_load(('[' * n) + (']' * n))
164
164
  rescue Exception => e
165
165
  assert(false, e.message)
166
166
  end
@@ -266,12 +266,14 @@ class StrictJuice < Minitest::Test
266
266
 
267
267
  def test_io_file
268
268
  filename = File.join(File.dirname(__FILE__), 'open_file_test.json')
269
- File.open(filename, 'w') { |f| f.write(%{{
269
+ File.open(filename, 'w') { |f|
270
+ f.write(%{{
270
271
  "x":true,
271
272
  "y":58,
272
273
  "z": [1,2,3]
273
274
  }
274
- }) }
275
+ })
276
+ }
275
277
  f = File.new(filename)
276
278
  obj = Oj.strict_load(f)
277
279
  f.close()
data/test/test_various.rb CHANGED
@@ -36,7 +36,7 @@ class Juice < Minitest::Test
36
36
  super
37
37
  end
38
38
 
39
- def to_json()
39
+ def to_json(*_args)
40
40
  %{{"json_class":"#{self.class}","x":#{@x},"y":#{@y}}}
41
41
  end
42
42
 
@@ -286,7 +286,6 @@ class Juice < Minitest::Test
286
286
  --],#
287
287
  --"a"~:*1#
288
288
  }} == json)
289
-
290
289
  end
291
290
 
292
291
  def test_null_char
@@ -319,7 +318,7 @@ class Juice < Minitest::Test
319
318
  }
320
319
  results = []
321
320
  Oj.load(json, :mode => :strict) { |x, start, len| results << [x, start, len] }
322
- assert_equal([[{"a"=>1}, 0, 7], [[1,2], 7, 6], [[3,4], 13, 5], [{"b"=>2}, 18, 8]], results)
321
+ assert_equal([[{"a"=>1}, 0, 7], [[1, 2], 7, 6], [[3, 4], 13, 5], [{"b"=>2}, 18, 8]], results)
323
322
  end
324
323
 
325
324
  def test_multiple_json_no_callback
@@ -575,21 +574,21 @@ class Juice < Minitest::Test
575
574
 
576
575
  IO.pipe do |r, w|
577
576
  if fork
578
- r.close
579
- #w.nonblock = false
580
- a = []
581
- 10_000.times do |i|
582
- a << i
583
- end
584
- Oj.to_stream(w, a, indent: 2)
585
- w.close
577
+ r.close
578
+ #w.nonblock = false
579
+ a = []
580
+ 10_000.times do |i|
581
+ a << i
582
+ end
583
+ Oj.to_stream(w, a, indent: 2)
584
+ w.close
586
585
  else
587
- w.close
588
- sleep(0.1) # to force a busy
589
- cnt = 0
590
- r.each_line { cnt += 1 }
591
- r.close
592
- Process.exit(0)
586
+ w.close
587
+ sleep(0.1) # to force a busy
588
+ cnt = 0
589
+ r.each_line { cnt += 1 }
590
+ r.close
591
+ Process.exit(0)
593
592
  end
594
593
  end
595
594
  end
@@ -693,24 +692,22 @@ class Juice < Minitest::Test
693
692
  msg = ''
694
693
  assert_raises(Oj::ParseError) {
695
694
  begin
696
- Oj.load(%|{
695
+ Oj.load(%|{
697
696
  "first": [
698
697
  1, 2, { "third": 123x }
699
698
  ]
700
699
  }|)
701
700
  rescue Oj::ParseError => e
702
- msg = e.message
703
- raise e
701
+ msg = e.message
702
+ raise e
704
703
  end
705
704
  }
706
705
  assert_equal('after first[2].third', msg.split('(')[1].split(')')[0])
707
706
  end
708
707
 
709
708
  def test_bad_bignum
710
- if '2.4.0' < RUBY_VERSION
711
- assert_raises Oj::ParseError do
712
- Oj.load(%|{ "big": -e123456789 }|, mode: :strict)
713
- end
709
+ assert_raises Oj::ParseError do
710
+ Oj.load(%|{ "big": -e123456789 }|, mode: :strict)
714
711
  end
715
712
  end
716
713
 
data/test/test_wab.rb CHANGED
@@ -32,7 +32,6 @@ module WAB
32
32
  end # UUID
33
33
  end # WAB
34
34
 
35
-
36
35
  class WabJuice < Minitest::Test
37
36
 
38
37
  module TestModule
@@ -101,7 +100,7 @@ class WabJuice < Minitest::Test
101
100
  end
102
101
 
103
102
  def test_array_deep
104
- dump_and_load([1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20]]]]]]]]]]]]]]]]]]]], false)
103
+ dump_and_load([1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]]], false)
105
104
  end
106
105
 
107
106
  def test_deep_nest
@@ -109,7 +108,7 @@ class WabJuice < Minitest::Test
109
108
 
110
109
  begin
111
110
  n = 10000
112
- Oj.wab_load('[' * n + ']' * n)
111
+ Oj.wab_load(('[' * n) + (']' * n))
113
112
  rescue Exception => e
114
113
  assert(false, e.message)
115
114
  end
@@ -189,12 +188,14 @@ class WabJuice < Minitest::Test
189
188
 
190
189
  def test_io_file
191
190
  filename = File.join(File.dirname(__FILE__), 'open_file_test.json')
192
- File.open(filename, 'w') { |f| f.write(%{{
191
+ File.open(filename, 'w') { |f|
192
+ f.write(%{{
193
193
  "x":true,
194
194
  "y":58,
195
195
  "z": [1,2,3]
196
196
  }
197
- }) }
197
+ })
198
+ }
198
199
  f = File.new(filename)
199
200
  obj = Oj.wab_load(f)
200
201
  f.close()
data/test/test_writer.rb CHANGED
@@ -96,7 +96,7 @@ class OjWriter < Minitest::Test
96
96
  w.push_value(nil)
97
97
  w.push_value("a string")
98
98
  w.push_value({'a' => 65})
99
- w.push_value([1,2])
99
+ w.push_value([1, 2])
100
100
  w.pop()
101
101
  assert_equal(%|[
102
102
  7,
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.14.1
4
+ version: 3.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-01 00:00:00.000000000 Z
11
+ date: 2023-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake-compiler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -30,20 +44,6 @@ dependencies:
30
44
  - - "<"
31
45
  - !ruby/object:Gem::Version
32
46
  version: '2.0'
33
- - !ruby/object:Gem::Dependency
34
- name: minitest
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '5'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '5'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: test-unit
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -111,6 +111,8 @@ files:
111
111
  - ext/oj/fast.c
112
112
  - ext/oj/intern.c
113
113
  - ext/oj/intern.h
114
+ - ext/oj/mem.c
115
+ - ext/oj/mem.h
114
116
  - ext/oj/mimic_json.c
115
117
  - ext/oj/object.c
116
118
  - ext/oj/odd.c
@@ -174,15 +176,6 @@ files:
174
176
  - test/_test_active_mimic.rb
175
177
  - test/_test_mimic_rails.rb
176
178
  - test/activerecord/result_test.rb
177
- - test/activesupport4/decoding_test.rb
178
- - test/activesupport4/encoding_test.rb
179
- - test/activesupport4/test_helper.rb
180
- - test/activesupport5/abstract_unit.rb
181
- - test/activesupport5/decoding_test.rb
182
- - test/activesupport5/encoding_test.rb
183
- - test/activesupport5/encoding_test_cases.rb
184
- - test/activesupport5/test_helper.rb
185
- - test/activesupport5/time_zone_test_helpers.rb
186
179
  - test/activesupport6/abstract_unit.rb
187
180
  - test/activesupport6/decoding_test.rb
188
181
  - test/activesupport6/encoding_test.rb
@@ -297,14 +290,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
297
290
  requirements:
298
291
  - - ">="
299
292
  - !ruby/object:Gem::Version
300
- version: '2.4'
293
+ version: '2.7'
301
294
  required_rubygems_version: !ruby/object:Gem::Requirement
302
295
  requirements:
303
296
  - - ">="
304
297
  - !ruby/object:Gem::Version
305
298
  version: '0'
306
299
  requirements: []
307
- rubygems_version: 3.3.3
300
+ rubygems_version: 3.4.1
308
301
  signing_key:
309
302
  specification_version: 4
310
303
  summary: A fast JSON parser and serializer.