oj 2.14.6 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ $VERBOSE = true
5
+
6
+ %w(lib ext test).each do |dir|
7
+ $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
8
+ end
9
+
10
+ require 'rubygems' if RUBY_VERSION.start_with?('1.8.')
11
+
12
+ #require "minitest/spec"
13
+ require "minitest/autorun"
14
+
15
+ require "oj"
16
+
17
+ # Uncomment this line and test_big_decimal will fail
18
+ require "active_support/json"
19
+
20
+ # With ActiveSupport 4.0, neither of these settings affect BigDecimal#to_json,
21
+ # only BigDecimal#as_json
22
+ #
23
+ # ActiveSupport.encode_big_decimal_as_string = false
24
+ # ActiveSupport::JSON::Encoding.encode_big_decimal_as_string = false
25
+
26
+ describe Oj do
27
+
28
+ # Options set by default in Rails 4.0 / Rabl
29
+ def options
30
+ {
31
+ :bigdecimal_as_decimal=>true, # default = true
32
+ :use_to_json=>true, # default = false
33
+ :mode=>:compat, # default = object
34
+ :time_format=>:ruby, # default = unix
35
+ }
36
+ end
37
+
38
+ def test_big_decimal
39
+ orig = BigDecimal.new("3.14159265359")
40
+ puts "*** to_s: #{orig.to_s}"
41
+ puts "*** to_json: #{orig.to_json}"
42
+ puts "*** JSON.dump: #{JSON.dump(orig)}"
43
+ json = Oj.dump(orig, options)
44
+ puts "*** json: #{json}"
45
+
46
+ value = Oj.load(json)
47
+ puts "*** value: #{value.class}"
48
+ assert_equal(value, orig)
49
+
50
+ # by default, without active support
51
+ # assert_equal("0.314159265359E1", json)
52
+ # in Rails 4.1, with active support
53
+ # assert_equal("3.14159265359", json)
54
+ end
55
+
56
+ # Floats are unaffected
57
+ def test_float
58
+ orig = 3.14159265359
59
+ json = Oj.dump(orig, options)
60
+ assert_equal("3.14159265359", json)
61
+ end
62
+
63
+ end
@@ -1,16 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
+ $VERBOSE = true
5
+
4
6
  %w(lib ext test).each do |dir|
5
7
  $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
6
8
  end
7
9
 
10
+ require 'rubygems' if RUBY_VERSION.start_with?('1.8.')
8
11
  require 'oj'
9
12
 
13
+ Oj.mimic_JSON
14
+
15
+ #puts Oj.default_options
16
+
17
+ range = ("01".."12")
10
18
 
11
- Thread.new do
12
- string_io = StringIO.new('{"foo":"bar"}')
13
- Oj.load(string_io)
14
- string_io.rewind
15
- puts string_io.read
16
- end.join
19
+ puts Oj.dump(range)
@@ -138,6 +138,7 @@ class Juice < Minitest::Test
138
138
  :array_nl=>'a',
139
139
  :object_nl=>'o',
140
140
  :space_before=>'b',
141
+ :nan=>:huge,
141
142
  }
142
143
  Oj.default_options = alt
143
144
  opts = Oj.default_options()
@@ -214,6 +215,24 @@ class Juice < Minitest::Test
214
215
  assert_equal('-95.640172', Oj.dump(-95.640172))
215
216
  end
216
217
 
