oj 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of oj might be problematic. Click here for more details.

metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-22 00:00:00.000000000 Z
12
+ date: 2012-02-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'The fastest JSON parser and object serializer. '
15
15
  email: peter@ohler.com
@@ -22,15 +22,34 @@ files:
22
22
  - lib/oj/version.rb
23
23
  - lib/oj.rb
24
24
  - ext/oj/extconf.rb
25
+ - ext/oj/cache.h
25
26
  - ext/oj/oj.h
27
+ - ext/oj/cache.c
26
28
  - ext/oj/dump.c
27
29
  - ext/oj/load.c
28
30
  - ext/oj/oj.c
29
31
  - test/boo.rb
32
+ - test/files.rb
30
33
  - test/foo.rb
34
+ - test/perf.rb
35
+ - test/perf_obj.rb
31
36
  - test/perf_simple.rb
37
+ - test/perf_strict.rb
38
+ - test/sample/change.rb
39
+ - test/sample/dir.rb
40
+ - test/sample/doc.rb
41
+ - test/sample/file.rb
42
+ - test/sample/group.rb
43
+ - test/sample/hasprops.rb
44
+ - test/sample/layer.rb
45
+ - test/sample/line.rb
46
+ - test/sample/oval.rb
47
+ - test/sample/rect.rb
48
+ - test/sample/shape.rb
49
+ - test/sample/text.rb
32
50
  - test/sample.rb
33
- - test/simple.rb
51
+ - test/sample_json.rb
52
+ - test/tests.rb
34
53
  - LICENSE
35
54
  - README.md
36
55
  homepage: https://github.com/ohler55/oj
@@ -61,3 +80,4 @@ signing_key:
61
80
  specification_version: 3
62
81
  summary: A fast JSON parser and serializer.
63
82
  test_files: []
