json_pure 1.4.0 → 1.4.6

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.
@@ -102,6 +102,51 @@ EOT
102
102
  assert s[:check_circular?]
103
103
  end
104
104
 
105
+ def test_pretty_state
106
+ state = PRETTY_STATE_PROTOTYPE.dup
107
+ assert_equal({
108
+ :allow_nan => false,
109
+ :array_nl => "\n",
110
+ :ascii_only => false,
111
+ :depth => 0,
112
+ :indent => " ",
113
+ :max_nesting => 19,
114
+ :object_nl => "\n",
115
+ :space => " ",
116
+ :space_before => "",
117
+ }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
118
+ end
119
+
120
+ def test_safe_state
121
+ state = SAFE_STATE_PROTOTYPE.dup
122
+ assert_equal({
123
+ :allow_nan => false,
124
+ :array_nl => "",
125
+ :ascii_only => false,
126
+ :depth => 0,
127
+ :indent => "",
128
+ :max_nesting => 19,
129
+ :object_nl => "",
130
+ :space => "",
131
+ :space_before => "",
132
+ }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
133
+ end
134
+
135
+ def test_fast_state
136
+ state = FAST_STATE_PROTOTYPE.dup
137
+ assert_equal({
138
+ :allow_nan => false,
139
+ :array_nl => "",
140
+ :ascii_only => false,
141
+ :depth => 0,
142
+ :indent => "",
143
+ :max_nesting => 0,
144
+ :object_nl => "",
145
+ :space => "",
146
+ :space_before => "",
147
+ }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
148
+ end
149
+
105
150
  def test_allow_nan
106
151
  assert_raises(GeneratorError) { generate([JSON::NaN]) }
107
152
  assert_equal '[NaN]', generate([JSON::NaN], :allow_nan => true)
@@ -119,4 +164,18 @@ EOT
119
164
  assert_raises(GeneratorError) { pretty_generate([JSON::MinusInfinity]) }
120
165
  assert_equal "[\n -Infinity\n]", pretty_generate([JSON::MinusInfinity], :allow_nan => true)
121
166
  end
167
+
168
+ def test_depth
169
+ ary = []; ary << ary
170
+ assert_equal 0, JSON::SAFE_STATE_PROTOTYPE.depth
171
+ assert_raises(JSON::NestingError) { JSON.generate(ary) }
172
+ assert_equal 0, JSON::SAFE_STATE_PROTOTYPE.depth
173
+ assert_equal 0, JSON::PRETTY_STATE_PROTOTYPE.depth
174
+ assert_raises(JSON::NestingError) { JSON.pretty_generate(ary) }
175
+ assert_equal 0, JSON::PRETTY_STATE_PROTOTYPE.depth
176
+ s = JSON.state.new
177
+ assert_equal 0, s.depth
178
+ assert_raises(JSON::NestingError) { ary.to_json(s) }
179
+ assert_equal 19, s.depth
180
+ end
122
181
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_pure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-23 00:00:00 +02:00
12
+ date: 2010-08-09 00:00:00 +02:00
13
13
  default_executable: edit_json.rb
14
14
  dependencies: []
15
15
 
@@ -67,13 +67,13 @@ files:
67
67
  - benchmarks/generator_benchmark.rb
68
68
  - benchmarks/parser2_benchmark.rb
69
69
  - benchmarks/ohai.ruby
70
- - ext/json/ext/extconf_generator.rb
71
- - ext/json/ext/parser.rl
72
- - ext/json/ext/extconf_parser.rb
73
- - ext/json/ext/parser.h
74
- - ext/json/ext/parser.c
75
- - ext/json/ext/generator.c
76
- - ext/json/ext/generator.h
70
+ - ext/json/ext/generator/extconf.rb
71
+ - ext/json/ext/generator/generator.c
72
+ - ext/json/ext/generator/generator.h
73
+ - ext/json/ext/parser/extconf.rb
74
+ - ext/json/ext/parser/parser.rl
75
+ - ext/json/ext/parser/parser.h
76
+ - ext/json/ext/parser/parser.c
77
77
  - Rakefile
78
78
  - tools/fuzz.rb
79
79
  - tools/server.rb
File without changes