puppet 4.7.1-x64-mingw32 → 4.8.0-x64-mingw32
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/Gemfile +0 -3
- data/MAINTAINERS +76 -0
- data/README.md +0 -6
- data/Rakefile +2 -2
- data/lib/puppet/agent.rb +3 -3
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/configurer.rb +2 -2
- data/lib/puppet/data_providers.rb +1 -0
- data/lib/puppet/data_providers/data_adapter.rb +1 -0
- data/lib/puppet/data_providers/data_function_support.rb +1 -0
- data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_config.rb +1 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_support.rb +1 -2
- data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
- data/lib/puppet/defaults.rb +20 -1
- data/lib/puppet/environments.rb +5 -2
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/epp.rb +57 -11
- data/lib/puppet/face/module/install.rb +6 -6
- data/lib/puppet/functions.rb +23 -24
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/binary_file.rb +25 -0
- data/lib/puppet/functions/break.rb +22 -0
- data/lib/puppet/functions/contain.rb +33 -0
- data/lib/puppet/functions/crit.rb +14 -0
- data/lib/puppet/functions/debug.rb +14 -0
- data/lib/puppet/functions/emerg.rb +14 -0
- data/lib/puppet/functions/epp.rb +1 -1
- data/lib/puppet/functions/err.rb +14 -0
- data/lib/puppet/functions/find_file.rb +31 -0
- data/lib/puppet/functions/include.rb +21 -0
- data/lib/puppet/functions/info.rb +14 -0
- data/lib/puppet/functions/new.rb +1 -1
- data/lib/puppet/functions/next.rb +23 -0
- data/lib/puppet/functions/notice.rb +14 -0
- data/lib/puppet/functions/regsubst.rb +12 -16
- data/lib/puppet/functions/require.rb +37 -0
- data/lib/puppet/functions/return.rb +22 -0
- data/lib/puppet/functions/strftime.rb +35 -0
- data/lib/puppet/functions/warning.rb +14 -0
- data/lib/puppet/generate/models/type/type.rb +4 -0
- data/lib/puppet/generate/templates/type/pcore.erb +2 -1
- data/lib/puppet/indirector/face.rb +6 -1
- data/lib/puppet/network/http/error.rb +2 -2
- data/lib/puppet/network/http/handler.rb +2 -2
- data/lib/puppet/node/environment.rb +11 -0
- data/lib/puppet/parser/ast.rb +5 -0
- data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
- data/lib/puppet/parser/compiler.rb +29 -1
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/assert_type.rb +1 -1
- data/lib/puppet/parser/functions/binary_file.rb +24 -0
- data/lib/puppet/parser/functions/break.rb +39 -0
- data/lib/puppet/parser/functions/contain.rb +7 -15
- data/lib/puppet/parser/functions/defined.rb +2 -2
- data/lib/puppet/parser/functions/dig.rb +1 -1
- data/lib/puppet/parser/functions/each.rb +1 -1
- data/lib/puppet/parser/functions/epp.rb +2 -2
- data/lib/puppet/parser/functions/filter.rb +1 -1
- data/lib/puppet/parser/functions/find_file.rb +28 -0
- data/lib/puppet/parser/functions/hiera.rb +4 -4
- data/lib/puppet/parser/functions/hiera_array.rb +1 -1
- data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/include.rb +4 -8
- data/lib/puppet/parser/functions/inline_epp.rb +1 -1
- data/lib/puppet/parser/functions/lest.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +4 -2
- data/lib/puppet/parser/functions/map.rb +1 -1
- data/lib/puppet/parser/functions/match.rb +1 -1
- data/lib/puppet/parser/functions/new.rb +414 -18
- data/lib/puppet/parser/functions/next.rb +38 -0
- data/lib/puppet/parser/functions/reduce.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +4 -2
- data/lib/puppet/parser/functions/require.rb +4 -27
- data/lib/puppet/parser/functions/return.rb +71 -0
- data/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/lib/puppet/parser/functions/scanf.rb +13 -8
- data/lib/puppet/parser/functions/slice.rb +1 -1
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/functions/step.rb +1 -1
- data/lib/puppet/parser/functions/strftime.rb +185 -0
- data/lib/puppet/parser/functions/then.rb +1 -1
- data/lib/puppet/parser/functions/type.rb +1 -1
- data/lib/puppet/parser/functions/with.rb +3 -3
- data/lib/puppet/parser/resource.rb +8 -5
- data/lib/puppet/parser/scope.rb +1 -1
- data/lib/puppet/plugins/configuration.rb +8 -0
- data/lib/puppet/plugins/data_providers.rb +1 -0
- data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
- data/lib/puppet/plugins/data_providers/registry.rb +1 -0
- data/lib/puppet/pops.rb +4 -0
- data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
- data/lib/puppet/pops/evaluator/closure.rb +81 -12
- data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
- data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
- data/lib/puppet/pops/functions/dispatch.rb +9 -2
- data/lib/puppet/pops/functions/dispatcher.rb +3 -1
- data/lib/puppet/pops/functions/function.rb +19 -2
- data/lib/puppet/pops/issues.rb +9 -0
- data/lib/puppet/pops/label_provider.rb +2 -2
- data/lib/puppet/pops/loader/loader.rb +17 -0
- data/lib/puppet/pops/loader/static_loader.rb +0 -41
- data/lib/puppet/pops/lookup.rb +12 -0
- data/lib/puppet/pops/lookup/context.rb +86 -0
- data/lib/puppet/pops/lookup/explainer.rb +46 -6
- data/lib/puppet/pops/lookup/invocation.rb +19 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +20 -8
- data/lib/puppet/pops/model/model_label_provider.rb +3 -0
- data/lib/puppet/pops/model/model_meta.rb +2 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
- data/lib/puppet/pops/parser/egrammar.ra +11 -6
- data/lib/puppet/pops/parser/eparser.rb +1112 -1086
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/pcore.rb +1 -0
- data/lib/puppet/pops/puppet_stack.rb +3 -3
- data/lib/puppet/pops/resource/param.rb +5 -1
- data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
- data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
- data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
- data/lib/puppet/pops/serialization/deserializer.rb +5 -1
- data/lib/puppet/pops/serialization/extension.rb +2 -0
- data/lib/puppet/pops/serialization/json.rb +76 -26
- data/lib/puppet/pops/serialization/serializer.rb +5 -1
- data/lib/puppet/pops/serialization/time_factory.rb +2 -1
- data/lib/puppet/pops/time/timespan.rb +718 -0
- data/lib/puppet/pops/time/timestamp.rb +148 -0
- data/lib/puppet/pops/types/p_binary_type.rb +220 -0
- data/lib/puppet/pops/types/p_object_type.rb +12 -6
- data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
- data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
- data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
- data/lib/puppet/pops/types/string_converter.rb +62 -0
- data/lib/puppet/pops/types/type_asserter.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +17 -3
- data/lib/puppet/pops/types/type_factory.rb +35 -1
- data/lib/puppet/pops/types/type_formatter.rb +64 -11
- data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
- data/lib/puppet/pops/types/type_parser.rb +18 -4
- data/lib/puppet/pops/types/types.rb +98 -63
- data/lib/puppet/pops/validation.rb +9 -1
- data/lib/puppet/pops/validation/checker4_0.rb +7 -0
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider.rb +3 -6
- data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
- data/lib/puppet/provider/mount/parsed.rb +18 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
- data/lib/puppet/provider/package/gem.rb +6 -1
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +5 -1
- data/lib/puppet/provider/package/pkgng.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +10 -0
- data/lib/puppet/provider/service/launchd.rb +1 -0
- data/lib/puppet/provider/user/directoryservice.rb +6 -6
- data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/resource.rb +54 -12
- data/lib/puppet/resource/capability_finder.rb +15 -9
- data/lib/puppet/resource/catalog.rb +25 -6
- data/lib/puppet/resource/type.rb +3 -1
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +12 -4
- data/lib/puppet/syntax_checkers/base64.rb +41 -0
- data/lib/puppet/syntax_checkers/json.rb +0 -2
- data/lib/puppet/transaction.rb +6 -0
- data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
- data/lib/puppet/transaction/report.rb +7 -2
- data/lib/puppet/type.rb +2 -1
- data/lib/puppet/type/file/checksum.rb +1 -0
- data/lib/puppet/type/file/content.rb +4 -4
- data/lib/puppet/type/mount.rb +44 -0
- data/lib/puppet/type/ssh_authorized_key.rb +1 -1
- data/lib/puppet/type/tidy.rb +3 -0
- data/lib/puppet/type/user.rb +12 -6
- data/lib/puppet/util/log.rb +25 -0
- data/lib/puppet/util/plist.rb +8 -3
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_x.rb +7 -1
- data/spec/integration/application/apply_spec.rb +118 -0
- data/spec/integration/parser/compiler_spec.rb +28 -0
- data/spec/integration/parser/pcore_resource_spec.rb +40 -3
- data/spec/integration/provider/mount_spec.rb +2 -1
- data/spec/integration/util/windows/principal_spec.rb +2 -2
- data/spec/integration/util/windows/registry_spec.rb +4 -4
- data/spec/lib/puppet_spec/compiler.rb +5 -1
- data/spec/lib/puppet_spec/unindent.rb +5 -0
- data/spec/shared_contexts/types_setup.rb +6 -0
- data/spec/shared_examples/rhel_package_provider.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/agent_spec.rb +11 -0
- data/spec/unit/application/lookup_spec.rb +94 -3
- data/spec/unit/capability_spec.rb +22 -0
- data/spec/unit/configurer_spec.rb +8 -0
- data/spec/unit/face/epp_face_spec.rb +22 -3
- data/spec/unit/functions/assert_type_spec.rb +3 -3
- data/spec/unit/functions/binary_file_spec.rb +46 -0
- data/spec/unit/functions/break_spec.rb +89 -0
- data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
- data/spec/unit/functions/find_file_spec.rb +69 -0
- data/spec/unit/functions/include_spec.rb +175 -0
- data/spec/unit/functions/logging_spec.rb +54 -0
- data/spec/unit/functions/lookup_spec.rb +3 -3
- data/spec/unit/functions/new_spec.rb +105 -5
- data/spec/unit/functions/next_spec.rb +93 -0
- data/spec/unit/functions/require_spec.rb +83 -0
- data/spec/unit/functions/return_spec.rb +105 -0
- data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
- data/spec/unit/functions/strftime_spec.rb +152 -0
- data/spec/unit/functions4_spec.rb +22 -0
- data/spec/unit/indirector/face_spec.rb +10 -2
- data/spec/unit/network/http/error_spec.rb +1 -2
- data/spec/unit/network/http/handler_spec.rb +6 -5
- data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/lookup_spec.rb +1 -1
- data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
- data/spec/unit/parser/functions/split_spec.rb +1 -1
- data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
- data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
- data/spec/unit/pops/lookup/context_spec.rb +149 -0
- data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
- data/spec/unit/pops/puppet_stack_spec.rb +1 -1
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
- data/spec/unit/pops/serialization/packer_spec.rb +34 -14
- data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
- data/spec/unit/pops/time/timespan_spec.rb +121 -0
- data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
- data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
- data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
- data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
- data/spec/unit/pops/types/string_converter_spec.rb +89 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
- data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
- data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
- data/spec/unit/pops/types/type_parser_spec.rb +87 -4
- data/spec/unit/pops/types/types_spec.rb +1 -1
- data/spec/unit/pops/validator/validator_spec.rb +23 -0
- data/spec/unit/provider/mount/parsed_spec.rb +47 -29
- data/spec/unit/provider/package/pkg_spec.rb +109 -99
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
- data/spec/unit/provider/user/aix_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
- data/spec/unit/resource/capability_finder_spec.rb +29 -7
- data/spec/unit/resource/catalog_spec.rb +127 -0
- data/spec/unit/ssl/certificate_request_spec.rb +1 -1
- data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
- data/spec/unit/transaction/persistence_spec.rb +1 -6
- data/spec/unit/transaction/report_spec.rb +23 -0
- data/spec/unit/transaction_spec.rb +38 -0
- data/spec/unit/type/mount_spec.rb +5 -0
- data/spec/unit/util/plist_spec.rb +14 -2
- metadata +71 -12
- data/spec/integration/parser/functions/require_spec.rb +0 -43
- data/spec/unit/parser/functions/include_spec.rb +0 -55
- data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -107,7 +107,7 @@ module Puppet::Pops
|
|
107
107
|
version => '1.0.0',
|
108
108
|
OBJECT
|
109
109
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
110
|
-
/
|
110
|
+
/expects a value for key 'pcore_version'/)
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'version is missing' do
|
@@ -115,7 +115,7 @@ module Puppet::Pops
|
|
115
115
|
pcore_version => '1.0.0',
|
116
116
|
OBJECT
|
117
117
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
118
|
-
/
|
118
|
+
/expects a value for key 'version'/)
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'the version is an invalid semantic version' do
|
@@ -150,7 +150,7 @@ module Puppet::Pops
|
|
150
150
|
name_authority => 'not a valid URI'
|
151
151
|
OBJECT
|
152
152
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
153
|
-
/entry 'name_authority'
|
153
|
+
/entry 'name_authority' expects a match for Pattern\[.*\], got 'not a valid URI'/m)
|
154
154
|
end
|
155
155
|
|
156
156
|
context 'the types map' do
|
@@ -161,7 +161,7 @@ module Puppet::Pops
|
|
161
161
|
types => {}
|
162
162
|
OBJECT
|
163
163
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
164
|
-
/entry 'types'
|
164
|
+
/entry 'types' expects size to be at least 1, got 0/)
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'is not a map' do
|
@@ -171,7 +171,7 @@ module Puppet::Pops
|
|
171
171
|
types => []
|
172
172
|
OBJECT
|
173
173
|
expect { parse_type_set('MySet', ts) }.to raise_error(Puppet::Error,
|
174
|
-
/entry 'types'
|
174
|
+
/entry 'types' expects a Hash value, got Array/)
|
175
175
|
end
|
176
176
|
|
177
177
|
it 'contains values that are not types' do
|
@@ -195,7 +195,7 @@ module Puppet::Pops
|
|
195
195
|
}
|
196
196
|
OBJECT
|
197
197
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
198
|
-
/key of entry 'car'
|
198
|
+
/key of entry 'car' expects a match for Pattern\[\/\\A\[A-Z\]\\w\*\\z\/\], got 'car'/)
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
@@ -207,7 +207,7 @@ module Puppet::Pops
|
|
207
207
|
references => {}
|
208
208
|
OBJECT
|
209
209
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
210
|
-
/entry 'references'
|
210
|
+
/entry 'references' expects size to be at least 1, got 0/)
|
211
211
|
end
|
212
212
|
|
213
213
|
it 'is not a hash' do
|
@@ -217,7 +217,7 @@ module Puppet::Pops
|
|
217
217
|
references => []
|
218
218
|
OBJECT
|
219
219
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
220
|
-
/entry 'references'
|
220
|
+
/entry 'references' expects a Hash value, got Array/)
|
221
221
|
end
|
222
222
|
|
223
223
|
it 'contains something other than reference initialization maps' do
|
@@ -227,7 +227,7 @@ module Puppet::Pops
|
|
227
227
|
references => {Ref => 2}
|
228
228
|
OBJECT
|
229
229
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
230
|
-
/entry 'references' entry 'Ref'
|
230
|
+
/entry 'references' entry 'Ref' expects a Struct value, got Integer/)
|
231
231
|
end
|
232
232
|
|
233
233
|
it 'contains several initialization that refers to the same TypeSet' do
|
@@ -266,7 +266,7 @@ module Puppet::Pops
|
|
266
266
|
references => { Ref => { name => 'X' } }
|
267
267
|
OBJECT
|
268
268
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
269
|
-
/entry 'references' entry 'Ref'
|
269
|
+
/entry 'references' entry 'Ref' expects a value for key 'version_range'/)
|
270
270
|
end
|
271
271
|
|
272
272
|
it 'has no name' do
|
@@ -276,7 +276,7 @@ module Puppet::Pops
|
|
276
276
|
references => { Ref => { version_range => '1.x' } }
|
277
277
|
OBJECT
|
278
278
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
279
|
-
/entry 'references' entry 'Ref'
|
279
|
+
/entry 'references' entry 'Ref' expects a value for key 'name'/)
|
280
280
|
end
|
281
281
|
|
282
282
|
it 'has a name that is not a QRef' do
|
@@ -286,7 +286,7 @@ module Puppet::Pops
|
|
286
286
|
references => { Ref => { name => 'cars', version_range => '1.x' } }
|
287
287
|
OBJECT
|
288
288
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
289
|
-
/entry 'references' entry 'Ref' entry 'name'
|
289
|
+
/entry 'references' entry 'Ref' entry 'name' expects a match for Pattern\[\/\\A\[A-Z\]\[\\w\]\*\(\?:::\[A-Z\]\[\\w\]\*\)\*\\z\/\], got 'cars'/)
|
290
290
|
end
|
291
291
|
|
292
292
|
it 'has a version_range that is not a valid SemVer range' do
|
@@ -306,7 +306,7 @@ module Puppet::Pops
|
|
306
306
|
references => { 'cars' => { name => 'X', version_range => '1.x' } }
|
307
307
|
OBJECT
|
308
308
|
expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
|
309
|
-
/entry 'references' key of entry 'cars'
|
309
|
+
/entry 'references' key of entry 'cars' expects a match for Pattern\[\/\\A\[A-Z\]\\w\*\\z\/\], got 'cars'/)
|
310
310
|
end
|
311
311
|
end
|
312
312
|
end
|
@@ -81,14 +81,14 @@ describe 'Puppet Ruby Generator' do
|
|
81
81
|
it 'will perform type assertion of the arguments' do
|
82
82
|
expect { first.create('Bob Builder', '52') }.to(
|
83
83
|
raise_error(TypeAssertionError,
|
84
|
-
'MyModule::FirstGenerated[age]
|
84
|
+
'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got String')
|
85
85
|
)
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'will not accept nil as given value for an optional parameter that does not accept nil' do
|
89
89
|
expect { first.create('Bob Builder', nil) }.to(
|
90
90
|
raise_error(TypeAssertionError,
|
91
|
-
'MyModule::FirstGenerated[age]
|
91
|
+
'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got Undef')
|
92
92
|
)
|
93
93
|
end
|
94
94
|
|
@@ -128,7 +128,7 @@ describe 'Puppet Ruby Generator' do
|
|
128
128
|
it 'does not accept an initializer where optional values are nil and type does not accept nil' do
|
129
129
|
expect { first.from_hash('name' => 'Bob Builder', 'age' => nil) }.to(
|
130
130
|
raise_error(TypeAssertionError,
|
131
|
-
"MyModule::FirstGenerated initializer
|
131
|
+
"MyModule::FirstGenerated initializer has wrong type, entry 'age' expects an Integer value, got Undef")
|
132
132
|
)
|
133
133
|
end
|
134
134
|
end
|
@@ -205,14 +205,14 @@ describe 'Puppet Ruby Generator' do
|
|
205
205
|
it 'will perform type assertion of the arguments' do
|
206
206
|
expect { PuppetSpec::RubyGenerator::FirstGenerated.create('Bob Builder', '52') }.to(
|
207
207
|
raise_error(TypeAssertionError,
|
208
|
-
'MyModule::FirstGenerated[age]
|
208
|
+
'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got String')
|
209
209
|
)
|
210
210
|
end
|
211
211
|
|
212
212
|
it 'will not accept nil as given value for an optional parameter that does not accept nil' do
|
213
213
|
expect { PuppetSpec::RubyGenerator::FirstGenerated.create('Bob Builder', nil) }.to(
|
214
214
|
raise_error(TypeAssertionError,
|
215
|
-
'MyModule::FirstGenerated[age]
|
215
|
+
'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got Undef')
|
216
216
|
)
|
217
217
|
end
|
218
218
|
|
@@ -252,7 +252,7 @@ describe 'Puppet Ruby Generator' do
|
|
252
252
|
it 'does not accept an initializer where optional values are nil and type does not accept nil' do
|
253
253
|
expect { PuppetSpec::RubyGenerator::FirstGenerated.from_hash('name' => 'Bob Builder', 'age' => nil) }.to(
|
254
254
|
raise_error(TypeAssertionError,
|
255
|
-
"MyModule::FirstGenerated initializer
|
255
|
+
"MyModule::FirstGenerated initializer has wrong type, entry 'age' expects an Integer value, got Undef")
|
256
256
|
)
|
257
257
|
end
|
258
258
|
end
|
@@ -389,14 +389,14 @@ describe 'Puppet Ruby Generator' do
|
|
389
389
|
it 'will perform type assertion of the arguments' do
|
390
390
|
expect { first.create('Bob Builder', '52') }.to(
|
391
391
|
raise_error(TypeAssertionError,
|
392
|
-
'MyModule::FirstGenerated[age]
|
392
|
+
'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got String')
|
393
393
|
)
|
394
394
|
end
|
395
395
|
|
396
396
|
it 'will not accept nil as given value for an optional parameter that does not accept nil' do
|
397
397
|
expect { first.create('Bob Builder', nil) }.to(
|
398
398
|
raise_error(TypeAssertionError,
|
399
|
-
'MyModule::FirstGenerated[age]
|
399
|
+
'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got Undef')
|
400
400
|
)
|
401
401
|
end
|
402
402
|
|
@@ -436,7 +436,7 @@ describe 'Puppet Ruby Generator' do
|
|
436
436
|
it 'does not accept an initializer where optional values are nil and type does not accept nil' do
|
437
437
|
expect { first.from_hash('name' => 'Bob Builder', 'age' => nil) }.to(
|
438
438
|
raise_error(TypeAssertionError,
|
439
|
-
"MyModule::FirstGenerated initializer
|
439
|
+
"MyModule::FirstGenerated initializer has wrong type, entry 'age' expects an Integer value, got Undef")
|
440
440
|
)
|
441
441
|
end
|
442
442
|
end
|
@@ -519,14 +519,14 @@ describe 'Puppet Ruby Generator' do
|
|
519
519
|
it 'will perform type assertion of the arguments' do
|
520
520
|
expect { PuppetSpec::RubyGenerator::My::FirstGenerated.create('Bob Builder', '52') }.to(
|
521
521
|
raise_error(TypeAssertionError,
|
522
|
-
'MyModule::FirstGenerated[age]
|
522
|
+
'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got String')
|
523
523
|
)
|
524
524
|
end
|
525
525
|
|
526
526
|
it 'will not accept nil as given value for an optional parameter that does not accept nil' do
|
527
527
|
expect { PuppetSpec::RubyGenerator::My::FirstGenerated.create('Bob Builder', nil) }.to(
|
528
528
|
raise_error(TypeAssertionError,
|
529
|
-
'MyModule::FirstGenerated[age]
|
529
|
+
'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got Undef')
|
530
530
|
)
|
531
531
|
end
|
532
532
|
|
@@ -566,7 +566,7 @@ describe 'Puppet Ruby Generator' do
|
|
566
566
|
it 'does not accept an initializer where optional values are nil and type does not accept nil' do
|
567
567
|
expect { PuppetSpec::RubyGenerator::My::FirstGenerated.from_hash('name' => 'Bob Builder', 'age' => nil) }.to(
|
568
568
|
raise_error(TypeAssertionError,
|
569
|
-
"MyModule::FirstGenerated initializer
|
569
|
+
"MyModule::FirstGenerated initializer has wrong type, entry 'age' expects an Integer value, got Undef")
|
570
570
|
)
|
571
571
|
end
|
572
572
|
end
|
@@ -5,6 +5,7 @@ describe 'The string converter' do
|
|
5
5
|
let(:converter) { Puppet::Pops::Types::StringConverter.singleton }
|
6
6
|
let(:factory) { Puppet::Pops::Types::TypeFactory }
|
7
7
|
let(:format) { Puppet::Pops::Types::StringConverter::Format }
|
8
|
+
let(:binary) { Puppet::Pops::Types::PBinaryType::Binary }
|
8
9
|
|
9
10
|
describe 'helper Format' do
|
10
11
|
it 'parses a single character like "%d" as a format' do
|
@@ -903,6 +904,94 @@ describe 'The string converter' do
|
|
903
904
|
end
|
904
905
|
end
|
905
906
|
|
907
|
+
context 'when converting binary' do
|
908
|
+
let(:sample) { binary.from_binary_string('binary') }
|
909
|
+
|
910
|
+
it 'the binary is converted to strict base64 string unquoted by default (same as %B)' do
|
911
|
+
expect(converter.convert(sample, :default)).to eq("YmluYXJ5")
|
912
|
+
end
|
913
|
+
|
914
|
+
it 'the binary is converted using %p by default when contained in an array' do
|
915
|
+
expect(converter.convert([sample], :default)).to eq("[Binary(\"YmluYXJ5\")]")
|
916
|
+
end
|
917
|
+
|
918
|
+
it '%B formats in base64 strict mode (same as default)' do
|
919
|
+
string_formats = { Puppet::Pops::Types::PBinaryType::DEFAULT => '%B'}
|
920
|
+
expect(converter.convert(sample, string_formats)).to eq("YmluYXJ5")
|
921
|
+
end
|
922
|
+
|
923
|
+
it '%b formats in base64 relaxed mode, and adds newline' do
|
924
|
+
string_formats = { Puppet::Pops::Types::PBinaryType::DEFAULT => '%b'}
|
925
|
+
expect(converter.convert(sample, string_formats)).to eq("YmluYXJ5\n")
|
926
|
+
end
|
927
|
+
|
928
|
+
it '%u formats in base64 urlsafe mode' do
|
929
|
+
string_formats = { Puppet::Pops::Types::PBinaryType::DEFAULT => '%u'}
|
930
|
+
expect(converter.convert(binary.from_base64("++//"), string_formats)).to eq("--__")
|
931
|
+
end
|
932
|
+
|
933
|
+
it '%p formats with type name' do
|
934
|
+
string_formats = { Puppet::Pops::Types::PBinaryType::DEFAULT => '%p'}
|
935
|
+
expect(converter.convert(sample, string_formats)).to eq("Binary(\"YmluYXJ5\")")
|
936
|
+
end
|
937
|
+
|
938
|
+
it '%#s formats as quoted string with escaped non printable bytes' do
|
939
|
+
string_formats = { Puppet::Pops::Types::PBinaryType::DEFAULT => '%#s'}
|
940
|
+
expect(converter.convert(binary.from_base64("apa="), string_formats)).to eq("\"j\\x96\"")
|
941
|
+
end
|
942
|
+
|
943
|
+
it '%s formats as unquoted string with valid UTF-8 chars' do
|
944
|
+
string_formats = { Puppet::Pops::Types::PBinaryType::DEFAULT => '%s'}
|
945
|
+
# womans hat emoji is E318, a three byte UTF-8 char EE 8C 98
|
946
|
+
expect(converter.convert(binary.from_binary_string("\xEE\x8C\x98"), string_formats)).to eq("\uE318")
|
947
|
+
end
|
948
|
+
|
949
|
+
it '%s errors if given non UTF-8 bytes' do
|
950
|
+
string_formats = { Puppet::Pops::Types::PBinaryType::DEFAULT => '%s'}
|
951
|
+
expect {
|
952
|
+
converter.convert(binary.from_base64("apa="), string_formats)
|
953
|
+
}.to raise_error(Encoding::UndefinedConversionError)
|
954
|
+
end
|
955
|
+
|
956
|
+
{ "%s" => 'binary',
|
957
|
+
"%#s" => '"binary"',
|
958
|
+
"%8s" => ' binary',
|
959
|
+
"%.2s" => 'bi',
|
960
|
+
"%-8s" => 'binary ',
|
961
|
+
"%p" => 'Binary("YmluYXJ5")',
|
962
|
+
"%10p" => 'Binary(" YmluYXJ5")',
|
963
|
+
"%-10p" => 'Binary("YmluYXJ5 ")',
|
964
|
+
"%.2p" => 'Binary("Ym")',
|
965
|
+
"%b" => "YmluYXJ5\n",
|
966
|
+
"%11b" => " YmluYXJ5\n",
|
967
|
+
"%-11b" => "YmluYXJ5\n ",
|
968
|
+
"%.2b" => "Ym",
|
969
|
+
"%B" => "YmluYXJ5",
|
970
|
+
"%11B" => " YmluYXJ5",
|
971
|
+
"%-11B" => "YmluYXJ5 ",
|
972
|
+
"%.2B" => "Ym",
|
973
|
+
"%u" => "YmluYXJ5",
|
974
|
+
"%11u" => " YmluYXJ5",
|
975
|
+
"%-11u" => "YmluYXJ5 ",
|
976
|
+
"%.2u" => "Ym",
|
977
|
+
"%t" => 'Binary',
|
978
|
+
"%#t" => '"Binary"',
|
979
|
+
"%8t" => ' Binary',
|
980
|
+
"%-8t" => 'Binary ',
|
981
|
+
"%.3t" => 'Bin',
|
982
|
+
"%T" => 'BINARY',
|
983
|
+
"%#T" => '"BINARY"',
|
984
|
+
"%8T" => ' BINARY',
|
985
|
+
"%-8T" => 'BINARY ',
|
986
|
+
"%.3T" => 'BIN',
|
987
|
+
}.each do |fmt, result |
|
988
|
+
it "the format #{fmt} produces #{result}" do
|
989
|
+
string_formats = { Puppet::Pops::Types::PBinaryType::DEFAULT => fmt}
|
990
|
+
expect(converter.convert(sample, string_formats)).to eq(result)
|
991
|
+
end
|
992
|
+
end
|
993
|
+
end
|
994
|
+
|
906
995
|
context 'when converting iterator' do
|
907
996
|
it 'the iterator is transformed to an array and formatted using array rules' do
|
908
997
|
itor = Puppet::Pops::Types::Iterator.new(Puppet::Pops::Types::PIntegerType::DEFAULT, [1,2,3]).reverse_each
|
@@ -8,19 +8,19 @@ describe 'the type asserter' do
|
|
8
8
|
context 'when deferring formatting of subject'
|
9
9
|
it 'can use an array' do
|
10
10
|
expect{ asserter.assert_instance_of(['The %s in the %s', 'gizmo', 'gadget'], PIntegerType::DEFAULT, 'lens') }.to(
|
11
|
-
raise_error(TypeAssertionError, 'The gizmo in the gadget
|
11
|
+
raise_error(TypeAssertionError, 'The gizmo in the gadget has wrong type, expects an Integer value, got String'))
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'can use an array obtained from block' do
|
15
15
|
expect do
|
16
16
|
asserter.assert_instance_of('gizmo', PIntegerType::DEFAULT, 'lens') { |s| ['The %s in the %s', s, 'gadget'] }
|
17
|
-
end.to(raise_error(TypeAssertionError, 'The gizmo in the gadget
|
17
|
+
end.to(raise_error(TypeAssertionError, 'The gizmo in the gadget has wrong type, expects an Integer value, got String'))
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'can use an subject obtained from zero argument block' do
|
21
21
|
expect do
|
22
22
|
asserter.assert_instance_of(nil, PIntegerType::DEFAULT, 'lens') { 'The gizmo in the gadget' }
|
23
|
-
end.to(raise_error(TypeAssertionError, 'The gizmo in the gadget
|
23
|
+
end.to(raise_error(TypeAssertionError, 'The gizmo in the gadget has wrong type, expects an Integer value, got String'))
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'does not produce a string unless the assertion fails' do
|
@@ -214,6 +214,12 @@ describe 'The type calculator' do
|
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
217
|
+
context 'binary' do
|
218
|
+
it 'translates to PBinaryType' do
|
219
|
+
expect(calculator.infer(PBinaryType::Binary.from_binary_string("binary")).class).to eq(PBinaryType)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
217
223
|
context 'version' do
|
218
224
|
it 'translates to PVersionType' do
|
219
225
|
expect(calculator.infer(Semantic::Version.new(1,0,0)).class).to eq(PSemVerType)
|
@@ -233,6 +239,34 @@ describe 'The type calculator' do
|
|
233
239
|
end
|
234
240
|
end
|
235
241
|
|
242
|
+
context 'timespan' do
|
243
|
+
it 'translates to PTimespanType' do
|
244
|
+
expect(calculator.infer(Time::Timespan.from_fields_hash('days' => 2))).to be_a(PTimespanType)
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'translates to a limited PTimespanType by infer_set' do
|
248
|
+
ts = Time::Timespan.from_fields_hash('days' => 2)
|
249
|
+
t = calculator.infer_set(ts)
|
250
|
+
expect(t.class).to eq(PTimespanType)
|
251
|
+
expect(t.from).to be(ts)
|
252
|
+
expect(t.to).to be(ts)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context 'timestamp' do
|
257
|
+
it 'translates to PTimespanType' do
|
258
|
+
expect(calculator.infer(Time::Timestamp.now)).to be_a(PTimestampType)
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'translates to a limited PTimespanType by infer_set' do
|
262
|
+
ts = Time::Timestamp.now
|
263
|
+
t = calculator.infer_set(ts)
|
264
|
+
expect(t.class).to eq(PTimestampType)
|
265
|
+
expect(t.from).to be(ts)
|
266
|
+
expect(t.to).to be(ts)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
236
270
|
context 'array' do
|
237
271
|
it 'translates to PArrayType' do
|
238
272
|
expect(calculator.infer([1,2]).class).to eq(PArrayType)
|
@@ -559,6 +593,24 @@ describe 'The type calculator' do
|
|
559
593
|
expect(common_t.param_types.class).to be(PTupleType)
|
560
594
|
expect(common_t.block_type).to eql(callable_t(scalar_t))
|
561
595
|
end
|
596
|
+
|
597
|
+
it 'return_type is included in the check (incompatible return_type)' do
|
598
|
+
t1 = callable_t([String], String)
|
599
|
+
t2 = callable_t([String], Integer)
|
600
|
+
common_t = calculator.common_type(t1, t2)
|
601
|
+
expect(common_t.class).to be(PCallableType)
|
602
|
+
expect(common_t.param_types).to be_nil
|
603
|
+
expect(common_t.return_type).to be_nil
|
604
|
+
end
|
605
|
+
|
606
|
+
it 'return_type is included in the check (compatible return_type)' do
|
607
|
+
t1 = callable_t([String], Numeric)
|
608
|
+
t2 = callable_t([String], Integer)
|
609
|
+
common_t = calculator.common_type(t1, t2)
|
610
|
+
expect(common_t.class).to be(PCallableType)
|
611
|
+
expect(common_t.param_types).to be_a(PTupleType)
|
612
|
+
expect(common_t.return_type).to eql(PNumericType::DEFAULT)
|
613
|
+
end
|
562
614
|
end
|
563
615
|
end
|
564
616
|
|
@@ -864,6 +916,34 @@ describe 'The type calculator' do
|
|
864
916
|
end
|
865
917
|
end
|
866
918
|
|
919
|
+
context 'for Timespan such that' do
|
920
|
+
it 'Timespan is assignable to less constrained Timespan' do
|
921
|
+
t1 = PTimespanType.new('00:00:10', '00:00:20')
|
922
|
+
t2 = PTimespanType.new('00:00:11', '00:00:19')
|
923
|
+
expect(t2).to be_assignable_to(t1)
|
924
|
+
end
|
925
|
+
|
926
|
+
it 'Timespan is not assignable to more constrained Timespan' do
|
927
|
+
t1 = PTimespanType.new('00:00:10', '00:00:20')
|
928
|
+
t2 = PTimespanType.new('00:00:11', '00:00:19')
|
929
|
+
expect(t1).not_to be_assignable_to(t2)
|
930
|
+
end
|
931
|
+
end
|
932
|
+
|
933
|
+
context 'for Timestamp such that' do
|
934
|
+
it 'Timestamp is assignable to less constrained Timestamp' do
|
935
|
+
t1 = PTimestampType.new('2016-01-01', '2016-12-31')
|
936
|
+
t2 = PTimestampType.new('2016-02-01', '2016-11-30')
|
937
|
+
expect(t2).to be_assignable_to(t1)
|
938
|
+
end
|
939
|
+
|
940
|
+
it 'Timestamp is not assignable to more constrained Timestamp' do
|
941
|
+
t1 = PTimestampType.new('2016-01-01', '2016-12-31')
|
942
|
+
t2 = PTimestampType.new('2016-02-01', '2016-11-30')
|
943
|
+
expect(t1).not_to be_assignable_to(t2)
|
944
|
+
end
|
945
|
+
end
|
946
|
+
|
867
947
|
context 'for Tuple, such that' do
|
868
948
|
it 'Tuple is not assignable to any other non Array based Collection type' do
|
869
949
|
t = PTupleType::DEFAULT
|
@@ -875,8 +955,8 @@ describe 'The type calculator' do
|
|
875
955
|
end
|
876
956
|
|
877
957
|
it 'A tuple with parameters is assignable to the default Tuple' do
|
878
|
-
t =
|
879
|
-
t2 =
|
958
|
+
t = PTupleType::DEFAULT
|
959
|
+
t2 = PTupleType.new([PStringType::DEFAULT])
|
880
960
|
expect(t2).to be_assignable_to(t)
|
881
961
|
end
|
882
962
|
|
@@ -967,11 +1047,39 @@ describe 'The type calculator' do
|
|
967
1047
|
end
|
968
1048
|
|
969
1049
|
it 'a callable with parameter is assignable to the default callable' do
|
970
|
-
expect(callable_t(string_t)).to be_assignable_to(
|
1050
|
+
expect(callable_t(string_t)).to be_assignable_to(PCallableType::DEFAULT)
|
971
1051
|
end
|
972
1052
|
|
973
1053
|
it 'the default callable is not assignable to a callable with parameter' do
|
974
|
-
expect(
|
1054
|
+
expect(PCallableType::DEFAULT).not_to be_assignable_to(callable_t(string_t))
|
1055
|
+
end
|
1056
|
+
|
1057
|
+
it 'a callable with a return type is assignable to the default callable' do
|
1058
|
+
expect(callable_t([], string_t)).to be_assignable_to(PCallableType::DEFAULT)
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
it 'the default callable is not assignable to a callable with a return type' do
|
1062
|
+
expect(PCallableType::DEFAULT).not_to be_assignable_to(callable_t([],string_t))
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
it 'a callable with a return type Any is assignable to the default callable' do
|
1066
|
+
expect(callable_t([], object_t)).to be_assignable_to(PCallableType::DEFAULT)
|
1067
|
+
end
|
1068
|
+
|
1069
|
+
it 'a callable with a return type Any is equal to a callable with the same parameters and no return type' do
|
1070
|
+
expect(callable_t([string_t], object_t)).to eql(callable_t(string_t))
|
1071
|
+
end
|
1072
|
+
|
1073
|
+
it 'a callable with a return type different than Any is not equal to a callable with the same parameters and no return type' do
|
1074
|
+
expect(callable_t([string_t], string_t)).not_to eql(callable_t(string_t))
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
it 'a callable with a return type is assignable from another callable with an assignable return type' do
|
1078
|
+
expect(callable_t([], string_t)).to be_assignable_to(callable_t([], PScalarType::DEFAULT))
|
1079
|
+
end
|
1080
|
+
|
1081
|
+
it 'a callable with a return type is not assignable from another callable unless the return type is assignable' do
|
1082
|
+
expect(callable_t([], string_t)).not_to be_assignable_to(callable_t([], integer_t))
|
975
1083
|
end
|
976
1084
|
end
|
977
1085
|
|
@@ -1720,7 +1828,7 @@ describe 'The type calculator' do
|
|
1720
1828
|
it 'a Closure should be considered a Callable' do
|
1721
1829
|
factory = Model::Factory
|
1722
1830
|
params = [factory.PARAM('a')]
|
1723
|
-
the_block = factory.LAMBDA(params,factory.literal(42))
|
1831
|
+
the_block = factory.LAMBDA(params,factory.literal(42), nil)
|
1724
1832
|
the_closure = Evaluator::Closure::Dynamic.new(:fake_evaluator, the_block, :fake_scope)
|
1725
1833
|
expect(calculator.instance?(all_callables_t, the_closure)).to be_truthy
|
1726
1834
|
expect(calculator.instance?(callable_t(object_t), the_closure)).to be_truthy
|