oj 3.13.21 → 3.13.22

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_custom.rb CHANGED
@@ -260,8 +260,6 @@ class CustomJuice < Minitest::Test
260
260
  end
261
261
 
262
262
  def test_object
263
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
264
-
265
263
  obj = Jeez.new(true, 58)
266
264
  json = Oj.dump(obj, create_id: "^o", use_to_json: false, use_as_json: false, use_to_hash: false)
267
265
  assert_equal(%|{"x":true,"y":58,"_z":"true"}|, json)
@@ -407,15 +405,11 @@ class CustomJuice < Minitest::Test
407
405
  end
408
406
 
409
407
  def test_range
410
- skip 'TruffleRuby fails this spec' if RUBY_ENGINE == 'truffleruby'
411
-
412
408
  obj = 3..8
413
409
  dump_and_load(obj, false, :create_id => "^o", :create_additions => true)
414
410
  end
415
411
 
416
412
  def test_date
417
- skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
418
-
419
413
  obj = Date.new(2017, 1, 5)
420
414
  dump_and_load(obj, false, :create_id => "^o", :create_additions => true)
421
415
  end
@@ -445,8 +439,6 @@ class CustomJuice < Minitest::Test
445
439
  end
446
440
 
447
441
  def test_datetime
448
- skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
449
-
450
442
  obj = DateTime.new(2017, 1, 5, 10, 20, 30)
451
443
  dump_and_load(obj, false, :create_id => "^o", :create_additions => true)
452
444
  end
@@ -493,8 +485,15 @@ class CustomJuice < Minitest::Test
493
485
  skip 'TruffleRuby fails this spec' if RUBY_ENGINE == 'truffleruby'
494
486
 
495
487
  obj = Time.now()
496
- dump_load_dump(obj, false, :time_format => :unix, :create_id => "^o", :create_additions => true)
497
- dump_load_dump(obj, false, :time_format => :unix_zone, :create_id => "^o", :create_additions => true)
488
+ # These two forms should be able to recreate the time precisely,
489
+ # so we check they can load a dumped version and recreate the
490
+ # original object correctly.
491
+ dump_and_load(obj, false, :time_format => :unix, :create_id => "^o", :create_additions => true)
492
+ dump_and_load(obj, false, :time_format => :unix_zone, :create_id => "^o", :create_additions => true)
493
+ # These two forms will lose precision while dumping as they don't
494
+ # preserve full precision. We check that a dumped version is equal
495
+ # to that version loaded and dumped a second time, but don't check
496
+ # that the loaded Ruby objects is still the same as the original.
498
497
  dump_load_dump(obj, false, :time_format => :xmlschema, :create_id => "^o", :create_additions => true)
499
498
  dump_load_dump(obj, false, :time_format => :ruby, :create_id => "^o", :create_additions => true)
500
499
  end
data/test/test_file.rb CHANGED
@@ -125,15 +125,12 @@ class FileJuice < Minitest::Test
125
125
 
126
126
  # Time
127
127
  def test_time_object
128
- skip 'TruffleRuby fails this spec' if RUBY_ENGINE == 'truffleruby'
129
-
130
128
  t = Time.now()
131
129
  Oj.default_options = { :mode => :object, :time_format => :unix_zone }
132
130
  dump_and_load(t, false)
133
131
  end
134
132
  def test_time_object_early
135
133
  skip 'Windows does not support dates before 1970.' if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
136
- skip 'TruffleRuby fails this spec' if RUBY_ENGINE == 'truffleruby'
137
134
 
138
135
  t = Time.xmlschema("1954-01-05T00:00:00.123456")
139
136
  Oj.default_options = { :mode => :object, :time_format => :unix_zone }
@@ -165,14 +162,10 @@ class FileJuice < Minitest::Test
165
162
  def test_range_object
166
163
  Oj.default_options = { :mode => :object }
167
164
  json = Oj.dump(1..7, :mode => :object, :indent => 0)
