oj 3.14.2 → 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 +5 -1
  3. data/README.md +0 -1
  4. data/ext/oj/buf.h +2 -2
  5. data/ext/oj/cache.c +16 -16
  6. data/ext/oj/cache8.c +7 -7
  7. data/ext/oj/circarray.c +2 -1
  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 +6 -14
  12. data/ext/oj/custom.c +1 -1
  13. data/ext/oj/debug.c +3 -9
  14. data/ext/oj/dump.c +16 -16
  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 +35 -36
  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 +24 -38
  24. data/ext/oj/intern.c +38 -42
  25. data/ext/oj/intern.h +3 -7
  26. data/ext/oj/mem.c +211 -217
  27. data/ext/oj/mem.h +10 -10
  28. data/ext/oj/mimic_json.c +18 -24
  29. data/ext/oj/object.c +5 -5
  30. data/ext/oj/odd.c +2 -1
  31. data/ext/oj/odd.h +4 -4
  32. data/ext/oj/oj.c +60 -81
  33. data/ext/oj/oj.h +53 -54
  34. data/ext/oj/parse.c +55 -118
  35. data/ext/oj/parse.h +5 -10
  36. data/ext/oj/parser.c +7 -8
  37. data/ext/oj/parser.h +7 -8
  38. data/ext/oj/rails.c +28 -59
  39. data/ext/oj/reader.c +5 -9
  40. data/ext/oj/reader.h +1 -1
  41. data/ext/oj/resolve.c +3 -4
  42. data/ext/oj/rxclass.c +1 -1
  43. data/ext/oj/rxclass.h +1 -1
  44. data/ext/oj/saj.c +4 -4
  45. data/ext/oj/saj2.c +32 -49
  46. data/ext/oj/saj2.h +1 -1
  47. data/ext/oj/scp.c +3 -14
  48. data/ext/oj/sparse.c +18 -67
  49. data/ext/oj/stream_writer.c +5 -18
  50. data/ext/oj/strict.c +7 -13
  51. data/ext/oj/string_writer.c +6 -14
  52. data/ext/oj/trace.h +27 -16
  53. data/ext/oj/usual.c +62 -61
  54. data/ext/oj/usual.h +6 -6
  55. data/ext/oj/util.h +1 -1
  56. data/ext/oj/val_stack.h +4 -4
  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 -48
  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 +1 -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 +17 -26
  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/perf_once.rb CHANGED
