json_pure 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,9 @@
3
3
 
4
4
  require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
- load 'json/add/core.rb'
6
+ require 'json/add/core'
7
+ require 'json/add/complex'
8
+ require 'json/add/rational'
7
9
  require 'date'
8
10
 
9
11
  class TC_JSONAddition < Test::Unit::TestCase
@@ -19,7 +21,7 @@ class TC_JSONAddition < Test::Unit::TestCase
19
21
  def ==(other)
20
22
  a == other.a
21
23
  end
22
-
24
+
23
25
  def self.json_create(object)
24
26
  new(*object['args'])
25
27
  end
@@ -164,4 +166,9 @@ class TC_JSONAddition < Test::Unit::TestCase
164
166
  d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(12,24))
165
167
  assert_equal d, JSON.parse(d.to_json)
166
168
  end
169
+
170
+ def test_rational_complex
171
+ assert_equal Rational(2, 9), JSON(JSON(Rational(2, 9)))
172
+ assert_equal Complex(2, 9), JSON(JSON(Complex(2, 9)))
173
+ end
167
174
  end
@@ -50,6 +50,7 @@ EOT
50
50
  parsed_json = parse(json)
51
51
  assert_equal({"1"=>2}, parsed_json)
52
52
  assert_raise(GeneratorError) { generate(666) }
53
+ assert_equal '666', generate(666, :quirks_mode => true)
53
54
  end
54
55
 
55
56
  def test_generate_pretty
@@ -67,6 +68,7 @@ EOT
67
68
  parsed_json = parse(json)
68
69
  assert_equal({"1"=>2}, parsed_json)
69
70
  assert_raise(GeneratorError) { pretty_generate(666) }
71
+ assert_equal '666', pretty_generate(666, :quirks_mode => true)
70
72
  end
71
73
 
72
74
  def test_fast_generate
@@ -79,9 +81,24 @@ EOT
79
81
  parsed_json = parse(json)
80
82
  assert_equal({"1"=>2}, parsed_json)
81
83
  assert_raise(GeneratorError) { fast_generate(666) }
84
+ assert_equal '666', fast_generate(666, :quirks_mode => true)
82
85
  end
83
86
 
84
-
87
+ def test_own_state
88
+ state = State.new
89
+ json = generate(@hash, state)
90
+ assert_equal(JSON.parse(@json2), JSON.parse(json))
91
+ parsed_json = parse(json)
92
+ assert_equal(@hash, parsed_json)
93
+ json = generate({1=>2}, state)
94
+ assert_equal('{"1":2}', json)
95
+ parsed_json = parse(json)
96
+ assert_equal({"1"=>2}, parsed_json)
97
+ assert_raise(GeneratorError) { generate(666, state) }
98
+ state.quirks_mode = true
99
+ assert state.quirks_mode?
100
+ assert_equal '666', generate(666, state)
101
+ end
85
102
 
86
103
  def test_states
87
104
  json = generate({1=>2}, nil)
@@ -107,6 +124,7 @@ EOT
107
124
  :allow_nan => false,
108
125
  :array_nl => "\n",
109
126
  :ascii_only => false,
127
+ :quirks_mode => false,
110
128
  :depth => 0,
111
129
  :indent => " ",
112
130
  :max_nesting => 19,
@@ -122,6 +140,7 @@ EOT
122
140
  :allow_nan => false,
123
141
  :array_nl => "",
124
142
  :ascii_only => false,
143
+ :quirks_mode => false,
125
144
  :depth => 0,
126
145
  :indent => "",
127
146
  :max_nesting => 19,
@@ -137,6 +156,7 @@ EOT
137
156
  :allow_nan => false,
138
157
  :array_nl => "",
139
158
  :ascii_only => false,
159
+ :quirks_mode => false,
140
160
  :depth => 0,
141
161
  :indent => "",
142
162
  :max_nesting => 0,
@@ -177,4 +197,17 @@ EOT
177
197
  assert_raises(JSON::NestingError) { ary.to_json(s) }
178
198
  assert_equal 19, s.depth
179
199
  end
200
+
201
+ def test_gc
202
+ bignum_too_long_to_embed_as_string = 1234567890123456789012345
203
+ expect = bignum_too_long_to_embed_as_string.to_s
204
+ stress, GC.stress = GC.stress, true
205
+
206
+ 10.times do |i|
207
+ tmp = bignum_too_long_to_embed_as_string.to_json
208
+ assert_equal expect, tmp
209
+ end
210
+ ensure
211
+ GC.stress = stress
212
+ end if GC.respond_to?(:stress=)
180
213
  end
