oj 3.13.10 → 3.13.13
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 +13 -0
- data/ext/oj/circarray.c +1 -1
- data/ext/oj/code.c +15 -22
- data/ext/oj/custom.c +28 -55
- data/ext/oj/dump.c +128 -161
- data/ext/oj/dump.h +12 -8
- data/ext/oj/dump_compat.c +43 -80
- data/ext/oj/dump_leaf.c +14 -58
- data/ext/oj/dump_object.c +28 -96
- data/ext/oj/dump_strict.c +12 -24
- data/ext/oj/encoder.c +43 -0
- data/ext/oj/fast.c +9 -9
- data/ext/oj/intern.c +9 -2
- data/ext/oj/intern.h +1 -1
- data/ext/oj/mimic_json.c +25 -23
- data/ext/oj/odd.c +83 -63
- data/ext/oj/odd.h +13 -13
- data/ext/oj/oj.c +28 -16
- data/ext/oj/oj.h +20 -2
- data/ext/oj/parse.c +3 -2
- data/ext/oj/parser.c +10 -15
- data/ext/oj/rails.c +38 -57
- data/ext/oj/rails.h +1 -1
- data/ext/oj/reader.c +2 -0
- data/ext/oj/saj.c +11 -23
- data/ext/oj/stream_writer.c +3 -1
- data/ext/oj/string_writer.c +12 -5
- data/ext/oj/wab.c +8 -8
- data/lib/oj/version.rb +1 -1
- data/test/bar.rb +1 -8
- data/test/foo.rb +67 -25
- data/test/perf_dump.rb +50 -0
- data/test/test_object.rb +12 -7
- data/test/test_saj.rb +1 -1
- data/test/test_various.rb +27 -2
- data/test/tests.rb +0 -1
- metadata +6 -3
data/test/test_object.rb
CHANGED
@@ -221,6 +221,13 @@ class ObjectJuice < Minitest::Test
|
|
221
221
|
|
222
222
|
def teardown
|
223
223
|
Oj.default_options = @default_options
|
224
|
+
#=begin
|
225
|
+
if '3.1.0' <= RUBY_VERSION && !(RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/)
|
226
|
+
#Oj::debug_odd("teardown before GC.verify_compaction_references")
|
227
|
+
GC.verify_compaction_references(double_heap: true, toward: :empty)
|
228
|
+
#Oj::debug_odd("teardown after GC.verify_compaction_references")
|
229
|
+
end
|
230
|
+
#=end
|
224
231
|
end
|
225
232
|
|
226
233
|
def test_nil
|
@@ -948,6 +955,11 @@ class ObjectJuice < Minitest::Test
|
|
948
955
|
|
949
956
|
def test_odd_date
|
950
957
|
dump_and_load(Date.new(2012, 6, 19), false)
|
958
|
+
|
959
|
+
Oj.register_odd(Date, Date, :jd, :jd)
|
960
|
+
json = Oj.dump(Date.new(2015, 3, 7), :mode => :object)
|
961
|
+
assert_equal(%|{"^O":"Date","jd":2457089}|, json)
|
962
|
+
dump_and_load(Date.new(2012, 6, 19), false)
|
951
963
|
end
|
952
964
|
|
953
965
|
def test_odd_datetime
|
@@ -972,13 +984,6 @@ class ObjectJuice < Minitest::Test
|
|
972
984
|
dump_and_load(s, false)
|
973
985
|
end
|
974
986
|
|
975
|
-
def test_odd_date_replaced
|
976
|
-
Oj.register_odd(Date, Date, :jd, :jd)
|
977
|
-
json = Oj.dump(Date.new(2015, 3, 7), :mode => :object)
|
978
|
-
assert_equal(%|{"^O":"Date","jd":2457089}|, json)
|
979
|
-
dump_and_load(Date.new(2012, 6, 19), false)
|
980
|
-
end
|
981
|
-
|
982
987
|
def test_odd_raw
|
983
988
|
Oj.register_odd_raw(Raw, Raw, :create, :to_json)
|
984
989
|
json = Oj.dump(Raw.new(%|{"a":1}|), :mode => :object)
|
data/test/test_saj.rb
CHANGED
@@ -180,7 +180,7 @@ class SajTest < Minitest::Test
|
|
180
180
|
assert_equal([:add_value, 12345, nil], handler.calls.first)
|
181
181
|
type, message, line, column = handler.calls.last
|
182
182
|
assert_equal([:error, 1, 6], [type, line, column])
|
183
|
-
assert_match(%r{invalid format, extra characters at line 1, column 6 \[(?:[a-z\.]+/)*saj\.c:\d+\]}, message)
|
183
|
+
assert_match(%r{invalid format, extra characters at line 1, column 6 \[(?:[A-Za-z]:\/)?(?:[a-z\.]+/)*saj\.c:\d+\]}, message)
|
184
184
|
end
|
185
185
|
|
186
186
|
end
|
data/test/test_various.rb
CHANGED
@@ -528,7 +528,7 @@ class Juice < Minitest::Test
|
|
528
528
|
assert_equal(58, obj.y)
|
529
529
|
end
|
530
530
|
|
531
|
-
# Stream Deeply Nested
|
531
|
+
# Stream Deeply Nested
|
532
532
|
def test_deep_nest_dump
|
533
533
|
begin
|
534
534
|
a = []
|
@@ -541,7 +541,7 @@ class Juice < Minitest::Test
|
|
541
541
|
assert(false, "*** expected an exception")
|
542
542
|
end
|
543
543
|
|
544
|
-
# Stream IO
|
544
|
+
# Stream IO
|
545
545
|
def test_io_string
|
546
546
|
src = { 'x' => true, 'y' => 58, 'z' => [1, 2, 3]}
|
547
547
|
output = StringIO.open("", "w+")
|
@@ -553,6 +553,9 @@ class Juice < Minitest::Test
|
|
553
553
|
end
|
554
554
|
|
555
555
|
def test_io_file
|
556
|
+
# Windows does not support fork
|
557
|
+
return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
|
558
|
+
|
556
559
|
src = { 'x' => true, 'y' => 58, 'z' => [1, 2, 3]}
|
557
560
|
filename = File.join(File.dirname(__FILE__), 'open_file_test.json')
|
558
561
|
File.open(filename, "w") { |f|
|
@@ -564,6 +567,28 @@ class Juice < Minitest::Test
|
|
564
567
|
assert_equal(src, obj)
|
565
568
|
end
|
566
569
|
|
570
|
+
def test_io_stream
|
571
|
+
IO.pipe do |r, w|
|
572
|
+
if fork
|
573
|
+
r.close
|
574
|
+
#w.nonblock = false
|
575
|
+
a = []
|
576
|
+
10_000.times do |i|
|
577
|
+
a << i
|
578
|
+
end
|
579
|
+
Oj.to_stream(w, a, indent: 2)
|
580
|
+
w.close
|
581
|
+
else
|
582
|
+
w.close
|
583
|
+
sleep(0.1) # to force a busy
|
584
|
+
cnt = 0
|
585
|
+
r.each_line { cnt += 1 }
|
586
|
+
r.close
|
587
|
+
Process.exit(0)
|
588
|
+
end
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
567
592
|
# comments
|
568
593
|
def test_comment_slash
|
569
594
|
json = %{{
|
data/test/tests.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.13.
|
4
|
+
version: 3.13.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- ext/oj/dump_object.c
|
118
118
|
- ext/oj/dump_strict.c
|
119
119
|
- ext/oj/encode.h
|
120
|
+
- ext/oj/encoder.c
|
120
121
|
- ext/oj/err.c
|
121
122
|
- ext/oj/err.h
|
122
123
|
- ext/oj/extconf.rb
|
@@ -227,6 +228,7 @@ files:
|
|
227
228
|
- test/mem.rb
|
228
229
|
- test/perf.rb
|
229
230
|
- test/perf_compat.rb
|
231
|
+
- test/perf_dump.rb
|
230
232
|
- test/perf_fast.rb
|
231
233
|
- test/perf_file.rb
|
232
234
|
- test/perf_object.rb
|
@@ -306,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
306
308
|
- !ruby/object:Gem::Version
|
307
309
|
version: '0'
|
308
310
|
requirements: []
|
309
|
-
rubygems_version: 3.
|
311
|
+
rubygems_version: 3.3.3
|
310
312
|
signing_key:
|
311
313
|
specification_version: 4
|
312
314
|
summary: A fast JSON parser and serializer.
|
@@ -359,6 +361,7 @@ test_files:
|
|
359
361
|
- test/mem.rb
|
360
362
|
- test/perf.rb
|
361
363
|
- test/perf_compat.rb
|
364
|
+
- test/perf_dump.rb
|
362
365
|
- test/perf_fast.rb
|
363
366
|
- test/perf_file.rb
|
364
367
|
- test/perf_object.rb
|