oj 3.10.8 → 3.10.9

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: cb725babd05d3dadf33c86b0737e278f0f2eed8bb1792300dca74f5138a472a5
4
- data.tar.gz: c60cd42eccaeea5937726f90225a611b19901ff4d133968e304de6f6d9077a31
3
+ metadata.gz: 3b5fb7fd1905154e2b5ebd902ec807b12108f7619f59d7c24e47b49e6aaf569f
4
+ data.tar.gz: c93ce257ece0931ad32d997670ecbc3960d65c0fb722986c7d13d34c9d486ca6
5
5
  SHA512:
6
- metadata.gz: 56791447ce08bbe3aca701ff0b50e17f70dbd2bae22bcc07fcdbe5216b9da7e976f6ee748bee83d12a2915148ddc83e99ac52203e9baa7a3e268023a808515e0
7
- data.tar.gz: 9906af11fb4fd41f2a4d311d0c7e0a4d72c3947e53201fa745717f356d67cbc757ebcbbb341eff03f7d4c1cb1bb76da59d05b14e31119f098e1b398d8f164304
6
+ metadata.gz: 597ca25a4f92c2c836ee46420f390a6bf4dbbd884deff31148fe03a684603e45b4e6361b928002d1eb16e46c2653b22ede1064ed5f46818cceb44c58440f62f8
7
+ data.tar.gz: 5972ca3d493979fee3b2dbd14bbc6a2cbb367175b48ef540fe3dab3e92a76dae28b5d1b366b27115f02d6dbfdfef59698ad251849b1598e457397edb0fbfbdb5
@@ -513,7 +513,8 @@ mimic_parse_core(int argc, VALUE *argv, VALUE self, bool bang) {
513
513
  pi.options.create_ok = No;
514
514
  pi.options.allow_nan = (bang ? Yes : No);
515
515
  pi.options.nilnil = No;
516
- pi.options.bigdec_load = FloatDec;
516
+ //pi.options.bigdec_load = FloatDec;
517
+ pi.options.bigdec_load = RubyDec;
517
518
  pi.options.mode = CompatMode;
518
519
  pi.max_depth = 100;
519
520
 
@@ -686,7 +687,7 @@ static struct _options mimic_object_to_json_options = {
686
687
  No, // class_cache
687
688
  RubyTime, // time_format
688
689
  No, // bigdec_as_num
689
- FloatDec, // bigdec_load
690
+ RubyDec, // bigdec_load
690
691
  No, // to_hash
691
692
  No, // to_json
692
693
  No, // as_json
@@ -707,7 +708,7 @@ static struct _options mimic_object_to_json_options = {
707
708
  oj_json_class,// create_id
708
709
  10, // create_id_len
709
710
  3, // sec_prec
710
- 16, // float_prec
711
+ 0, // float_prec
711
712
  "%0.16g", // float_fmt
712
713
  Qnil, // hash_class
713
714
  Qnil, // array_class
@@ -78,7 +78,8 @@ typedef enum {
78
78
  BigDec = 'b',
79
79
  FloatDec = 'f',
80
80
  AutoDec = 'a',
81
- FastDec = 'F'
81
+ FastDec = 'F',
82
+ RubyDec = 'r',
82
83
  } BigLoad;
83
84
 
84
85
  typedef enum {
@@ -394,7 +394,7 @@ read_num(ParseInfo pi) {
394
394
  ni.nan = 0;
395
395
  ni.neg = 0;
396
396
  ni.has_exp = 0;
397
- ni.no_big = (FloatDec == pi->options.bigdec_load || FastDec == pi->options.bigdec_load);
397
+ ni.no_big = (FloatDec == pi->options.bigdec_load || FastDec == pi->options.bigdec_load || RubyDec == pi->options.bigdec_load);
398
398
  ni.bigdec_load = pi->options.bigdec_load;
399
399
 
400
400
  if ('-' == *pi->cur) {
@@ -877,6 +877,10 @@ oj_num_as_value(NumInfo ni) {
877
877
  ld = -ld;
878
878
  }
879
879
  rnum = rb_float_new((double)ld);
880
+ } else if (RubyDec == ni->bigdec_load) {
881
+ volatile VALUE sv = rb_str_new(ni->str, ni->len);
882
+
883
+ rnum = rb_funcall(sv, rb_intern("to_f"), 0);
880
884
  } else {
881
885
  char *end;
882
886
  double d = strtod(ni->str, &end);
@@ -408,7 +408,7 @@ read_num(ParseInfo pi) {
408
408
  ni.nan = 0;
409
409
  ni.neg = 0;
410
410
  ni.has_exp = 0;
411
- ni.no_big = (FloatDec == pi->options.bigdec_load || FastDec == pi->options.bigdec_load);
411
+ ni.no_big = (FloatDec == pi->options.bigdec_load || FastDec == pi->options.bigdec_load || RubyDec == pi->options.bigdec_load);
412
412
  ni.bigdec_load = pi->options.bigdec_load;
413
413
 
414
414
  c = reader_get(&pi->rd);
@@ -549,7 +549,7 @@ read_nan(ParseInfo pi) {
549
549
  ni.infinity = 0;
550
550
  ni.nan = 1;
551
551
  ni.neg = 0;
552
- ni.no_big = (FloatDec == pi->options.bigdec_load || FastDec == pi->options.bigdec_load);
552
+ ni.no_big = (FloatDec == pi->options.bigdec_load || FastDec == pi->options.bigdec_load || RubyDec == pi->options.bigdec_load);
553
553
  ni.bigdec_load = pi->options.bigdec_load;
554
554
 
555
555
  if ('a' != reader_get(&pi->rd) ||
@@ -747,7 +747,7 @@ oj_sparse2(ParseInfo pi) {
747
747
  ni.infinity = 0;
748
748
  ni.nan = 1;
749
749
  ni.neg = 0;
750
- ni.no_big = (FloatDec == pi->options.bigdec_load);
750
+ ni.no_big = (FloatDec == pi->options.bigdec_load || RubyDec == pi->options.bigdec_load || FastDec == pi->options.bigdec_load);
751
751
  ni.bigdec_load = pi->options.bigdec_load;
752
752
  add_num_value(pi, &ni);
753
753
  } else {
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.10.8'
4
+ VERSION = '3.10.9'
5
5
  end
@@ -23,8 +23,14 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
23
23
  'h' => 1000.0,
24
24
  'i' => 0.001
25
25
  }
26
+ # Tired of chasing floating point rounding and precision. Oj not uses the
27
+ # Ruby float parser in compat mode yet on i386 machines there are issues
28
+ # with this test when the float is included.
29
+
26
30
  @json = '{"a":2,"b":5.23683071,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},'\
27
31
  '"g":"\\"\\u0000\\u001f","h":1000.0,"i":0.001}'
32
+ #@json = '{"a":2,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},'\
33
+ #p '"g":"\\"\\u0000\\u001f","h":1000.0,"i":0.001}'
28
34
  end
29
35
 
30
36
  def test_index
@@ -126,7 +126,7 @@ class CustomJuice < Minitest::Test
126
126
  def test_float_parse_fast
127
127
  f = Oj.load("12.123456789012345678", mode: :custom, bigdecimal_load: :fast);
128
128
  assert_equal(Float, f.class)
129
- assert_equal(12.123456789012346, f)
129
+ assert_equal('12.12345678901235', "%0.14f" % [f]) # only care about 16 digits
130
130
  end
131
131
 
132
132
  def test_nan_dump
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.8
4
+ version: 3.10.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-24 00:00:00.000000000 Z
11
+ date: 2020-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bigdecimal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake-compiler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -277,7 +291,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
277
291
  requirements:
278
292
  - - ">="
279
293
  - !ruby/object:Gem::Version
280
- version: '2.3'
294
+ version: '2.4'
281
295
  required_rubygems_version: !ruby/object:Gem::Requirement
282
296
  requirements:
283
297
  - - ">="