83
+ has_rdoc: true
@@ -1,208 +0,0 @@
1
- #!/usr/bin/env ruby -wW1
2
- # encoding: UTF-8
3
-
4
- $: << File.join(File.dirname(__FILE__), "../lib")
5
- $: << File.join(File.dirname(__FILE__), "../ext")
6
-
7
- require 'test/unit'
8
- require 'oj'
9
-
10
- class Jeez
11
- def initialize(x, y)
12
- @x = x
13
- @y = y
14
- end
15
-
16
- def to_json()
17
- %{{"x":#{@x},"y":#{@y}}}
18
- end
19
-
20
- end # Jeez
21
-
22
- class Jazz
23
- def initialize(x, y)
24
- @x = x
25
- @y = y
26
- end
27
- def to_hash()
28
- { 'x' => @x, 'y' => @y }
29
- end
30
-
31
- end # Jazz
32
-
33
- class Juice < ::Test::Unit::TestCase
34
-
35
- def test_get_options
36
- opts = Oj.default_options()
37
- assert_equal(opts, {
38
- :encoding=>nil,
39
- :indent=>0,
40
- :circular=>false,
41
- :mode=>:object})
42
- end
43
-
44
- def test_set_options
45
- orig = {
46
- :encoding=>nil,
47
- :indent=>0,
48
- :circular=>false,
49
- :mode=>:object}
50
- o2 = {
51
- :encoding=>"UTF-8",
52
- :indent=>4,
53
- :circular=>true,
54
- :mode=>:compat}
55
- o3 = { :indent => 4 }
56
- Oj.default_options = o2
57
- opts = Oj.default_options()
58
- assert_equal(opts, o2);
59
- Oj.default_options = o3 # see if it throws an exception
60
- Oj.default_options = orig # return to original
61
- end
62
-
63
- def test_nil
64
- dump_and_load(nil, false)
65
- end
66
-
67
- def test_true
68
- dump_and_load(true, false)
69
- end
70
-
71
- def test_false
72
- dump_and_load(false, false)
73
- end
74
-
75
- def test_fixnum
76
- dump_and_load(0, false)
77
- dump_and_load(12345, false)
78
- dump_and_load(-54321, false)
79
- dump_and_load(1, false)
80
- end
81
-
82
- def test_bignum
83
- dump_and_load(12345678901234567890123456789, true)
84
- end
85
-
86
- def test_float
87
- dump_and_load(0.0, false)
88
- dump_and_load(12345.6789, false)
89
- dump_and_load(-54321.012, false)
90
- dump_and_load(2.48e16, false)
91
- end
92
-
93
- def test_string
94
- dump_and_load('', false)
95
- dump_and_load('abc', false)
96
- dump_and_load("abc\ndef", false)
97
- dump_and_load("a\u0041", false)
98
- end
99
-
100
- def test_class
101
- begin
102
- json = Oj.dump(self.class, :mode => :strict)
103
- rescue Exception => e
104
- assert(true)
105
- end
106
- json = Oj.dump(self.class, :mode => :object)
107
- assert_equal('{"*":"Class","-":"Juice"}', json)
108
- json = Oj.dump(self.class, :mode => :null)
109
- assert_equal('null', json)
110
- end
111
-
112
- def test_array
113
- dump_and_load([], false)
114
- dump_and_load([true, false], false)
115
- dump_and_load(['a', 1, nil], false)
116
- dump_and_load([[nil]], false)
117
- dump_and_load([[nil], 58], false)
118
- end
119
-
120
- def test_hash
121
- dump_and_load({}, false)
122
- dump_and_load({ 'true' => true, 'false' => false}, false)
123
- dump_and_load({ 'true' => true, 'array' => [], 'hash' => { }}, false)
124
- end
125
-
126
- def test_encode
127
- Oj.default_options = { :encoding => 'UTF-8' }
128
- dump_and_load("ぴーたー", false)
129
- Oj.default_options = { :encoding => nil }
130
- end
131
-
132
- def test_time
133
- t = Time.new(2012, 1, 5, 23, 58, 7)
134
- begin
135
- json = Oj.dump(t, :mode => :strict)
136
- rescue Exception => e
137
- assert(true)
138
- end
139
- json = Oj.dump(t, :mode => :compat)
140
- assert_equal(%{{"*":"Time","-":1325775487.000000}}, json)
141
- json = Oj.dump(t, :mode => :null)
142
- assert_equal('null', json)
143
- end
144
-
145
- def test_json_object
146
- begin
147
- json = Oj.dump(Jeez.new(true, 58), :mode => :strict)
148
- rescue Exception => e
149
- assert(true)
150
- end
151
- json = Oj.dump(Jeez.new(true, 58), :mode => :compat, :indent => 2)
152
- assert_equal(%{{"x":true,"y":58}}, json)
153
- json = Oj.dump(Jeez.new(true, 58), :mode => :null)
154
- assert_equal('null', json)
155
- end
156
-
157
- def test_hash_object
158
- begin
159
- json = Oj.dump(Jazz.new(true, 58), :mode => :strict)
160
- rescue Exception => e
161
- assert(true)
162
- end
163
- json = Oj.dump(Jazz.new(true, 58), :mode => :compat, :indent => 2)
164
- assert_equal(%{{
165
- "x":true,
166
- "y":58}}, json)
167
- json = Oj.dump(Jazz.new(true, 58), :mode => :null)
168
- assert_equal('null', json)
169
- end
170
-
171
- def test_object
172
- begin
173
- json = Oj.dump(Jazz.new(true, 58), :mode => :strict)
174
- rescue Exception => e
175
- assert(true)
176
- end
177
- json = Oj.dump(Jazz.new(true, 58), :mode => :object, :indent => 2)
178
- assert_equal(%{{
179
- "*":"Jazz",
180
- "x":true,
181
- "y":58}}, json)
182
- json = Oj.dump(Jazz.new(true, 58), :mode => :null)
183
- assert_equal('null', json)
184
- end
185
-
186
- def test_exception
187
- err = nil
188
- begin
189
- raise StandardError.new('A Message')
190
- rescue Exception => e
191
- err = e
192
- end
193
- json = Oj.dump(err, :mode => :object, :indent => 2)
194
- e2 = Oj.load(json, :mode => :strict)
195
- assert_equal(err.class.to_s, e2['*'])
196
- assert_equal(err.message, e2['mesg'])
197
- assert_equal(err.backtrace, e2['bt'])
198
- end
199
-
200
- def dump_and_load(obj, trace=false)
201
- json = Oj.dump(obj, :indent => 2)
202
- puts json if trace
203
- loaded = Oj.load(json);
204
- assert_equal(obj, loaded)
205
- loaded
206
- end
207
-
208
- end