168
- if 'rubinius' == $ruby
169
- assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
170
- elsif 'jruby' == $ruby
171
- assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
172
- elsif 'truffleruby' == $ruby
173
- assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
174
- else
165
+ if $ruby == 'ruby'
175
166
  assert_equal(%{{"^u":["Range",1,7,false]}}, json)
167
+ else
168
+ assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
176
169
  end
177
170
  dump_and_load(1..7, false)
178
171
  dump_and_load(1..1, false)
data/test/test_gc.rb CHANGED
@@ -43,8 +43,6 @@ class GCTest < Minitest::Test
43
43
  end
44
44
 
45
45
  def test_parse_object_gc
46
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
47
-
48
46
  g = Goo.new(0, nil)
49
47
  100.times { |i| g = Goo.new(i, g) }
50
48
  json = Oj.dump(g, :mode => :object)
@@ -23,24 +23,18 @@ class IntegerRangeTest < Minitest::Test
23
23
  end
24
24
 
25
25
  def test_range
26
- skip 'TruffleRuby fails this spec with `ArgumentError: :integer_range must be a range of Fixnum.`' if RUBY_ENGINE == 'truffleruby'
27
-
28
26
  test = {s: 0, s2: -1, s3: 1, u: -2, u2: 2, u3: 9007199254740993}
29
27
  exp = '{"s":0,"s2":-1,"s3":1,"u":"-2","u2":"2","u3":"9007199254740993"}'
30
28
  assert_equal(exp, Oj.dump(test, integer_range: (-1..1)))
31
29
  end
32
30
 
33
31
  def test_bignum
34
- skip 'TruffleRuby fails this spec with `ArgumentError: :integer_range must be a range of Fixnum.`' if RUBY_ENGINE == 'truffleruby'
35
-
36
32
  test = {u: -10000000000000000000, u2: 10000000000000000000}
37
33
  exp = '{"u":"-10000000000000000000","u2":"10000000000000000000"}'
38
34
  assert_equal(exp, Oj.dump(test, integer_range: (-1..1)))
39
35
  end
40
36
 
41
37
  def test_valid_modes
42
- skip 'TruffleRuby fails this spec with `ArgumentError: :integer_range must be a range of Fixnum.`' if RUBY_ENGINE == 'truffleruby'
43
-
44
38
  test = {safe: 0, unsafe: 9007199254740993}
45
39
  exp = '{"safe":0,"unsafe":"9007199254740993"}'
46
40
 
data/test/test_object.rb CHANGED
@@ -221,13 +221,6 @@ 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
- verify_gc_compaction
228
- #Oj::debug_odd("teardown after GC.verify_compaction_references")
229
- end
230
- #=end
231
224
  end
232
225
 
233
226
  def test_nil
@@ -461,8 +454,6 @@ class ObjectJuice < Minitest::Test
461
454
  end
462
455
 
463
456
  def test_json_module_object
464
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
465
-
466
457
  obj = One::Two::Three::Deep.new()
467
458
  dump_and_load(obj, false)
468
459
  end
@@ -633,15 +624,11 @@ class ObjectJuice < Minitest::Test
633
624
  end
634
625
 
635
626
  def test_json_object
636
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
637
-
638
627
  obj = Jeez.new(true, 58)
639
628
  dump_and_load(obj, false)
640
629
  end
641
630
 
642
631
  def test_json_object_create_deep
643
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
644
-
645
632
  obj = One::Two::Three::Deep.new()
646
633
  dump_and_load(obj, false)
647
634
  end
@@ -678,8 +665,6 @@ class ObjectJuice < Minitest::Test
678
665
  end
679
666
 
680
667
  def test_json_anonymous_struct
681
- skip 'TruffleRuby fails this spec with `TypeError: allocator undefined for Class`' if RUBY_ENGINE == 'truffleruby'
682
-
683
668
  s = Struct.new(:x, :y)
684
669
  obj = s.new(1, 2)
