oj 3.13.18 → 3.13.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7ca20e7921e7b9a3e2838ecbe3505ecb736bce338113a3db3187f411d1762ca
4
- data.tar.gz: 6c09a24ddb7017caa2a2850076a6b0fcbccc6ed27cd6e28e28de7fadacbaa7fe
3
+ metadata.gz: 958a558e09c25d5de9548af67dff6586686def4a9073b3cee6ba8403930eda48
4
+ data.tar.gz: 2f928e9e849ca695d03ad9a396ec7f2df3508b99d10baa11a8cb538a7b3a0e52
5
5
  SHA512:
6
- metadata.gz: 9e1bb01e19979391421d87b0598ff543ce3035a86fcbb06a68b63d4b56f4194739213d506fdd0492f5cf4a2aabd037872935fcb16f5d083fd6e532c6aa869b8d
7
- data.tar.gz: 29db51398d6008cbcb827af666da0b41b750f6aea3e561fe37b2354f48b88d2bf393dcbfed931679072042bd19cf179ec0ae674027527b627391c2c4792f3c63
6
+ metadata.gz: 758bb300ed853d161750d100a8fbdd755e37ae8e15ae94f1e7a4cbd613c787002758d4fc5834fd47a7ef8fb78446208f896afee31c0bc023bcdeb381aba1f98c
7
+ data.tar.gz: 54127873544ca146a61d7ca4012ff9d2eb4b83bdcbb3f06eea092d4e4ad517c453196a59edc2743b42736ab276e0eb96889045e0d3f2200dcbaf4a2b79353db3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.13.20 - 2022-08-07
4
+
5
+ - SSE4 made optional with a `--with-sse42` flag to the compile.
6
+
7
+ ## 3.13.19 - 2022-07-29
8
+
9
+ - TruffleRuby issues resolved.
10
+
3
11
  ## 3.13.18 - 2022-07-25
4
12
 
5
13
  - Fixed SSE detection at run time.
data/ext/oj/extconf.rb CHANGED
@@ -34,21 +34,9 @@ have_func('rb_hash_bulk_insert', 'ruby.h') unless '2' == version[0] && '6' == ve
34
34
 
35
35
  dflags['OJ_DEBUG'] = true unless ENV['OJ_DEBUG'].nil?
36
36
 
37
- src =<<~SRC
38
- #include <string.h>
39
- #include <nmmintrin.h>
40
- int main(int argc, char **argv) {
41
- const char *str = "hello ";
42
- const char chars[16] = "\x00\\\"";
43
- const __m128i terminate = _mm_loadu_si128((const __m128i *)&chars[0]);
44
- const __m128i string = _mm_loadu_si128((const __m128i *)str);
45
- int r = _mm_cmpestri(terminate, 3, string, 16, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_LEAST_SIGNIFICANT);
46
- return r == 16 ? 0 : 1;
47
- }
48
- SRC
49
-
50
- if try_run(src, '-msse4.2')
37
+ if with_config('--with-sse42')
51
38
  $CPPFLAGS += ' -msse4.2'
39
+ dflags['OJ_USE_SSE4_2'] = 1
52
40
  end
53
41
 
54
42
  dflags.each do |k,v|
data/ext/oj/parse.c CHANGED
@@ -192,28 +192,7 @@ static inline const char *scan_string_noSIMD(const char *str, const char *end) {
192
192
  return str;
193
193
  }
194
194
 