data/tools/fuzz.rb CHANGED
@@ -120,7 +120,7 @@ loop do
120
120
  if $DEBUG
121
121
  puts "-" * 80
122
122
  puts json, json.size
123
- else
123
+ else
124
124
  puts json.size
125
125
  end
126
126
  begin
metadata CHANGED
@@ -1,60 +1,80 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: json_pure
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.4
4
5
  prerelease:
5
- version: 1.5.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Florian Frank
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-20 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-31 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: permutation
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2151824220 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :development
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: bullshit
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2151824220
25
+ - !ruby/object:Gem::Dependency
26
+ name: bullshit
27
+ requirement: &2151823400 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
35
33
  type: :development
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
34
+ prerelease: false
35
+ version_requirements: *2151823400
36
+ - !ruby/object:Gem::Dependency
38
37
  name: sdoc
38
+ requirement: &2151822900 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
39
45
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
46
+ version_requirements: *2151822900
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &2151821780 !ruby/object:Gem::Requirement
41
50
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.2
46
55
  type: :development
47
- version_requirements: *id003
56
+ prerelease: false
57
+ version_requirements: *2151821780
58
+ - !ruby/object:Gem::Dependency
59
+ name: spruz
60
+ requirement: &2151820960 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 0.2.8
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *2151820960
48
69
  description: This is a JSON implementation in pure Ruby.
49
70
  email: flori@ping.de
50
- executables:
71
+ executables:
51
72
  - edit_json.rb
52
73
  - prettify_json.rb
53
74
  extensions: []
54
-
55
- extra_rdoc_files:
75
+ extra_rdoc_files:
56
76
  - README.rdoc
57
- files:
77
+ files:
58
78
  - tests/test_json_string_matching.rb
59
79
  - tests/test_json_fixtures.rb
60
80
  - tests/setup_variant.rb
@@ -138,8 +158,9 @@ files:
138
158
  - lib/json/TrueClass.xpm
139
159
  - lib/json/version.rb
140
160
  - lib/json/Array.xpm
161
+ - lib/json/add/complex.rb
162
+ - lib/json/add/rational.rb
141
163
  - lib/json/add/core.rb
142
- - lib/json/add/rails.rb
143
164
  - lib/json/common.rb
144
165
  - lib/json/pure/generator.rb
145
166
  - lib/json/pure/parser.rb
@@ -202,35 +223,33 @@ files:
202
223
  - ./tests/test_json.rb
203
224
  homepage: http://flori.github.com/json
204
225
  licenses: []
205
-
206
226
  post_install_message:
207
- rdoc_options:
227
+ rdoc_options:
208
228
  - --title
209
229
  - JSON implemention for ruby
210
230
  - --main
211
231
  - README.rdoc
212
- require_paths:
232
+ require_paths:
213
233
  - lib
214
- required_ruby_version: !ruby/object:Gem::Requirement
234
+ required_ruby_version: !ruby/object:Gem::Requirement
215
235
  none: false
216
- requirements:
217
- - - ">="
218
- - !ruby/object:Gem::Version
219
- version: "0"
220
- required_rubygems_version: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - ! '>='
238
+ - !ruby/object:Gem::Version
239
+ version: '0'
240
+ required_rubygems_version: !ruby/object:Gem::Requirement
221
241
  none: false
222
- requirements:
223
- - - ">="
224
- - !ruby/object:Gem::Version
225
- version: "0"
242
+ requirements:
243
+ - - ! '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
226
246
  requirements: []
227
-
228
247
  rubyforge_project: json
229
- rubygems_version: 1.8.5
248
+ rubygems_version: 1.8.10
230
249
  signing_key:
231
250
  specification_version: 3
232
251
  summary: JSON Implementation for Ruby
233
- test_files:
252
+ test_files:
234
253
  - ./tests/test_json_string_matching.rb
235
254
  - ./tests/test_json_fixtures.rb
236
255
  - ./tests/test_json_unicode.rb
@@ -1,8 +0,0 @@
1
- # This file used to implementations of rails custom objects for
2
- # serialisation/deserialisation and is obsoleted now.
3
-
4
- unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
5
- require 'json'
6
- end
7
-
8
- $DEBUG and warn "required json/add/rails which is obsolete now!"