685
670
  json = Oj.dump(obj, :indent => 2, :mode => :object)
@@ -702,8 +687,6 @@ class ObjectJuice < Minitest::Test
702
687
  end
703
688
 
704
689
  def test_json_object_object
705
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
706
-
707
690
  obj = Jeez.new(true, 58)
708
691
  json = Oj.dump(obj, mode: :object, indent: 2, ignore_under: true)
709
692
  assert(%{{
@@ -723,8 +706,6 @@ class ObjectJuice < Minitest::Test
723
706
  end
724
707
 
725
708
  def test_to_hash_object_object
726
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
727
-
728
709
  obj = Jazz.new(true, 58)
729
710
  json = Oj.dump(obj, :mode => :object, :indent => 2)
730
711
  assert(%{{
@@ -744,8 +725,6 @@ class ObjectJuice < Minitest::Test
744
725
  end
745
726
 
746
727
  def test_as_json_object_object
747
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
748
-
749
728
  obj = Orange.new(true, 58)
750
729
  json = Oj.dump(obj, :mode => :object, :indent => 2)
751
730
  assert(%{{
@@ -765,8 +744,6 @@ class ObjectJuice < Minitest::Test
765
744
  end
766
745
 
767
746
  def test_object_object_no_cache
768
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
769
-
770
747
  obj = Jam.new(true, 58)
771
748
  json = Oj.dump(obj, :mode => :object, :indent => 2)
772
749
  assert(%{{
@@ -795,8 +772,6 @@ class ObjectJuice < Minitest::Test
795
772
  end
796
773
 
797
774
  def test_exception
798
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
799
-
800
775
  err = nil
801
776
  begin
802
777
  raise StandardError.new('A Message')
@@ -827,8 +802,6 @@ class ObjectJuice < Minitest::Test
827
802
  end
828
803
 
829
804
  def test_exception_subclass
830
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
831
-
832
805
  err = nil
833
806
  begin
834
807
  raise SubX.new
@@ -848,12 +821,10 @@ class ObjectJuice < Minitest::Test
848
821
  def test_range_object
849
822
  Oj.default_options = { :mode => :object }
850
823
  json = Oj.dump(1..7, :mode => :object, :indent => 0)
851
- if 'rubinius' == $ruby
852
- assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
853
- elsif 'truffleruby' == $ruby
854
- assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
855
- else
824
+ if 'ruby' == $ruby
856
825
  assert_equal(%{{"^u":["Range",1,7,false]}}, json)
826
+ else
827
+ assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
857
828
  end
858
829
  dump_and_load(1..7, false)
859
830
  dump_and_load(1..1, false)
@@ -917,8 +888,6 @@ class ObjectJuice < Minitest::Test
917
888
  end
918
889
 
919
890
  def test_circular_object
920
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
921
-
922
891
  obj = Jeez.new(nil, 58)
923
892
  obj.x = obj
924
893
  json = Oj.dump(obj, :mode => :object, :indent => 2, :circular => true)
@@ -927,8 +896,6 @@ class ObjectJuice < Minitest::Test
927
896
  end
928
897
 
929
898
  def test_circular_object2
930
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
931
-
932
899
  obj = Jam.new(nil, 58)
933
900
  obj.x = obj
934
901
  json = Oj.dump(obj, :mode => :object, :indent => 2, :circular => true)
@@ -951,8 +918,6 @@ class ObjectJuice < Minitest::Test
951
918
  end
952
919
 
953
920
  def test_circular
954
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
955
-
956
921
  h = { 'a' => 7 }
957
922
  obj = Jeez.new(h, 58)
958
923
  obj.x['b'] = obj
@@ -963,8 +928,6 @@ class ObjectJuice < Minitest::Test
963
928
  end
964
929
 
965
930
  def test_circular2
966
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
967
-
968
931
  h = { 'a' => 7 }
969
932
  obj = Jam.new(h, 58)
970
933
  obj.x['b'] = obj
@@ -977,8 +940,6 @@ class ObjectJuice < Minitest::Test
977
940
  end
978
941
 
979
942
  def test_omit_nil
980
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
981
-
982
943
  jam = Jam.new({'a' => 1, 'b' => nil }, nil)
983
944
 
984
945
  json = Oj.dump(jam, :omit_nil => true, :mode => :object)
@@ -1033,22 +994,16 @@ class ObjectJuice < Minitest::Test
1033
994
  end
1034
995
 
1035
996
  def test_auto_string
1036
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
1037
-
1038
997
  s = AutoStrung.new("Pete", true)
1039
998
  dump_and_load(s, false)
1040
999
  end
1041
1000
 
1042
1001
  def test_auto_array
1043
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
1044
-
1045
1002
  a = AutoArray.new([1, 'abc', nil], true)
1046
1003
  dump_and_load(a, false)
1047
1004
  end
1048
1005
 
1049
1006
  def test_auto_hash
1050
- skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
1051
-
1052
1007
  h = AutoHash.new(nil, true)
1053
1008
  h['a'] = 1
1054
1009
  h['b'] = 2
data/test/test_parser.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+ # encoding: UTF-8
3
3
 
4
4
  $: << File.dirname(__FILE__)
5
5
  $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
@@ -7,21 +7,5 @@ $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
7
7
  $: << File.join($oj_dir, dir)
8
8
  end
9
9
 
10
- require 'minitest'
11
- require 'minitest/autorun'
12
- require 'stringio'
13
- require 'date'
14
- require 'bigdecimal'
15
- require 'oj'
16
-
17
- class ParserJuice < Minitest::Test
18
-
19
- def test_array
20
- p = Oj::Parser.new(:debug)
21
- out = p.parse(%|[true, false, null, 123, -1.23, "abc"]|)
22
- puts out
23
- out = p.parse(%|{"abc": []}|)
24
- puts out
25
- end
26
-
27
- end
10
+ require 'test_parser_usual'
11
+ require 'test_parser_saj'
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ $: << File.dirname(__FILE__)
5
+ $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
6
+ %w(lib ext).each do |dir|
7
+ $: << File.join($oj_dir, dir)
8
+ end
9
+
10
+ require 'minitest'
11
+ require 'minitest/autorun'
12
+ require 'stringio'
13
+ require 'date'
14
+ require 'bigdecimal'
15
+ require 'oj'
16
+
17
+ class ParserJuice < Minitest::Test
18
+
19
+ def test_array
20
+ p = Oj::Parser.new(:debug)
21
+ out = p.parse(%|[true, false, null, 123, -1.23, "abc"]|)
22
+ puts out
23
+ out = p.parse(%|{"abc": []}|)
24
+ puts out
25
+ end
26
+
27
+ end
data/test/test_scp.rb CHANGED
@@ -320,8 +320,7 @@ class ScpTest < Minitest::Test
320
320
  end
321
321
 
322
322
  def test_pipe
323
- skip ' Windows does not support fork' if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
324
- skip 'TruffleRuby fails this spec with `NotImplementedError: fork is not available`' if RUBY_ENGINE == 'truffleruby'
323
+ skip 'needs fork' unless Process.respond_to?(:fork)
325
324
 
326
325
  handler = AllHandler.new()
327
326
  json = %{{"one":true,"two":false}}
@@ -357,8 +356,7 @@ class ScpTest < Minitest::Test
357
356
  end
358
357
 
359
358
  def test_pipe_close
360
- skip 'Windows does not support fork' if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
361
- skip 'TruffleRuby fails this spec with `NotImplementedError: fork is not available`' if RUBY_ENGINE == 'truffleruby'
359
+ skip 'needs fork' unless Process.respond_to?(:fork)
362
360
 
363
361
  json = %{{"one":true,"two":false}}
364
362
  IO.pipe do |read_io, write_io|
data/test/test_various.rb CHANGED
@@ -559,9 +559,6 @@ class Juice < Minitest::Test
559
559
  end
560
560
 
561
561
  def test_io_file
562
- # Windows does not support fork
563
- return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
564
-
565
562
  src = { 'x' => true, 'y' => 58, 'z' => [1, 2, 3]}
566
563
  filename = File.join(File.dirname(__FILE__), 'open_file_test.json')
567
564
  File.open(filename, "w") { |f|
@@ -574,6 +571,8 @@ class Juice < Minitest::Test
574
571
  end
575
572
 
576
573
  def test_io_stream
574
+ skip 'needs fork' unless Process.respond_to?(:fork)
575
+
577
576
  IO.pipe do |r, w|
578
577
  if fork
579
578
  r.close
data/test/tests.rb CHANGED
@@ -22,3 +22,12 @@ require 'test_rails'
22
22
  require 'test_wab'
23
23
  require 'test_writer'
24
24
  require 'test_integer_range'
25
+
26
+ at_exit do
27
+ require 'helper'
28
+ if '3.1.0' <= RUBY_VERSION && !(RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/)
29
+ #Oj::debug_odd("teardown before GC.verify_compaction_references")
30
+ verify_gc_compaction
31
+ #Oj::debug_odd("teardown after GC.verify_compaction_references")
32
+ end
33
+ end
data/test/tests_mimic.rb CHANGED
@@ -12,3 +12,12 @@ require 'json_generator_test'
12
12
  require 'json_generic_object_test'
13
13
  require 'json_parser_test'
14
14
  require 'json_string_matching_test'
15
+
16
+ at_exit do
17
+ require 'helper'
18
+ if '3.1.0' <= RUBY_VERSION && !(RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/)
19
+ #Oj::debug_odd("teardown before GC.verify_compaction_references")
20
+ verify_gc_compaction
21
+ #Oj::debug_odd("teardown after GC.verify_compaction_references")
22
+ end
23
+ end
@@ -5,3 +5,12 @@ $: << File.dirname(__FILE__)
5
5
  $: << File.join(File.dirname(__FILE__), 'json_gem')
6
6
 
7
7
  require 'json_addition_test'
8
+
9
+ at_exit do
10
+ require 'helper'
11
+ if '3.1.0' <= RUBY_VERSION && !(RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/)
12
+ #Oj::debug_odd("teardown before GC.verify_compaction_references")
13
+ verify_gc_compaction
14
+ #Oj::debug_odd("teardown after GC.verify_compaction_references")
15
+ end
16
+ end
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.21
4
+ version: 3.13.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-19 00:00:00.000000000 Z
11
+ date: 2022-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -110,6 +110,7 @@ files:
110
110
  - ext/oj/fast.c
111
111
  - ext/oj/intern.c
112
112
  - ext/oj/intern.h
113
+ - ext/oj/introspect.c
113
114
  - ext/oj/mimic_json.c
114
115
  - ext/oj/object.c
115
116
  - ext/oj/odd.c
@@ -130,6 +131,7 @@ files:
130
131
  - ext/oj/rxclass.h
131
132
  - ext/oj/saj.c
132
133
  - ext/oj/saj2.c
134
+ - ext/oj/saj2.h
133
135
  - ext/oj/scp.c
134
136
  - ext/oj/sparse.c
135
137
  - ext/oj/stream_writer.c
@@ -138,6 +140,7 @@ files:
138
140
  - ext/oj/trace.c
139
141
  - ext/oj/trace.h
140
142
  - ext/oj/usual.c
143
+ - ext/oj/usual.h
141
144
  - ext/oj/util.c
142
145
  - ext/oj/util.h
143
146
  - ext/oj/val_stack.c
@@ -257,6 +260,7 @@ files:
257
260
  - test/test_null.rb
258
261
  - test/test_object.rb
259
262
  - test/test_parser.rb
263
+ - test/test_parser_debug.rb
260
264
  - test/test_parser_saj.rb
261
265
  - test/test_parser_usual.rb
262
266
  - test/test_rails.rb