@@ -14,10 +14,10 @@ File.open(filename, "w") { |f|
14
14
  ('a'..'z').each { |a|
15
15
  ('a'..'z').each { |b|
16
16
  ('a'..'z').each { |c|
17
- ('a'..'z').each { |d|
18
- f.puts(%|"#{a}#{b}#{c}#{d}":#{cnt},|)
19
- cnt += 1
20
- }
17
+ ('a'..'z').each { |d|
18
+ f.puts(%|"#{a}#{b}#{c}#{d}":#{cnt},|)
19
+ cnt += 1
20
+ }
21
21
  }
22
22
  }
23
23
  }
data/test/perf_parser.rb CHANGED
@@ -164,7 +164,6 @@ $obj_json = %|{
164
164
  "juliet": "junk"
165
165
  }|
166
166
 
167
-
168
167
  p_usual = Oj::Parser.new(:usual)
169
168
  p_usual.cache_keys = $cache_keys
170
169
  p_usual.cache_strings = ($cache_keys ? 6 : 0)
@@ -186,5 +185,5 @@ perf.run($iter)
186
185
 
187
186
  unless $failed.empty?
188
187
  puts "The following packages were not included for the reason listed"
189
- $failed.each { |tag,msg| puts "***** #{tag}: #{msg}" }
188
+ $failed.each { |tag, msg| puts "***** #{tag}: #{msg}" }
190
189
  end
data/test/perf_saj.rb CHANGED
@@ -93,7 +93,6 @@ if $verbose
93
93
  puts "json:\n#{$json}\n"
94
94
  end
95
95
 
96
-
97
96
  puts '-' * 80
98
97
  puts "Parse Performance"
99
98
  perf = Perf.new()
@@ -105,5 +104,5 @@ perf.run($iter)
105
104
 
106
105
  unless $failed.empty?
107
106
  puts "The following packages were not included for the reason listed"
108
- $failed.each { |tag,msg| puts "***** #{tag}: #{msg}" }
107
+ $failed.each { |tag, msg| puts "***** #{tag}: #{msg}" }
109
108
  end
data/test/perf_scp.rb CHANGED
@@ -148,5 +148,5 @@ perf.run($iter)
148
148
 
149
149
  unless $failed.empty?
150
150
  puts "The following packages were not included for the reason listed"
151
- $failed.each { |tag,msg| puts "***** #{tag}: #{msg}" }
151
+ $failed.each { |tag, msg| puts "***** #{tag}: #{msg}" }
152
152
  end
data/test/perf_simple.rb CHANGED
@@ -21,7 +21,7 @@ class Jazz
21
21
  @array = [true, false, nil]
22
22
  @hash = { 'one' => 1, 'two' => 2 }
23
23
  end
24
- def to_json()
24
+ def to_json(*_args)
25
25
  %{
26
26
  { "boolean":#{@boolean},
27
27
  "number":#{@number},
@@ -177,7 +177,7 @@ puts "%d Ox.load()s in %0.3f seconds or %0.1f loads/msec" % [$iter, dt, $iter/dt
177
177
 
178
178
  puts "Parser results:"
179
179
  puts "gem seconds parses/msec X faster than #{base_name} (higher is better)"
180
- parse_results.each do |name,dt|
180
+ parse_results.each do |name, dt|
181
181
  if 0.0 == dt
182
182
  puts "#{name} failed to generate JSON"
183
183
  next
@@ -276,7 +276,7 @@ puts "%d Ox.dump()s in %0.3f seconds or %0.1f dumps/msec" % [$iter, dt, $iter/dt
276
276
 
277
277
  puts "Parser results:"
278
278
  puts "gem seconds dumps/msec X faster than #{base_name} (higher is better)"
279
- parse_results.each do |name,dt|
279
+ parse_results.each do |name, dt|
280
280
  if 0.0 == dt
281
281
  puts "#{name} failed to generate JSON"
282
282
  next
data/test/perf_strict.rb CHANGED
@@ -135,5 +135,5 @@ puts
135
135
 
136
136
  unless $failed.empty?
137
137
  puts "The following packages were not included for the reason listed"
138
- $failed.each { |tag,msg| puts "***** #{tag}: #{msg}" }
138
+ $failed.each { |tag, msg| puts "***** #{tag}: #{msg}" }
139
139
  end
data/test/perf_wab.rb CHANGED
@@ -127,5 +127,5 @@ puts
127
127
 
128
128
  unless $failed.empty?
129
129
  puts "The following packages were not included for the reason listed"
130
- $failed.each { |tag,msg| puts "***** #{tag}: #{msg}" }
130
+ $failed.each { |tag, msg| puts "***** #{tag}: #{msg}" }
131
131
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module Sample
3
2
  class Change
4
3
  attr_accessor :time
data/test/sample/dir.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  require 'etc'
3
2
 
4
3
  module Sample
data/test/sample/doc.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  require 'sample/hasprops'
3
2
  require 'sample/group'
4
3
  require 'sample/layer'
data/test/sample/file.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  require 'etc'
3
2
 
4
3
  module Sample
data/test/sample/group.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  module Sample
3
2
  class Group
4
3
  attr_reader :members
@@ -1,4 +1,3 @@
1
-
2
1
  module Sample
3
2
  module HasProps
4
3
 
data/test/sample/layer.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  module Sample
3
2
  class Layer < Group
4
3
  attr_accessor :name
data/test/sample/rect.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  module Sample
3
2
  class Rect < Shape
4
3
 
data/test/sample/shape.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  module Sample
3
2
  class Shape
4
3
  include HasProps
data/test/sample/text.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  module Sample
3
2
  class Text < Shape
4
3
  attr_accessor :text
data/test/sample.rb CHANGED
@@ -7,7 +7,6 @@ if $0 == __FILE__
7
7
  $: << '../ext'
8
8
  end
9
9
 
10
- require 'pp'
11
10
  require 'sample/doc'
12
11
 
13
12
  def sample_doc(size=3)
@@ -27,7 +26,7 @@ def sample_doc(size=3)
27
26
  g = ::Sample::Group.new
28
27
  (1..size).each do |k|
29
28
  g2 = ::Sample::Group.new
30
- r = ::Sample::Rect.new(j * 40 + 10.0, i * 10.0,
29
+ r = ::Sample::Rect.new((j * 40) + 10.0, i * 10.0,
31
30
  10.123456 / k, 10.0 / k, colors[(i + j + k) % colors.size])
32
31
  r.add_prop(:part_of, layer.name)
33
32
  g2 << r
@@ -36,7 +35,7 @@ def sample_doc(size=3)
36
35
  end
37
36
  g2 = ::Sample::Group.new
38
37
  (1..size).each do |k|
39
- o = ::Sample::Oval.new(j * 40 + 12.0, i * 10.0 + 2.0,
38
+ o = ::Sample::Oval.new((j * 40) + 12.0, (i * 10.0) + 2.0,
40
39
  6.0 / k, 6.0 / k, colors[(i + j + k) % colors.size])
41
40
  o.add_prop(:inside, true)
42
41
  g << o
data/test/sample_json.rb CHANGED
@@ -7,7 +7,6 @@ if $0 == __FILE__
7
7
  $: << '../ext'
8
8
  end
9
9
 
10
- require 'pp'
11
10
  require 'oj'
12
11
 
13
12
  def sample_json(size=3)
data/test/test_compat.rb CHANGED
@@ -30,7 +30,7 @@ class CompatJuice < Minitest::Test
30
30
  alias == eql?
31
31
 
32
32
  def to_json(*a)
33
- %|{"json_class":"#{self.class.to_s}","x":#{@x},"y":#{@y}}|
33
+ %|{"json_class":"#{self.class}","x":#{@x},"y":#{@y}}|
34
34
  end
35
35
 
36
36
  def self.json_create(h)
@@ -170,7 +170,7 @@ class CompatJuice < Minitest::Test
170
170
  end
171
171
 
172
172
  def test_array_deep
173
- dump_and_load([1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20]]]]]]]]]]]]]]]]]]]], false)
173
+ dump_and_load([1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]]], false)
174
174
  end
