oj 2.14.0 → 2.14.1

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
  SHA1:
3
- metadata.gz: 3c5b4c3cba3688cc740907e024a5c586dc87ee8e
4
- data.tar.gz: 779f5f0c8ca3485a69099c63bb7e9048f7c3b1cd
3
+ metadata.gz: 8e5d3a7192d7fefd4923450eb9ca27fa3e480f53
4
+ data.tar.gz: 96278a7d936f76e660b8ae89ccfe25550cd75a77
5
5
  SHA512:
6
- metadata.gz: 35a08d84c9b2e4cef975627ab66cb92ae5db9f1f9baf45cb2a9a10ecb21f3c96c5f3db15b5abff775cfdb56f99fdad21e6d5e65c74a4fbc76061d2cc7d3bb977
7
- data.tar.gz: 89a87edcd3f140d729dd0de077fcd9a9d39f39b29106a3fd247b8293a722241a31e4a7140962737b5222e98bd9f9898b55c0415d66bd504235251728258bc62b
6
+ metadata.gz: b457b1f450686bc06d0e196bdf3e683fc16a835d8dd790b22592fce7cc1e911b42f61258c16aab45cb49a7c38496ffe3dc3b54a6dc320861032166e8690a98ec
7
+ data.tar.gz: 937af1a3a9270efe743e0a475510f4ca6f64d87ba04cdc1cd94ea5b0590b50e95f2eff8adf5e453cc04640ae99bfac5cbb7144546675623d0d727603f5e7653a
data/README.md CHANGED
@@ -159,13 +159,11 @@ Oj.default_options = {:mode => :compat }
159
159
 
160
160
  ## Releases
161
161
 
162
- **Release 2.14.0**
162
+ **Release 2.14.1**
163
163
 
164
- - More tweaking on decimal rounding.
164
+ - Fixed bug that reverted to BigDecimal when a decimal had preceeding zeros
165
+ after the decimal point.
165
166
 
166
- - Made dump options available in the default options and not only in the mimic
167
- generate calls.
168
-
169
167
  [Older release notes](http://www.ohler.com/dev/oj_misc/release_notes.html).
170
168
 
171
169
  ## Compatibility
@@ -428,7 +428,9 @@ read_num(ParseInfo pi) {
428
428
  int dec_cnt = 0;
429
429
 
430
430
  for (; '0' <= *pi->cur && *pi->cur <= '9'; pi->cur++) {
431
- dec_cnt++;
431
+ if (0 < ni.i) {
432
+ dec_cnt++;
433
+ }
432
434
  if (ni.big) {
433
435
  ni.big++;
434
436
  } else {
@@ -441,12 +443,13 @@ read_num(ParseInfo pi) {
441
443
  }
442
444
  }
443
445
  if ('.' == *pi->cur) {
444
- dec_cnt = 0;
445
446
  pi->cur++;
446
447
  for (; '0' <= *pi->cur && *pi->cur <= '9'; pi->cur++) {
447
448
  int d = (*pi->cur - '0');
448
449
 
449
- dec_cnt++;
450
+ if (0 < ni.num) {
451
+ dec_cnt++;
452
+ }
450
453
  ni.num = ni.num * 10 + d;
451
454
  ni.div *= 10;
452
455
  ni.di++;
@@ -431,7 +431,9 @@ read_num(ParseInfo pi) {
431
431
  int dec_cnt = 0;
432
432
 
433
433
  for (; '0' <= c && c <= '9'; c = reader_get(&pi->rd)) {
434
- dec_cnt++;
434
+ if (0 < ni.i) {
435
+ dec_cnt++;
436
+ }
435
437
  if (ni.big) {
436
438
  ni.big++;
437
439
  } else {
@@ -444,12 +446,13 @@ read_num(ParseInfo pi) {
444
446
  }
445
447
  }
446
448
  if ('.' == c) {
447
- dec_cnt = 0;
448
449
  c = reader_get(&pi->rd);
449
450
  for (; '0' <= c && c <= '9'; c = reader_get(&pi->rd)) {
450
451
  int d = (c - '0');
451
452
 
452
- dec_cnt++;
453
+ if (0 < ni.num) {
454
+ dec_cnt++;
455
+ }
453
456
  ni.num = ni.num * 10 + d;
454
457
  ni.div *= 10;
455
458
  ni.di++;
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '2.14.0'
4
+ VERSION = '2.14.1'
5
5
  end
@@ -168,6 +168,25 @@ class Juice < Minitest::Test
168
168
  dump_and_load(1, false)
169
169
  end
170
170
 
171
+ def test_float_parse
172
+ Oj.default_options = { :float_precision => 16 }
173
+ n = Oj.load('0.00001234567890123456')
174
+ assert_equal(Float, n.class)
175
+ assert_equal('1.234567890123456e-05', "%0.15e" % [n])
176
+
177
+ n = Oj.load('-0.00001234567890123456')
178
+ assert_equal(Float, n.class)
179
+ assert_equal('-1.234567890123456e-05', "%0.15e" % [n])
180
+
181
+ n = Oj.load('1000.0000123456789')
182
+ assert_equal(BigDecimal, n.class)
183
+ assert_equal('0.10000000123456789E4', n.to_s)
184
+
185
+ n = Oj.load('-0.000012345678901234567')
186
+ assert_equal(BigDecimal, n.class)
187
+ assert_equal('-0.12345678901234567E-4', n.to_s)
188
+ end
189
+
171
190
  def test_float_dump
172
191
  Oj.default_options = { :float_precision => 16 }
173
192
  assert_equal('1405460727.723866', Oj.dump(1405460727.723866))
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: 2.14.0
4
+ version: 2.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler