oj 3.3.4 → 3.3.5
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/ext/oj/dump.c +21 -8
- data/ext/oj/rails.c +1 -1
- data/ext/oj/sparse.c +1 -1
- data/lib/oj/version.rb +1 -1
- data/pages/Compatibility.md +1 -1
- data/test/bug.rb +138 -9
- data/test/helper.rb +0 -1
- data/test/isolated/shared.rb +2 -4
- data/test/json_gem/json_encoding_test.rb +1 -3
- data/test/test_fast.rb +27 -28
- data/test/test_file.rb +11 -13
- data/test/test_object.rb +31 -59
- data/test/test_various.rb +1 -5
- data/test/tests.rb +5 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c07155b4f125fbaf35a6569b293d440aa44f7331
|
4
|
+
data.tar.gz: 6250fe522da7b0bde33f6462dcee5881f79a2051
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fb8687b5a703d12954859ce85967b494d2913d9bfc681fc93496327878c02c6b1bf0aec58bbd4af0c3b782523dca7e648636b6293f487ef7e829a91dc2069ee
|
7
|
+
data.tar.gz: c0a0e8f5d5b728627b0a1658e8bef7ecd130e7f0494ae2c0559789ead19eab11a0b8e9818c0867e4b970a698055619b13f1873bdbf47a4eeddf1ef7d32c30694
|
data/ext/oj/dump.c
CHANGED
@@ -91,7 +91,7 @@ static char hixss_friendly_chars[256] = "\
|
|
91
91
|
11111111111111111111111111111111\
|
92
92
|
11111111111111111111111111111111\
|
93
93
|
11111111111111111111111111111111\
|
94
|
-
|
94
|
+
11611111111111111111111111111111";
|
95
95
|
|
96
96
|
// Rails HTML non-escape
|
97
97
|
static char rails_friendly_chars[256] = "\
|
@@ -102,7 +102,7 @@ static char rails_friendly_chars[256] = "\
|
|
102
102
|
11111111111111111111111111111111\
|
103
103
|
11111111111111111111111111111111\
|
104
104
|
11111111111111111111111111111111\
|
105
|
-
|
105
|
+
11611111111111111111111111111111";
|
106
106
|
|
107
107
|
static void
|
108
108
|
raise_strict(VALUE obj) {
|
@@ -741,7 +741,7 @@ oj_dump_cstr(const char *str, size_t cnt, bool is_sym, bool escape1, Out out) {
|
|
741
741
|
} else {
|
742
742
|
const char *end = str + cnt;
|
743
743
|
const char *check_start = str;
|
744
|
-
|
744
|
+
|
745
745
|
if (is_sym) {
|
746
746
|
*out->cur++ = ':';
|
747
747
|
}
|
@@ -784,11 +784,24 @@ oj_dump_cstr(const char *str, size_t cnt, bool is_sym, bool escape1, Out out) {
|
|
784
784
|
str = dump_unicode(str, end, out);
|
785
785
|
break;
|
786
786
|
case '6': // control characters
|
787
|
-
*
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
787
|
+
if (*(uint8_t*)str < 0x80) {
|
788
|
+
*out->cur++ = '\\';
|
789
|
+
*out->cur++ = 'u';
|
790
|
+
*out->cur++ = '0';
|
791
|
+
*out->cur++ = '0';
|
792
|
+
dump_hex((uint8_t)*str, out);
|
793
|
+
} else {
|
794
|
+
if (0xe2 == (uint8_t)*str && JXEsc == out->opts->escape_mode && 2 <= end - str) {
|
795
|
+
if (0x80 == (uint8_t)str[1] && (0xa8 == (uint8_t)str[2] || 0xa9 == (uint8_t)str[2])) {
|
796
|
+
str = dump_unicode(str, end, out);
|
797
|
+
} else {
|
798
|
+
check_start = check_unicode(str, end);
|
799
|
+
*out->cur++ = *str;
|
800
|
+
}
|
801
|
+
break;
|
802
|
+
}
|
803
|
+
str = dump_unicode(str, end, out);
|
804
|
+
}
|
792
805
|
break;
|
793
806
|
default:
|
794
807
|
break; // ignore, should never happen if the table is correct
|
data/ext/oj/rails.c
CHANGED
data/ext/oj/sparse.c
CHANGED
@@ -761,7 +761,7 @@ oj_sparse2(ParseInfo pi) {
|
|
761
761
|
case '\0':
|
762
762
|
return;
|
763
763
|
default:
|
764
|
-
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "unexpected character");
|
764
|
+
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "unexpected character '%c' [0x%02x]", c, c);
|
765
765
|
return;
|
766
766
|
}
|
767
767
|
if (err_has(&pi->err)) {
|
data/lib/oj/version.rb
CHANGED
data/pages/Compatibility.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
**Ruby**
|
4
4
|
|
5
|
-
Oj is compatible with Ruby
|
5
|
+
Oj is compatible with Ruby 2.0.0, 2.1, 2.2, 2.3, 2.4 and RBX.
|
6
6
|
Support for JRuby has been removed as JRuby no longer supports C extensions and
|
7
7
|
there are bugs in the older versions that are not being fixed.
|
8
8
|
|
data/test/bug.rb
CHANGED
@@ -5,18 +5,147 @@
|
|
5
5
|
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
6
6
|
end
|
7
7
|
|
8
|
-
#require 'rails'
|
9
|
-
#require 'active_support/json'
|
10
8
|
require 'oj'
|
9
|
+
require 'active_support/json'
|
11
10
|
|
12
|
-
|
11
|
+
Oj::Rails.set_encoder
|
12
|
+
ActiveSupport::JSON::Encoding.escape_html_entities_in_json = false
|
13
13
|
|
14
|
-
|
14
|
+
text = [
|
15
|
+
42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 195, 156, 42, 32, 195, 156, 42, 42,
|
16
|
+
42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 13,
|
17
|
+
10, 240, 159, 147, 183, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 58, 32, 42, 42, 42, 42, 42, 42, 42,
|
18
|
+
42, 42, 42, 32, 13, 10, 240, 159, 147, 141, 32, 42, 42, 42, 42, 195, 188, 42, 42, 42, 42, 42, 32,
|
19
|
+
13, 10, 226, 160, 128, 32, 226, 160, 128, 32, 226, 160, 128, 32, 226, 160, 128, 32, 226, 160, 128,
|
20
|
+
32, 226, 160, 128, 32, 226, 160, 128, 32, 226, 160, 128, 32, 226, 160, 128, 32, 226, 160, 128, 32,
|
21
|
+
226, 160, 128, 32, 226, 160, 128, 32, 226, 160, 128, 32, 226, 160, 128, 32, 226, 160, 128, 32, 226,
|
22
|
+
160, 128, 32, 13, 10, 38, 42, 42, 42, 42, 59, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42,
|
23
|
+
42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 195, 159, 32, 42, 42, 42, 42, 42, 42,
|
24
|
+
42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 42, 32, 42, 42, 42, 32,
|
25
|
+
42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 38, 42, 42, 42, 42, 59, 32, 45, 32, 42, 42,
|
26
|
+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 58, 32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42,
|
27
|
+
42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 42, 42, 46,
|
28
|
+
32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 32,
|
29
|
+
42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 46, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 46, 46, 32,
|
30
|
+
226, 152, 186, 32, 13, 10, 226, 149, 148, 226, 149, 144, 198, 184, 204, 181, 204, 161, 211, 156,
|
31
|
+
204, 181, 204, 168, 204, 132, 198, 183, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144,
|
32
|
+
226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149,
|
33
|
+
144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226,
|
34
|
+
149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 151,
|
35
|
+
32, 13, 10, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 226, 153,
|
36
|
+
165, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42,
|
37
|
+
42, 33, 32, 13, 10, 226, 149, 154, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226,
|
38
|
+
149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144,
|
39
|
+
226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149,
|
40
|
+
144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 226, 149, 144, 198, 184, 204, 181,
|
41
|
+
204, 161, 211, 156, 204, 181, 204, 168, 204, 132, 198, 183, 226, 149, 144, 13, 10, 13, 10, 226, 128,
|
42
|
+
162, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 195, 164, 32, 42, 32, 42, 32, 42, 32, 42,
|
43
|
+
32, 42, 32, 42, 32, 42, 32, 42, 32, 226, 128, 162, 32, 13, 10, 42, 42, 42, 42, 42, 42, 32, 42, 42,
|
44
|
+
42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 44, 32, 42, 42, 42,
|
45
|
+
42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42,
|
46
|
+
42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 195, 164, 42,
|
47
|
+
42, 42, 42, 46, 32, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42,
|
48
|
+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32,
|
49
|
+
42, 42, 42, 195, 182, 42, 42, 42, 42, 33, 32, 13, 10, 42, 42, 42, 42, 42, 32, 42, 195, 188, 42, 42,
|
50
|
+
42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42,
|
51
|
+
42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 195, 164, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42,
|
52
|
+
32, 42, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42,
|
53
|
+
42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42,
|
54
|
+
42, 42, 42, 42, 42, 42, 32, 38, 42, 42, 42, 42, 59, 32, 42, 42, 42, 42, 32, 42, 42, 32, 38, 42, 42,
|
55
|
+
42, 42, 59, 46, 46, 32, 13, 10, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
56
|
+
42, 32, 42, 42, 42, 42, 42, 58, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42,
|
57
|
+
42, 42, 195, 164, 42, 42, 42, 42, 42, 32, 42, 42, 42, 195, 188, 42, 44, 32, 42, 42, 42, 42, 32, 42,
|
58
|
+
42, 42, 42, 32, 42, 42, 42, 32, 42, 195, 164, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42,
|
59
|
+
42, 42, 195, 182, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
60
|
+
32, 42, 42, 42, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42,
|
61
|
+
42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 195, 188, 42, 42, 42, 42, 32,
|
62
|
+
42, 42, 42, 42, 42, 42, 42, 46, 13, 10, 40, 33, 41, 32, 42, 42, 32, 42, 42, 42, 42, 32, 195, 188,
|
63
|
+
42, 42, 42, 42, 42, 42, 42, 32, 58, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42,
|
64
|
+
32, 42, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42,
|
65
|
+
32, 45, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42,
|
66
|
+
42, 42, 32, 40, 33, 41, 13, 10, 13, 10, 226, 128, 162, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32,
|
67
|
+
42, 32, 47, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 47, 32, 42, 32, 42, 32, 42,
|
68
|
+
32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 226, 128, 162, 32, 13,
|
69
|
+
10, 42, 42, 42, 32, 42, 42, 42, 32, 42, 195, 188, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 45,
|
70
|
+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 33, 32, 42, 42, 42, 32,
|
71
|
+
42, 42, 42, 195, 159, 42, 32, 58, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42,
|
72
|
+
42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42,
|
73
|
+
42, 42, 42, 32, 40, 32, 42, 42, 42, 195, 188, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42,
|
74
|
+
42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42,
|
75
|
+
42, 32, 41, 32, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 46, 32,
|
76
|
+
13, 10, 13, 10, 226, 128, 162, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 226, 128,
|
77
|
+
162, 32, 13, 10, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42,
|
78
|
+
42, 42, 42, 42, 42, 42, 46, 46, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 42,
|
79
|
+
32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42,
|
80
|
+
42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32,
|
81
|
+
42, 195, 182, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 46, 32, 42, 42, 32,
|
82
|
+
42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42,
|
83
|
+
42, 42, 44, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
84
|
+
42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32,
|
85
|
+
42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 32, 40, 32, 42, 46, 42, 46, 32, 42, 42, 42, 32,
|
86
|
+
42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 46, 42, 42, 46, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42,
|
87
|
+
42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 32, 42,
|
88
|
+
42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42,
|
89
|
+
42, 42, 32, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32,
|
90
|
+
41, 32, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32,
|
91
|
+
42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42,
|
92
|
+
42, 42, 32, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
93
|
+
32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 44, 32, 42, 42, 42, 42, 42,
|
94
|
+
42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 46, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42,
|
95
|
+
42, 32, 42, 42, 42, 42, 42, 32, 42, 195, 182, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42,
|
96
|
+
42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 195, 164, 42, 42, 42, 42, 32, 42, 42, 42, 42,
|
97
|
+
42, 42, 46, 46, 32, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32,
|
98
|
+
42, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32,
|
99
|
+
42, 42, 42, 42, 42, 42, 42, 32, 45, 32, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42,
|
100
|
+
42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
101
|
+
32, 58, 45, 41, 13, 10, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42,
|
102
|
+
42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42,
|
103
|
+
42, 42, 42, 42, 32, 42, 42, 42, 42, 44, 32, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42,
|
104
|
+
42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42,
|
105
|
+
42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 32, 42,
|
106
|
+
42, 42, 32, 42, 195, 164, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42,
|
107
|
+
42, 32, 42, 42, 195, 182, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 195, 188, 42, 42,
|
108
|
+
42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42,
|
109
|
+
42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42,
|
110
|
+
42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42,
|
111
|
+
46, 32, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 195, 188,
|
112
|
+
42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32,
|
113
|
+
42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 46, 32, 13, 10,
|
114
|
+
42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42,
|
115
|
+
42, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 195, 188, 42, 42, 42,
|
116
|
+
42, 42, 32, 42, 42, 42, 42, 33, 32, 13, 10, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42,
|
117
|
+
32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42,
|
118
|
+
32, 42, 195, 164, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
119
|
+
42, 42, 42, 32, 42, 42, 42, 42, 46, 32, 40, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 195,
|
120
|
+
188, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 42, 32,
|
121
|
+
42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 195, 159, 32, 42, 42, 42, 32, 42,
|
122
|
+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 46, 46, 32, 41, 13, 10, 13,
|
123
|
+
10, 226, 128, 162, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 47, 32, 42, 32, 42, 32, 42,
|
124
|
+
32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 47, 32, 42, 32, 42, 32, 42, 32, 195, 164, 32, 42, 32,
|
125
|
+
42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 226, 128, 162, 32, 13, 10,
|
126
|
+
42, 42, 32, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42,
|
127
|
+
42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 32, 42, 42, 42,
|
128
|
+
32, 42, 195, 164, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42,
|
129
|
+
32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42,
|
130
|
+
42, 42, 195, 164, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 46, 32, 194, 167, 32, 42, 42, 42, 32, 42,
|
131
|
+
42, 42, 46, 42, 32, 42, 42, 42, 32, 13, 10, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42,
|
132
|
+
32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 195, 188, 42, 42, 46, 32, 42, 42, 42,
|
133
|
+
42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 195, 164, 42,
|
134
|
+
42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42, 44, 32, 42, 42, 42, 42, 42, 42, 32,
|
135
|
+
42, 42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 32, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42,
|
136
|
+
42, 42, 42, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 42, 42,
|
137
|
+
46, 32, 13, 10, 42, 42, 42, 32, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42,
|
138
|
+
42, 42, 42, 42, 32, 42, 42, 42, 42, 42, 46, 46, 32, 13, 10, 42, 42, 42, 32, 42, 195, 188, 42, 42,
|
139
|
+
42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 42, 32, 42, 42, 42, 195, 159, 32, 42, 42, 42, 42,
|
140
|
+
32, 42, 42, 42, 42, 42, 42, 42, 42, 33, 32, 58, 45, 41 ]
|
141
|
+
.pack('c*').force_encoding('UTF-8')
|
15
142
|
|
16
|
-
|
143
|
+
puts text.length
|
17
144
|
|
18
|
-
|
145
|
+
hash = {
|
146
|
+
k1: 'x' * 800,
|
147
|
+
k2: text,
|
148
|
+
}
|
19
149
|
|
20
|
-
|
21
|
-
|
22
|
-
puts Oj.dump(NoMethodError.new, mode: :custom)
|
150
|
+
puts ActiveSupport::JSON.encode(hash)
|
151
|
+
#puts Oj::Rails::Encoder.new.encode(hash)
|
data/test/helper.rb
CHANGED
data/test/isolated/shared.rb
CHANGED
@@ -36,8 +36,6 @@ class SharedMimicTest < Minitest::Test
|
|
36
36
|
@expected_time_string =
|
37
37
|
if defined?(Rails)
|
38
38
|
%{"2014-05-13T16:53:20.000Z"}
|
39
|
-
elsif RUBY_VERSION.start_with?('1.8')
|
40
|
-
%{"Tue May 13 16:53:20 UTC 2014"}
|
41
39
|
else
|
42
40
|
%{"2014-05-13 16:53:20 UTC"}
|
43
41
|
end
|
@@ -145,7 +143,7 @@ class SharedMimicTest < Minitest::Test
|
|
145
143
|
Oj.mimic_JSON
|
146
144
|
children = []
|
147
145
|
json = %{{"a":1,"b":[true,false]}}
|
148
|
-
if 'rubinius' == $ruby
|
146
|
+
if 'rubinius' == $ruby
|
149
147
|
obj = JSON.load(json) {|x| children << x }
|
150
148
|
else
|
151
149
|
p = Proc.new {|x| children << x }
|
@@ -275,7 +273,7 @@ class SharedMimicTest < Minitest::Test
|
|
275
273
|
children = []
|
276
274
|
JSON.recurse_proc({ 'a' => 1, 'b' => [true, false]}) { |x| children << x }
|
277
275
|
# JRuby 1.7.0 rb_yield() is broken and converts the [true, false] array into true
|
278
|
-
unless 'jruby' == $ruby
|
276
|
+
unless 'jruby' == $ruby
|
279
277
|
assert([1, true, false, [true, false], { 'a' => 1, 'b' => [true, false]}] == children ||
|
280
278
|
[true, false, [true, false], 1, { 'b' => [true, false], 'a' => 1}] == children)
|
281
279
|
end
|
@@ -88,9 +88,7 @@ class JSONEncodingTest < Test::Unit::TestCase
|
|
88
88
|
def test_chars
|
89
89
|
(0..0x7f).each do |i|
|
90
90
|
json = '["\u%04x"]' % i
|
91
|
-
|
92
|
-
i = i.chr
|
93
|
-
end
|
91
|
+
i = i.chr
|
94
92
|
assert_equal i, JSON.parse(json).first[0]
|
95
93
|
if i == ?\b
|
96
94
|
generated = JSON.generate(["" << i])
|
data/test/test_fast.rb
CHANGED
@@ -5,24 +5,23 @@ $: << File.dirname(__FILE__)
|
|
5
5
|
|
6
6
|
require 'helper'
|
7
7
|
|
8
|
-
$json1 = %|{
|
9
|
-
"array": [
|
10
|
-
{
|
11
|
-
"num" : 3,
|
12
|
-
"string": "message",
|
13
|
-
"hash" : {
|
14
|
-
"h2" : {
|
15
|
-
"a" : [ 1, 2, 3 ]
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
],
|
20
|
-
"boolean" : true
|
21
|
-
}|
|
22
|
-
|
23
8
|
class DocTest < Minitest::Test
|
24
9
|
def setup
|
25
10
|
@default_options = Oj.default_options
|
11
|
+
@json1 = %|{
|
12
|
+
"array": [
|
13
|
+
{
|
14
|
+
"num" : 3,
|
15
|
+
"string": "message",
|
16
|
+
"hash" : {
|
17
|
+
"h2" : {
|
18
|
+
"a" : [ 1, 2, 3 ]
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
],
|
23
|
+
"boolean" : true
|
24
|
+
}|
|
26
25
|
end
|
27
26
|
|
28
27
|
def teardown
|
@@ -160,7 +159,7 @@ class DocTest < Minitest::Test
|
|
160
159
|
end
|
161
160
|
|
162
161
|
def test_move
|
163
|
-
Oj::Doc.open(
|
162
|
+
Oj::Doc.open(@json1) do |doc|
|
164
163
|
[ '/',
|
165
164
|
'/array',
|
166
165
|
'/boolean',
|
@@ -193,7 +192,7 @@ class DocTest < Minitest::Test
|
|
193
192
|
end
|
194
193
|
|
195
194
|
def test_move_relative
|
196
|
-
Oj::Doc.open(
|
195
|
+
Oj::Doc.open(@json1) do |doc|
|
197
196
|
[['/', 'array', '/array'],
|
198
197
|
['/array', '1/num', '/array/1/num'],
|
199
198
|
['/array/1/hash', 'h2/a', '/array/1/hash/h2/a'],
|
@@ -214,7 +213,7 @@ class DocTest < Minitest::Test
|
|
214
213
|
else
|
215
214
|
num_class = Fixnum
|
216
215
|
end
|
217
|
-
Oj::Doc.open(
|
216
|
+
Oj::Doc.open(@json1) do |doc|
|
218
217
|
[['/', Hash],
|
219
218
|
['/array', Array],
|
220
219
|
['/array/1', Hash],
|
@@ -230,7 +229,7 @@ class DocTest < Minitest::Test
|
|
230
229
|
end
|
231
230
|
|
232
231
|
def test_local_key
|
233
|
-
Oj::Doc.open(
|
232
|
+
Oj::Doc.open(@json1) do |doc|
|
234
233
|
[['/', nil],
|
235
234
|
['/array', 'array'],
|
236
235
|
['/array/1', 1],
|
@@ -252,7 +251,7 @@ class DocTest < Minitest::Test
|
|
252
251
|
end
|
253
252
|
|
254
253
|
def test_fetch_move
|
255
|
-
Oj::Doc.open(
|
254
|
+
Oj::Doc.open(@json1) do |doc|
|
256
255
|
[['/array/1/num', 3],
|
257
256
|
['/array/1/string', 'message'],
|
258
257
|
['/array/1/hash/h2/a', [1, 2, 3]],
|
@@ -270,7 +269,7 @@ class DocTest < Minitest::Test
|
|
270
269
|
end
|
271
270
|
|
272
271
|
def test_fetch_path
|
273
|
-
Oj::Doc.open(
|
272
|
+
Oj::Doc.open(@json1) do |doc|
|
274
273
|
[['/array/1/num', 3],
|
275
274
|
['/array/1/string', 'message'],
|
276
275
|
['/array/1/hash/h2/a', [1, 2, 3]],
|
@@ -287,7 +286,7 @@ class DocTest < Minitest::Test
|
|
287
286
|
end
|
288
287
|
|
289
288
|
def test_move_fetch_path
|
290
|
-
Oj::Doc.open(
|
289
|
+
Oj::Doc.open(@json1) do |doc|
|
291
290
|
[['/array/1', 'num', 3],
|
292
291
|
['/array/1', 'string', 'message'],
|
293
292
|
['/array/1/hash', 'h2/a', [1, 2, 3]],
|
@@ -299,7 +298,7 @@ class DocTest < Minitest::Test
|
|
299
298
|
end
|
300
299
|
|
301
300
|
def test_home
|
302
|
-
Oj::Doc.open(
|
301
|
+
Oj::Doc.open(@json1) do |doc|
|
303
302
|
doc.move('/array/1/num')
|
304
303
|
doc.home()
|
305
304
|
assert_equal('/', doc.where?)
|
@@ -307,7 +306,7 @@ class DocTest < Minitest::Test
|
|
307
306
|
end
|
308
307
|
|
309
308
|
def test_each_value_root
|
310
|
-
Oj::Doc.open(
|
309
|
+
Oj::Doc.open(@json1) do |doc|
|
311
310
|
values = []
|
312
311
|
doc.each_value() { |v| values << v.to_s }
|
313
312
|
assert_equal(['1', '2', '3', '3', 'message', 'true'], values.sort)
|
@@ -315,7 +314,7 @@ class DocTest < Minitest::Test
|
|
315
314
|
end
|
316
315
|
|
317
316
|
def test_each_value_move
|
318
|
-
Oj::Doc.open(
|
317
|
+
Oj::Doc.open(@json1) do |doc|
|
319
318
|
doc.move('/array/1/hash')
|
320
319
|
values = []
|
321
320
|
doc.each_value() { |v| values << v.to_s }
|
@@ -324,7 +323,7 @@ class DocTest < Minitest::Test
|
|
324
323
|
end
|
325
324
|
|
326
325
|
def test_each_value_path
|
327
|
-
Oj::Doc.open(
|
326
|
+
Oj::Doc.open(@json1) do |doc|
|
328
327
|
values = []
|
329
328
|
doc.each_value('/array/1/hash') { |v| values << v.to_s }
|
330
329
|
assert_equal(['1', '2', '3'], values.sort)
|
@@ -332,7 +331,7 @@ class DocTest < Minitest::Test
|
|
332
331
|
end
|
333
332
|
|
334
333
|
def test_each_child_move
|
335
|
-
Oj::Doc.open(
|
334
|
+
Oj::Doc.open(@json1) do |doc|
|
336
335
|
locations = []
|
337
336
|
doc.move('/array/1/hash/h2/a')
|
338
337
|
doc.each_child() { |d| locations << d.where? }
|
@@ -345,7 +344,7 @@ class DocTest < Minitest::Test
|
|
345
344
|
end
|
346
345
|
|
347
346
|
def test_each_child_path
|
348
|
-
Oj::Doc.open(
|
347
|
+
Oj::Doc.open(@json1) do |doc|
|
349
348
|
locations = []
|
350
349
|
doc.each_child('/array/1/hash/h2/a') { |d| locations << d.where? }
|
351
350
|
assert_equal(['/array/1/hash/h2/a/1', '/array/1/hash/h2/a/2', '/array/1/hash/h2/a/3'], locations)
|
data/test/test_file.rb
CHANGED
@@ -160,20 +160,18 @@ class FileJuice < Minitest::Test
|
|
160
160
|
|
161
161
|
# Range
|
162
162
|
def test_range_object
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
assert_equal(%{{"^u":["Range",1,7,false]}}, json)
|
172
|
-
end
|
173
|
-
dump_and_load(1..7, false)
|
174
|
-
dump_and_load(1..1, false)
|
175
|
-
dump_and_load(1...7, false)
|
163
|
+
Oj.default_options = { :mode => :object }
|
164
|
+
json = Oj.dump(1..7, :mode => :object, :indent => 0)
|
165
|
+
if 'rubinius' == $ruby
|
166
|
+
assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
|
167
|
+
elsif 'jruby' == $ruby
|
168
|
+
assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
|
169
|
+
else
|
170
|
+
assert_equal(%{{"^u":["Range",1,7,false]}}, json)
|
176
171
|
end
|
172
|
+
dump_and_load(1..7, false)
|
173
|
+
dump_and_load(1..1, false)
|
174
|
+
dump_and_load(1...7, false)
|
177
175
|
end
|
178
176
|
|
179
177
|
# BigNum
|
data/test/test_object.rb
CHANGED
@@ -458,11 +458,7 @@ class ObjectJuice < Minitest::Test
|
|
458
458
|
end
|
459
459
|
|
460
460
|
def test_xml_time
|
461
|
-
|
462
|
-
t = Time.parse('2015-01-05T21:37:07.123456789-08:00')
|
463
|
-
else
|
464
|
-
t = Time.new(2015, 1, 5, 21, 37, 7.123456789, -8 * 3600)
|
465
|
-
end
|
461
|
+
t = Time.new(2015, 1, 5, 21, 37, 7.123456789, -8 * 3600)
|
466
462
|
# The fractional seconds are not always recreated exactly which causes a
|
467
463
|
# mismatch so instead the seconds, nsecs, and gmt_offset are checked
|
468
464
|
# separately along with utc.
|
@@ -480,11 +476,7 @@ class ObjectJuice < Minitest::Test
|
|
480
476
|
end
|
481
477
|
|
482
478
|
def test_xml_time_utc
|
483
|
-
|
484
|
-
t = Time.parse('2015-01-05T21:37:07.123456789Z')
|
485
|
-
else
|
486
|
-
t = Time.utc(2015, 1, 5, 21, 37, 7.123456789)
|
487
|
-
end
|
479
|
+
t = Time.utc(2015, 1, 5, 21, 37, 7.123456789)
|
488
480
|
# The fractional seconds are not always recreated exactly which causes a
|
489
481
|
# mismatch so instead the seconds, nsecs, and gmt_offset are checked
|
490
482
|
# separately along with utc.
|
@@ -501,11 +493,7 @@ class ObjectJuice < Minitest::Test
|
|
501
493
|
end
|
502
494
|
|
503
495
|
def test_ruby_time
|
504
|
-
|
505
|
-
t = Time.parse('2015-01-05T21:37:07.123456789-08:00')
|
506
|
-
else
|
507
|
-
t = Time.new(2015, 1, 5, 21, 37, 7.123456789, -8 * 3600)
|
508
|
-
end
|
496
|
+
t = Time.new(2015, 1, 5, 21, 37, 7.123456789, -8 * 3600)
|
509
497
|
# The fractional seconds are not always recreated exactly which causes a
|
510
498
|
# mismatch so instead the seconds, nsecs, and gmt_offset are checked
|
511
499
|
# separately along with utc.
|
@@ -523,11 +511,7 @@ class ObjectJuice < Minitest::Test
|
|
523
511
|
end
|
524
512
|
|
525
513
|
def test_ruby_time_12345
|
526
|
-
|
527
|
-
t = Time.parse('2015-01-05T21:37:07.123456789+03:25')
|
528
|
-
else
|
529
|
-
t = Time.new(2015, 1, 5, 21, 37, 7.123456789, 12345/60*60)
|
530
|
-
end
|
514
|
+
t = Time.new(2015, 1, 5, 21, 37, 7.123456789, 12345/60*60)
|
531
515
|
# The fractional seconds are not always recreated exactly which causes a
|
532
516
|
# mismatch so instead the seconds, nsecs, and gmt_offset are checked
|
533
517
|
# separately along with utc.
|
@@ -546,11 +530,7 @@ class ObjectJuice < Minitest::Test
|
|
546
530
|
end
|
547
531
|
|
548
532
|
def test_ruby_time_utc
|
549
|
-
|
550
|
-
t = Time.parse('2015-01-05T21:37:07.123456789Z')
|
551
|
-
else
|
552
|
-
t = Time.utc(2015, 1, 5, 21, 37, 7.123456789)
|
553
|
-
end
|
533
|
+
t = Time.utc(2015, 1, 5, 21, 37, 7.123456789)
|
554
534
|
# The fractional seconds are not always recreated exactly which causes a
|
555
535
|
# mismatch so instead the seconds, nsecs, and gmt_offset are checked
|
556
536
|
# separately along with utc.
|
@@ -606,32 +586,26 @@ class ObjectJuice < Minitest::Test
|
|
606
586
|
assert_equal(t.utc_offset, loaded.utc_offset)
|
607
587
|
end
|
608
588
|
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
assert_equal(t.tv_usec, loaded.tv_usec)
|
623
|
-
end
|
624
|
-
assert_equal(t.utc?, loaded.utc?)
|
625
|
-
assert_equal(t.utc_offset, loaded.utc_offset)
|
589
|
+
def test_time_unix_zone_12345
|
590
|
+
t = Time.new(2015, 1, 5, 21, 37, 7.123456789, 12345)
|
591
|
+
# The fractional seconds are not always recreated exactly which causes a
|
592
|
+
# mismatch so instead the seconds, nsecs, and gmt_offset are checked
|
593
|
+
# separately along with utc.
|
594
|
+
json = Oj.dump(t, :mode => :object, :time_format => :unix_zone)
|
595
|
+
#puts json
|
596
|
+
loaded = Oj.object_load(json);
|
597
|
+
assert_equal(t.tv_sec, loaded.tv_sec)
|
598
|
+
if t.respond_to?(:tv_nsec)
|
599
|
+
assert_equal(t.tv_nsec, loaded.tv_nsec)
|
600
|
+
else
|
601
|
+
assert_equal(t.tv_usec, loaded.tv_usec)
|
626
602
|
end
|
603
|
+
assert_equal(t.utc?, loaded.utc?)
|
604
|
+
assert_equal(t.utc_offset, loaded.utc_offset)
|
627
605
|
end
|
628
606
|
|
629
607
|
def test_time_unix_zone_utc
|
630
|
-
|
631
|
-
t = Time.parse('2015-01-05T21:37:07.123456789Z')
|
632
|
-
else
|
633
|
-
t = Time.utc(2015, 1, 5, 21, 37, 7.123456789)
|
634
|
-
end
|
608
|
+
t = Time.utc(2015, 1, 5, 21, 37, 7.123456789)
|
635
609
|
# The fractional seconds are not always recreated exactly which causes a
|
636
610
|
# mismatch so instead the seconds, nsecs, and gmt_offset are checked
|
637
611
|
# separately along with utc.
|
@@ -801,7 +775,7 @@ class ObjectJuice < Minitest::Test
|
|
801
775
|
assert_equal(err.message, e2['~mesg'])
|
802
776
|
assert_equal(err.backtrace, e2['~bt'])
|
803
777
|
e2 = Oj.load(json, :mode => :object)
|
804
|
-
if
|
778
|
+
if 'rubinius' == $ruby
|
805
779
|
assert_equal(e.class, e2.class);
|
806
780
|
assert_equal(e.message, e2.message);
|
807
781
|
assert_equal(e.backtrace, e2.backtrace);
|
@@ -811,18 +785,16 @@ class ObjectJuice < Minitest::Test
|
|
811
785
|
end
|
812
786
|
|
813
787
|
def test_range_object
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
assert_equal(%{{"^u":["Range",1,7,false]}}, json)
|
821
|
-
end
|
822
|
-
dump_and_load(1..7, false)
|
823
|
-
dump_and_load(1..1, false)
|
824
|
-
dump_and_load(1...7, false)
|
788
|
+
Oj.default_options = { :mode => :object }
|
789
|
+
json = Oj.dump(1..7, :mode => :object, :indent => 0)
|
790
|
+
if 'rubinius' == $ruby
|
791
|
+
assert(%{{"^O":"Range","begin":1,"end":7,"exclude_end?":false}} == json)
|
792
|
+
else
|
793
|
+
assert_equal(%{{"^u":["Range",1,7,false]}}, json)
|
825
794
|
end
|
795
|
+
dump_and_load(1..7, false)
|
796
|
+
dump_and_load(1..1, false)
|
797
|
+
dump_and_load(1...7, false)
|
826
798
|
end
|
827
799
|
|
828
800
|
def test_circular_hash
|
data/test/test_various.rb
CHANGED
@@ -214,11 +214,7 @@ class Juice < Minitest::Test
|
|
214
214
|
Oj.default_options = { :float_precision => 5 }
|
215
215
|
assert_equal('1.4055', Oj.dump(1.405460727))
|
216
216
|
Oj.default_options = { :float_precision => 0 }
|
217
|
-
|
218
|
-
assert_equal('1405460727.72387', Oj.dump(1405460727.723866))
|
219
|
-
else
|
220
|
-
assert_equal('1405460727.723866', Oj.dump(1405460727.723866))
|
221
|
-
end
|
217
|
+
assert_equal('1405460727.723866', Oj.dump(1405460727.723866))
|
222
218
|
Oj.default_options = { :float_precision => 15 }
|
223
219
|
assert_equal('0.56', Oj.dump(0.56))
|
224
220
|
assert_equal('0.5773', Oj.dump(0.5773))
|
data/test/tests.rb
CHANGED
@@ -7,17 +7,17 @@ $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
|
7
7
|
$: << File.join($oj_dir, dir)
|
8
8
|
end
|
9
9
|
|
10
|
-
require 'test_strict'
|
11
|
-
require 'test_null'
|
12
10
|
require 'test_compat'
|
13
|
-
require 'test_object'
|
14
11
|
require 'test_custom'
|
15
|
-
require 'test_writer'
|
16
12
|
require 'test_fast'
|
17
|
-
require 'test_hash'
|
18
13
|
require 'test_file'
|
19
14
|
require 'test_gc'
|
15
|
+
require 'test_hash'
|
16
|
+
require 'test_null'
|
17
|
+
require 'test_object'
|
20
18
|
require 'test_saj'
|
21
19
|
require 'test_scp'
|
20
|
+
require 'test_strict'
|
22
21
|
require 'test_various'
|
23
22
|
require 'test_wab'
|
23
|
+
require 'test_writer'
|
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.3.
|
4
|
+
version: 3.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -232,7 +232,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
232
232
|
requirements:
|
233
233
|
- - ">="
|
234
234
|
- !ruby/object:Gem::Version
|
235
|
-
version: '0'
|
235
|
+
version: '2.0'
|
236
236
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
237
237
|
requirements:
|
238
238
|
- - ">="
|