175
175
 
176
176
  def test_symbol
@@ -341,12 +341,14 @@ class CompatJuice < Minitest::Test
341
341
 
342
342
  def test_io_file
343
343
  filename = File.join(File.dirname(__FILE__), 'open_file_test.json')
344
- File.open(filename, 'w') { |f| f.write(%{{
344
+ File.open(filename, 'w') { |f|
345
+ f.write(%{{
345
346
  "x":true,
346
347
  "y":58,
347
348
  "z": [1,2,3]
348
349
  }
349
- }) }
350
+ })
351
+ }
350
352
  f = File.new(filename)
351
353
  obj = Oj.compat_load(f)
352
354
  f.close()
@@ -485,7 +487,7 @@ class CompatJuice < Minitest::Test
485
487
 
486
488
  def test_parse_to_s
487
489
  s = Stringy.new
488
- assert_equal([1,2], Oj.load(s, :mode => :compat))
490
+ assert_equal([1, 2], Oj.load(s, :mode => :compat))
489
491
  end
490
492
 
491
493
  def test_parse_large_string
@@ -496,10 +498,10 @@ class CompatJuice < Minitest::Test
496
498
  assert(error.message.include?('quoted string not terminated'))
497
499
 
498
500
  json =<<~JSON
499
- {
500
- "a": "\\u3074\\u30fc\\u305f\\u30fc",
501
- "b": "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
502
- }
501
+ {
502
+ "a": "\\u3074\\u30fc\\u305f\\u30fc",
503
+ "b": "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
504
+ }
503
505
  JSON
504
506
  assert_equal("ぴーたー", Oj.load(json)['a'])
505
507
  end
data/test/test_custom.rb CHANGED
@@ -196,7 +196,7 @@ class CustomJuice < Minitest::Test
196
196
  end
197
197
 
198
198
  def test_array_deep
199
- dump_and_load([1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20]]]]]]]]]]]]]]]]]]]], false)
199
+ dump_and_load([1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]]], false)
200
200
  end
201
201
 
202
202
  def test_deep_nest
@@ -204,7 +204,7 @@ class CustomJuice < Minitest::Test
204
204
 
205
205
  begin
206
206
  n = 10000
207
- Oj.strict_load('[' * n + ']' * n)
207
+ Oj.strict_load(('[' * n) + (']' * n))
208
208
  rescue Exception => e
209
209
  assert(false, e.message)
210
210
  end
@@ -343,7 +343,6 @@ class CustomJuice < Minitest::Test
343
343
  "b":[3]
344
344
  }
345
345
  |, json)
346
-
347
346
  end
348
347
 
349
348
  def test_symbol
@@ -450,12 +449,9 @@ class CustomJuice < Minitest::Test
450
449
  end
451
450
 
452
451
  def test_datetime_unix_zone
453
- # older versions seems to have issues getting the utc offset.
454
- if '2.4' <= RUBY_VERSION
455
- obj = DateTime.new(2017, 1, 5, 10, 20, 30, '-0500')
456
- json = Oj.dump(obj, :indent => 2, time_format: :unix_zone)
457
- assert_equal('1483629630.000000000e-18000', json)
458
- end
452
+ obj = DateTime.new(2017, 1, 5, 10, 20, 30, '-0500')
453
+ json = Oj.dump(obj, :indent => 2, time_format: :unix_zone)
454
+ assert_equal('1483629630.000000000e-18000', json)
459
455
  end
460
456
 
461
457
  def test_datetime_ruby
data/test/test_debian.rb CHANGED
@@ -16,7 +16,7 @@ class DebJuice < Minitest::Test
16
16
  end
17
17
  alias == eql?
18
18
 
19
- end# Jam
19
+ end # Jam
20
20
 
21
21
  # contributed by sauliusg to fix as_json
22
22
  class Orange < Jam
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)