195
- // Taken from Tensorflow:
196
- // https://github.com/tensorflow/tensorflow/blob/5dcfc51118817f27fad5246812d83e5dccdc5f72/tensorflow/core/lib/hash/crc32c_accelerate.cc#L21-L38
197
- #ifdef __SSE4_2__
198
- #if defined(__x86_64__) && defined(__GNUC__) && \
199
- (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
200
- #define USE_SSE_DETECT 1
201
- #elif defined(__x86_64__) && defined(__clang__)
202
- #if __has_builtin(__builtin_cpu_supports)
203
- #define USE_SSE_DETECT 1
204
- #endif
205
- #endif
206
- #endif /* __SSE4_2__ */
207
-
208
- // This version of Apple clang has a bug:
209
- // https://llvm.org/bugs/show_bug.cgi?id=25510
210
- #if defined(__APPLE__) && (__clang_major__ <= 8)
211
- #undef USE_SSE_DETECT
212
- #endif
213
-
214
- #ifdef USE_SSE_DETECT
215
- #include <nmmintrin.h>
216
-
195
+ #ifdef OJ_USE_SSE4_2
217
196
  static inline const char *scan_string_SIMD(const char *str, const char *end) {
218
197
  static const char chars[16] = "\x00\\\"";
219
198
  const __m128i terminate = _mm_loadu_si128((const __m128i *)&chars[0]);
@@ -232,23 +211,12 @@ static inline const char *scan_string_SIMD(const char *str, const char *end) {
232
211
  }
233
212
  #endif
234
213
 
235
- static bool cpu_supports_sse42(void) {
236
- #if USE_SSE_DETECT
237
- __builtin_cpu_init();
238
- return (__builtin_cpu_supports("sse4.2"));
239
- #else
240
- return false;
241
- #endif
242
- }
243
-
244
214
  static const char *(*scan_func) (const char *str, const char *end) = scan_string_noSIMD;
245
215
 
246
216
  void oj_scanner_init(void) {
247
- if (cpu_supports_sse42()) {
248
- #if USE_SSE_DETECT
249
- scan_func = scan_string_SIMD;
217
+ #ifdef OJ_USE_SSE4_2
218
+ scan_func = scan_string_SIMD;
250
219
  #endif
251
- }
252
220
  }
253
221
 
254
222
  // entered at /
@@ -663,7 +631,7 @@ static void read_num(ParseInfo pi) {
663
631
  }
664
632
 
665
633
  static void array_start(ParseInfo pi) {
666
- volatile VALUE v = pi->start_array(pi);
634
+ VALUE v = pi->start_array(pi);
667
635
 
668
636
  stack_push(&pi->stack, v, NEXT_ARRAY_NEW);
669
637
  }
@@ -687,13 +655,13 @@ static void array_end(ParseInfo pi) {
687
655
  }
688
656
 
689
657
  static void hash_start(ParseInfo pi) {
690
- volatile VALUE v = pi->start_hash(pi);
658
+ VALUE v = pi->start_hash(pi);
691
659
 
692
660
  stack_push(&pi->stack, v, NEXT_HASH_NEW);
693
661
  }
694
662
 
695
663
  static void hash_end(ParseInfo pi) {
696
- volatile Val hash = stack_peek(&pi->stack);
664
+ Val hash = stack_peek(&pi->stack);
697
665
 
698
666
  // leave hash on stack until just before
699
667
  if (0 == hash) {
@@ -880,7 +848,7 @@ static long double exp_plus[] = {
880
848
 
881
849
  VALUE
882
850
  oj_num_as_value(NumInfo ni) {
883
- volatile VALUE rnum = Qnil;
851
+ VALUE rnum = Qnil;
884
852
 
885
853
  if (ni->infinity) {
886
854
  if (ni->neg) {
@@ -915,7 +883,7 @@ oj_num_as_value(NumInfo ni) {
915
883
  }
916
884
  } else { // decimal
917
885
  if (ni->big) {
918
- volatile VALUE bd = rb_str_new(ni->str, ni->len);
886
+ VALUE bd = rb_str_new(ni->str, ni->len);
919
887
 
920
888
  rnum = rb_rescue2(parse_big_decimal, bd, rescue_big_decimal, bd, rb_eException, 0);
921
889
  if (ni->no_big) {
@@ -943,7 +911,7 @@ oj_num_as_value(NumInfo ni) {
943
911
  }
944
912
  rnum = rb_float_new((double)ld);
945
913
  } else if (RubyDec == ni->bigdec_load) {
946
- volatile VALUE sv = rb_str_new(ni->str, ni->len);
914
+ VALUE sv = rb_str_new(ni->str, ni->len);
947
915
 
948
916
  rnum = rb_funcall(sv, rb_intern("to_f"), 0);
949
917
  } else {
@@ -1038,7 +1006,7 @@ static VALUE protect_parse(VALUE pip) {
1038
1006
 
1039
1007
  extern int oj_utf8_index;
1040
1008
 
1041
- static void oj_pi_set_input_str(ParseInfo pi, volatile VALUE *inputp) {
1009
+ static void oj_pi_set_input_str(ParseInfo pi, VALUE *inputp) {
1042
1010
  int idx = RB_ENCODING_GET(*inputp);
1043
1011
 
1044
1012
  if (oj_utf8_encoding_index != idx) {
@@ -1051,12 +1019,12 @@ static void oj_pi_set_input_str(ParseInfo pi, volatile VALUE *inputp) {
1051
1019
 
1052
1020
  VALUE
1053
1021
  oj_pi_parse(int argc, VALUE *argv, ParseInfo pi, char *json, size_t len, int yieldOk) {
1054
- char * buf = 0;
1055
- volatile VALUE input;
1056
- volatile VALUE wrapped_stack;
1057
- volatile VALUE result = Qnil;
1058
- int line = 0;
1059
- int free_json = 0;
1022
+ char * buf = 0;
1023
+ VALUE input;
1024
+ VALUE wrapped_stack;
1025
+ VALUE result = Qnil;
1026
+ int line = 0;
1027
+ int free_json = 0;
1060
1028
 
1061
1029
  if (argc < 1) {
1062
1030
  rb_raise(rb_eArgError, "Wrong number of arguments to parse.");
@@ -1092,8 +1060,8 @@ oj_pi_parse(int argc, VALUE *argv, ParseInfo pi, char *json, size_t len, int yie
1092
1060
  rb_raise(rb_eTypeError, "Nil is not a valid JSON source.");
1093
1061
  }
1094
1062
  } else {
1095
- VALUE clas = rb_obj_class(input);
1096
- volatile VALUE s;
1063
+ VALUE clas = rb_obj_class(input);
1064
+ VALUE s;
1097
1065
 
1098
1066
  if (oj_stringio_class == clas) {
1099
1067
  s = rb_funcall2(input, oj_string_id, 0, 0);
data/ext/oj/parse.h CHANGED
@@ -97,7 +97,7 @@ static inline void parse_info_init(ParseInfo pi) {
97
97
  memset(pi, 0, sizeof(struct _parseInfo));
98
98
  }
99
99
 
100
- extern void oj_scanner_init();
100
+ extern void oj_scanner_init(void);
101
101
 
102
102
  static inline bool empty_ok(Options options) {
103
103
  switch (options->mode) {
data/ext/oj/saj2.c CHANGED
@@ -289,7 +289,7 @@ static void add_float_key_loc(ojParser p) {
289
289
  }
290
290
 
291
291
  static void add_big(ojParser p) {
292
- rb_funcall((VALUE)p->ctx,
292
+ rb_funcall(((Delegate)p->ctx)->handler,
293
293
  oj_add_value_id,
294
294
  2,
295
295
  rb_funcall(rb_cObject, oj_bigdecimal_id, 1, rb_str_new(buf_str(&p->buf), buf_len(&p->buf))),
@@ -297,7 +297,7 @@ static void add_big(ojParser p) {
297
297
  }
298
298
 
299
299
  static void add_big_loc(ojParser p) {
300
- rb_funcall((VALUE)p->ctx,
300
+ rb_funcall(((Delegate)p->ctx)->handler,
301
301
  oj_add_value_id,
302
302
  4,
303
303
  rb_funcall(rb_cObject, oj_bigdecimal_id, 1, rb_str_new(buf_str(&p->buf), buf_len(&p->buf))),
@@ -307,7 +307,7 @@ static void add_big_loc(ojParser p) {
307
307
  }
308
308
 
309
309
  static void add_big_key(ojParser p) {
310
- rb_funcall((VALUE)p->ctx,
310
+ rb_funcall(((Delegate)p->ctx)->handler,
311
311
  oj_add_value_id,
312
312
  2,
313
313
  rb_funcall(rb_cObject, oj_bigdecimal_id, 1, rb_str_new(buf_str(&p->buf), buf_len(&p->buf))),
data/lib/oj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.13.18'
4
+ VERSION = '3.13.20'
5
5
  end
data/test/helper.rb CHANGED
@@ -19,10 +19,16 @@ require 'pp'
19
19
  require 'oj'
20
20
 
21
21
 
22
- if defined?(GC.verify_compaction_references) == 'method'
22
+ def verify_gc_compaction
23
23
  # This method was added in Ruby 3.0.0. Calling it this way asks the GC to
24
24
  # move objects around, helping to find object movement bugs.
25
- GC.verify_compaction_references(double_heap: true, toward: :empty)
25
+ if defined?(GC.verify_compaction_references) == 'method' && !(RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/)
26
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.2.0")
27
+ GC.verify_compaction_references(expand_heap: true, toward: :empty)
28
+ else
29
+ GC.verify_compaction_references(double_heap: true, toward: :empty)
30
+ end
31
+ end
26
32
  end
27
33
 
28
34
 
@@ -24,6 +24,8 @@ class JSONParserTest < Test::Unit::TestCase
24
24
  end if defined?(Encoding::UTF_16)
25
25
 
26
26
  def test_error_message_encoding
27
+ omit 'TruffleRuby causes NameError(<uninitialized constant JSON::Ext>)' if RUBY_ENGINE == 'truffleruby'
28
+
27
29
  bug10705 = '[ruby-core:67386] [Bug #10705]'
28
30
  json = ".\"\xE2\x88\x9A\"".force_encoding(Encoding::UTF_8)
29
31
  e = assert_raise(JSON::ParserError) {
@@ -15,10 +15,14 @@ else
15
15
  require 'oj'
16
16
  Oj.mimic_JSON
17
17
 
18
+ # This method was added in Ruby 3.0.0. Calling it this way asks the GC to
19
+ # move objects around, helping to find object movement bugs.
18
20
  if defined?(GC.verify_compaction_references) == 'method'
19
- # This method was added in Ruby 3.0.0. Calling it this way asks the GC to
20
- # move objects around, helping to find object movement bugs.
21
- GC.verify_compaction_references(double_heap: true, toward: :empty)
21
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.2.0")
22
+ GC.verify_compaction_references(expand_heap: true, toward: :empty)
23
+ else
24
+ GC.verify_compaction_references(double_heap: true, toward: :empty)
25
+ end
22
26
  end
23
27
  end
24
28
 
data/test/test_custom.rb CHANGED
@@ -200,6 +200,8 @@ class CustomJuice < Minitest::Test
200
200
  end
201
201
 
202
202
  def test_deep_nest
203
+ skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
204
+
203
205
  begin
204
206
  n = 10000
205
207
  Oj.strict_load('[' * n + ']' * n)
@@ -258,6 +260,8 @@ class CustomJuice < Minitest::Test
258
260
  end
259
261
 
260
262
  def test_object
263
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
264
+
261
265
  obj = Jeez.new(true, 58)
262
266
  json = Oj.dump(obj, create_id: "^o", use_to_json: false, use_as_json: false, use_to_hash: false)
263
267
  assert_equal(%|{"x":true,"y":58,"_z":"true"}|, json)
@@ -403,11 +407,15 @@ class CustomJuice < Minitest::Test
403
407
  end
404
408
 
405
409
  def test_range
410
+ skip 'TruffleRuby fails this spec' if RUBY_ENGINE == 'truffleruby'
411
+
406
412
  obj = 3..8
407
413
  dump_and_load(obj, false, :create_id => "^o", :create_additions => true)
408
414
  end
409
415
 
410
416
  def test_date
417
+ skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
418
+
411
419
  obj = Date.new(2017, 1, 5)
412
420
  dump_and_load(obj, false, :create_id => "^o", :create_additions => true)
413
421
  end
@@ -437,6 +445,8 @@ class CustomJuice < Minitest::Test
437
445
  end
438
446
 
439
447
  def test_datetime
448
+ skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
449
+
440
450
  obj = DateTime.new(2017, 1, 5, 10, 20, 30)
441
451
  dump_and_load(obj, false, :create_id => "^o", :create_additions => true)
442
452
  end
@@ -480,6 +490,8 @@ class CustomJuice < Minitest::Test
480
490
  end
481
491
 
482
492
  def test_time
493
+ skip 'TruffleRuby fails this spec' if RUBY_ENGINE == 'truffleruby'
494
+
483
495
  obj = Time.now()
484
496
  dump_load_dump(obj, false, :time_format => :unix, :create_id => "^o", :create_additions => true)
485
497
  dump_load_dump(obj, false, :time_format => :unix_zone, :create_id => "^o", :create_additions => true)
data/test/test_file.rb CHANGED
@@ -125,13 +125,16 @@ 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
+
128
130
  t = Time.now()
129
131
  Oj.default_options = { :mode => :object, :time_format => :unix_zone }
130
132
  dump_and_load(t, false)
131
133
  end
132
134
  def test_time_object_early
133
- # Windows does not support dates before 1970.
134
- return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
135
+ 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
+
135
138
  t = Time.xmlschema("1954-01-05T00:00:00.123456")
136
139
  Oj.default_options = { :mode => :object, :time_format => :unix_zone }
137
140
  dump_and_load(t, false)
@@ -166,6 +169,8 @@ class FileJuice < Minitest::Test
166
169
  assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
167
170
  elsif 'jruby' == $ruby
168
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)
169
174
  else
170
175
  assert_equal(%{{"^u":["Range",1,7,false]}}, json)
171
176
  end
data/test/test_gc.rb CHANGED
@@ -26,10 +26,12 @@ class GCTest < Minitest::Test
26
26
 
27
27
  def setup
28
28
  @default_options = Oj.default_options
29
+ GC.stress = true
29
30
  end
30
31
 
31
32
  def teardown
32
33
  Oj.default_options = @default_options
34
+ GC.stress = false
33
35
  end
34
36
 
35
37
  # if no crash then the GC marking is working
@@ -41,9 +43,20 @@ class GCTest < Minitest::Test
41
43
  end
42
44
 
43
45
  def test_parse_object_gc
46
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
47
+
44
48
  g = Goo.new(0, nil)
45
49
  100.times { |i| g = Goo.new(i, g) }
46
50
  json = Oj.dump(g, :mode => :object)
47
51
  Oj.object_load(json)
48
52
  end
53
+
54
+ def test_parse_gc
55
+ json = '{"a":"Alpha","b":true,"c":12345,"d":[true,[false,[-123456789,null],3.9676,["Something else.",false],null]],"e":{"zero":null,"one":1,"two":2,"three":[3],"four":[0,1,2,3,4]},"f":null,"h":{"a":{"b":{"c":{"d":{"e":{"f":{"g":null}}}}}}},"i":[[[[[[[null]]]]]]]}'
56
+
57
+ 50.times do
58
+ data = Oj.load(json)
59
+ assert_equal(json, Oj.dump(data))
60
+ end
61
+ end
49
62
  end
@@ -23,18 +23,24 @@ 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
+
26
28
  test = {s: 0, s2: -1, s3: 1, u: -2, u2: 2, u3: 9007199254740993}
27
29
  exp = '{"s":0,"s2":-1,"s3":1,"u":"-2","u2":"2","u3":"9007199254740993"}'
28
30
  assert_equal(exp, Oj.dump(test, integer_range: (-1..1)))
29
31
  end
30
32
 
31
33
  def test_bignum
34
+ skip 'TruffleRuby fails this spec with `ArgumentError: :integer_range must be a range of Fixnum.`' if RUBY_ENGINE == 'truffleruby'
35
+
32
36
  test = {u: -10000000000000000000, u2: 10000000000000000000}
33
37
  exp = '{"u":"-10000000000000000000","u2":"10000000000000000000"}'
34
38
  assert_equal(exp, Oj.dump(test, integer_range: (-1..1)))
35
39
  end
36
40
 
37
41
  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
+
38
44
  test = {safe: 0, unsafe: 9007199254740993}
39
45
  exp = '{"safe":0,"unsafe":"9007199254740993"}'
40
46
 
data/test/test_object.rb CHANGED
@@ -224,7 +224,7 @@ class ObjectJuice < Minitest::Test
224
224
  #=begin
225
225
  if '3.1.0' <= RUBY_VERSION && !(RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/)
226
226
  #Oj::debug_odd("teardown before GC.verify_compaction_references")
227
- GC.verify_compaction_references(double_heap: true, toward: :empty)
227
+ verify_gc_compaction
228
228
  #Oj::debug_odd("teardown after GC.verify_compaction_references")
229
229
  end
230
230
  #=end
@@ -461,6 +461,8 @@ class ObjectJuice < Minitest::Test
461
461
  end
462
462
 
463
463
  def test_json_module_object
464
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
465
+
464
466
  obj = One::Two::Three::Deep.new()
465
467
  dump_and_load(obj, false)
466
468
  end
@@ -631,11 +633,15 @@ class ObjectJuice < Minitest::Test
631
633
  end
632
634
 
633
635
  def test_json_object
636
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
637
+
634
638
  obj = Jeez.new(true, 58)
635
639
  dump_and_load(obj, false)
636
640
  end
637
641
 
638
642
  def test_json_object_create_deep
643
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
644
+
639
645
  obj = One::Two::Three::Deep.new()
640
646
  dump_and_load(obj, false)
641
647
  end
@@ -672,6 +678,8 @@ class ObjectJuice < Minitest::Test
672
678
  end
673
679
 
674
680
  def test_json_anonymous_struct
681
+ skip 'TruffleRuby fails this spec with `TypeError: allocator undefined for Class`' if RUBY_ENGINE == 'truffleruby'
682
+
675
683
  s = Struct.new(:x, :y)
676
684
  obj = s.new(1, 2)
677
685
  json = Oj.dump(obj, :indent => 2, :mode => :object)
@@ -694,6 +702,8 @@ class ObjectJuice < Minitest::Test
694
702
  end
695
703
 
696
704
  def test_json_object_object
705
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
706
+
697
707
  obj = Jeez.new(true, 58)
698
708
  json = Oj.dump(obj, mode: :object, indent: 2, ignore_under: true)
699
709
  assert(%{{
@@ -713,6 +723,8 @@ class ObjectJuice < Minitest::Test
713
723
  end
714
724
 
715
725
  def test_to_hash_object_object
726
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
727
+
716
728
  obj = Jazz.new(true, 58)
717
729
  json = Oj.dump(obj, :mode => :object, :indent => 2)
718
730
  assert(%{{
@@ -732,6 +744,8 @@ class ObjectJuice < Minitest::Test
732
744
  end
733
745
 
734
746
  def test_as_json_object_object
747
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
748
+
735
749
  obj = Orange.new(true, 58)
736
750
  json = Oj.dump(obj, :mode => :object, :indent => 2)
737
751
  assert(%{{
@@ -751,6 +765,8 @@ class ObjectJuice < Minitest::Test
751
765
  end
752
766
 
753
767
  def test_object_object_no_cache
768
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
769
+
754
770
  obj = Jam.new(true, 58)
755
771
  json = Oj.dump(obj, :mode => :object, :indent => 2)
756
772
  assert(%{{
@@ -779,6 +795,8 @@ class ObjectJuice < Minitest::Test
779
795
  end
780
796
 
781
797
  def test_exception
798
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
799
+
782
800
  err = nil
783
801
  begin
784
802
  raise StandardError.new('A Message')
@@ -809,6 +827,8 @@ class ObjectJuice < Minitest::Test
809
827
  end
810
828
 
811
829
  def test_exception_subclass
830
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
831
+
812
832
  err = nil
813
833
  begin
814
834
  raise SubX.new
@@ -830,6 +850,8 @@ class ObjectJuice < Minitest::Test
830
850
  json = Oj.dump(1..7, :mode => :object, :indent => 0)
831
851
  if 'rubinius' == $ruby
832
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)
833
855
  else
834
856
  assert_equal(%{{"^u":["Range",1,7,false]}}, json)
835
857
  end
@@ -895,6 +917,8 @@ class ObjectJuice < Minitest::Test
895
917
  end
896
918
 
897
919
  def test_circular_object
920
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
921
+
898
922
  obj = Jeez.new(nil, 58)
899
923
  obj.x = obj
900
924
  json = Oj.dump(obj, :mode => :object, :indent => 2, :circular => true)
@@ -903,6 +927,8 @@ class ObjectJuice < Minitest::Test
903
927
  end
904
928
 
905
929
  def test_circular_object2
930
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
931
+
906
932
  obj = Jam.new(nil, 58)
907
933
  obj.x = obj
908
934
  json = Oj.dump(obj, :mode => :object, :indent => 2, :circular => true)
@@ -925,6 +951,8 @@ class ObjectJuice < Minitest::Test
925
951
  end
926
952
 
927
953
  def test_circular
954
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
955
+
928
956
  h = { 'a' => 7 }
929
957
  obj = Jeez.new(h, 58)
930
958
  obj.x['b'] = obj
@@ -935,6 +963,8 @@ class ObjectJuice < Minitest::Test
935
963
  end
936
964
 
937
965
  def test_circular2
966
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
967
+
938
968
  h = { 'a' => 7 }
939
969
  obj = Jam.new(h, 58)
940
970
  obj.x['b'] = obj
@@ -947,6 +977,8 @@ class ObjectJuice < Minitest::Test
947
977
  end
948
978
 
949
979
  def test_omit_nil
980
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
981
+
950
982
  jam = Jam.new({'a' => 1, 'b' => nil }, nil)
951
983
 
952
984
  json = Oj.dump(jam, :omit_nil => true, :mode => :object)
@@ -1001,16 +1033,22 @@ class ObjectJuice < Minitest::Test
1001
1033
  end
1002
1034
 
1003
1035
  def test_auto_string
1036
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
1037
+
1004
1038
  s = AutoStrung.new("Pete", true)
1005
1039
  dump_and_load(s, false)
1006
1040
  end
1007
1041
 
1008
1042
  def test_auto_array
1043
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
1044
+
1009
1045
  a = AutoArray.new([1, 'abc', nil], true)
1010
1046
  dump_and_load(a, false)
1011
1047
  end
1012
1048
 
1013
1049
  def test_auto_hash
1050
+ skip 'TruffleRuby fails this spec with `RuntimeError: rb_ivar_foreach not implemented`' if RUBY_ENGINE == 'truffleruby'
1051
+
1014
1052
  h = AutoHash.new(nil, true)
1015
1053
  h['a'] = 1
1016
1054
  h['b'] = 2
@@ -149,6 +149,17 @@ class SajTest < Minitest::Test
149
149
  assert_equal((12345.6789e7 * 10000).to_i, (handler.calls[0][1] * 10000).to_i)
150
150
  end
151
151
 
152
+ def test_bignum
153
+ handler = AllSaj.new()
154
+ json = %{-11.899999999999999}
155
+ p = Oj::Parser.new(:saj)
156
+ p.handler = handler
157
+ p.parse(json)
158
+ assert_equal(1, handler.calls.size)
159
+ assert_equal(:add_value, handler.calls[0][0])
160
+ assert_equal(-118999, (handler.calls[0][1] * 10000).to_i)
161
+ end
162
+
152
163
  def test_array_empty
153
164
  handler = AllSaj.new()
154
165
  json = %{[]}
data/test/test_scp.rb CHANGED
@@ -320,8 +320,8 @@ class ScpTest < Minitest::Test
320
320
  end
321
321
 
322
322
  def test_pipe
323
- # Windows does not support fork
324
- return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
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'
325
325
 
326
326
  handler = AllHandler.new()
327
327
  json = %{{"one":true,"two":false}}
@@ -357,8 +357,8 @@ class ScpTest < Minitest::Test
357
357
  end
358
358
 
359
359
  def test_pipe_close
360
- # Windows does not support fork
361
- return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
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'
362
362
 
363
363
  json = %{{"one":true,"two":false}}
364
364
  IO.pipe do |read_io, write_io|
data/test/test_strict.rb CHANGED
@@ -156,6 +156,8 @@ class StrictJuice < Minitest::Test
156
156
  end
157
157
 
158
158
  def test_deep_nest
159
+ skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
160
+
159
161
  begin
160
162
  n = 10000
161
163
  Oj.strict_load('[' * n + ']' * n)
data/test/test_wab.rb CHANGED
@@ -105,6 +105,8 @@ class WabJuice < Minitest::Test
105
105
  end
106
106
 
107
107
  def test_deep_nest
108
+ skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
109
+
108
110
  begin
109
111
  n = 10000
110
112
  Oj.wab_load('[' * n + ']' * n)
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.18
4
+ version: 3.13.20
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-07-25 00:00:00.000000000 Z
11
+ date: 2022-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler