json-maglev- 1.6.1 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,8 @@ require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
  require 'json/add/core'
7
7
  require 'json/add/complex'
8
8
  require 'json/add/rational'
9
+ require 'json/add/bigdecimal'
10
+ require 'json/add/ostruct'
9
11
  require 'date'
10
12
 
11
13
  class TC_JSONAddition < Test::Unit::TestCase
@@ -128,7 +130,7 @@ class TC_JSONAddition < Test::Unit::TestCase
128
130
 
129
131
  def test_core
130
132
  t = Time.now
131
- assert_equal t.inspect, JSON(JSON(t)).inspect
133
+ assert_equal t, JSON(JSON(t))
132
134
  d = Date.today
133
135
  assert_equal d, JSON(JSON(d))
134
136
  d = DateTime.civil(2007, 6, 14, 14, 57, 10, Rational(1, 12), 2299161)
@@ -171,4 +173,16 @@ class TC_JSONAddition < Test::Unit::TestCase
171
173
  assert_equal Rational(2, 9), JSON(JSON(Rational(2, 9)))
172
174
  assert_equal Complex(2, 9), JSON(JSON(Complex(2, 9)))
173
175
  end
176
+
177
+ def test_bigdecimal
178
+ assert_equal BigDecimal('3.141', 23), JSON(JSON(BigDecimal('3.141', 23)))
179
+ assert_equal BigDecimal('3.141', 666), JSON(JSON(BigDecimal('3.141', 666)))
180
+ end
181
+
182
+ def test_ostruct
183
+ o = OpenStruct.new
184
+ # XXX this won't work; o.foo = { :bar => true }
185
+ o.foo = { 'bar' => true }
186
+ assert_equal o, JSON(JSON(o))
187
+ end
174
188
  end
@@ -43,6 +43,8 @@ EOT
43
43
  def test_generate
44
44
  json = generate(@hash)
45
45
  assert_equal(JSON.parse(@json2), JSON.parse(json))
46
+ json = JSON[@hash]
47
+ assert_equal(JSON.parse(@json2), JSON.parse(json))
46
48
  parsed_json = parse(json)
47
49
  assert_equal(@hash, parsed_json)
48
50
  json = generate({1=>2})
@@ -121,48 +123,51 @@ EOT
121
123
  def test_pretty_state
122
124
  state = PRETTY_STATE_PROTOTYPE.dup
123
125
  assert_equal({
124
- :allow_nan => false,
125
- :array_nl => "\n",
126
- :ascii_only => false,
127
- :quirks_mode => false,
128
- :depth => 0,
129
- :indent => " ",
130
- :max_nesting => 19,
131
- :object_nl => "\n",
132
- :space => " ",
133
- :space_before => "",
126
+ :allow_nan => false,
127
+ :array_nl => "\n",
128
+ :ascii_only => false,
129
+ :buffer_initial_length => 1024,
130
+ :quirks_mode => false,
131
+ :depth => 0,
132
+ :indent => " ",
133
+ :max_nesting => 19,
134
+ :object_nl => "\n",
135
+ :space => " ",
136
+ :space_before => "",
134
137
  }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
135
138
  end
136
139
 
137
140
  def test_safe_state
138
141
  state = SAFE_STATE_PROTOTYPE.dup
139
142
  assert_equal({
140
- :allow_nan => false,
141
- :array_nl => "",
142
- :ascii_only => false,
143
- :quirks_mode => false,
144
- :depth => 0,
145
- :indent => "",
146
- :max_nesting => 19,
147
- :object_nl => "",
148
- :space => "",
149
- :space_before => "",
143
+ :allow_nan => false,
144
+ :array_nl => "",
145
+ :ascii_only => false,
146
+ :buffer_initial_length => 1024,
147
+ :quirks_mode => false,
148
+ :depth => 0,
149
+ :indent => "",
150
+ :max_nesting => 19,
151
+ :object_nl => "",
152
+ :space => "",
153
+ :space_before => "",
150
154
  }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
151
155
  end
152
156
 
153
157
  def test_fast_state
154
158
  state = FAST_STATE_PROTOTYPE.dup
155
159
  assert_equal({
156
- :allow_nan => false,
157
- :array_nl => "",
158
- :ascii_only => false,
159
- :quirks_mode => false,
160
- :depth => 0,
161
- :indent => "",
162
- :max_nesting => 0,
163
- :object_nl => "",
164
- :space => "",
165
- :space_before => "",
160
+ :allow_nan => false,
161
+ :array_nl => "",
162
+ :ascii_only => false,
163
+ :buffer_initial_length => 1024,
164
+ :quirks_mode => false,
165
+ :depth => 0,
166
+ :indent => "",
167
+ :max_nesting => 0,
168
+ :object_nl => "",
169
+ :space => "",
170
+ :space_before => "",
166
171
  }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
167
172
  end
168
173
 
@@ -198,6 +203,17 @@ EOT
198
203
  assert_equal 19, s.depth
199
204
  end
200
205
 
206
+ def test_buffer_initial_length
207
+ s = JSON.state.new
208
+ assert_equal 1024, s.buffer_initial_length
209
+ s.buffer_initial_length = 0
210
+ assert_equal 1024, s.buffer_initial_length
211
+ s.buffer_initial_length = -1
212
+ assert_equal 1024, s.buffer_initial_length
213
+ s.buffer_initial_length = 128
214
+ assert_equal 128, s.buffer_initial_length
215
+ end
216
+
201
217
  def test_gc
202
218
  bignum_too_long_to_embed_as_string = 1234567890123456789012345
203
219
  expect = bignum_too_long_to_embed_as_string.to_s
@@ -210,4 +226,24 @@ EOT
210
226
  ensure
211
227
  GC.stress = stress
212
228
  end if GC.respond_to?(:stress=)
229
+
230
+ def test_broken_bignum # [ruby-core:38867]
231
+ pid = fork do
232
+ Bignum.class_eval do
233
+ def to_s
234
+ end
235
+ end
236
+ begin
237
+ JSON::Ext::Generator::State.new.generate(1<<64)
238
+ exit 1
239
+ rescue TypeError
240
+ exit 0
241
+ end
242
+ end
243
+ _, status = Process.waitpid2(pid)
244
+ assert status.success?
245
+ rescue NotImplementedError
246
+ # forking to avoid modifying core class of a parent process and
247
+ # introducing race conditions of tests are run in parallel
248
+ end if defined?(JSON::Ext)
213
249
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-maglev-
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
4
+ hash: 9
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 1
10
- version: 1.6.1
9
+ - 3
10
+ version: 1.6.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Florian Frank
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-18 00:00:00 -07:00
18
+ date: 2011-12-01 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -70,139 +70,148 @@ extensions:
70
70
  extra_rdoc_files:
71
71
  - README.rdoc
72
72
  files:
73
- - tests/test_json_string_matching.rb
74
- - tests/test_json_fixtures.rb
75
- - tests/setup_variant.rb
76
- - tests/fixtures/fail6.json
77
- - tests/fixtures/fail9.json
78
- - tests/fixtures/fail10.json
79
- - tests/fixtures/fail24.json
80
- - tests/fixtures/fail28.json
81
- - tests/fixtures/fail13.json
82
- - tests/fixtures/fail4.json
83
- - tests/fixtures/pass3.json
84
- - tests/fixtures/fail11.json
85
- - tests/fixtures/fail14.json
86
- - tests/fixtures/fail3.json
87
- - tests/fixtures/fail12.json
88
- - tests/fixtures/pass16.json
89
- - tests/fixtures/pass15.json
90
- - tests/fixtures/fail20.json
91
- - tests/fixtures/fail8.json
92
- - tests/fixtures/pass2.json
93
- - tests/fixtures/fail5.json
94
- - tests/fixtures/fail1.json
95
- - tests/fixtures/fail25.json
96
- - tests/fixtures/pass17.json
97
- - tests/fixtures/fail7.json
98
- - tests/fixtures/pass26.json
99
- - tests/fixtures/fail21.json
100
- - tests/fixtures/pass1.json
101
- - tests/fixtures/fail23.json
102
- - tests/fixtures/fail18.json
103
- - tests/fixtures/fail2.json
104
- - tests/fixtures/fail22.json
105
- - tests/fixtures/fail27.json
106
- - tests/fixtures/fail19.json
107
- - tests/test_json_unicode.rb
108
- - tests/test_json_addition.rb
109
- - tests/test_json_generate.rb
110
- - tests/test_json_encoding.rb
111
- - tests/test_json.rb
73
+ - .gitignore
74
+ - .travis.yml
75
+ - CHANGES
112
76
  - COPYING
113
- - TODO
77
+ - COPYING-json-jruby
78
+ - GPL
79
+ - Gemfile
80
+ - README-json-jruby.markdown
81
+ - README.rdoc
114
82
  - Rakefile
115
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat
116
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log
117
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log
118
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log
119
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log
120
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat
121
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat
122
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat
123
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log
124
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat
125
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat
126
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat
127
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat
128
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat
129
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log
130
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat
131
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat
132
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat
83
+ - TODO
84
+ - VERSION
85
+ - benchmarks/data-p4-3GHz-ruby18/.keep
133
86
  - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log
134
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat
135
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log
136
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat
137
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat
138
87
  - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat
88
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat
89
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat
139
90
  - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat
91
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat
92
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat
93
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log
140
94
  - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat
141
95
  - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat
96
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat
97
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat
98
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat
99
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat
100
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log
101
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat
102
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat
103
+ - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log
142
104
  - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log
143
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat
105
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat
106
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat
107
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log
108
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat
109
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat
110
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log
111
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat
112
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat
113
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log
144
114
  - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat
145
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat
146
- - benchmarks/parser2_benchmark.rb
147
- - benchmarks/parser_benchmark.rb
115
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat
116
+ - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log
117
+ - benchmarks/data/.keep
148
118
  - benchmarks/generator2_benchmark.rb
149
119
  - benchmarks/generator_benchmark.rb
150
- - benchmarks/ohai.ruby
151
120
  - benchmarks/ohai.json
152
- - lib/json/version.rb
153
- - lib/json/add/symbol.rb
154
- - lib/json/add/struct.rb
155
- - lib/json/add/complex.rb
156
- - lib/json/add/rational.rb
157
- - lib/json/add/exception.rb
158
- - lib/json/add/time.rb
159
- - lib/json/add/date_time.rb
160
- - lib/json/add/core.rb
161
- - lib/json/add/range.rb
162
- - lib/json/add/date.rb
163
- - lib/json/add/regexp.rb
164
- - lib/json/common.rb
165
- - lib/json/pure/generator.rb
166
- - lib/json/pure/parser.rb
167
- - lib/json/ext.rb
168
- - lib/json/pure.rb
169
- - lib/json.rb
170
- - Gemfile
171
- - README.rdoc
172
- - json_pure.gemspec
173
- - GPL
174
- - CHANGES
175
- - COPYING-json-jruby
176
- - ext/json/ext/parser/parser.h
177
- - ext/json/ext/parser/extconf.rb
178
- - ext/json/ext/parser/parser.rl
179
- - ext/json/ext/parser/parser.c
180
- - ext/json/ext/generator/generator.c
121
+ - benchmarks/ohai.ruby
122
+ - benchmarks/parser2_benchmark.rb
123
+ - benchmarks/parser_benchmark.rb
124
+ - data/example.json
125
+ - data/index.html
126
+ - data/prototype.js
127
+ - diagrams/.keep
128
+ - ext/json/ext/fbuffer/fbuffer.h
181
129
  - ext/json/ext/generator/extconf.rb
130
+ - ext/json/ext/generator/generator.c
182
131
  - ext/json/ext/generator/generator.h
183
- - VERSION
184
- - data/prototype.js
185
- - data/index.html
186
- - data/example.json
187
- - json.gemspec
188
- - java/src/json/ext/Parser.java
189
- - java/src/json/ext/RuntimeInfo.java
132
+ - ext/json/ext/parser/extconf.rb
133
+ - ext/json/ext/parser/parser.c
134
+ - ext/json/ext/parser/parser.h
135
+ - ext/json/ext/parser/parser.rl
136
+ - install.rb
137
+ - java/lib/bytelist-1.0.6.jar
138
+ - java/lib/jcodings.jar
139
+ - java/src/json/ext/ByteListTranscoder.java
140
+ - java/src/json/ext/Generator.java
141
+ - java/src/json/ext/GeneratorMethods.java
142
+ - java/src/json/ext/GeneratorService.java
190
143
  - java/src/json/ext/GeneratorState.java
191
144
  - java/src/json/ext/OptionsReader.java
192
- - java/src/json/ext/ParserService.java
145
+ - java/src/json/ext/Parser.java
193
146
  - java/src/json/ext/Parser.rl
147
+ - java/src/json/ext/ParserService.java
148
+ - java/src/json/ext/RuntimeInfo.java
149
+ - java/src/json/ext/StringDecoder.java
194
150
  - java/src/json/ext/StringEncoder.java
195
- - java/src/json/ext/GeneratorService.java
196
151
  - java/src/json/ext/Utils.java
197
- - java/src/json/ext/StringDecoder.java
198
- - java/src/json/ext/Generator.java
199
- - java/src/json/ext/ByteListTranscoder.java
200
- - java/src/json/ext/GeneratorMethods.java
201
- - java/lib/bytelist-1.0.6.jar
202
- - java/lib/jcodings.jar
203
- - README-json-jruby.markdown
204
- - install.rb
205
152
  - json-java.gemspec
153
+ - json.gemspec
154
+ - json_pure.gemspec
155
+ - lib/json.rb
156
+ - lib/json/add/bigdecimal.rb
157
+ - lib/json/add/complex.rb
158
+ - lib/json/add/core.rb
159
+ - lib/json/add/date.rb
160
+ - lib/json/add/date_time.rb
161
+ - lib/json/add/exception.rb
162
+ - lib/json/add/ostruct.rb
163
+ - lib/json/add/range.rb
164
+ - lib/json/add/rational.rb
165
+ - lib/json/add/regexp.rb
166
+ - lib/json/add/struct.rb
167
+ - lib/json/add/symbol.rb
168
+ - lib/json/add/time.rb
169
+ - lib/json/common.rb
170
+ - lib/json/ext.rb
171
+ - lib/json/ext/.keep
172
+ - lib/json/pure.rb
173
+ - lib/json/pure/generator.rb
174
+ - lib/json/pure/parser.rb
175
+ - lib/json/version.rb
176
+ - tests/fixtures/fail1.json
177
+ - tests/fixtures/fail10.json
178
+ - tests/fixtures/fail11.json
179
+ - tests/fixtures/fail12.json
180
+ - tests/fixtures/fail13.json
181
+ - tests/fixtures/fail14.json
182
+ - tests/fixtures/fail18.json
183
+ - tests/fixtures/fail19.json
184
+ - tests/fixtures/fail2.json
185
+ - tests/fixtures/fail20.json
186
+ - tests/fixtures/fail21.json
187
+ - tests/fixtures/fail22.json
188
+ - tests/fixtures/fail23.json
189
+ - tests/fixtures/fail24.json
190
+ - tests/fixtures/fail25.json
191
+ - tests/fixtures/fail27.json
192
+ - tests/fixtures/fail28.json
193
+ - tests/fixtures/fail3.json
194
+ - tests/fixtures/fail4.json
195
+ - tests/fixtures/fail5.json
196
+ - tests/fixtures/fail6.json
197
+ - tests/fixtures/fail7.json
198
+ - tests/fixtures/fail8.json
199
+ - tests/fixtures/fail9.json
200
+ - tests/fixtures/pass1.json
201
+ - tests/fixtures/pass15.json
202
+ - tests/fixtures/pass16.json
203
+ - tests/fixtures/pass17.json
204
+ - tests/fixtures/pass2.json
205
+ - tests/fixtures/pass26.json
206
+ - tests/fixtures/pass3.json
207
+ - tests/setup_variant.rb
208
+ - tests/test_json.rb
209
+ - tests/test_json_addition.rb
210
+ - tests/test_json_encoding.rb
211
+ - tests/test_json_fixtures.rb
212
+ - tests/test_json_generate.rb
213
+ - tests/test_json_string_matching.rb
214
+ - tests/test_json_unicode.rb
206
215
  - tools/fuzz.rb
207
216
  - tools/server.rb
208
217
  - ./tests/test_json_string_matching.rb
@@ -247,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
256
  requirements: []
248
257
 
249
258
  rubyforge_project: json
250
- rubygems_version: 1.3.7
259
+ rubygems_version: 1.5.2
251
260
  signing_key:
252
261
  specification_version: 3
253
262
  summary: JSON Implementation for Ruby