218
+ def test_nan_dump
219
+ assert_equal('null', Oj.dump(0/0.0, :mode => :strict, :nan => :null))
220
+ assert_equal('NaN', Oj.dump(0/0.0, :mode => :strict, :nan => :word))
221
+ assert_equal('3.3e14159265358979323846', Oj.dump(0/0.0, :mode => :strict, :nan => :huge))
222
+ end
223
+
224
+ def test_infinity_dump
225
+ assert_equal('null', Oj.dump(1/0.0, :mode => :strict, :nan => :null))
226
+ assert_equal('Infinity', Oj.dump(1/0.0, :mode => :strict, :nan => :word))
227
+ assert_equal('3.0e14159265358979323846', Oj.dump(1/0.0, :mode => :strict, :nan => :huge))
228
+ end
229
+
230
+ def test_neg_infinity_dump
231
+ assert_equal('null', Oj.dump(-1/0.0, :mode => :strict, :nan => :null))
232
+ assert_equal('-Infinity', Oj.dump(-1/0.0, :mode => :strict, :nan => :word))
233
+ assert_equal('-3.0e14159265358979323846', Oj.dump(-1/0.0, :mode => :strict, :nan => :huge))
234
+ end
235
+
217
236
  def test_float
218
237
  mode = Oj.default_options()[:mode]
219
238
  Oj.default_options = {:mode => :object}
@@ -229,7 +248,7 @@ class Juice < Minitest::Test
229
248
  dump_and_load(1/0.0, false)
230
249
  # NaN does not always == NaN
231
250
  json = Oj.dump(0/0.0)
232
- assert_equal('NaN', json)
251
+ assert_equal('3.3e14159265358979323846', json)
233
252
  loaded = Oj.load(json);
234
253
  assert_equal(true, loaded.nan?)
235
254
  Oj.default_options = {:mode => mode}
@@ -1213,7 +1232,8 @@ class Juice < Minitest::Test
1213
1232
  end
1214
1233
 
1215
1234
  def test_comment_c
