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.
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
@@ -18,7 +18,6 @@ require 'test_object'
18
18
  require 'test_saj'
19
19
  require 'test_scp'
20
20
  require 'test_strict'
21
- require 'test_various'
22
21
  require 'test_rails'
23
22
  require 'test_wab'
24
23
  require 'test_writer'
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.10
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: 2021-12-12 00:00:00.000000000 Z
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.2.22
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