fluentd 0.10.49 → 0.10.50
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog +11 -0
- data/fluentd.gemspec +1 -1
- data/lib/fluent/config/v1_parser.rb +4 -4
- data/lib/fluent/engine.rb +22 -6
- data/lib/fluent/formatter.rb +4 -1
- data/lib/fluent/mixin.rb +0 -14
- data/lib/fluent/parser.rb +70 -17
- data/lib/fluent/plugin/buf_memory.rb +1 -1
- data/lib/fluent/plugin/in_http.rb +0 -7
- data/lib/fluent/plugin/in_syslog.rb +7 -7
- data/lib/fluent/plugin/in_tail.rb +56 -40
- data/lib/fluent/test/input_test.rb +3 -4
- data/lib/fluent/version.rb +1 -1
- data/spec/config/config_parser_spec.rb +30 -30
- data/spec/config/configurable_spec.rb +2 -2
- data/spec/config/configure_proxy_spec.rb +20 -20
- data/spec/config/dsl_spec.rb +1 -1
- data/spec/config/helper.rb +3 -3
- data/spec/config/literal_parser_spec.rb +136 -136
- data/spec/config/section_spec.rb +5 -5
- data/test/plugin/test_in_tail.rb +129 -14
- data/test/plugin/test_out_file.rb +24 -0
- data/test/test_formatter.rb +9 -2
- data/test/test_parser.rb +209 -119
- metadata +4 -4
@@ -72,11 +72,10 @@ module Fluent
|
|
72
72
|
|
73
73
|
def run(&block)
|
74
74
|
m = method(:emit_stream)
|
75
|
+
Engine.define_singleton_method(:emit_stream) {|tag,es|
|
76
|
+
m.call(tag, es)
|
77
|
+
}
|
75
78
|
super {
|
76
|
-
Engine.define_singleton_method(:emit_stream) {|tag,es|
|
77
|
-
m.call(tag, es)
|
78
|
-
}
|
79
|
-
|
80
79
|
block.call if block
|
81
80
|
|
82
81
|
if @expects
|
data/lib/fluent/version.rb
CHANGED
@@ -28,21 +28,21 @@ describe Fluent::Config::V1Parser do
|
|
28
28
|
|
29
29
|
describe 'attribute parsing' do
|
30
30
|
it "parses attributes" do
|
31
|
-
%[
|
31
|
+
expect(%[
|
32
32
|
k1 v1
|
33
33
|
k2 v2
|
34
|
-
].
|
34
|
+
]).to be_parsed_as("k1"=>"v1", "k2"=>"v2")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "allows attribute without value" do
|
38
|
-
%[
|
38
|
+
expect(%[
|
39
39
|
k1
|
40
40
|
k2 v2
|
41
|
-
].
|
41
|
+
]).to be_parsed_as("k1"=>"", "k2"=>"v2")
|
42
42
|
end
|
43
43
|
|
44
44
|
it "parses attribute key always string" do
|
45
|
-
"1 1".
|
45
|
+
expect("1 1").to be_parsed_as("1" => "1")
|
46
46
|
end
|
47
47
|
|
48
48
|
[
|
@@ -51,41 +51,41 @@ describe Fluent::Config::V1Parser do
|
|
51
51
|
"()*{}.[]",
|
52
52
|
].each do |v|
|
53
53
|
it "parses a value with symbol #{v.inspect}" do
|
54
|
-
"k #{v}".
|
54
|
+
expect("k #{v}").to be_parsed_as("k" => v)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it "ignores spacing around value" do
|
59
|
-
" k1 a ".
|
59
|
+
expect(" k1 a ").to be_parsed_as("k1" => "a")
|
60
60
|
end
|
61
61
|
|
62
62
|
it "allows spaces in value" do
|
63
|
-
"k1 a b c".
|
63
|
+
expect("k1 a b c").to be_parsed_as("k1" => "a b c")
|
64
64
|
end
|
65
65
|
|
66
66
|
it "ignores comments after value" do
|
67
|
-
" k1 a#comment".
|
67
|
+
expect(" k1 a#comment").to be_parsed_as("k1" => "a")
|
68
68
|
end
|
69
69
|
|
70
70
|
it "allows # in value if quoted" do
|
71
|
-
' k1 "a#comment"'.
|
71
|
+
expect(' k1 "a#comment"').to be_parsed_as("k1" => "a#comment")
|
72
72
|
end
|
73
73
|
|
74
74
|
it "rejects characters after quoted string" do
|
75
|
-
' k1 "a" 1'.
|
75
|
+
expect(' k1 "a" 1').to be_parse_error
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
describe 'element parsing' do
|
80
80
|
it do
|
81
|
-
"".
|
81
|
+
expect("").to be_parsed_as(root)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "accepts empty element" do
|
85
|
-
%[
|
85
|
+
expect(%[
|
86
86
|
<test>
|
87
87
|
</test>
|
88
|
-
].
|
88
|
+
]).to be_parsed_as(
|
89
89
|
root(
|
90
90
|
e("test")
|
91
91
|
)
|
@@ -93,17 +93,17 @@ describe Fluent::Config::V1Parser do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
it "accepts argument and attributes" do
|
96
|
-
%[
|
96
|
+
expect(%[
|
97
97
|
<test var>
|
98
98
|
key val
|
99
99
|
</test>
|
100
|
-
].
|
100
|
+
]).to be_parsed_as(root(
|
101
101
|
e("test", 'var', {'key'=>"val"})
|
102
102
|
))
|
103
103
|
end
|
104
104
|
|
105
105
|
it "accepts nested elements" do
|
106
|
-
%[
|
106
|
+
expect(%[
|
107
107
|
<test var>
|
108
108
|
key 1
|
109
109
|
<nested1>
|
@@ -111,7 +111,7 @@ describe Fluent::Config::V1Parser do
|
|
111
111
|
<nested2>
|
112
112
|
</nested2>
|
113
113
|
</test>
|
114
|
-
].
|
114
|
+
]).to be_parsed_as(root(
|
115
115
|
e("test", 'var', {'key'=>'val'}, [
|
116
116
|
e('nested1'),
|
117
117
|
e('nested2')
|
@@ -128,52 +128,52 @@ describe Fluent::Config::V1Parser do
|
|
128
128
|
"()*{}.[]",
|
129
129
|
].each do |arg|
|
130
130
|
it "parses element argument #{arg.inspect}" do
|
131
|
-
%[
|
131
|
+
expect(%[
|
132
132
|
<test #{arg}>
|
133
133
|
</test>
|
134
|
-
].
|
134
|
+
]).to be_parsed_as(root(
|
135
135
|
e("test", arg)
|
136
136
|
))
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
140
|
it "parses empty element argument to nil" do
|
141
|
-
%[
|
141
|
+
expect(%[
|
142
142
|
<test >
|
143
143
|
</test>
|
144
|
-
].
|
144
|
+
]).to be_parsed_as(root(
|
145
145
|
e("test", nil)
|
146
146
|
))
|
147
147
|
end
|
148
148
|
|
149
149
|
it "ignores spacing around element argument" do
|
150
|
-
%[
|
150
|
+
expect(%[
|
151
151
|
<test a >
|
152
152
|
</test>
|
153
|
-
].
|
153
|
+
]).to be_parsed_as(root(
|
154
154
|
e("test", "a")
|
155
155
|
))
|
156
156
|
end
|
157
157
|
|
158
158
|
it "considers comments in element argument" do
|
159
|
-
%[
|
159
|
+
expect(%[
|
160
160
|
<test #a>
|
161
161
|
</test>
|
162
|
-
].
|
162
|
+
]).to be_parse_error
|
163
163
|
end
|
164
164
|
|
165
165
|
it "requires line_end after begin tag" do
|
166
|
-
%[
|
166
|
+
expect(%[
|
167
167
|
<test></test>
|
168
|
-
].
|
168
|
+
]).to be_parse_error
|
169
169
|
end
|
170
170
|
|
171
171
|
it "requires line_end after end tag" do
|
172
|
-
%[
|
172
|
+
expect(%[
|
173
173
|
<test>
|
174
174
|
</test><test>
|
175
175
|
</test>
|
176
|
-
].
|
176
|
+
]).to be_parse_error
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
@@ -174,8 +174,8 @@ describe Fluent::Configurable do
|
|
174
174
|
|
175
175
|
it 'create non-required and multi without any specifications' do
|
176
176
|
b3 = ConfigurableSpec::Base3.new
|
177
|
-
expect(b3.class.merged_configure_proxy.sections[:node].required?).to
|
178
|
-
expect(b3.class.merged_configure_proxy.sections[:node].multi?).to
|
177
|
+
expect(b3.class.merged_configure_proxy.sections[:node].required?).to be false
|
178
|
+
expect(b3.class.merged_configure_proxy.sections[:node].multi?).to be true
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
@@ -11,27 +11,27 @@ describe Fluent::Config::ConfigureProxy do
|
|
11
11
|
expect(proxy.name).to eql(:section)
|
12
12
|
expect(proxy.param_name).to eql(:section)
|
13
13
|
expect(proxy.required).to be_nil
|
14
|
-
expect(proxy.required?).to
|
14
|
+
expect(proxy.required?).to be false
|
15
15
|
expect(proxy.multi).to be_nil
|
16
|
-
expect(proxy.multi?).to
|
16
|
+
expect(proxy.multi?).to be true
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'can specify param_name/required/multi with optional arguments' do
|
20
20
|
proxy = Fluent::Config::ConfigureProxy.new(:section, param_name: 'sections', required: false, multi: true)
|
21
21
|
expect(proxy.name).to eql(:section)
|
22
22
|
expect(proxy.param_name).to eql(:sections)
|
23
|
-
expect(proxy.required).to
|
24
|
-
expect(proxy.required?).to
|
25
|
-
expect(proxy.multi).to
|
26
|
-
expect(proxy.multi?).to
|
23
|
+
expect(proxy.required).to be false
|
24
|
+
expect(proxy.required?).to be false
|
25
|
+
expect(proxy.multi).to be true
|
26
|
+
expect(proxy.multi?).to be true
|
27
27
|
|
28
28
|
proxy = Fluent::Config::ConfigureProxy.new(:section, param_name: :sections, required: true, multi: false)
|
29
29
|
expect(proxy.name).to eql(:section)
|
30
30
|
expect(proxy.param_name).to eql(:sections)
|
31
|
-
expect(proxy.required).to
|
32
|
-
expect(proxy.required?).to
|
33
|
-
expect(proxy.multi).to
|
34
|
-
expect(proxy.multi?).to
|
31
|
+
expect(proxy.required).to be true
|
32
|
+
expect(proxy.required?).to be true
|
33
|
+
expect(proxy.multi).to be false
|
34
|
+
expect(proxy.multi?).to be false
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -41,18 +41,18 @@ describe Fluent::Config::ConfigureProxy do
|
|
41
41
|
expect(proxy.name).to eql(:section)
|
42
42
|
expect(proxy.param_name).to eql(:section)
|
43
43
|
expect(proxy.required).to be_nil
|
44
|
-
expect(proxy.required?).to
|
44
|
+
expect(proxy.required?).to be false
|
45
45
|
expect(proxy.multi).to be_nil
|
46
|
-
expect(proxy.multi?).to
|
46
|
+
expect(proxy.multi?).to be true
|
47
47
|
|
48
48
|
p2 = Fluent::Config::ConfigureProxy.new(:section, param_name: :sections, required: true, multi: false)
|
49
49
|
proxy = p1.merge(p2)
|
50
50
|
expect(proxy.name).to eql(:section)
|
51
51
|
expect(proxy.param_name).to eql(:sections)
|
52
|
-
expect(proxy.required).to
|
53
|
-
expect(proxy.required?).to
|
54
|
-
expect(proxy.multi).to
|
55
|
-
expect(proxy.multi?).to
|
52
|
+
expect(proxy.required).to be true
|
53
|
+
expect(proxy.required?).to be true
|
54
|
+
expect(proxy.multi).to be false
|
55
|
+
expect(proxy.multi?).to be false
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'does not overwrite with argument object without any specifications of required/multi' do
|
@@ -62,10 +62,10 @@ describe Fluent::Config::ConfigureProxy do
|
|
62
62
|
proxy = p1.merge(p2).merge(p3)
|
63
63
|
expect(proxy.name).to eql(:section3)
|
64
64
|
expect(proxy.param_name).to eql(:section3)
|
65
|
-
expect(proxy.required).to
|
66
|
-
expect(proxy.required?).to
|
67
|
-
expect(proxy.multi).to
|
68
|
-
expect(proxy.multi?).to
|
65
|
+
expect(proxy.required).to be true
|
66
|
+
expect(proxy.required?).to be true
|
67
|
+
expect(proxy.multi).to be false
|
68
|
+
expect(proxy.multi?).to be false
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
data/spec/config/dsl_spec.rb
CHANGED
@@ -156,7 +156,7 @@ describe Fluent::Config::DSL::Parser do
|
|
156
156
|
it 'does not make worker element implicitly because DSL configuration does not support v10 compat mode' do
|
157
157
|
expect(root.elements.size).to eql(1)
|
158
158
|
expect(root.elements.first.name).to eql('source')
|
159
|
-
expect(root.elements.find{|e| e.name == 'worker'}).to
|
159
|
+
expect(root.elements.find{|e| e.name == 'worker'}).to be_falsey
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
data/spec/config/helper.rb
CHANGED
@@ -9,7 +9,7 @@ shared_context 'config_helper' do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
failure_message do |text|
|
13
13
|
msg = parse_text(text).inspect rescue 'failed'
|
14
14
|
"expected that #{text.inspect} would be a parsed as #{obj.inspect} but got #{msg}"
|
15
15
|
end
|
@@ -21,7 +21,7 @@ shared_context 'config_helper' do
|
|
21
21
|
v == obj
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
failure_message do |text|
|
25
25
|
msg = parse_text(text).inspect rescue 'failed'
|
26
26
|
"expected that #{text.inspect} would be a parsed as #{obj.inspect} but got #{msg}"
|
27
27
|
end
|
@@ -37,7 +37,7 @@ shared_context 'config_helper' do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
failure_message do |text|
|
41
41
|
begin
|
42
42
|
msg = parse_text(text).inspect
|
43
43
|
rescue
|
@@ -22,169 +22,169 @@ describe Fluent::Config::LiteralParser do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe 'boolean parsing' do
|
25
|
-
it { 'true'.
|
26
|
-
it { 'false'.
|
27
|
-
it { 'trueX'.
|
28
|
-
it { 'falseX'.
|
25
|
+
it { expect('true').to be_parsed_as("true") }
|
26
|
+
it { expect('false').to be_parsed_as("false") }
|
27
|
+
it { expect('trueX').to be_parsed_as("trueX") }
|
28
|
+
it { expect('falseX').to be_parsed_as("falseX") }
|
29
29
|
end
|
30
30
|
|
31
31
|
describe 'integer parsing' do
|
32
|
-
it { '0'.
|
33
|
-
it { '1'.
|
34
|
-
it { '10'.
|
35
|
-
it { '-1'.
|
36
|
-
it { '-10'.
|
37
|
-
it { '0 '.
|
38
|
-
it { ' -1 '.
|
32
|
+
it { expect('0').to be_parsed_as("0") }
|
33
|
+
it { expect('1').to be_parsed_as("1") }
|
34
|
+
it { expect('10').to be_parsed_as("10") }
|
35
|
+
it { expect('-1').to be_parsed_as("-1") }
|
36
|
+
it { expect('-10').to be_parsed_as("-10") }
|
37
|
+
it { expect('0 ').to be_parsed_as("0") }
|
38
|
+
it { expect(' -1 ').to be_parsed_as("-1") }
|
39
39
|
# string
|
40
|
-
it { '01'.
|
41
|
-
it { '00'.
|
42
|
-
it { '-01'.
|
43
|
-
it { '-00'.
|
44
|
-
it { '0x61'.
|
45
|
-
it { '0s'.
|
40
|
+
it { expect('01').to be_parsed_as("01") }
|
41
|
+
it { expect('00').to be_parsed_as("00") }
|
42
|
+
it { expect('-01').to be_parsed_as("-01") }
|
43
|
+
it { expect('-00').to be_parsed_as("-00") }
|
44
|
+
it { expect('0x61').to be_parsed_as("0x61") }
|
45
|
+
it { expect('0s').to be_parsed_as("0s") }
|
46
46
|
end
|
47
47
|
|
48
48
|
describe 'float parsing' do
|
49
|
-
it { '1.1'.
|
50
|
-
it { '0.1'.
|
51
|
-
it { '0.0'.
|
52
|
-
it { '-1.1'.
|
53
|
-
it { '-0.1'.
|
54
|
-
it { '1.10'.
|
49
|
+
it { expect('1.1').to be_parsed_as("1.1") }
|
50
|
+
it { expect('0.1').to be_parsed_as("0.1") }
|
51
|
+
it { expect('0.0').to be_parsed_as("0.0") }
|
52
|
+
it { expect('-1.1').to be_parsed_as("-1.1") }
|
53
|
+
it { expect('-0.1').to be_parsed_as("-0.1") }
|
54
|
+
it { expect('1.10').to be_parsed_as("1.10") }
|
55
55
|
# string
|
56
|
-
it { '12e8'.
|
57
|
-
it { '12.1e7'.
|
58
|
-
it { '-12e8'.
|
59
|
-
it { '-12.1e7'.
|
60
|
-
it { '.0'.
|
61
|
-
it { '.1'.
|
62
|
-
it { '0.'.
|
63
|
-
it { '1.'.
|
64
|
-
it { '.0a'.
|
65
|
-
it { '1.a'.
|
66
|
-
it { '0@'.
|
56
|
+
it { expect('12e8').to be_parsed_as("12e8") }
|
57
|
+
it { expect('12.1e7').to be_parsed_as("12.1e7") }
|
58
|
+
it { expect('-12e8').to be_parsed_as("-12e8") }
|
59
|
+
it { expect('-12.1e7').to be_parsed_as("-12.1e7") }
|
60
|
+
it { expect('.0').to be_parsed_as(".0") }
|
61
|
+
it { expect('.1').to be_parsed_as(".1") }
|
62
|
+
it { expect('0.').to be_parsed_as("0.") }
|
63
|
+
it { expect('1.').to be_parsed_as("1.") }
|
64
|
+
it { expect('.0a').to be_parsed_as(".0a") }
|
65
|
+
it { expect('1.a').to be_parsed_as("1.a") }
|
66
|
+
it { expect('0@').to be_parsed_as("0@") }
|
67
67
|
end
|
68
68
|
|
69
69
|
describe 'float keywords parsing' do
|
70
|
-
it { 'NaN'.
|
71
|
-
it { 'Infinity'.
|
72
|
-
it { '-Infinity'.
|
73
|
-
it { 'NaNX'.
|
74
|
-
it { 'InfinityX'.
|
75
|
-
it { '-InfinityX'.
|
70
|
+
it { expect('NaN').to be_parsed_as("NaN") }
|
71
|
+
it { expect('Infinity').to be_parsed_as("Infinity") }
|
72
|
+
it { expect('-Infinity').to be_parsed_as("-Infinity") }
|
73
|
+
it { expect('NaNX').to be_parsed_as("NaNX") }
|
74
|
+
it { expect('InfinityX').to be_parsed_as("InfinityX") }
|
75
|
+
it { expect('-InfinityX').to be_parsed_as("-InfinityX") }
|
76
76
|
end
|
77
77
|
|
78
78
|
describe 'quoted string' do
|
79
|
-
it { '""'.
|
80
|
-
it { '"text"'.
|
81
|
-
it { '"\\""'.
|
82
|
-
it { '"\\t"'.
|
83
|
-
it { '"\\n"'.
|
84
|
-
it { '"\\r\\n"'.
|
85
|
-
it { '"\\f\\b"'.
|
86
|
-
it { '"\\.t"'.
|
87
|
-
it { '"\\$t"'.
|
88
|
-
it { '"\\#t"'.
|
89
|
-
it { '"\\z"'.
|
90
|
-
it { '"\\0"'.
|
91
|
-
it { '"\\1"'.
|
92
|
-
it { '"t'.
|
93
|
-
it { 't"'.
|
94
|
-
it { '"."'.
|
95
|
-
it { '"*"'.
|
96
|
-
it { '"@"'.
|
97
|
-
it { '"\\#{test}"'.
|
98
|
-
it { '"$"'.
|
99
|
-
it { '"$t"'.
|
100
|
-
it { '"$}"'.
|
79
|
+
it { expect('""').to be_parsed_as("") }
|
80
|
+
it { expect('"text"').to be_parsed_as("text") }
|
81
|
+
it { expect('"\\""').to be_parsed_as("\"") }
|
82
|
+
it { expect('"\\t"').to be_parsed_as("\t") }
|
83
|
+
it { expect('"\\n"').to be_parsed_as("\n") }
|
84
|
+
it { expect('"\\r\\n"').to be_parsed_as("\r\n") }
|
85
|
+
it { expect('"\\f\\b"').to be_parsed_as("\f\b") }
|
86
|
+
it { expect('"\\.t"').to be_parsed_as(".t") }
|
87
|
+
it { expect('"\\$t"').to be_parsed_as("$t") }
|
88
|
+
it { expect('"\\#t"').to be_parsed_as("#t") }
|
89
|
+
it { expect('"\\z"').to be_parse_error } # unknown escaped character
|
90
|
+
it { expect('"\\0"').to be_parse_error } # unknown escaped character
|
91
|
+
it { expect('"\\1"').to be_parse_error } # unknown escaped character
|
92
|
+
it { expect('"t').to be_parse_error } # non-terminated quoted character
|
93
|
+
it { expect('t"').to be_parsed_as('t"') }
|
94
|
+
it { expect('"."').to be_parsed_as('.') }
|
95
|
+
it { expect('"*"').to be_parsed_as('*') }
|
96
|
+
it { expect('"@"').to be_parsed_as('@') }
|
97
|
+
it { expect('"\\#{test}"').to be_parsed_as("\#{test}") }
|
98
|
+
it { expect('"$"').to be_parsed_as('$') }
|
99
|
+
it { expect('"$t"').to be_parsed_as('$t') }
|
100
|
+
it { expect('"$}"').to be_parsed_as('$}') }
|
101
101
|
end
|
102
102
|
|
103
103
|
describe 'nonquoted string parsing' do
|
104
104
|
# empty
|
105
|
-
it { ''.
|
106
|
-
|
107
|
-
it { 't'.
|
108
|
-
it { 'T'.
|
109
|
-
it { '_'.
|
110
|
-
it { 'T1'.
|
111
|
-
it { '_2'.
|
112
|
-
it { 't0'.
|
113
|
-
it { 't@'.
|
114
|
-
it { 't-'.
|
115
|
-
it { 't.'.
|
116
|
-
it { 't+'.
|
117
|
-
it { 't/'.
|
118
|
-
it { 't='.
|
119
|
-
it { 't,'.
|
120
|
-
it { '0t'.
|
121
|
-
it { '@1t'.
|
122
|
-
it { '-1t'.
|
123
|
-
it { '.1t'.
|
124
|
-
it { ',1t'.
|
125
|
-
it { '.t'.
|
126
|
-
it { '*t'.
|
127
|
-
it { '@t'.
|
128
|
-
it { '$t'.
|
129
|
-
it { '{t'.
|
130
|
-
it { 't{'.
|
131
|
-
it { '}t'.
|
132
|
-
it { '[t'.
|
133
|
-
it { 't['.
|
134
|
-
it { ']t'.
|
135
|
-
it { '$t'.
|
136
|
-
it { 't:'.
|
137
|
-
it { 't;'.
|
138
|
-
it { 't?'.
|
139
|
-
it { 't^'.
|
140
|
-
it { 't`'.
|
141
|
-
it { 't~'.
|
142
|
-
it { 't|'.
|
143
|
-
it { 't>'.
|
144
|
-
it { 't<'.
|
145
|
-
it { 't('.
|
146
|
-
it { 't['.
|
105
|
+
it { expect('').to be_parsed_as(nil) }
|
106
|
+
|
107
|
+
it { expect('t').to be_parsed_as('t') }
|
108
|
+
it { expect('T').to be_parsed_as('T') }
|
109
|
+
it { expect('_').to be_parsed_as('_') }
|
110
|
+
it { expect('T1').to be_parsed_as('T1') }
|
111
|
+
it { expect('_2').to be_parsed_as('_2') }
|
112
|
+
it { expect('t0').to be_parsed_as('t0') }
|
113
|
+
it { expect('t@').to be_parsed_as('t@') }
|
114
|
+
it { expect('t-').to be_parsed_as('t-') }
|
115
|
+
it { expect('t.').to be_parsed_as('t.') }
|
116
|
+
it { expect('t+').to be_parsed_as('t+') }
|
117
|
+
it { expect('t/').to be_parsed_as('t/') }
|
118
|
+
it { expect('t=').to be_parsed_as('t=') }
|
119
|
+
it { expect('t,').to be_parsed_as('t,') }
|
120
|
+
it { expect('0t').to be_parsed_as("0t") }
|
121
|
+
it { expect('@1t').to be_parsed_as('@1t') }
|
122
|
+
it { expect('-1t').to be_parsed_as('-1t') }
|
123
|
+
it { expect('.1t').to be_parsed_as('.1t') }
|
124
|
+
it { expect(',1t').to be_parsed_as(',1t') }
|
125
|
+
it { expect('.t').to be_parsed_as('.t') }
|
126
|
+
it { expect('*t').to be_parsed_as('*t') }
|
127
|
+
it { expect('@t').to be_parsed_as('@t') }
|
128
|
+
it { expect('$t').to be_parsed_as('$t') }
|
129
|
+
it { expect('{t').to be_parse_error } # '{' begins map
|
130
|
+
it { expect('t{').to be_parsed_as('t{') }
|
131
|
+
it { expect('}t').to be_parsed_as('}t') }
|
132
|
+
it { expect('[t').to be_parse_error } # '[' begins array
|
133
|
+
it { expect('t[').to be_parsed_as('t[') }
|
134
|
+
it { expect(']t').to be_parsed_as(']t') }
|
135
|
+
it { expect('$t').to be_parsed_as('$t') }
|
136
|
+
it { expect('t:').to be_parsed_as('t:') }
|
137
|
+
it { expect('t;').to be_parsed_as('t;') }
|
138
|
+
it { expect('t?').to be_parsed_as('t?') }
|
139
|
+
it { expect('t^').to be_parsed_as('t^') }
|
140
|
+
it { expect('t`').to be_parsed_as('t`') }
|
141
|
+
it { expect('t~').to be_parsed_as('t~') }
|
142
|
+
it { expect('t|').to be_parsed_as('t|') }
|
143
|
+
it { expect('t>').to be_parsed_as('t>') }
|
144
|
+
it { expect('t<').to be_parsed_as('t<') }
|
145
|
+
it { expect('t(').to be_parsed_as('t(') }
|
146
|
+
it { expect('t[').to be_parsed_as('t[') }
|
147
147
|
end
|
148
148
|
|
149
149
|
describe 'embedded ruby code parsing' do
|
150
|
-
it { '"#{v1}"'.
|
151
|
-
it { '"#{v2}"'.
|
152
|
-
it { '"#{v3}"'.
|
153
|
-
it { '"#{1+1}"'.
|
154
|
-
it { '"#{}"'.
|
155
|
-
it { '"t#{v1}"'.
|
156
|
-
it { '"t#{v1}t"'.
|
157
|
-
it { '"#{"}"}"'.
|
158
|
-
it { '"#{#}"'.
|
159
|
-
it { "\"\#{\n=begin\n}\"".
|
150
|
+
it { expect('"#{v1}"').to be_parsed_as("#{v1}") }
|
151
|
+
it { expect('"#{v2}"').to be_parsed_as("#{v2}") }
|
152
|
+
it { expect('"#{v3}"').to be_parsed_as("#{v3}") }
|
153
|
+
it { expect('"#{1+1}"').to be_parsed_as("2") }
|
154
|
+
it { expect('"#{}"').to be_parsed_as("") }
|
155
|
+
it { expect('"t#{v1}"').to be_parsed_as("t#{v1}") }
|
156
|
+
it { expect('"t#{v1}t"').to be_parsed_as("t#{v1}t") }
|
157
|
+
it { expect('"#{"}"}"').to be_parsed_as("}") }
|
158
|
+
it { expect('"#{#}"').to be_parse_error } # error in embedded ruby code
|
159
|
+
it { expect("\"\#{\n=begin\n}\"").to be_parse_error } # error in embedded ruby code
|
160
160
|
end
|
161
161
|
|
162
162
|
describe 'array parsing' do
|
163
|
-
it { '[]'.
|
164
|
-
it { '[1]'.
|
165
|
-
it { '[1,2]'.
|
166
|
-
it { '[1, 2]'.
|
167
|
-
it { '[ 1 , 2 ]'.
|
168
|
-
it { '[1,2,]'.
|
169
|
-
it { "[\n1\n,\n2\n]".
|
170
|
-
it { '["a"]'.
|
171
|
-
it { '["a","b"]'.
|
172
|
-
it { '[ "a" , "b" ]'.
|
173
|
-
it { "[\n\"a\"\n,\n\"b\"\n]".
|
174
|
-
it { '["ab","cd"]'.
|
163
|
+
it { expect('[]').to be_parsed_as_json([]) }
|
164
|
+
it { expect('[1]').to be_parsed_as_json([1]) }
|
165
|
+
it { expect('[1,2]').to be_parsed_as_json([1,2]) }
|
166
|
+
it { expect('[1, 2]').to be_parsed_as_json([1,2]) }
|
167
|
+
it { expect('[ 1 , 2 ]').to be_parsed_as_json([1,2]) }
|
168
|
+
it { expect('[1,2,]').to be_parse_error } # TODO: Need trailing commas support?
|
169
|
+
it { expect("[\n1\n,\n2\n]").to be_parsed_as_json([1,2]) }
|
170
|
+
it { expect('["a"]').to be_parsed_as_json(["a"]) }
|
171
|
+
it { expect('["a","b"]').to be_parsed_as_json(["a","b"]) }
|
172
|
+
it { expect('[ "a" , "b" ]').to be_parsed_as_json(["a","b"]) }
|
173
|
+
it { expect("[\n\"a\"\n,\n\"b\"\n]").to be_parsed_as_json(["a","b"]) }
|
174
|
+
it { expect('["ab","cd"]').to be_parsed_as_json(["ab","cd"]) }
|
175
175
|
end
|
176
176
|
|
177
177
|
describe 'map parsing' do
|
178
|
-
it { '{}'.
|
179
|
-
it { '{"a":1}'.
|
180
|
-
it { '{"a":1,"b":2}'.
|
181
|
-
it { '{ "a" : 1 , "b" : 2 }'.
|
182
|
-
it { '{"a":1,"b":2,}'.
|
183
|
-
it { "{\n\"a\"\n:\n1\n,\n\"b\"\n:\n2\n}".
|
184
|
-
it { '{"a":"b"}'.
|
185
|
-
it { '{"a":"b","c":"d"}'.
|
186
|
-
it { '{ "a" : "b" , "c" : "d" }'.
|
187
|
-
it { "{\n\"a\"\n:\n\"b\"\n,\n\"c\"\n:\n\"d\"\n}".
|
178
|
+
it { expect('{}').to be_parsed_as_json({}) }
|
179
|
+
it { expect('{"a":1}').to be_parsed_as_json({"a"=>1}) }
|
180
|
+
it { expect('{"a":1,"b":2}').to be_parsed_as_json({"a"=>1,"b"=>2}) }
|
181
|
+
it { expect('{ "a" : 1 , "b" : 2 }').to be_parsed_as_json({"a"=>1,"b"=>2}) }
|
182
|
+
it { expect('{"a":1,"b":2,}').to be_parse_error } # TODO: Need trailing commas support?
|
183
|
+
it { expect("{\n\"a\"\n:\n1\n,\n\"b\"\n:\n2\n}").to be_parsed_as_json({"a"=>1,"b"=>2}) }
|
184
|
+
it { expect('{"a":"b"}').to be_parsed_as_json({"a"=>"b"}) }
|
185
|
+
it { expect('{"a":"b","c":"d"}').to be_parsed_as_json({"a"=>"b","c"=>"d"}) }
|
186
|
+
it { expect('{ "a" : "b" , "c" : "d" }').to be_parsed_as_json({"a"=>"b","c"=>"d"}) }
|
187
|
+
it { expect("{\n\"a\"\n:\n\"b\"\n,\n\"c\"\n:\n\"d\"\n}").to be_parsed_as_json({"a"=>"b","c"=>"d"}) }
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|