puppet 5.1.0-universal-darwin → 5.2.0-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/lib/puppet.rb +6 -53
- data/lib/puppet/application.rb +14 -7
- data/lib/puppet/application/agent.rb +6 -2
- data/lib/puppet/application/apply.rb +6 -2
- data/lib/puppet/application/cert.rb +6 -2
- data/lib/puppet/application/describe.rb +6 -2
- data/lib/puppet/application/device.rb +40 -29
- data/lib/puppet/application/doc.rb +6 -2
- data/lib/puppet/application/filebucket.rb +6 -2
- data/lib/puppet/application/lookup.rb +6 -2
- data/lib/puppet/application/master.rb +6 -2
- data/lib/puppet/application/resource.rb +6 -2
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/certificate_request.rb +1 -1
- data/lib/puppet/face/certificate_revocation_list.rb +1 -1
- data/lib/puppet/face/help.rb +17 -13
- data/lib/puppet/file_serving/configuration.rb +3 -0
- data/lib/puppet/file_serving/configuration/parser.rb +2 -0
- data/lib/puppet/file_serving/mount/tasks.rb +21 -0
- data/lib/puppet/functions/epp.rb +3 -0
- data/lib/puppet/functions/lookup.rb +2 -1
- data/lib/puppet/generate/models/type/property.rb +1 -1
- data/lib/puppet/gettext/config.rb +70 -0
- data/lib/puppet/gettext/stubs.rb +11 -0
- data/lib/puppet/indirector/request.rb +4 -4
- data/lib/puppet/info_service.rb +10 -0
- data/lib/puppet/info_service/task_information_service.rb +32 -0
- data/lib/puppet/module.rb +43 -12
- data/lib/puppet/module/task.rb +90 -0
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/functions/dig.rb +11 -2
- data/lib/puppet/parser/functions/epp.rb +3 -0
- data/lib/puppet/parser/functions/new.rb +8 -8
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +1 -0
- data/lib/puppet/pops/issues.rb +11 -5
- data/lib/puppet/pops/loader/static_loader.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +42 -2
- data/lib/puppet/pops/model/model_tree_dumper.rb +1 -1
- data/lib/puppet/pops/parser/egrammar.ra +30 -9
- data/lib/puppet/pops/parser/eparser.rb +1094 -1043
- data/lib/puppet/pops/patterns.rb +1 -1
- data/lib/puppet/pops/serialization/from_data_converter.rb +1 -1
- data/lib/puppet/pops/serialization/json_path.rb +1 -1
- data/lib/puppet/pops/serialization/to_data_converter.rb +12 -3
- data/lib/puppet/pops/types/p_object_type.rb +31 -3
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +3 -3
- data/lib/puppet/pops/types/p_timespan_type.rb +1 -1
- data/lib/puppet/pops/types/p_timestamp_type.rb +1 -1
- data/lib/puppet/pops/types/string_converter.rb +15 -12
- data/lib/puppet/pops/types/type_calculator.rb +1 -1
- data/lib/puppet/pops/types/type_factory.rb +7 -0
- data/lib/puppet/pops/types/type_formatter.rb +1 -1
- data/lib/puppet/pops/types/type_mismatch_describer.rb +86 -130
- data/lib/puppet/pops/types/type_parser.rb +10 -4
- data/lib/puppet/pops/types/types.rb +81 -22
- data/lib/puppet/provider/package/aix.rb +4 -4
- data/lib/puppet/provider/package/yum.rb +1 -0
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/mount.rb +1 -1
- data/lib/puppet/type/sshkey.rb +9 -1
- data/lib/puppet/util.rb +1 -1
- data/lib/puppet/util/command_line.rb +1 -1
- data/lib/puppet/util/log.rb +15 -10
- data/lib/puppet/util/windows/api_types.rb +9 -5
- data/lib/puppet/util/windows/process.rb +9 -1
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +1 -3
- data/lib/puppet/version.rb +1 -1
- data/locales/ja/puppet.po +9270 -0
- data/locales/puppet.pot +272 -212
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-plugin-output.txt +36 -0
- data/spec/integration/indirector/file_content/file_server_spec.rb +17 -0
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +10 -0
- data/spec/integration/util/windows/process_spec.rb +45 -0
- data/spec/lib/puppet_spec/modules.rb +10 -0
- data/spec/shared_contexts/types_setup.rb +19 -4
- data/spec/spec_helper.rb +6 -7
- data/spec/unit/face/help_spec.rb +2 -2
- data/spec/unit/file_serving/configuration_spec.rb +14 -4
- data/spec/unit/file_serving/mount/modules_spec.rb +1 -1
- data/spec/unit/file_serving/mount/tasks_spec.rb +72 -0
- data/spec/unit/functions/epp_spec.rb +5 -0
- data/spec/unit/functions/regsubst_spec.rb +1 -1
- data/spec/unit/gettext_config_spec.rb +57 -0
- data/spec/unit/indirector/request_spec.rb +41 -0
- data/spec/unit/info_service_spec.rb +66 -2
- data/spec/unit/module_spec.rb +81 -1
- data/spec/unit/parser/ast/leaf_spec.rb +3 -4
- data/spec/unit/pops/evaluator/access_ops_spec.rb +5 -0
- data/spec/unit/pops/factory_spec.rb +5 -1
- data/spec/unit/pops/parser/parser_spec.rb +138 -0
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +74 -1
- data/spec/unit/pops/types/p_init_type_spec.rb +1 -1
- data/spec/unit/pops/types/p_object_type_spec.rb +217 -33
- data/spec/unit/pops/types/p_timespan_type_spec.rb +7 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +7 -0
- data/spec/unit/pops/types/string_converter_spec.rb +48 -11
- data/spec/unit/pops/types/type_calculator_spec.rb +37 -5
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +12 -0
- data/spec/unit/pops/types/type_parser_spec.rb +25 -0
- data/spec/unit/pops/validator/validator_spec.rb +2 -2
- data/spec/unit/provider/package/aix_spec.rb +26 -1
- data/spec/unit/provider/package/yum_spec.rb +10 -0
- data/spec/unit/task_spec.rb +102 -0
- data/spec/unit/util/log_spec.rb +32 -3
- data/spec/unit/util/windows/api_types_spec.rb +51 -0
- metadata +3476 -3450
- checksums.yaml +0 -7
@@ -191,7 +191,7 @@ describe 'The Init Type' do
|
|
191
191
|
expect(eval_and_collect_notices(code)).to eql(['true'])
|
192
192
|
end
|
193
193
|
|
194
|
-
it 'T1 is assignable to Init[T2] if T2 can be created from instance of T1
|
194
|
+
it 'T1 is assignable to Init[T2] if T2 can be created from instance of T1' do
|
195
195
|
code = <<-CODE
|
196
196
|
notice(Integer < Init[String])
|
197
197
|
CODE
|
@@ -91,6 +91,19 @@ describe 'The Object Type' do
|
|
91
91
|
expect(attr.value?).to be_truthy
|
92
92
|
end
|
93
93
|
|
94
|
+
it 'attribute value can be defined using heredoc?' do
|
95
|
+
tp = parse_object('MyObject', <<-OBJECT.unindent)
|
96
|
+
attributes => {
|
97
|
+
a => { type => String, value => @(END) }
|
98
|
+
The value is some
|
99
|
+
multiline text
|
100
|
+
|-END
|
101
|
+
}
|
102
|
+
OBJECT
|
103
|
+
attr = tp['a']
|
104
|
+
expect(attr.value).to eql("The value is some\nmultiline text")
|
105
|
+
end
|
106
|
+
|
94
107
|
it 'attribute without defined value responds false to value?' do
|
95
108
|
tp = parse_object('MyObject', <<-OBJECT)
|
96
109
|
attributes => {
|
@@ -122,44 +135,88 @@ describe 'The Object Type' do
|
|
122
135
|
end
|
123
136
|
|
124
137
|
context 'that are constants' do
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
kind => constant,
|
131
|
-
value => 3
|
138
|
+
context 'and declared under key "constants"' do
|
139
|
+
it 'sets final => true' do
|
140
|
+
tp = parse_object('MyObject', <<-OBJECT)
|
141
|
+
constants => {
|
142
|
+
a => 3
|
132
143
|
}
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
a => {
|
142
|
-
type => Integer,
|
143
|
-
kind => constant
|
144
|
+
OBJECT
|
145
|
+
expect(tp['a'].final?).to be_truthy
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'sets kind => constant' do
|
149
|
+
tp = parse_object('MyObject', <<-OBJECT)
|
150
|
+
constants => {
|
151
|
+
a => 3
|
144
152
|
}
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
153
|
+
OBJECT
|
154
|
+
expect(tp['a'].constant?).to be_truthy
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'infers generic type from value' do
|
158
|
+
tp = parse_object('MyObject', <<-OBJECT)
|
159
|
+
constants => {
|
160
|
+
a => 3
|
161
|
+
}
|
162
|
+
OBJECT
|
163
|
+
expect(tp['a'].type.to_s).to eql('Integer')
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'cannot have the same name as an attribute' do
|
167
|
+
obj = <<-OBJECT
|
168
|
+
constants => {
|
169
|
+
a => 3
|
170
|
+
},
|
171
|
+
attributes => {
|
172
|
+
a => Integer
|
173
|
+
}
|
174
|
+
OBJECT
|
175
|
+
expect { parse_object('MyObject', obj) }.to raise_error(Puppet::ParseError,
|
176
|
+
'attribute MyObject[a] is defined as both a constant and an attribute')
|
177
|
+
end
|
149
178
|
end
|
150
179
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
180
|
+
context 'and declared under key "attributes"' do
|
181
|
+
it 'sets final => true when declard in attributes' do
|
182
|
+
tp = parse_object('MyObject', <<-OBJECT)
|
183
|
+
attributes => {
|
184
|
+
a => {
|
185
|
+
type => Integer,
|
186
|
+
kind => constant,
|
187
|
+
value => 3
|
188
|
+
}
|
158
189
|
}
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
190
|
+
OBJECT
|
191
|
+
expect(tp['a'].final?).to be_truthy
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'raises an error when no value is declared' do
|
195
|
+
obj = <<-OBJECT
|
196
|
+
attributes => {
|
197
|
+
a => {
|
198
|
+
type => Integer,
|
199
|
+
kind => constant
|
200
|
+
}
|
201
|
+
}
|
202
|
+
OBJECT
|
203
|
+
expect { parse_object('MyObject', obj) }.to raise_error(Puppet::ParseError,
|
204
|
+
"attribute MyObject[a] of kind 'constant' requires a value")
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'raises an error when final => false' do
|
208
|
+
obj = <<-OBJECT
|
209
|
+
attributes => {
|
210
|
+
a => {
|
211
|
+
type => Integer,
|
212
|
+
kind => constant,
|
213
|
+
final => false
|
214
|
+
}
|
215
|
+
}
|
216
|
+
OBJECT
|
217
|
+
expect { parse_object('MyObject', obj) }.to raise_error(Puppet::ParseError,
|
218
|
+
"attribute MyObject[a] of kind 'constant' cannot be combined with final => false")
|
219
|
+
end
|
163
220
|
end
|
164
221
|
end
|
165
222
|
end
|
@@ -207,6 +264,24 @@ describe 'The Object Type' do
|
|
207
264
|
expect(tp['a'].type).to eql(PIntegerType.new(0,10))
|
208
265
|
end
|
209
266
|
|
267
|
+
it 'can redefine inherited constant to assignable type' do
|
268
|
+
parent = <<-OBJECT
|
269
|
+
constants => {
|
270
|
+
a => 23
|
271
|
+
}
|
272
|
+
OBJECT
|
273
|
+
obj = <<-OBJECT
|
274
|
+
parent => MyObject,
|
275
|
+
constants => {
|
276
|
+
a => 46
|
277
|
+
}
|
278
|
+
OBJECT
|
279
|
+
tp = parse_object('MyObject', parent)
|
280
|
+
td = parse_object('MyDerivedObject', obj)
|
281
|
+
expect(tp['a'].value).to eql(23)
|
282
|
+
expect(td['a'].value).to eql(46)
|
283
|
+
end
|
284
|
+
|
210
285
|
it 'raises an error when an attribute overrides a function' do
|
211
286
|
parent = <<-OBJECT
|
212
287
|
attributes => {
|
@@ -845,6 +920,115 @@ describe 'The Object Type' do
|
|
845
920
|
/attribute MySecondObject\[a\] attempts to override final attribute MyObject\[a\]/)
|
846
921
|
end
|
847
922
|
|
923
|
+
context 'type alias using bracket-less (implicit Object) form' do
|
924
|
+
let(:logs) { [] }
|
925
|
+
let(:notices) { logs.select { |log| log.level == :notice }.map { |log| log.message } }
|
926
|
+
let(:warnings) { logs.select { |log| log.level == :warning }.map { |log| log.message } }
|
927
|
+
let(:node) { Puppet::Node.new('example.com') }
|
928
|
+
let(:compiler) { Puppet::Parser::Compiler.new(node) }
|
929
|
+
|
930
|
+
def compile(code)
|
931
|
+
Puppet[:code] = code
|
932
|
+
Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) { compiler.compile }
|
933
|
+
end
|
934
|
+
|
935
|
+
it 'Object is implicit' do
|
936
|
+
compile(<<-CODE)
|
937
|
+
type MyObject = { name => 'MyFirstObject', attributes => { a => Integer}}
|
938
|
+
notice(MyObject =~ Type)
|
939
|
+
notice(MyObject(3))
|
940
|
+
CODE
|
941
|
+
expect(warnings).to be_empty
|
942
|
+
expect(notices).to eql(['true', "MyObject({'a' => 3})"])
|
943
|
+
end
|
944
|
+
|
945
|
+
it 'Object can be specified' do
|
946
|
+
compile(<<-CODE)
|
947
|
+
type MyObject = Object { name => 'MyFirstObject', attributes => { a =>Integer }}
|
948
|
+
notice(MyObject =~ Type)
|
949
|
+
notice(MyObject(3))
|
950
|
+
CODE
|
951
|
+
expect(warnings).to be_empty
|
952
|
+
expect(notices).to eql(['true', "MyObject({'a' => 3})"])
|
953
|
+
end
|
954
|
+
|
955
|
+
it 'parent can be specified before the hash' do
|
956
|
+
compile(<<-CODE)
|
957
|
+
type MyObject = { name => 'MyFirstObject', attributes => { a => String }}
|
958
|
+
type MySecondObject = MyObject { attributes => { b => String }}
|
959
|
+
notice(MySecondObject =~ Type)
|
960
|
+
notice(MySecondObject < MyObject)
|
961
|
+
notice(MyObject('hi'))
|
962
|
+
notice(MySecondObject('hello', 'world'))
|
963
|
+
CODE
|
964
|
+
expect(warnings).to be_empty
|
965
|
+
expect(notices).to eql(
|
966
|
+
['true', 'true', "MyObject({'a' => 'hi'})", "MySecondObject({'a' => 'hello', 'b' => 'world'})"])
|
967
|
+
end
|
968
|
+
|
969
|
+
it 'parent can be specified in the hash' do
|
970
|
+
Puppet[:strict] = 'warning'
|
971
|
+
compile(<<-CODE)
|
972
|
+
type MyObject = { name => 'MyFirstObject', attributes => { a => String }}
|
973
|
+
type MySecondObject = { parent => MyOtherType, attributes => { b => String }}
|
974
|
+
notice(MySecondObject =~ Type)
|
975
|
+
CODE
|
976
|
+
expect(warnings).to be_empty
|
977
|
+
expect(notices).to eql(['true'])
|
978
|
+
end
|
979
|
+
|
980
|
+
it 'Object before the hash and parent inside the hash can be combined' do
|
981
|
+
Puppet[:strict] = 'warning'
|
982
|
+
compile(<<-CODE)
|
983
|
+
type MyObject = { name => 'MyFirstObject', attributes => { a => String }}
|
984
|
+
type MySecondObject = Object { parent => MyOtherType, attributes => { b => String }}
|
985
|
+
notice(MySecondObject =~ Type)
|
986
|
+
CODE
|
987
|
+
expect(warnings).to be_empty
|
988
|
+
expect(notices).to eql(['true'])
|
989
|
+
end
|
990
|
+
|
991
|
+
it 'if strict == warning, a warning is issued when the same is parent specified both before and inside the hash' do
|
992
|
+
Puppet[:strict] = 'warning'
|
993
|
+
compile(<<-CODE)
|
994
|
+
type MyObject = { name => 'MyFirstObject', attributes => { a => String }}
|
995
|
+
type MySecondObject = MyObject { parent => MyObject, attributes => { b => String }}
|
996
|
+
notice(MySecondObject =~ Type)
|
997
|
+
CODE
|
998
|
+
expect(notices).to eql(['true'])
|
999
|
+
expect(warnings).to eql(["The key 'parent' is declared more than once"])
|
1000
|
+
end
|
1001
|
+
|
1002
|
+
it 'if strict == warning, a warning is issued when different parents are specified before and inside the hash. The former overrides the latter' do
|
1003
|
+
Puppet[:strict] = 'warning'
|
1004
|
+
compile(<<-CODE)
|
1005
|
+
type MyObject = { name => 'MyFirstObject', attributes => { a => String }}
|
1006
|
+
type MySecondObject = MyObject { parent => MyObject, attributes => { b => String }}
|
1007
|
+
notice(MySecondObject =~ Type)
|
1008
|
+
CODE
|
1009
|
+
expect(notices).to eql(['true'])
|
1010
|
+
expect(warnings).to eql(["The key 'parent' is declared more than once"])
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
it 'if strict == error, an error is raised when the same parent is specified both before and inside the hash' do
|
1014
|
+
Puppet[:strict] = 'error'
|
1015
|
+
expect { compile(<<-CODE) }.to raise_error(/The key 'parent' is declared more than once/)
|
1016
|
+
type MyObject = { name => 'MyFirstObject', attributes => { a => String }}
|
1017
|
+
type MySecondObject = MyObject { parent => MyObject, attributes => { b => String }}
|
1018
|
+
notice(MySecondObject =~ Type)
|
1019
|
+
CODE
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
it 'if strict == error, an error is raised when different parents are specified before and inside the hash' do
|
1023
|
+
Puppet[:strict] = 'error'
|
1024
|
+
expect { compile(<<-CODE) }.to raise_error(/The key 'parent' is declared more than once/)
|
1025
|
+
type MyObject = { name => 'MyFirstObject', attributes => { a => String }}
|
1026
|
+
type MySecondObject = MyObject { parent => MyOtherType, attributes => { b => String }}
|
1027
|
+
notice(MySecondObject =~ Type)
|
1028
|
+
CODE
|
1029
|
+
end
|
1030
|
+
end
|
1031
|
+
|
848
1032
|
it 'can inherit from an aliased type' do
|
849
1033
|
code = <<-CODE
|
850
1034
|
type MyObject = Object[{ name => 'MyFirstObject', attributes => { a => Integer }}]
|
@@ -107,6 +107,13 @@ describe 'Timespan type' do
|
|
107
107
|
%w(1-11:23:13.0 0-11:23:13.0 1-11:23:00.0 1-11:00:00.0 0-11:23:00.0 0-00:23:13.0 1-00:00:00.0 0-11:00:00.0 0-00:23:00.0 0-00:00:13.0))
|
108
108
|
end
|
109
109
|
|
110
|
+
it 'it cannot be created using an empty formats array' do
|
111
|
+
code = <<-CODE
|
112
|
+
notice(Timespan('1d11h23m13s', []))
|
113
|
+
CODE
|
114
|
+
expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /parameter 'format' variant 1 expects size to be at least 1, got 0/)
|
115
|
+
end
|
116
|
+
|
110
117
|
it 'can be created from a integer that represents seconds since epoch' do
|
111
118
|
code = <<-CODE
|
112
119
|
$o = Timespan(6800)
|
@@ -163,6 +163,13 @@ describe 'Timestamp type' do
|
|
163
163
|
['2016-08-28T12:15:00.000000000 UTC', '2016-07-24T01:20:00.000000000 UTC', '2016-06-21T18:23:15.000000000 UTC'])
|
164
164
|
end
|
165
165
|
|
166
|
+
it 'it cannot be created using an empty formats array' do
|
167
|
+
code = <<-CODE
|
168
|
+
notice(Timestamp('2015-03-01T11:12:13', []))
|
169
|
+
CODE
|
170
|
+
expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /parameter 'format' variant 1 expects size to be at least 1, got 0/)
|
171
|
+
end
|
172
|
+
|
166
173
|
it 'can be created from a string, array of formats, and a timezone' do
|
167
174
|
code = <<-CODE
|
168
175
|
$fmts = [
|
@@ -87,6 +87,12 @@ describe 'The string converter' do
|
|
87
87
|
end.to raise_error(/Only one of the delimiters/)
|
88
88
|
end
|
89
89
|
|
90
|
+
it "Is an error to have trailing characters after the format" do
|
91
|
+
expect do
|
92
|
+
fmt = format.new("%dv")
|
93
|
+
end.to raise_error(/The format '%dv' is not a valid format/)
|
94
|
+
end
|
95
|
+
|
90
96
|
it "Is an error to specify the same flag more than once" do
|
91
97
|
expect do
|
92
98
|
fmt = format.new("%[[d")
|
@@ -644,15 +650,19 @@ describe 'The string converter' do
|
|
644
650
|
"% a" => "1, 'hello'",
|
645
651
|
|
646
652
|
{'format' => '%(a',
|
647
|
-
'separator' => ''
|
653
|
+
'separator' => ' '
|
648
654
|
} => "(1 'hello')",
|
649
655
|
|
650
|
-
{'format' => '
|
656
|
+
{'format' => '%(a',
|
651
657
|
'separator' => ''
|
658
|
+
} => "(1'hello')",
|
659
|
+
|
660
|
+
{'format' => '%|a',
|
661
|
+
'separator' => ' '
|
652
662
|
} => "|1 'hello'|",
|
653
663
|
|
654
664
|
{'format' => '%(a',
|
655
|
-
'separator' => '',
|
665
|
+
'separator' => ' ',
|
656
666
|
'string_formats' => {Puppet::Pops::Types::PIntegerType::DEFAULT => '%#x'}
|
657
667
|
} => "(0x1 'hello')",
|
658
668
|
}.each do |fmt, result |
|
@@ -674,7 +684,7 @@ describe 'The string converter' do
|
|
674
684
|
end
|
675
685
|
|
676
686
|
it 'indents elements in alternate mode' do
|
677
|
-
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#a', 'separator' =>"," } }
|
687
|
+
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#a', 'separator' =>", " } }
|
678
688
|
# formatting matters here
|
679
689
|
result = [
|
680
690
|
"[1, 2, 9, 9,",
|
@@ -689,7 +699,7 @@ describe 'The string converter' do
|
|
689
699
|
end
|
690
700
|
|
691
701
|
it 'treats hashes as nested arrays wrt indentation' do
|
692
|
-
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#a', 'separator' =>"," } }
|
702
|
+
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#a', 'separator' =>", " } }
|
693
703
|
# formatting matters here
|
694
704
|
result = [
|
695
705
|
"[1, 2, 9, 9,",
|
@@ -704,7 +714,7 @@ describe 'The string converter' do
|
|
704
714
|
end
|
705
715
|
|
706
716
|
it 'indents and breaks when a sequence > given width, in alternate mode' do
|
707
|
-
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#3a', 'separator' =>"," } }
|
717
|
+
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#3a', 'separator' =>", " } }
|
708
718
|
# formatting matters here
|
709
719
|
result = [
|
710
720
|
"[ 1,",
|
@@ -722,7 +732,7 @@ describe 'The string converter' do
|
|
722
732
|
end
|
723
733
|
|
724
734
|
it 'indents and breaks when a sequence (placed last) > given width, in alternate mode' do
|
725
|
-
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#3a', 'separator' =>"," } }
|
735
|
+
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#3a', 'separator' =>", " } }
|
726
736
|
# formatting matters here
|
727
737
|
result = [
|
728
738
|
"[ 1,",
|
@@ -740,7 +750,7 @@ describe 'The string converter' do
|
|
740
750
|
end
|
741
751
|
|
742
752
|
it 'indents and breaks nested sequences when one is placed first' do
|
743
|
-
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#a', 'separator' =>"," } }
|
753
|
+
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#a', 'separator' =>", " } }
|
744
754
|
# formatting matters here
|
745
755
|
result = [
|
746
756
|
"[",
|
@@ -801,7 +811,12 @@ describe 'The string converter' do
|
|
801
811
|
} => "(1 'hello', 2 'world')",
|
802
812
|
|
803
813
|
{'format' => '%(h',
|
804
|
-
'separator' => '
|
814
|
+
'separator' => '',
|
815
|
+
'separator2' => ''
|
816
|
+
} => "(1'hello'2'world')",
|
817
|
+
|
818
|
+
{'format' => '%(h',
|
819
|
+
'separator' => ' >> ',
|
805
820
|
'separator2' => ' <=> ',
|
806
821
|
'string_formats' => {Puppet::Pops::Types::PIntegerType::DEFAULT => '%#x'}
|
807
822
|
} => "(0x1 <=> 'hello' >> 0x2 <=> 'world')",
|
@@ -851,7 +866,7 @@ describe 'The string converter' do
|
|
851
866
|
|
852
867
|
it 'both hash and array renders with breaks and indentation if so specified for both' do
|
853
868
|
string_formats = {
|
854
|
-
Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#1a', 'separator' =>"," },
|
869
|
+
Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#1a', 'separator' =>", " },
|
855
870
|
Puppet::Pops::Types::PHashType::DEFAULT => { 'format' => '%#h', 'separator' =>"," }
|
856
871
|
}
|
857
872
|
result = [
|
@@ -867,7 +882,7 @@ describe 'The string converter' do
|
|
867
882
|
|
868
883
|
it 'hash, but not array is rendered with breaks and indentation if so specified only for the hash' do
|
869
884
|
string_formats = {
|
870
|
-
Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%a', 'separator' =>"," },
|
885
|
+
Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%a', 'separator' =>", " },
|
871
886
|
Puppet::Pops::Types::PHashType::DEFAULT => { 'format' => '%#h', 'separator' =>"," }
|
872
887
|
}
|
873
888
|
result = [
|
@@ -993,6 +1008,28 @@ describe 'The string converter' do
|
|
993
1008
|
string_formats = { Puppet::Pops::Types::PRegexpType::DEFAULT => '%p'}
|
994
1009
|
expect(converter.convert(/foo\/bar/, string_formats)).to eq('/foo\/bar/')
|
995
1010
|
end
|
1011
|
+
|
1012
|
+
context 'and slashes' do
|
1013
|
+
it 'the format %s produces \'(?m-ix:foo/bar)\' for expression /foo\/bar/m' do
|
1014
|
+
string_formats = { Puppet::Pops::Types::PRegexpType::DEFAULT => '%s'}
|
1015
|
+
expect(converter.convert(/foo\/bar/m, string_formats)).to eq('(?m-ix:foo/bar)')
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
it 'the format %s produces \'(?m-ix:foo\/bar)\' for expression /foo\\\/bar/m' do
|
1019
|
+
string_formats = { Puppet::Pops::Types::PRegexpType::DEFAULT => '%s'}
|
1020
|
+
expect(converter.convert(/foo\\\/bar/m, string_formats)).to eq('(?m-ix:foo\\\\/bar)')
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
it 'the format %p produces \'(?m-ix:foo\/bar)\' for expression /foo\/bar/m' do
|
1024
|
+
string_formats = { Puppet::Pops::Types::PRegexpType::DEFAULT => '%p'}
|
1025
|
+
expect(converter.convert(/foo\/bar/m, string_formats)).to eq('/(?m-ix:foo\/bar)/')
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
it 'the format %p produces \'(?m-ix:foo\/bar)\' for expression /(?m-ix:foo\/bar)/' do
|
1029
|
+
string_formats = { Puppet::Pops::Types::PRegexpType::DEFAULT => '%p'}
|
1030
|
+
expect(converter.convert(/(?m-ix:foo\/bar)/, string_formats)).to eq('/(?m-ix:foo\/bar)/')
|
1031
|
+
end
|
1032
|
+
end
|
996
1033
|
end
|
997
1034
|
|
998
1035
|
it 'errors when format is not recognized' do
|