1216
- json = %{{
1235
+ json = %{/*before*/
1236
+ {
1217
1237
  "x"/*one*/:/*two*/true,
1218
1238
  "y":58,
1219
1239
  "z": [1,2,3]}
metadata CHANGED
@@ -1,58 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.6
4
+ version: 2.15.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Peter Ohler
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-02-26 00:00:00.000000000 Z
12
+ date: 2016-03-28 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake-compiler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0.9'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0.9'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: minitest
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - "~>"
35
+ - - ~>
32
36
  - !ruby/object:Gem::Version
33
37
  version: '5'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - "~>"
43
+ - - ~>
39
44
  - !ruby/object:Gem::Version
40
45
  version: '5'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rails
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - "~>"
51
+ - - ~>
46
52
  - !ruby/object:Gem::Version
47
53
  version: '4'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - "~>"
59
+ - - ~>
53
60
  - !ruby/object:Gem::Version
54
61
  version: '4'
55
- description: 'The fastest JSON parser and object serializer. '
62
+ description: ! 'The fastest JSON parser and object serializer. '
56
63
  email: peter@ohler.com
57
64
  executables: []
58
65
  extensions:
@@ -60,60 +67,52 @@ extensions:
60
67
  extra_rdoc_files:
61
68
  - README.md
62
69
  files:
63
- - LICENSE
64
- - README.md
70
+ - lib/oj/active_support_helper.rb
71
+ - lib/oj/bag.rb
72
+ - lib/oj/error.rb
73
+ - lib/oj/mimic.rb
74
+ - lib/oj/saj.rb
75
+ - lib/oj/schandler.rb
76
+ - lib/oj/version.rb
77
+ - lib/oj.rb
78
+ - ext/oj/extconf.rb
65
79
  - ext/oj/buf.h
66
- - ext/oj/cache8.c
67
80
  - ext/oj/cache8.h
68
- - ext/oj/circarray.c
69
81
  - ext/oj/circarray.h
82
+ - ext/oj/encode.h
83
+ - ext/oj/err.h
84
+ - ext/oj/hash.h
85
+ - ext/oj/odd.h
86
+ - ext/oj/oj.h
87
+ - ext/oj/parse.h
88
+ - ext/oj/reader.h
89
+ - ext/oj/resolve.h
90
+ - ext/oj/val_stack.h
91
+ - ext/oj/cache8.c
92
+ - ext/oj/circarray.c
70
93
  - ext/oj/compat.c
71
94
  - ext/oj/dump.c
72
- - ext/oj/encode.h
73
95
  - ext/oj/err.c
74
- - ext/oj/err.h
75
- - ext/oj/extconf.rb
76
96
  - ext/oj/fast.c
77
97
  - ext/oj/hash.c
78
- - ext/oj/hash.h
79
98
  - ext/oj/hash_test.c
80
99
  - ext/oj/object.c
81
100
  - ext/oj/odd.c
82
- - ext/oj/odd.h
83
101
  - ext/oj/oj.c
84
- - ext/oj/oj.h
85
102
  - ext/oj/parse.c
86
- - ext/oj/parse.h
87
103
  - ext/oj/reader.c
88
- - ext/oj/reader.h
89
104
  - ext/oj/resolve.c
90
- - ext/oj/resolve.h
91
105
  - ext/oj/saj.c
92
106
  - ext/oj/scp.c
93
107
  - ext/oj/sparse.c
94
108
  - ext/oj/strict.c
95
109
  - ext/oj/val_stack.c
96
- - ext/oj/val_stack.h
97
- - lib/oj.rb
98
- - lib/oj/active_support_helper.rb
99
- - lib/oj/bag.rb
100
- - lib/oj/error.rb
101
- - lib/oj/mimic.rb
102
- - lib/oj/saj.rb
103
- - lib/oj/schandler.rb
104
- - lib/oj/version.rb
105
110
  - test/_test_active.rb
106
111
  - test/_test_active_mimic.rb
107
112
  - test/_test_mimic_rails.rb
108
113
  - test/bug.rb
109
- - test/bug2.rb
110
- - test/bug3.rb
111
- - test/bug_fast.rb
112
- - test/bug_load.rb
113
- - test/example.rb
114
114
  - test/files.rb
115
115
  - test/helper.rb
116
- - test/io.rb
117
116
  - test/isolated/shared.rb
118
117
  - test/isolated/test_mimic_after.rb
119
118
  - test/isolated/test_mimic_alone.rb
@@ -122,18 +121,18 @@ files:
122
121
  - test/isolated/test_mimic_define.rb
123
122
  - test/isolated/test_mimic_rails_after.rb
124
123
  - test/isolated/test_mimic_rails_before.rb
125
- - test/mod.rb
126
124
  - test/perf.rb
125
+ - test/perf1.rb
126
+ - test/perf2.rb
127
127
  - test/perf_compat.rb
128
128
  - test/perf_fast.rb
129
129
  - test/perf_file.rb
130
+ - test/perf_obj_old.rb
130
131
  - test/perf_object.rb
131
132
  - test/perf_saj.rb
132
133
  - test/perf_scp.rb
133
134
  - test/perf_simple.rb
134
135
  - test/perf_strict.rb
135
- - test/russian.rb
136
- - test/sample.rb
137
136
  - test/sample/change.rb
138
137
  - test/sample/dir.rb
139
138
  - test/sample/doc.rb
@@ -146,60 +145,57 @@ files:
146
145
  - test/sample/rect.rb
147
146
  - test/sample/shape.rb
148
147
  - test/sample/text.rb
148
+ - test/sample.rb
149
149
  - test/sample_json.rb
150
- - test/struct.rb
150
+ - test/test_bigd.rb
151
151
  - test/test_compat.rb
152
152
  - test/test_debian.rb
153
153
  - test/test_fast.rb
154
154
  - test/test_file.rb
155
155
  - test/test_gc.rb
156
156
  - test/test_object.rb
157
+ - test/test_range.rb
157
158
  - test/test_saj.rb
158
159
  - test/test_scp.rb
159
- - test/test_serializer.rb
160
160
  - test/test_strict.rb
161
161
  - test/test_various.rb
162
162
  - test/test_writer.rb
163
- - test/write_timebars.rb
163
+ - LICENSE
164
+ - README.md
164
165
  homepage: http://www.ohler.com/oj
165
166
  licenses:
166
167
  - MIT
167
- metadata: {}
168
168
  post_install_message:
169
169
  rdoc_options:
170
- - "--main"
170
+ - --main
171
171
  - README.md
172
172
  require_paths:
173
173
  - lib
174
174
  required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
175
176
  requirements:
176
- - - ">="
177
+ - - ! '>='
177
178
  - !ruby/object:Gem::Version
178
179
  version: '0'
179
180
  required_rubygems_version: !ruby/object:Gem::Requirement
181
+ none: false
180
182
  requirements:
181
- - - ">="
183
+ - - ! '>='
182
184
  - !ruby/object:Gem::Version
183
185
  version: '0'
184
186
  requirements: []
185
187
  rubyforge_project: oj
186
- rubygems_version: 2.4.5
188
+ rubygems_version: 1.8.23.2
187
189
  signing_key:
188
- specification_version: 4
190
+ specification_version: 3
189
191
  summary: A fast JSON parser and serializer.
190
192
  test_files:
191
193
  - test/_test_active.rb
192
194
  - test/_test_active_mimic.rb
193
195
  - test/_test_mimic_rails.rb
194
196
  - test/bug.rb
195
- - test/bug2.rb
196
- - test/bug3.rb
197
- - test/bug_fast.rb
198
- - test/bug_load.rb
199
- - test/example.rb
200
197
  - test/files.rb
201
198
  - test/helper.rb
202
- - test/io.rb
203
199
  - test/isolated/shared.rb
204
200
  - test/isolated/test_mimic_after.rb
205
201
  - test/isolated/test_mimic_alone.rb
@@ -208,17 +204,18 @@ test_files:
208
204
  - test/isolated/test_mimic_define.rb
209
205
  - test/isolated/test_mimic_rails_after.rb
210
206
  - test/isolated/test_mimic_rails_before.rb
211
- - test/mod.rb
212
207
  - test/perf.rb
208
+ - test/perf1.rb
209
+ - test/perf2.rb
213
210
  - test/perf_compat.rb
214
211
  - test/perf_fast.rb
215
212
  - test/perf_file.rb
213
+ - test/perf_obj_old.rb
216
214
  - test/perf_object.rb
217
215
  - test/perf_saj.rb
218
216
  - test/perf_scp.rb
219
217
  - test/perf_simple.rb
220
218
  - test/perf_strict.rb
221
- - test/russian.rb
222
219
  - test/sample/change.rb
223
220
  - test/sample/dir.rb
224
221
  - test/sample/doc.rb
@@ -233,18 +230,16 @@ test_files:
233
230
  - test/sample/text.rb
234
231
  - test/sample.rb
235
232
  - test/sample_json.rb
236
- - test/struct.rb
233
+ - test/test_bigd.rb
237
234
  - test/test_compat.rb
238
235
  - test/test_debian.rb
239
236
  - test/test_fast.rb
240
237
  - test/test_file.rb
241
238
  - test/test_gc.rb
242
239
  - test/test_object.rb
240
+ - test/test_range.rb
243
241
  - test/test_saj.rb
244
242
  - test/test_scp.rb
245
- - test/test_serializer.rb
246
243
  - test/test_strict.rb
247
244
  - test/test_various.rb
248
245
  - test/test_writer.rb
249
- - test/write_timebars.rb
250
- has_rdoc: true
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: a4eeac461218d534327dc278a6dfe132de7227bb
4
- data.tar.gz: 9197b3baa13fe3077519d6156a9d9dbbd1176066
5
- SHA512:
6
- metadata.gz: 1a89867a9e4e684a3d0f268e18179d54f63471a0b8f3fed3ed174a11b5dc3f0cd582bce893955de582e57872985196c6dd671078624b1de4bbfb17805508e9ef
7
- data.tar.gz: 9eb8668bbc77cc0a3057321706f08bbded75ab0bca623964554796bdc9835ede42e34b36a596f64637a81461b9bc9a67d94cd5d46ee8fca5fce04c8a9ab5f6cb
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #!/usr/bin/env ruby
4
- # encoding: UTF-8
5
-
6
- $: << File.dirname(__FILE__)
7
-
8
- require 'helper'
9
-
10
-