oj 2.14.0 → 2.14.1
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.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/ext/oj/parse.c +6 -3
- data/ext/oj/sparse.c +6 -3
- data/lib/oj/version.rb +1 -1
- data/test/test_various.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e5d3a7192d7fefd4923450eb9ca27fa3e480f53
|
4
|
+
data.tar.gz: 96278a7d936f76e660b8ae89ccfe25550cd75a77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
162
|
+
**Release 2.14.1**
|
163
163
|
|
164
|
-
-
|
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
|
data/ext/oj/parse.c
CHANGED
@@ -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
|
-
|
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
|
-
|
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++;
|
data/ext/oj/sparse.c
CHANGED
@@ -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
|
-
|
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
|
-
|
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++;
|
data/lib/oj/version.rb
CHANGED
data/test/test_various.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|