puppet 4.1.0 → 4.10.0
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.
- checksums.yaml +4 -4
- data/COMMITTERS.md +2 -2
- data/CONTRIBUTING.md +34 -10
- data/Gemfile +26 -9
- data/LICENSE +3 -3
- data/MAINTAINERS +71 -0
- data/README.md +9 -11
- data/Rakefile +35 -0
- data/conf/auth.conf +2 -2
- data/conf/puppet.conf +1 -1
- data/ext/README.environment +1 -1
- data/ext/build_defaults.yaml +2 -2
- data/ext/debian/README.source +1 -1
- data/ext/debian/control +3 -5
- data/ext/debian/copyright +4 -4
- data/ext/debian/puppet.init +0 -1
- data/ext/debian/puppet.logrotate +14 -5
- data/ext/debian/puppetmaster.README.debian +11 -9
- data/ext/emacs/puppet-mode.el +1 -1
- data/ext/envpuppet +2 -2
- data/ext/ips/puppetagent.xml +1 -1
- data/ext/ips/puppetmaster.xml +1 -1
- data/ext/osx/puppet.plist +30 -0
- data/ext/project_data.yaml +31 -15
- data/ext/puppet-test +3 -3
- data/ext/rack/example-passenger-vhost.conf +1 -1
- data/ext/redhat/client.init +67 -17
- data/ext/redhat/client.sysconfig +1 -10
- data/ext/redhat/logrotate +15 -3
- data/ext/redhat/puppet.spec.erb +6 -11
- data/ext/redhat/server.init +1 -1
- data/ext/regexp_nodes/regexp_nodes.rb +1 -1
- data/ext/solaris/pkginfo +1 -1
- data/ext/solaris/smf/puppet +44 -0
- data/ext/solaris/smf/puppet.xml +44 -0
- data/ext/suse/client.init +30 -33
- data/ext/suse/puppet.spec +2 -2
- data/ext/suse/server.init +2 -2
- data/ext/systemd/puppet.service +13 -1
- data/ext/upload_facts.rb +1 -1
- data/ext/windows/puppet_interactive.bat +6 -0
- data/ext/windows/puppet_shell.bat +9 -0
- data/ext/windows/run_puppet_interactive.bat +9 -0
- data/ext/windows/service/daemon.rb +2 -1
- data/ext/yaml_nodes.rb +1 -1
- data/install.rb +98 -65
- data/lib/hiera/puppet_function.rb +17 -18
- data/lib/hiera/scope.rb +12 -14
- data/lib/hiera_puppet.rb +6 -14
- data/lib/puppet/agent/locker.rb +11 -2
- data/lib/puppet/agent.rb +12 -27
- data/lib/puppet/application/agent.rb +35 -19
- data/lib/puppet/application/apply.rb +46 -14
- data/lib/puppet/application/ca.rb +1 -0
- data/lib/puppet/application/cert.rb +52 -3
- data/lib/puppet/application/device.rb +2 -2
- data/lib/puppet/application/face_base.rb +4 -0
- data/lib/puppet/application/filebucket.rb +79 -5
- data/lib/puppet/application/generate.rb +5 -0
- data/lib/puppet/application/inspect.rb +5 -2
- data/lib/puppet/application/lookup.rb +344 -0
- data/lib/puppet/application/master.rb +7 -3
- data/lib/puppet/application/resource.rb +2 -6
- data/lib/puppet/application.rb +20 -4
- data/lib/puppet/application_support.rb +1 -1
- data/lib/puppet/compilable_resource_type.rb +15 -0
- data/lib/puppet/configurer/plugin_handler.rb +7 -5
- data/lib/puppet/configurer.rb +177 -37
- data/lib/puppet/context/trusted_information.rb +21 -1
- data/lib/puppet/context.rb +16 -1
- data/lib/puppet/daemon.rb +17 -13
- data/lib/puppet/data_binding.rb +4 -2
- data/lib/puppet/data_providers/data_adapter.rb +14 -68
- data/lib/puppet/data_providers/data_function_support.rb +13 -26
- data/lib/puppet/data_providers/function_env_data_provider.rb +7 -9
- data/lib/puppet/data_providers/function_module_data_provider.rb +7 -22
- data/lib/puppet/data_providers/hiera_config.rb +151 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +25 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +21 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +30 -0
- data/lib/puppet/data_providers/hiera_support.rb +42 -0
- data/lib/puppet/data_providers/json_data_provider_factory.rb +38 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +40 -0
- data/lib/puppet/data_providers.rb +17 -14
- data/lib/puppet/defaults.rb +273 -59
- data/lib/puppet/environments.rb +104 -9
- data/lib/puppet/error.rb +4 -0
- data/lib/puppet/etc.rb +125 -0
- data/lib/puppet/external/dot.rb +1 -1
- data/lib/puppet/face/ca.rb +6 -1
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/certificate.rb +7 -1
- data/lib/puppet/face/certificate_request.rb +2 -0
- data/lib/puppet/face/certificate_revocation_list.rb +2 -0
- data/lib/puppet/face/config.rb +2 -2
- data/lib/puppet/face/epp.rb +63 -17
- data/lib/puppet/face/file.rb +3 -0
- data/lib/puppet/face/generate.rb +64 -0
- data/lib/puppet/face/help/face.erb +3 -0
- data/lib/puppet/face/help/man.erb +1 -1
- data/lib/puppet/face/help.rb +35 -27
- data/lib/puppet/face/key.rb +1 -0
- data/lib/puppet/face/man.rb +5 -3
- data/lib/puppet/face/module/changes.rb +2 -1
- data/lib/puppet/face/module/generate.rb +1 -1
- data/lib/puppet/face/module/install.rb +6 -6
- data/lib/puppet/face/parser.rb +12 -9
- data/lib/puppet/face/plugin.rb +7 -14
- data/lib/puppet/face/status.rb +4 -1
- data/lib/puppet/feature/base.rb +9 -2
- data/lib/puppet/feature/cfacter.rb +1 -0
- data/lib/puppet/feature/cfpropertylist.rb +3 -0
- data/lib/puppet/feature/external_facts.rb +1 -1
- data/lib/puppet/feature/hiera_eyaml.rb +3 -0
- data/lib/puppet/feature/hocon.rb +3 -0
- data/lib/puppet/feature/telnet.rb +9 -0
- data/lib/puppet/file_bucket/dipper.rb +58 -2
- data/lib/puppet/file_serving/http_metadata.rb +46 -0
- data/lib/puppet/file_serving/metadata.rb +18 -2
- data/lib/puppet/file_serving/terminus_selector.rb +2 -0
- data/lib/puppet/file_system/file_impl.rb +7 -2
- data/lib/puppet/file_system/memory_impl.rb +5 -1
- data/lib/puppet/file_system/path_pattern.rb +1 -0
- data/lib/puppet/file_system/uniquefile.rb +3 -3
- data/lib/puppet/file_system/windows.rb +28 -13
- data/lib/puppet/file_system.rb +33 -5
- data/lib/puppet/forge/repository.rb +3 -35
- data/lib/puppet/forge.rb +7 -7
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/assert_type.rb +53 -19
- data/lib/puppet/functions/binary_file.rb +19 -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/defined.rb +88 -58
- data/lib/puppet/functions/dig.rb +23 -0
- data/lib/puppet/functions/each.rb +89 -39
- data/lib/puppet/functions/emerg.rb +14 -0
- data/lib/puppet/functions/epp.rb +29 -37
- data/lib/puppet/functions/err.rb +14 -0
- data/lib/puppet/functions/eyaml_lookup_key.rb +90 -0
- data/lib/puppet/functions/filter.rb +64 -38
- data/lib/puppet/functions/find_file.rb +31 -0
- data/lib/puppet/functions/hiera.rb +76 -3
- data/lib/puppet/functions/hiera_array.rb +66 -4
- data/lib/puppet/functions/hiera_hash.rb +74 -2
- data/lib/puppet/functions/hiera_include.rb +78 -5
- data/lib/puppet/functions/hocon_data.rb +35 -0
- data/lib/puppet/functions/include.rb +21 -0
- data/lib/puppet/functions/info.rb +14 -0
- data/lib/puppet/functions/inline_epp.rb +44 -71
- data/lib/puppet/functions/json_data.rb +29 -0
- data/lib/puppet/functions/lest.rb +17 -0
- data/lib/puppet/functions/lookup.rb +172 -184
- data/lib/puppet/functions/map.rb +60 -33
- data/lib/puppet/functions/match.rb +30 -12
- data/lib/puppet/functions/new.rb +31 -0
- data/lib/puppet/functions/next.rb +23 -0
- data/lib/puppet/functions/notice.rb +14 -0
- data/lib/puppet/functions/reduce.rb +99 -70
- data/lib/puppet/functions/regsubst.rb +22 -25
- data/lib/puppet/functions/require.rb +37 -0
- data/lib/puppet/functions/return.rb +22 -0
- data/lib/puppet/functions/reverse_each.rb +25 -0
- data/lib/puppet/functions/scanf.rb +15 -18
- data/lib/puppet/functions/slice.rb +22 -36
- data/lib/puppet/functions/split.rb +2 -2
- data/lib/puppet/functions/step.rb +26 -0
- data/lib/puppet/functions/strftime.rb +35 -0
- data/lib/puppet/functions/then.rb +14 -0
- data/lib/puppet/functions/type.rb +31 -0
- data/lib/puppet/functions/unwrap.rb +40 -0
- data/lib/puppet/functions/versioncmp.rb +36 -0
- data/lib/puppet/functions/warning.rb +14 -0
- data/lib/puppet/functions/with.rb +15 -7
- data/lib/puppet/functions/yaml_data.rb +38 -0
- data/lib/puppet/functions.rb +180 -32
- data/lib/puppet/generate/models/type/property.rb +70 -0
- data/lib/puppet/generate/models/type/type.rb +61 -0
- data/lib/puppet/generate/templates/type/pcore.erb +42 -0
- data/lib/puppet/generate/type.rb +239 -0
- data/lib/puppet/graph/rb_tree_map.rb +1 -1
- data/lib/puppet/graph/simple_graph.rb +6 -8
- data/lib/puppet/indirector/catalog/compiler.rb +195 -8
- data/lib/puppet/indirector/catalog/static_compiler.rb +50 -31
- data/lib/puppet/indirector/data_binding/none.rb +4 -1
- data/lib/puppet/indirector/face.rb +6 -1
- data/lib/puppet/indirector/facts/facter.rb +3 -6
- data/lib/puppet/indirector/file_bucket_file/file.rb +137 -25
- data/lib/puppet/indirector/file_content/http.rb +15 -0
- data/lib/puppet/indirector/file_metadata/http.rb +27 -0
- data/lib/puppet/indirector/generic_http.rb +16 -0
- data/lib/puppet/indirector/hiera.rb +7 -1
- data/lib/puppet/indirector/indirection.rb +12 -3
- data/lib/puppet/indirector/json.rb +3 -3
- data/lib/puppet/indirector/key/ca.rb +2 -2
- data/lib/puppet/indirector/key/file.rb +2 -1
- data/lib/puppet/indirector/msgpack.rb +2 -2
- data/lib/puppet/indirector/node/exec.rb +1 -1
- data/lib/puppet/indirector/node/ldap.rb +1 -1
- data/lib/puppet/indirector/request.rb +36 -12
- data/lib/puppet/indirector/resource_type/parser.rb +10 -3
- data/lib/puppet/indirector/rest.rb +80 -5
- data/lib/puppet/indirector/ssl_file.rb +24 -3
- data/lib/puppet/indirector/terminus.rb +4 -4
- data/lib/puppet/info_service/class_information_service.rb +111 -0
- data/lib/puppet/info_service.rb +7 -0
- data/lib/puppet/interface/documentation.rb +1 -1
- data/lib/puppet/interface/face_collection.rb +1 -1
- data/lib/puppet/interface.rb +14 -2
- data/lib/puppet/loaders.rb +5 -0
- data/lib/puppet/metatype/manager.rb +25 -8
- data/lib/puppet/module.rb +65 -31
- data/lib/puppet/module_tool/applications/application.rb +1 -1
- data/lib/puppet/module_tool/applications/builder.rb +5 -4
- data/lib/puppet/module_tool/applications/installer.rb +14 -14
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/applications/upgrader.rb +13 -13
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/errors/installer.rb +2 -2
- data/lib/puppet/module_tool/installed_modules.rb +7 -7
- data/lib/puppet/module_tool/local_tarball.rb +3 -3
- data/lib/puppet/module_tool/metadata.rb +34 -11
- data/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +14 -3
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +42 -38
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +19 -4
- data/lib/puppet/module_tool/skeleton/templates/generator/{tests → examples}/init.pp.erb +2 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +25 -18
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +1 -2
- data/lib/puppet/module_tool/tar/mini.rb +3 -3
- data/lib/puppet/module_tool.rb +5 -5
- data/lib/puppet/network/auth_config_parser.rb +1 -1
- data/lib/puppet/network/authconfig.rb +21 -1
- data/lib/puppet/network/authorization.rb +8 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +23 -34
- data/lib/puppet/network/http/api/master/v3/environment.rb +63 -0
- data/lib/puppet/network/http/api/master/v3.rb +7 -1
- data/lib/puppet/network/http/compression.rb +2 -1
- data/lib/puppet/network/http/connection.rb +2 -0
- data/lib/puppet/network/http/error.rb +1 -1
- data/lib/puppet/network/http/factory.rb +8 -4
- data/lib/puppet/network/http/handler.rb +3 -2
- data/lib/puppet/network/http/pool.rb +9 -0
- data/lib/puppet/network/http/rack/rest.rb +25 -2
- data/lib/puppet/network/http/webrick.rb +2 -1
- data/lib/puppet/network/rights.rb +1 -11
- data/lib/puppet/node/environment.rb +49 -14
- data/lib/puppet/node/facts.rb +1 -1
- data/lib/puppet/node.rb +22 -7
- data/lib/puppet/parameter/boolean.rb +1 -1
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parameter.rb +23 -3
- data/lib/puppet/parser/ast/pops_bridge.rb +97 -27
- data/lib/puppet/parser/ast/resource.rb +5 -0
- data/lib/puppet/parser/ast/resource_instance.rb +5 -1
- data/lib/puppet/parser/ast/resourceparam.rb +5 -0
- data/lib/puppet/parser/ast.rb +5 -0
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +60 -0
- data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
- data/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
- data/lib/puppet/parser/compiler.rb +325 -42
- data/lib/puppet/parser/e4_parser_adapter.rb +13 -12
- data/lib/puppet/parser/environment_compiler.rb +201 -0
- data/lib/puppet/parser/functions/assert_type.rb +47 -17
- 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/create_resources.rb +39 -23
- data/lib/puppet/parser/functions/defined.rb +106 -93
- data/lib/puppet/parser/functions/dig.rb +29 -0
- data/lib/puppet/parser/functions/each.rb +86 -28
- data/lib/puppet/parser/functions/epp.rb +30 -38
- data/lib/puppet/parser/functions/filter.rb +60 -24
- data/lib/puppet/parser/functions/find_file.rb +28 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +3 -3
- data/lib/puppet/parser/functions/hiera.rb +98 -28
- data/lib/puppet/parser/functions/hiera_array.rb +86 -29
- data/lib/puppet/parser/functions/hiera_hash.rb +96 -31
- data/lib/puppet/parser/functions/hiera_include.rb +96 -41
- data/lib/puppet/parser/functions/include.rb +4 -8
- data/lib/puppet/parser/functions/inline_epp.rb +36 -61
- data/lib/puppet/parser/functions/inline_template.rb +2 -2
- data/lib/puppet/parser/functions/lest.rb +49 -0
- data/lib/puppet/parser/functions/lookup.rb +129 -151
- data/lib/puppet/parser/functions/map.rb +56 -21
- data/lib/puppet/parser/functions/match.rb +29 -13
- data/lib/puppet/parser/functions/new.rb +926 -0
- data/lib/puppet/parser/functions/next.rb +38 -0
- data/lib/puppet/parser/functions/reduce.rb +98 -61
- 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 +83 -0
- data/lib/puppet/parser/functions/scanf.rb +25 -31
- data/lib/puppet/parser/functions/slice.rb +18 -25
- data/lib/puppet/parser/functions/split.rb +2 -2
- data/lib/puppet/parser/functions/step.rb +84 -0
- data/lib/puppet/parser/functions/strftime.rb +185 -0
- data/lib/puppet/parser/functions/then.rb +73 -0
- data/lib/puppet/parser/functions/type.rb +53 -0
- data/lib/puppet/parser/functions/with.rb +17 -9
- data/lib/puppet/parser/functions.rb +34 -16
- data/lib/puppet/parser/resource.rb +149 -35
- data/lib/puppet/parser/scope.rb +344 -88
- data/lib/puppet/parser/type_loader.rb +1 -1
- data/lib/puppet/parser.rb +3 -1
- data/lib/puppet/plugins/configuration.rb +11 -2
- data/lib/puppet/plugins/data_providers/data_provider.rb +406 -0
- data/lib/puppet/plugins/data_providers/registry.rb +51 -0
- data/lib/puppet/plugins/data_providers.rb +15 -60
- data/lib/puppet/pops/adaptable.rb +4 -4
- data/lib/puppet/pops/adapters.rb +114 -31
- data/lib/puppet/pops/binder/binder.rb +21 -17
- data/lib/puppet/pops/binder/binder_issues.rb +8 -6
- data/lib/puppet/pops/binder/bindings_checker.rb +12 -8
- data/lib/puppet/pops/binder/bindings_composer.rb +16 -12
- data/lib/puppet/pops/binder/bindings_factory.rb +108 -104
- data/lib/puppet/pops/binder/bindings_label_provider.rb +3 -1
- data/lib/puppet/pops/binder/bindings_loader.rb +6 -2
- data/lib/puppet/pops/binder/bindings_model.rb +49 -47
- data/lib/puppet/pops/binder/bindings_model_meta.rb +2 -2
- data/lib/puppet/pops/binder/config/binder_config.rb +1 -1
- data/lib/puppet/pops/binder/config/diagnostic_producer.rb +10 -6
- data/lib/puppet/pops/binder/injector.rb +55 -50
- data/lib/puppet/pops/binder/key_factory.rb +10 -12
- data/lib/puppet/pops/binder/producers.rb +70 -65
- data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +1 -1
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
- data/lib/puppet/pops/evaluator/access_operator.rb +246 -147
- data/lib/puppet/pops/evaluator/callable_signature.rb +7 -0
- data/lib/puppet/pops/evaluator/closure.rb +231 -115
- data/lib/puppet/pops/evaluator/collector_transformer.rb +44 -15
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -2
- data/lib/puppet/pops/evaluator/compare_operator.rb +69 -12
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +9 -8
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +194 -106
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +84 -0
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
- data/lib/puppet/pops/evaluator/relationship_operator.rb +18 -11
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +60 -51
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +119 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +111 -79
- data/lib/puppet/pops/functions/dispatch.rb +27 -7
- data/lib/puppet/pops/functions/dispatcher.rb +15 -20
- data/lib/puppet/pops/functions/function.rb +30 -4
- data/lib/puppet/pops/issue_reporter.rb +7 -5
- data/lib/puppet/pops/issues.rb +177 -17
- data/lib/puppet/pops/label_provider.rb +18 -4
- data/lib/puppet/pops/loader/base_loader.rb +74 -20
- data/lib/puppet/pops/loader/dependency_loader.rb +27 -2
- data/lib/puppet/pops/loader/loader.rb +43 -49
- data/lib/puppet/pops/loader/loader_paths.rb +48 -2
- data/lib/puppet/pops/loader/module_loaders.rb +53 -20
- data/lib/puppet/pops/loader/null_loader.rb +17 -1
- data/lib/puppet/pops/loader/predefined_loader.rb +29 -0
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +26 -20
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +80 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +16 -4
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +96 -0
- data/lib/puppet/pops/loader/static_loader.rb +139 -38
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +93 -0
- data/lib/puppet/pops/loader/typed_name.rb +48 -0
- data/lib/puppet/pops/loaders.rb +204 -26
- data/lib/puppet/pops/lookup/configured_data_provider.rb +93 -0
- data/lib/puppet/pops/lookup/context.rb +200 -0
- data/lib/puppet/pops/lookup/data_adapter.rb +27 -0
- data/lib/puppet/pops/lookup/data_dig_function_provider.rb +145 -0
- data/lib/puppet/pops/lookup/data_hash_function_provider.rb +126 -0
- data/lib/puppet/pops/lookup/data_provider.rb +107 -0
- data/lib/puppet/pops/lookup/environment_data_provider.rb +35 -0
- data/lib/puppet/pops/lookup/explainer.rb +594 -0
- data/lib/puppet/pops/lookup/function_provider.rb +110 -0
- data/lib/puppet/pops/lookup/global_data_provider.rb +78 -0
- data/lib/puppet/pops/lookup/hiera_config.rb +782 -0
- data/lib/puppet/pops/lookup/interpolation.rb +153 -0
- data/lib/puppet/pops/lookup/invocation.rb +251 -0
- data/lib/puppet/pops/lookup/location_resolver.rb +99 -0
- data/lib/puppet/pops/lookup/lookup_adapter.rb +510 -0
- data/lib/puppet/pops/lookup/lookup_key.rb +99 -0
- data/lib/puppet/pops/lookup/lookup_key_function_provider.rb +92 -0
- data/lib/puppet/pops/lookup/module_data_provider.rb +81 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +90 -0
- data/lib/puppet/pops/lookup.rb +47 -49
- data/lib/puppet/pops/merge_strategy.rb +183 -47
- data/lib/puppet/pops/migration/migration_checker.rb +4 -0
- data/lib/puppet/pops/model/ast_transformer.rb +8 -1
- data/lib/puppet/pops/model/factory.rb +254 -162
- data/lib/puppet/pops/model/model.rb +25 -8
- data/lib/puppet/pops/model/model_label_provider.rb +28 -6
- data/lib/puppet/pops/model/model_meta.rb +45 -2
- data/lib/puppet/pops/model/model_tree_dumper.rb +44 -0
- data/lib/puppet/pops/parser/code_merger.rb +13 -1
- data/lib/puppet/pops/parser/egrammar.ra +150 -32
- data/lib/puppet/pops/parser/eparser.rb +1887 -1321
- data/lib/puppet/pops/parser/epp_support.rb +15 -9
- data/lib/puppet/pops/parser/evaluating_parser.rb +21 -13
- data/lib/puppet/pops/parser/heredoc_support.rb +16 -13
- data/lib/puppet/pops/parser/interpolation_support.rb +7 -0
- data/lib/puppet/pops/parser/lexer2.rb +465 -396
- data/lib/puppet/pops/parser/lexer_support.rb +85 -7
- data/lib/puppet/pops/parser/locator.rb +63 -9
- data/lib/puppet/pops/parser/parser_support.rb +40 -28
- data/lib/puppet/pops/parser/slurp_support.rb +23 -14
- data/lib/puppet/pops/patterns.rb +16 -1
- data/lib/puppet/pops/pcore.rb +96 -0
- data/lib/puppet/pops/puppet_stack.rb +43 -0
- data/lib/puppet/pops/resource/param.rb +55 -0
- data/lib/puppet/pops/resource/resource_type_impl.rb +314 -0
- data/lib/puppet/pops/resource/resource_type_set.pcore +22 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +176 -0
- data/lib/puppet/pops/serialization/abstract_writer.rb +207 -0
- data/lib/puppet/pops/serialization/deserializer.rb +77 -0
- data/lib/puppet/pops/serialization/extension.rb +157 -0
- data/lib/puppet/pops/serialization/instance_reader.rb +19 -0
- data/lib/puppet/pops/serialization/instance_writer.rb +14 -0
- data/lib/puppet/pops/serialization/json.rb +297 -0
- data/lib/puppet/pops/serialization/object.rb +71 -0
- data/lib/puppet/pops/serialization/rgen.rb +152 -0
- data/lib/puppet/pops/serialization/serializer.rb +118 -0
- data/lib/puppet/pops/serialization/time_factory.rb +67 -0
- data/lib/puppet/pops/serialization.rb +17 -0
- data/lib/puppet/pops/time/timespan.rb +718 -0
- data/lib/puppet/pops/time/timestamp.rb +148 -0
- data/lib/puppet/pops/types/annotatable.rb +36 -0
- data/lib/puppet/pops/types/class_loader.rb +25 -23
- data/lib/puppet/pops/types/enumeration.rb +9 -27
- data/lib/puppet/pops/types/implementation_registry.rb +141 -0
- data/lib/puppet/pops/types/iterable.rb +308 -0
- data/lib/puppet/pops/types/p_binary_type.rb +220 -0
- data/lib/puppet/pops/types/p_meta_type.rb +83 -0
- data/lib/puppet/pops/types/p_object_type.rb +886 -0
- data/lib/puppet/pops/types/p_runtime_type.rb +115 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +187 -0
- data/lib/puppet/pops/types/p_sem_ver_type.rb +141 -0
- data/lib/puppet/pops/types/p_sensitive_type.rb +73 -0
- 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/p_type_set_type.rb +352 -0
- data/lib/puppet/pops/types/puppet_object.rb +16 -0
- data/lib/puppet/pops/types/recursion_guard.rb +136 -0
- data/lib/puppet/pops/types/ruby_generator.rb +275 -0
- data/lib/puppet/pops/types/string_converter.rb +1033 -0
- data/lib/puppet/pops/types/type_acceptor.rb +25 -0
- data/lib/puppet/pops/types/type_asserter.rb +21 -19
- data/lib/puppet/pops/types/type_assertion_error.rb +1 -0
- data/lib/puppet/pops/types/type_calculator.rb +244 -1287
- data/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/lib/puppet/pops/types/type_factory.rb +222 -169
- data/lib/puppet/pops/types/type_formatter.rb +686 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1105 -0
- data/lib/puppet/pops/types/type_parser.rb +364 -281
- data/lib/puppet/pops/types/type_set_reference.rb +59 -0
- data/lib/puppet/pops/types/types.rb +3286 -307
- data/lib/puppet/pops/utils.rb +11 -10
- data/lib/puppet/pops/validation/checker4_0.rb +238 -56
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +13 -5
- data/lib/puppet/pops/validation.rb +31 -16
- data/lib/puppet/pops/visitor.rb +9 -6
- data/lib/puppet/pops.rb +40 -25
- data/lib/puppet/property/ensure.rb +1 -1
- data/lib/puppet/property.rb +67 -7
- data/lib/puppet/provider/aixobject.rb +4 -4
- data/lib/puppet/provider/augeas/augeas.rb +57 -2
- data/lib/puppet/provider/cron/crontab.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/exec.rb +10 -3
- data/lib/puppet/provider/group/aix.rb +4 -4
- data/lib/puppet/provider/group/directoryservice.rb +10 -0
- data/lib/puppet/provider/group/pw.rb +1 -0
- data/lib/puppet/provider/group/windows_adsi.rb +15 -3
- data/lib/puppet/provider/macauthorization/macauthorization.rb +11 -10
- data/lib/puppet/provider/mailalias/aliases.rb +1 -1
- data/lib/puppet/provider/mcx/mcxcontent.rb +5 -4
- data/lib/puppet/provider/mount/parsed.rb +16 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +55 -62
- data/lib/puppet/provider/nameservice.rb +23 -8
- data/lib/puppet/provider/package/appdmg.rb +7 -6
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/dnf.rb +46 -0
- data/lib/puppet/provider/package/gem.rb +29 -3
- data/lib/puppet/provider/package/nim.rb +2 -2
- data/lib/puppet/provider/package/openbsd.rb +7 -7
- data/lib/puppet/provider/package/pacman.rb +11 -10
- data/lib/puppet/provider/package/pip.rb +72 -20
- data/lib/puppet/provider/package/pip3.rb +20 -0
- data/lib/puppet/provider/package/pkg.rb +12 -8
- data/lib/puppet/provider/package/pkgdmg.rb +11 -8
- data/lib/puppet/provider/package/pkgin.rb +4 -4
- data/lib/puppet/provider/package/pkgng.rb +15 -6
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +48 -8
- data/lib/puppet/provider/package/puppet_gem.rb +0 -0
- data/lib/puppet/provider/package/rpm.rb +123 -17
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/tdnf.rb +28 -0
- data/lib/puppet/provider/package/windows/exe_package.rb +10 -8
- data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/package/windows.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +62 -83
- data/lib/puppet/provider/package/zypper.rb +19 -0
- data/lib/puppet/provider/package.rb +6 -2
- data/lib/puppet/provider/parsedfile.rb +2 -2
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +7 -0
- data/lib/puppet/provider/selmodule/semodule.rb +20 -16
- data/lib/puppet/provider/service/base.rb +4 -3
- data/lib/puppet/provider/service/bsd.rb +9 -9
- data/lib/puppet/provider/service/daemontools.rb +5 -5
- data/lib/puppet/provider/service/debian.rb +14 -5
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/service/init.rb +20 -3
- data/lib/puppet/provider/service/launchd.rb +57 -19
- data/lib/puppet/provider/service/rcng.rb +51 -0
- data/lib/puppet/provider/service/redhat.rb +2 -1
- data/lib/puppet/provider/service/runit.rb +4 -4
- data/lib/puppet/provider/service/smf.rb +59 -8
- data/lib/puppet/provider/service/src.rb +66 -39
- data/lib/puppet/provider/service/systemd.rb +141 -22
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/provider/sshkey/parsed.rb +20 -10
- data/lib/puppet/provider/user/aix.rb +11 -5
- data/lib/puppet/provider/user/directoryservice.rb +43 -66
- data/lib/puppet/provider/user/hpux.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +1 -0
- data/lib/puppet/provider/user/user_role_add.rb +19 -2
- data/lib/puppet/provider/user/windows_adsi.rb +11 -5
- data/lib/puppet/provider/yumrepo/inifile.rb +9 -6
- data/lib/puppet/provider/zfs/zfs.rb +2 -2
- data/lib/puppet/provider/zone/solaris.rb +6 -3
- data/lib/puppet/provider/zpool/zpool.rb +2 -2
- data/lib/puppet/provider.rb +9 -7
- data/lib/puppet/reference/configuration.rb +13 -5
- data/lib/puppet/reference/indirection.rb +1 -1
- data/lib/puppet/reference/providers.rb +2 -3
- data/lib/puppet/reference/report.rb +9 -12
- data/lib/puppet/reference/type.rb +1 -1
- data/lib/puppet/reports.rb +5 -1
- data/lib/puppet/resource/capability_finder.rb +128 -0
- data/lib/puppet/resource/catalog.rb +167 -36
- data/lib/puppet/resource/status.rb +30 -5
- data/lib/puppet/resource/type.rb +247 -50
- data/lib/puppet/resource/type_collection.rb +83 -10
- data/lib/puppet/resource.rb +211 -145
- data/lib/puppet/settings/base_setting.rb +9 -3
- data/lib/puppet/settings/config_file.rb +3 -2
- data/lib/puppet/settings/directory_setting.rb +6 -0
- data/lib/puppet/settings/environment_conf.rb +26 -6
- data/lib/puppet/settings/file_or_directory_setting.rb +6 -0
- data/lib/puppet/settings/file_setting.rb +20 -9
- data/lib/puppet/settings/ini_file.rb +2 -2
- data/lib/puppet/settings/server_list_setting.rb +20 -0
- data/lib/puppet/settings/symbolic_enum_setting.rb +17 -0
- data/lib/puppet/settings.rb +98 -45
- data/lib/puppet/ssl/base.rb +14 -1
- data/lib/puppet/ssl/certificate.rb +1 -1
- data/lib/puppet/ssl/certificate_authority/interface.rb +166 -26
- data/lib/puppet/ssl/certificate_authority.rb +49 -13
- data/lib/puppet/ssl/certificate_factory.rb +3 -3
- data/lib/puppet/ssl/certificate_request.rb +5 -5
- data/lib/puppet/ssl/certificate_signer.rb +1 -1
- data/lib/puppet/ssl/configuration.rb +4 -1
- data/lib/puppet/ssl/host.rb +26 -4
- data/lib/puppet/ssl/inventory.rb +10 -3
- data/lib/puppet/ssl/key.rb +7 -3
- data/lib/puppet/ssl/oids.rb +43 -3
- data/lib/puppet/ssl/validator/default_validator.rb +3 -3
- data/lib/puppet/syntax_checkers/base64.rb +41 -0
- data/lib/puppet/syntax_checkers/json.rb +0 -2
- data/lib/puppet/test/test_helper.rb +21 -7
- data/lib/puppet/transaction/additional_resource_generator.rb +101 -8
- data/lib/puppet/transaction/event.rb +29 -2
- data/lib/puppet/transaction/event_manager.rb +1 -1
- data/lib/puppet/transaction/persistence.rb +84 -0
- data/lib/puppet/transaction/report.rb +86 -4
- data/lib/puppet/transaction/resource_harness.rb +95 -35
- data/lib/puppet/transaction.rb +64 -36
- data/lib/puppet/type/augeas.rb +13 -4
- data/lib/puppet/type/component.rb +11 -0
- data/lib/puppet/type/cron.rb +13 -13
- data/lib/puppet/type/exec.rb +43 -19
- data/lib/puppet/type/file/checksum.rb +1 -0
- data/lib/puppet/type/file/checksum_value.rb +53 -0
- data/lib/puppet/type/file/content.rb +36 -121
- data/lib/puppet/type/file/data_sync.rb +92 -0
- data/lib/puppet/type/file/ensure.rb +21 -18
- data/lib/puppet/type/file/selcontext.rb +1 -1
- data/lib/puppet/type/file/source.rb +121 -34
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/file.rb +145 -46
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +26 -8
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/interface.rb +8 -3
- data/lib/puppet/type/macauthorization.rb +1 -1
- data/lib/puppet/type/mount.rb +16 -1
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +32 -12
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/schedule.rb +5 -5
- data/lib/puppet/type/scheduled_task.rb +1 -1
- data/lib/puppet/type/service.rb +24 -0
- data/lib/puppet/type/ssh_authorized_key.rb +17 -11
- data/lib/puppet/type/sshkey.rb +5 -3
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/tidy.rb +7 -4
- data/lib/puppet/type/user.rb +51 -26
- data/lib/puppet/type/yumrepo.rb +23 -3
- data/lib/puppet/type/zone.rb +6 -6
- data/lib/puppet/type.rb +175 -41
- data/lib/puppet/util/autoload.rb +16 -11
- data/lib/puppet/util/character_encoding.rb +95 -0
- data/lib/puppet/util/checksums.rb +74 -31
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/command_line.rb +10 -2
- data/lib/puppet/util/execution.rb +35 -16
- data/lib/puppet/util/feature.rb +1 -1
- data/lib/puppet/util/filetype.rb +11 -5
- data/lib/puppet/util/http_proxy.rb +132 -0
- data/lib/puppet/util/inifile.rb +1 -1
- data/lib/puppet/util/instance_loader.rb +1 -1
- data/lib/puppet/util/log.rb +28 -1
- data/lib/puppet/util/logging.rb +46 -3
- data/lib/puppet/util/monkey_patches.rb +20 -7
- data/lib/puppet/util/multi_match.rb +51 -0
- data/lib/puppet/util/network_device/cisco/device.rb +24 -6
- data/lib/puppet/util/network_device/cisco/interface.rb +21 -9
- data/lib/puppet/util/network_device/config.rb +1 -1
- data/lib/puppet/util/network_device/transport/ssh.rb +7 -3
- data/lib/puppet/util/network_device/transport/telnet.rb +39 -36
- data/lib/puppet/util/plist.rb +151 -0
- data/lib/puppet/util/profiler/aggregate.rb +1 -1
- data/lib/puppet/util/profiler/around_profiler.rb +1 -1
- data/lib/puppet/util/profiler.rb +1 -1
- data/lib/puppet/util/psych_support.rb +1 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +2 -2
- data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +2 -1
- data/lib/puppet/util/rdoc.rb +2 -2
- data/lib/puppet/util/reference.rb +4 -2
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/rubygems.rb +1 -1
- data/lib/puppet/util/run_mode.rb +2 -2
- data/lib/puppet/util/skip_tags.rb +9 -0
- data/lib/puppet/util/splayer.rb +18 -0
- data/lib/puppet/util/tagging.rb +8 -2
- data/lib/puppet/util/watcher/periodic_watcher.rb +2 -2
- data/lib/puppet/util/windows/access_control_entry.rb +2 -2
- data/lib/puppet/util/windows/access_control_list.rb +3 -3
- data/lib/puppet/util/windows/adsi.rb +97 -32
- data/lib/puppet/util/windows/api_types.rb +24 -18
- data/lib/puppet/util/windows/com.rb +3 -3
- data/lib/puppet/util/windows/error.rb +1 -1
- data/lib/puppet/util/windows/file.rb +112 -19
- data/lib/puppet/util/windows/principal.rb +190 -0
- data/lib/puppet/util/windows/process.rb +88 -11
- data/lib/puppet/util/windows/registry.rb +22 -16
- data/lib/puppet/util/windows/root_certs.rb +5 -5
- data/lib/puppet/util/windows/security.rb +38 -37
- data/lib/puppet/util/windows/security_descriptor.rb +1 -1
- data/lib/puppet/util/windows/sid.rb +84 -15
- data/lib/puppet/util/windows/taskscheduler.rb +99 -43
- data/lib/puppet/util/windows/user.rb +32 -14
- data/lib/puppet/util/windows.rb +5 -0
- data/lib/puppet/util/yaml.rb +15 -3
- data/lib/puppet/util.rb +125 -23
- data/lib/puppet/vendor/deep_merge/deep_merge.gemspec +1 -1
- data/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +1 -1
- data/lib/puppet/vendor/load_semantic_puppet.rb +1 -0
- data/lib/puppet/vendor/pathspec/LICENSE +2 -2
- data/lib/puppet/vendor/pathspec/README.md +1 -1
- data/lib/puppet/vendor/pathspec/lib/pathspec.rb +2 -1
- data/lib/puppet/vendor/require_vendored.rb +0 -1
- data/lib/puppet/vendor/rgen/README.rdoc +1 -1
- data/lib/puppet/vendor/rgen_patch.rb +1 -1
- data/lib/puppet/vendor/semantic/lib/semantic.rb +4 -6
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/graph.rb +2 -2
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/graph_node.rb +2 -2
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/module_release.rb +17 -5
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/source.rb +2 -2
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/unsatisfiable_graph.rb +2 -2
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency.rb +7 -7
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +3 -0
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/locales/config.yaml +21 -0
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/version.rb +48 -21
- data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/version_range.rb +15 -17
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +17 -0
- data/lib/puppet/version.rb +7 -3
- data/lib/puppet.rb +86 -2
- data/lib/puppet_x.rb +7 -1
- data/lib/semver.rb +36 -13
- data/locales/config.yaml +29 -0
- data/locales/puppet.pot +93 -0
- data/man/man5/puppet.conf.5 +13 -13
- data/man/man8/extlookup2hiera.8 +1 -1
- data/man/man8/puppet-agent.8 +2 -2
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-ca.8 +2 -2
- data/man/man8/puppet-catalog.8 +2 -2
- data/man/man8/puppet-cert.8 +2 -2
- data/man/man8/puppet-certificate.8 +2 -2
- data/man/man8/puppet-certificate_request.8 +2 -2
- data/man/man8/puppet-certificate_revocation_list.8 +2 -2
- data/man/man8/puppet-config.8 +3 -3
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +2 -2
- data/man/man8/puppet-facts.8 +2 -2
- data/man/man8/puppet-file.8 +2 -2
- data/man/man8/puppet-filebucket.8 +2 -2
- data/man/man8/puppet-help.8 +2 -2
- data/man/man8/puppet-inspect.8 +2 -2
- data/man/man8/puppet-key.8 +2 -2
- data/man/man8/puppet-man.8 +2 -2
- data/man/man8/puppet-master.8 +2 -2
- data/man/man8/puppet-module.8 +9 -9
- data/man/man8/puppet-node.8 +2 -2
- data/man/man8/puppet-parser.8 +2 -2
- data/man/man8/puppet-plugin.8 +2 -2
- data/man/man8/puppet-report.8 +2 -2
- data/man/man8/puppet-resource.8 +2 -2
- data/man/man8/puppet-resource_type.8 +2 -2
- data/man/man8/puppet-status.8 +3 -3
- data/man/man8/puppet.8 +1 -1
- data/spec/fixtures/module.tar.gz +0 -0
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +22 -0
- data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
- data/spec/fixtures/unit/application/environments/production/manifests/site.pp +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/environment.conf +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/functions/environment/data.pp +10 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/third_utf8.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/utf8.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +22 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +48 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/server1.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/server2.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +20 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/data/common.yaml +6 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/manifests/init.pp +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/manifests/init.pp +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +2 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/manifests/init.pp +2 -1
- data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/lib/puppet/bindings/backend/default.rb +9 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/lib/puppet_x/backend/special_data_provider_factory.rb +23 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +2 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +1 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/manifests/init.pp +1 -1
- data/spec/fixtures/unit/functions/lookup/data/common.yaml +19 -0
- data/spec/fixtures/unit/functions/lookup_fixture/data/common.yaml +19 -0
- data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bad_data/lib/puppet/functions/bad_data/data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/bad_data/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_json/data/empty.json +0 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_json/data/empty_key.json +1 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_yaml/data/empty_key.yaml +1 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_key_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_yaml/data/empty.yaml +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/empty_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/hieraprovider/data/first.json +4 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/hieraprovider/hiera.yaml +8 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/hieraprovider/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/meta/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/meta/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/metawcp/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/metawcp/metadata.json +9 -0
- data/spec/fixtures/unit/module/trailing-comma.json +1 -1
- data/spec/fixtures/unit/parser/lexer/subclass_name_duplication.pp +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/functions/usee_puppet.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/functions/usee/usee_ruby.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/type/usee_type.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/manifests/init.pp +8 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/types/zero.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee2/lib/puppet/functions/usee2/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet_init.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_ruby.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/caller2.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet_init.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_ruby.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +87 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/metadata.json +2 -1
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseeone.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseezero.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/no_modules/manifests/site.pp +10 -0
- data/spec/fixtures/unit/pops/parser/lexer/subclass_name_duplication.pp +0 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-broken-notices.txt +187 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-obsoletes.txt +195 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
- data/spec/fixtures/unit/provider/service/smf/svcs.out +4 -3
- data/spec/fixtures/unit/provider/sshkey/parsed/sample_with_blank_lines +8 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_not_update_if_content_on_disk_is_up-to-date.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_update_if_content_differs_on_disk.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_mtime_is_older_on_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_no_header_specified.yml +197 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_not_update_if_mtime_is_newer_on_disk.yml +205 -0
- data/spec/integration/agent/logging_spec.rb +15 -14
- data/spec/integration/application/apply_spec.rb +383 -29
- data/spec/integration/application/doc_spec.rb +0 -0
- data/spec/integration/application/lookup_spec.rb +155 -0
- data/spec/integration/configurer_spec.rb +0 -0
- data/spec/integration/data_binding_spec.rb +195 -0
- data/spec/integration/defaults_spec.rb +27 -2
- data/spec/integration/directory_environments_spec.rb +16 -0
- data/spec/integration/environments/default_manifest_spec.rb +16 -16
- data/spec/integration/environments/setting_hooks_spec.rb +1 -1
- data/spec/integration/environments/settings_spec.rb +32 -4
- data/spec/integration/faces/ca_spec.rb +0 -0
- data/spec/integration/faces/config_spec.rb +80 -0
- data/spec/integration/faces/documentation_spec.rb +1 -1
- data/spec/integration/file_bucket/file_spec.rb +2 -2
- data/spec/integration/file_serving/fileset_spec.rb +0 -0
- data/spec/integration/file_serving/terminus_helper_spec.rb +0 -0
- data/spec/integration/file_system/uniquefile_spec.rb +29 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +0 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +0 -0
- data/spec/integration/indirector/facts/facter_spec.rb +38 -0
- data/spec/integration/indirector/file_content/file_server_spec.rb +0 -0
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +0 -0
- data/spec/integration/indirector/node/ldap_spec.rb +0 -0
- data/spec/integration/module_tool/tar/mini_spec.rb +28 -0
- data/spec/integration/network/formats_spec.rb +0 -0
- data/spec/integration/network/http/api/indirected_routes_spec.rb +33 -0
- data/spec/integration/node/environment_spec.rb +34 -0
- data/spec/integration/node/facts_spec.rb +0 -0
- data/spec/integration/node_spec.rb +0 -0
- data/spec/integration/parser/catalog_spec.rb +14 -2
- data/spec/integration/parser/collection_spec.rb +18 -0
- data/spec/integration/parser/compiler_spec.rb +225 -864
- data/spec/integration/parser/dynamic_scoping_spec.rb +67 -0
- data/spec/integration/parser/parameter_defaults_spec.rb +358 -0
- data/spec/integration/parser/pcore_resource_spec.rb +245 -0
- data/spec/integration/parser/resource_expressions_spec.rb +9 -7
- data/spec/integration/parser/scope_spec.rb +20 -2
- data/spec/integration/parser/undef_param_spec.rb +9 -1
- data/spec/integration/provider/mailalias/aliases_spec.rb +0 -0
- data/spec/integration/provider/mount_spec.rb +23 -36
- data/spec/integration/provider/service/init_spec.rb +0 -0
- data/spec/integration/provider/service/windows_spec.rb +3 -2
- data/spec/integration/provider/ssh_authorized_key_spec.rb +0 -0
- data/spec/integration/provider/yumrepo_spec.rb +4 -1
- data/spec/integration/reference/providers_spec.rb +0 -0
- data/spec/integration/reports_spec.rb +0 -0
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/resource/type_collection_spec.rb +8 -0
- data/spec/integration/ssl/autosign_spec.rb +18 -3
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -1
- data/spec/integration/ssl/certificate_request_spec.rb +0 -1
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -1
- data/spec/integration/ssl/host_spec.rb +0 -1
- data/spec/integration/ssl/key_spec.rb +104 -0
- data/spec/integration/test/test_helper_spec.rb +32 -0
- data/spec/integration/transaction/report_spec.rb +682 -0
- data/spec/integration/transaction_spec.rb +125 -1
- data/spec/integration/type/exec_spec.rb +0 -0
- data/spec/integration/type/file_spec.rb +237 -12
- data/spec/integration/type/package_spec.rb +72 -1
- data/spec/integration/type/tidy_spec.rb +21 -9
- data/spec/integration/type/user_spec.rb +13 -6
- data/spec/integration/type_spec.rb +0 -0
- data/spec/integration/util/autoload_spec.rb +0 -0
- data/spec/integration/util/execution_spec.rb +30 -0
- data/spec/integration/util/rdoc/parser_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +26 -0
- data/spec/integration/util/windows/adsi_spec.rb +99 -0
- data/spec/integration/util/windows/principal_spec.rb +250 -0
- data/spec/integration/util/windows/process_spec.rb +35 -2
- data/spec/{unit → integration}/util/windows/registry_spec.rb +92 -2
- data/spec/integration/util/windows/security_spec.rb +61 -16
- data/spec/integration/util/windows/user_spec.rb +27 -5
- data/spec/integration/util_spec.rb +49 -27
- data/spec/lib/matchers/include_in_order.rb +2 -3
- data/spec/lib/puppet/face/1.0.0/huzzah.rb +0 -0
- data/spec/lib/puppet/face/basetest.rb +0 -0
- data/spec/lib/puppet/face/huzzah.rb +0 -0
- data/spec/lib/puppet_spec/compiler.rb +32 -3
- data/spec/lib/puppet_spec/files.rb +16 -2
- data/spec/lib/puppet_spec/fixtures.rb +0 -0
- data/spec/lib/puppet_spec/language.rb +3 -1
- data/spec/lib/puppet_spec/module_tool/shared_functions.rb +2 -2
- data/spec/lib/puppet_spec/module_tool/stub_source.rb +1 -1
- data/spec/lib/puppet_spec/network.rb +12 -8
- data/spec/lib/puppet_spec/pops.rb +13 -0
- data/spec/lib/puppet_spec/unindent.rb +5 -0
- data/spec/lib/puppet_spec/verbose.rb +0 -0
- data/spec/shared_behaviours/all_parsedfile_providers.rb +0 -0
- data/spec/shared_behaviours/file_server_terminus.rb +0 -0
- data/spec/shared_behaviours/file_serving.rb +0 -0
- data/spec/shared_behaviours/iterative_functions.rb +9 -9
- data/spec/shared_behaviours/memory_terminus.rb +0 -0
- data/spec/shared_behaviours/path_parameters.rb +0 -0
- data/spec/shared_behaviours/things_that_declare_options.rb +0 -0
- data/spec/shared_contexts/types_setup.rb +106 -0
- data/spec/shared_examples/rhel_package_provider.rb +357 -0
- data/spec/spec_helper.rb +23 -2
- data/spec/unit/agent/locker_spec.rb +4 -4
- data/spec/unit/agent_spec.rb +12 -46
- data/spec/unit/application/agent_spec.rb +15 -0
- data/spec/unit/application/apply_spec.rb +31 -1
- data/spec/unit/application/cert_spec.rb +20 -0
- data/spec/unit/application/certificate_spec.rb +0 -0
- data/spec/unit/application/config_spec.rb +0 -0
- data/spec/unit/application/describe_spec.rb +0 -0
- data/spec/unit/application/device_spec.rb +0 -0
- data/spec/unit/application/doc_spec.rb +0 -0
- data/spec/unit/application/face_base_spec.rb +16 -0
- data/spec/unit/application/facts_spec.rb +0 -0
- data/spec/unit/application/filebucket_spec.rb +88 -2
- data/spec/unit/application/indirection_base_spec.rb +0 -0
- data/spec/unit/application/inspect_spec.rb +28 -10
- data/spec/unit/application/lookup_spec.rb +532 -0
- data/spec/unit/application/master_spec.rb +2 -2
- data/spec/unit/application/resource_spec.rb +0 -0
- data/spec/unit/application_spec.rb +3 -3
- data/spec/unit/capability_spec.rb +416 -0
- data/spec/unit/configurer/downloader_factory_spec.rb +0 -0
- data/spec/unit/configurer/downloader_spec.rb +5 -5
- data/spec/unit/configurer/fact_handler_spec.rb +0 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +18 -15
- data/spec/unit/configurer_spec.rb +336 -39
- data/spec/unit/confine/exists_spec.rb +0 -0
- data/spec/unit/confine/false_spec.rb +0 -0
- data/spec/unit/confine/feature_spec.rb +0 -0
- data/spec/unit/confine/true_spec.rb +0 -0
- data/spec/unit/confine/variable_spec.rb +0 -0
- data/spec/unit/confine_collection_spec.rb +0 -0
- data/spec/unit/confine_spec.rb +0 -0
- data/spec/unit/confiner_spec.rb +0 -0
- data/spec/unit/context/trusted_information_spec.rb +24 -1
- data/spec/unit/daemon_spec.rb +18 -8
- data/spec/unit/data_providers/{sample_data_provider_spec.rb → custom_data_provider_spec.rb} +14 -16
- data/spec/unit/data_providers/function_data_provider_spec.rb +21 -3
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +361 -0
- data/spec/unit/defaults_spec.rb +47 -0
- data/spec/unit/environments_spec.rb +26 -4
- data/spec/unit/etc_spec.rb +234 -0
- data/spec/unit/external/pson_spec.rb +0 -0
- data/spec/unit/face/ca_spec.rb +10 -0
- data/spec/unit/face/catalog_spec.rb +0 -0
- data/spec/unit/face/certificate_request_spec.rb +10 -0
- data/spec/unit/face/certificate_revocation_list_spec.rb +10 -0
- data/spec/unit/face/certificate_spec.rb +10 -2
- data/spec/unit/face/config_spec.rb +47 -0
- data/spec/unit/face/epp_face_spec.rb +24 -5
- data/spec/unit/face/facts_spec.rb +0 -0
- data/spec/unit/face/file_spec.rb +4 -0
- data/spec/unit/face/generate_spec.rb +230 -0
- data/spec/unit/face/help_spec.rb +70 -0
- data/spec/unit/face/key_spec.rb +10 -0
- data/spec/unit/face/module/search_spec.rb +1 -1
- data/spec/unit/face/node_spec.rb +1 -1
- data/spec/unit/face/parser_spec.rb +49 -2
- data/spec/unit/face/plugin_spec.rb +29 -4
- data/spec/unit/face/status_spec.rb +10 -0
- data/spec/unit/face_spec.rb +0 -0
- data/spec/unit/file_bucket/dipper_spec.rb +210 -1
- data/spec/unit/file_bucket/file_spec.rb +0 -0
- data/spec/unit/file_serving/base_spec.rb +0 -0
- data/spec/unit/file_serving/configuration/parser_spec.rb +25 -30
- data/spec/unit/file_serving/configuration_spec.rb +1 -1
- data/spec/unit/file_serving/content_spec.rb +0 -0
- data/spec/unit/file_serving/fileset_spec.rb +0 -0
- data/spec/unit/file_serving/http_metadata_spec.rb +85 -0
- data/spec/unit/file_serving/metadata_spec.rb +50 -0
- data/spec/unit/file_serving/mount/file_spec.rb +0 -0
- data/spec/unit/file_serving/mount/modules_spec.rb +0 -0
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +0 -0
- data/spec/unit/file_serving/mount/plugins_spec.rb +0 -0
- data/spec/unit/file_serving/mount_spec.rb +0 -0
- data/spec/unit/file_serving/terminus_helper_spec.rb +0 -0
- data/spec/unit/file_serving/terminus_selector_spec.rb +12 -2
- data/spec/unit/file_system/uniquefile_spec.rb +20 -0
- data/spec/unit/file_system_spec.rb +335 -6
- data/spec/unit/forge/repository_spec.rb +27 -0
- data/spec/unit/functions/assert_type_spec.rb +48 -8
- 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/defined_spec.rb +2 -2
- data/spec/unit/functions/dig_spec.rb +58 -0
- data/spec/unit/functions/epp_spec.rb +17 -9
- data/spec/unit/functions/filter_spec.rb +18 -0
- data/spec/unit/functions/find_file_spec.rb +69 -0
- data/spec/unit/functions/hiera_spec.rb +447 -47
- data/spec/unit/functions/include_spec.rb +175 -0
- data/spec/unit/functions/inline_epp_spec.rb +4 -4
- data/spec/unit/functions/lest_spec.rb +34 -0
- data/spec/unit/functions/logging_spec.rb +54 -0
- data/spec/unit/functions/lookup_fixture_spec.rb +693 -0
- data/spec/unit/functions/lookup_spec.rb +2904 -265
- data/spec/unit/functions/match_spec.rb +2 -2
- data/spec/unit/functions/new_spec.rb +694 -0
- data/spec/unit/functions/next_spec.rb +93 -0
- data/spec/unit/functions/regsubst_spec.rb +26 -9
- data/spec/unit/functions/require_spec.rb +83 -0
- data/spec/unit/functions/return_spec.rb +105 -0
- data/spec/unit/functions/reverse_each_spec.rb +108 -0
- data/spec/unit/functions/scanf_spec.rb +1 -1
- data/spec/unit/{parser/functions → functions}/shared.rb +15 -12
- data/spec/unit/functions/split_spec.rb +3 -3
- data/spec/unit/functions/step_spec.rb +113 -0
- data/spec/unit/functions/strftime_spec.rb +152 -0
- data/spec/unit/functions/then_spec.rb +40 -0
- data/spec/unit/functions/type_spec.rb +35 -0
- data/spec/unit/functions/unwrap_spec.rb +29 -0
- data/spec/unit/functions/versioncmp_spec.rb +36 -0
- data/spec/unit/functions4_spec.rb +270 -79
- data/spec/unit/graph/rb_tree_map_spec.rb +1 -1
- data/spec/unit/graph/relationship_graph_spec.rb +0 -0
- data/spec/unit/graph/sequential_prioritizer_spec.rb +1 -1
- data/spec/unit/graph/simple_graph_spec.rb +1 -1
- data/spec/unit/hiera/scope_spec.rb +6 -3
- data/spec/unit/hiera_puppet_spec.rb +49 -8
- data/spec/unit/indirector/catalog/compiler_spec.rb +752 -8
- data/spec/unit/indirector/catalog/json_spec.rb +0 -0
- data/spec/unit/indirector/catalog/msgpack_spec.rb +0 -0
- data/spec/unit/indirector/catalog/rest_spec.rb +0 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +38 -20
- data/spec/unit/indirector/catalog/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/catalog/yaml_spec.rb +0 -0
- data/spec/unit/indirector/certificate/ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate/file_spec.rb +0 -0
- data/spec/unit/indirector/certificate/rest_spec.rb +0 -0
- data/spec/unit/indirector/certificate_request/ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate_request/file_spec.rb +0 -0
- data/spec/unit/indirector/certificate_request/rest_spec.rb +0 -0
- data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -0
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +0 -0
- data/spec/unit/indirector/certificate_status/file_spec.rb +0 -0
- data/spec/unit/indirector/certificate_status/rest_spec.rb +0 -0
- data/spec/unit/indirector/code_spec.rb +0 -0
- data/spec/unit/indirector/data_binding/none_spec.rb +2 -2
- data/spec/unit/indirector/direct_file_server_spec.rb +0 -0
- data/spec/unit/indirector/envelope_spec.rb +0 -0
- data/spec/unit/indirector/exec_spec.rb +0 -0
- data/spec/unit/indirector/face_spec.rb +10 -2
- data/spec/unit/indirector/facts/facter_spec.rb +3 -10
- data/spec/unit/indirector/facts/network_device_spec.rb +0 -0
- data/spec/unit/indirector/facts/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/facts/yaml_spec.rb +0 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +86 -4
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_content/file_server_spec.rb +0 -0
- data/spec/unit/indirector/file_content/file_spec.rb +0 -0
- data/spec/unit/indirector/file_content/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/file_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_server_spec.rb +0 -0
- data/spec/unit/indirector/indirection_spec.rb +13 -2
- data/spec/unit/indirector/json_spec.rb +1 -1
- data/spec/unit/indirector/key/ca_spec.rb +0 -0
- data/spec/unit/indirector/key/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/key/file_spec.rb +1 -1
- data/spec/unit/indirector/ldap_spec.rb +0 -0
- data/spec/unit/indirector/memory_spec.rb +0 -0
- data/spec/unit/indirector/msgpack_spec.rb +11 -1
- data/spec/unit/indirector/node/exec_spec.rb +0 -0
- data/spec/unit/indirector/node/ldap_spec.rb +0 -0
- data/spec/unit/indirector/node/memory_spec.rb +0 -0
- data/spec/unit/indirector/node/msgpack_spec.rb +0 -0
- data/spec/unit/indirector/node/plain_spec.rb +0 -0
- data/spec/unit/indirector/node/rest_spec.rb +0 -0
- data/spec/unit/indirector/node/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/node/yaml_spec.rb +0 -0
- data/spec/unit/indirector/plain_spec.rb +0 -0
- data/spec/unit/indirector/report/msgpack_spec.rb +0 -0
- data/spec/unit/indirector/report/processor_spec.rb +0 -0
- data/spec/unit/indirector/report/rest_spec.rb +0 -0
- data/spec/unit/indirector/report/yaml_spec.rb +0 -0
- data/spec/unit/indirector/request_spec.rb +17 -8
- data/spec/unit/indirector/resource/ral_spec.rb +0 -0
- data/spec/unit/indirector/resource/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/resource_type/parser_spec.rb +5 -0
- data/spec/unit/indirector/resource_type/rest_spec.rb +0 -0
- data/spec/unit/indirector/rest_spec.rb +107 -9
- data/spec/unit/indirector/ssl_file_spec.rb +4 -4
- data/spec/unit/indirector/status/rest_spec.rb +0 -0
- data/spec/unit/indirector/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/terminus_spec.rb +0 -0
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/indirector_spec.rb +0 -0
- data/spec/unit/info_service_spec.rb +298 -0
- data/spec/unit/interface/action_builder_spec.rb +0 -0
- data/spec/unit/interface/action_manager_spec.rb +0 -0
- data/spec/unit/interface/action_spec.rb +0 -0
- data/spec/unit/interface/documentation_spec.rb +0 -0
- data/spec/unit/interface/face_collection_spec.rb +0 -0
- data/spec/unit/interface/option_builder_spec.rb +0 -0
- data/spec/unit/interface/option_spec.rb +0 -0
- data/spec/unit/interface_spec.rb +27 -0
- data/spec/unit/man_spec.rb +1 -1
- data/spec/unit/module_spec.rb +118 -74
- data/spec/unit/module_tool/application_spec.rb +1 -1
- data/spec/unit/module_tool/applications/builder_spec.rb +44 -9
- data/spec/unit/module_tool/applications/installer_spec.rb +11 -2
- data/spec/unit/module_tool/applications/unpacker_spec.rb +2 -1
- data/spec/unit/module_tool/applications/upgrader_spec.rb +9 -1
- data/spec/unit/module_tool/installed_modules_spec.rb +6 -6
- data/spec/unit/module_tool/metadata_spec.rb +31 -2
- data/spec/unit/module_tool/tar/mini_spec.rb +3 -3
- data/spec/unit/module_tool_spec.rb +3 -3
- data/spec/unit/network/auth_config_parser_spec.rb +16 -0
- data/spec/unit/network/authconfig_spec.rb +62 -32
- data/spec/unit/network/authorization_spec.rb +30 -2
- data/spec/unit/network/authstore_spec.rb +2 -2
- data/spec/unit/network/format_handler_spec.rb +0 -0
- data/spec/unit/network/format_spec.rb +0 -0
- data/spec/unit/network/formats_spec.rb +0 -0
- data/spec/unit/network/http/api/indirected_routes_spec.rb +70 -71
- data/spec/unit/network/http/api/master/v3/environment_spec.rb +60 -0
- data/spec/unit/network/http/api/master/v3_spec.rb +22 -4
- data/spec/unit/network/http/compression_spec.rb +40 -9
- data/spec/unit/network/http/connection_spec.rb +25 -19
- data/spec/unit/network/http/error_spec.rb +2 -1
- data/spec/unit/network/http/factory_spec.rb +18 -0
- data/spec/unit/network/http/handler_spec.rb +11 -8
- data/spec/unit/network/http/nocache_pool_spec.rb +0 -0
- data/spec/unit/network/http/pool_spec.rb +30 -0
- data/spec/unit/network/http/rack/rest_spec.rb +7 -0
- data/spec/unit/network/http/rack_spec.rb +0 -0
- data/spec/unit/network/http/session_spec.rb +0 -0
- data/spec/unit/network/http/site_spec.rb +0 -0
- data/spec/unit/network/http/webrick/rest_spec.rb +0 -0
- data/spec/unit/network/http/webrick_spec.rb +1 -1
- data/spec/unit/network/http_pool_spec.rb +0 -0
- data/spec/unit/network/http_spec.rb +0 -0
- data/spec/unit/network/resolver_spec.rb +0 -0
- data/spec/unit/network/rights_spec.rb +4 -4
- data/spec/unit/network/server_spec.rb +0 -0
- data/spec/unit/node/environment_spec.rb +10 -0
- data/spec/unit/node/facts_spec.rb +0 -0
- data/spec/unit/node_spec.rb +35 -0
- data/spec/unit/other/selinux_spec.rb +0 -0
- data/spec/unit/parameter/path_spec.rb +0 -0
- data/spec/unit/parameter/value_collection_spec.rb +0 -0
- data/spec/unit/parameter/value_spec.rb +0 -0
- data/spec/unit/parameter_spec.rb +11 -0
- data/spec/unit/parser/ast/leaf_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +134 -33
- data/spec/unit/parser/environment_compiler_spec.rb +688 -0
- data/spec/unit/parser/files_spec.rb +0 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +86 -5
- data/spec/unit/parser/functions/digest_spec.rb +0 -0
- data/spec/unit/parser/functions/fail_spec.rb +0 -0
- data/spec/unit/parser/functions/file_spec.rb +0 -0
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +6 -2
- data/spec/unit/parser/functions/generate_spec.rb +3 -12
- 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/inline_template_spec.rb +0 -0
- data/spec/unit/parser/functions/lookup_spec.rb +1 -1
- data/spec/unit/parser/functions/realize_spec.rb +0 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
- data/spec/unit/parser/functions/scanf_spec.rb +0 -0
- data/spec/unit/parser/functions/shellquote_spec.rb +0 -0
- data/spec/unit/parser/functions/split_spec.rb +1 -1
- data/spec/unit/parser/functions/sprintf_spec.rb +0 -0
- data/spec/unit/parser/functions/tag_spec.rb +0 -0
- data/spec/unit/parser/functions/template_spec.rb +0 -0
- data/spec/unit/parser/functions/versioncmp_spec.rb +0 -0
- data/spec/unit/parser/functions_spec.rb +0 -0
- data/spec/unit/parser/relationship_spec.rb +0 -0
- data/spec/unit/parser/resource/param_spec.rb +0 -0
- data/spec/unit/parser/resource_spec.rb +31 -32
- data/spec/unit/parser/scope_spec.rb +83 -16
- data/spec/unit/parser/templatewrapper_spec.rb +0 -0
- data/spec/unit/parser/type_loader_spec.rb +0 -0
- data/spec/unit/pops/binder/config/binder_config_spec.rb +1 -1
- data/spec/unit/pops/binder/injector_spec.rb +3 -3
- data/spec/unit/pops/evaluator/access_ops_spec.rb +115 -19
- data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
- data/spec/unit/pops/evaluator/basic_expressions_spec.rb +1 -2
- data/spec/unit/pops/evaluator/comparison_ops_spec.rb +3 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +76 -23
- data/spec/unit/pops/evaluator/evaluator_rspec_helper.rb +29 -25
- data/spec/unit/pops/evaluator/json_strict_literal_evaluator_spec.rb +63 -0
- data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +133 -0
- data/spec/unit/pops/evaluator/variables_spec.rb +1 -1
- data/spec/unit/pops/label_provider_spec.rb +5 -1
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +66 -1
- data/spec/unit/pops/loaders/environment_loader_spec.rb +172 -0
- data/spec/unit/pops/loaders/loader_paths_spec.rb +1 -1
- data/spec/unit/pops/loaders/loaders_spec.rb +323 -27
- data/spec/unit/pops/loaders/module_loaders_spec.rb +63 -2
- data/spec/unit/pops/loaders/static_loader_spec.rb +83 -18
- data/spec/unit/pops/lookup/context_spec.rb +334 -0
- data/spec/unit/pops/lookup/interpolation_spec.rb +333 -0
- data/spec/unit/pops/lookup/lookup_spec.rb +262 -0
- data/spec/unit/pops/merge_strategy_spec.rb +18 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +236 -10
- data/spec/unit/pops/parser/parse_application_spec.rb +35 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +31 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +25 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +40 -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/parser/parse_site_spec.rb +51 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +6 -0
- data/spec/unit/pops/parser/parser_spec.rb +28 -0
- data/spec/unit/pops/parser/source_pos_adapter_spec.rb +26 -0
- data/spec/unit/pops/puppet_stack_spec.rb +79 -0
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +111 -0
- data/spec/unit/pops/serialization/packer_spec.rb +154 -0
- data/spec/unit/pops/serialization/rgen_spec.rb +88 -0
- data/spec/unit/pops/serialization/serialization_spec.rb +314 -0
- data/spec/unit/pops/time/timespan_spec.rb +121 -0
- data/spec/unit/pops/types/enumeration_spec.rb +13 -12
- data/spec/unit/pops/types/iterable_spec.rb +262 -0
- data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +1167 -0
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +327 -0
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +169 -0
- 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 +453 -0
- data/spec/unit/pops/types/recursion_guard_spec.rb +93 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +625 -0
- data/spec/unit/pops/types/string_converter_spec.rb +1029 -0
- data/spec/unit/pops/types/type_acceptor_spec.rb +106 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +43 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +965 -934
- data/spec/unit/pops/types/type_factory_spec.rb +132 -91
- data/spec/unit/pops/types/type_formatter_spec.rb +396 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +228 -0
- data/spec/unit/pops/types/type_parser_spec.rb +203 -36
- data/spec/unit/pops/types/types_spec.rb +599 -0
- data/spec/unit/pops/validator/validator_spec.rb +400 -18
- data/spec/unit/property/ensure_spec.rb +0 -0
- data/spec/unit/property/keyvalue_spec.rb +0 -0
- data/spec/unit/property/list_spec.rb +0 -0
- data/spec/unit/property/ordered_list_spec.rb +0 -0
- data/spec/unit/property_spec.rb +49 -12
- data/spec/unit/provider/augeas/augeas_spec.rb +59 -0
- data/spec/unit/provider/cisco_spec.rb +0 -0
- data/spec/unit/provider/command_spec.rb +0 -0
- data/spec/unit/provider/cron/crontab_spec.rb +0 -0
- data/spec/unit/provider/cron/parsed_spec.rb +1 -0
- data/spec/unit/provider/exec/posix_spec.rb +0 -0
- data/spec/unit/provider/exec/shell_spec.rb +0 -0
- data/spec/unit/provider/exec/windows_spec.rb +0 -0
- data/spec/unit/provider/exec_spec.rb +0 -0
- data/spec/unit/provider/file/posix_spec.rb +0 -0
- data/spec/unit/provider/file/windows_spec.rb +0 -0
- data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
- data/spec/unit/provider/group/groupadd_spec.rb +0 -0
- data/spec/unit/provider/group/ldap_spec.rb +0 -0
- data/spec/unit/provider/group/pw_spec.rb +0 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +31 -9
- data/spec/unit/provider/host/parsed_spec.rb +0 -0
- data/spec/unit/provider/interface/cisco_spec.rb +0 -0
- data/spec/unit/provider/ldap_spec.rb +0 -0
- data/spec/unit/provider/macauthorization_spec.rb +5 -2
- data/spec/unit/provider/mcx/mcxcontent_spec.rb +0 -0
- data/spec/unit/provider/mount/parsed_spec.rb +0 -0
- data/spec/unit/provider/mount_spec.rb +0 -0
- data/spec/unit/provider/naginator_spec.rb +0 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +14 -19
- data/spec/unit/provider/nameservice_spec.rb +54 -12
- data/spec/unit/provider/network_device_spec.rb +0 -0
- data/spec/unit/provider/package/aix_spec.rb +0 -0
- data/spec/unit/provider/package/appdmg_spec.rb +3 -3
- data/spec/unit/provider/package/apt_spec.rb +0 -0
- data/spec/unit/provider/package/aptitude_spec.rb +0 -0
- data/spec/unit/provider/package/aptrpm_spec.rb +3 -3
- data/spec/unit/provider/package/base_spec.rb +18 -0
- data/spec/unit/provider/package/dnf_spec.rb +30 -0
- data/spec/unit/provider/package/dpkg_spec.rb +0 -0
- data/spec/unit/provider/package/freebsd_spec.rb +0 -0
- data/spec/unit/provider/package/gem_spec.rb +77 -0
- data/spec/unit/provider/package/hpux_spec.rb +0 -0
- data/spec/unit/provider/package/macports_spec.rb +0 -0
- data/spec/unit/provider/package/nim_spec.rb +6 -6
- data/spec/unit/provider/package/openbsd_spec.rb +0 -0
- data/spec/unit/provider/package/opkg_spec.rb +0 -0
- data/spec/unit/provider/package/pacman_spec.rb +55 -0
- data/spec/unit/provider/package/pip3_spec.rb +22 -0
- data/spec/unit/provider/package/pip_spec.rb +164 -46
- data/spec/unit/provider/package/pkg_spec.rb +139 -99
- data/spec/unit/provider/package/pkgdmg_spec.rb +32 -8
- data/spec/unit/provider/package/pkgin_spec.rb +23 -13
- data/spec/unit/provider/package/pkgng_spec.rb +16 -2
- data/spec/unit/provider/package/pkgutil_spec.rb +0 -0
- data/spec/unit/provider/package/portage_spec.rb +64 -8
- data/spec/unit/provider/package/puppet_gem_spec.rb +0 -0
- data/spec/unit/provider/package/rpm_spec.rb +170 -12
- data/spec/unit/provider/package/sun_spec.rb +0 -0
- data/spec/unit/provider/package/tdnf_spec.rb +18 -0
- data/spec/unit/provider/package/windows/package_spec.rb +45 -1
- data/spec/unit/provider/package/windows_spec.rb +8 -2
- data/spec/unit/provider/package/yum_spec.rb +29 -466
- data/spec/unit/provider/package/zypper_spec.rb +14 -0
- data/spec/unit/provider/parsedfile_spec.rb +0 -0
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +211 -0
- data/spec/unit/provider/selboolean_spec.rb +0 -0
- data/spec/unit/provider/selmodule_spec.rb +0 -0
- data/spec/unit/provider/service/base_spec.rb +6 -0
- data/spec/unit/provider/service/bsd_spec.rb +130 -0
- data/spec/unit/provider/service/daemontools_spec.rb +0 -0
- data/spec/unit/provider/service/debian_spec.rb +34 -4
- data/spec/unit/provider/service/freebsd_spec.rb +16 -0
- data/spec/unit/provider/service/gentoo_spec.rb +7 -0
- data/spec/unit/provider/service/init_spec.rb +24 -1
- data/spec/unit/provider/service/launchd_spec.rb +124 -25
- data/spec/unit/provider/service/openbsd_spec.rb +0 -0
- data/spec/unit/provider/service/openrc_spec.rb +7 -0
- data/spec/unit/provider/service/openwrt_spec.rb +0 -0
- data/spec/unit/provider/service/rcng_spec.rb +41 -0
- data/spec/unit/provider/service/redhat_spec.rb +8 -1
- data/spec/unit/provider/service/runit_spec.rb +0 -0
- data/spec/unit/provider/service/smf_spec.rb +77 -13
- data/spec/unit/provider/service/src_spec.rb +31 -4
- data/spec/unit/provider/service/systemd_spec.rb +228 -39
- data/spec/unit/provider/service/upstart_spec.rb +64 -0
- data/spec/unit/provider/service/windows_spec.rb +0 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -1
- data/spec/unit/provider/sshkey/parsed_spec.rb +42 -18
- data/spec/unit/provider/user/aix_spec.rb +7 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +164 -83
- data/spec/unit/provider/user/hpux_spec.rb +0 -0
- data/spec/unit/provider/user/ldap_spec.rb +0 -0
- data/spec/unit/provider/user/openbsd_spec.rb +0 -0
- data/spec/unit/provider/user/pw_spec.rb +0 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +0 -0
- data/spec/unit/provider/user/useradd_spec.rb +1 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +30 -6
- data/spec/unit/provider/vlan/cisco_spec.rb +0 -0
- data/spec/unit/provider/yumrepo/inifile_spec.rb +16 -0
- data/spec/unit/provider/zfs/zfs_spec.rb +0 -0
- data/spec/unit/provider/zone/solaris_spec.rb +64 -12
- data/spec/unit/provider/zpool/zpool_spec.rb +0 -0
- data/spec/unit/provider_spec.rb +0 -0
- data/spec/unit/puppet_spec.rb +15 -1
- data/spec/unit/relationship_spec.rb +0 -0
- data/spec/unit/reports/http_spec.rb +0 -0
- data/spec/unit/reports/store_spec.rb +0 -0
- data/spec/unit/reports_spec.rb +10 -0
- data/spec/unit/resource/capability_finder_spec.rb +147 -0
- data/spec/unit/resource/catalog_spec.rb +235 -10
- data/spec/unit/resource/status_spec.rb +0 -0
- data/spec/unit/resource/type_collection_spec.rb +23 -2
- data/spec/unit/resource/type_spec.rb +169 -12
- data/spec/unit/resource_spec.rb +137 -48
- data/spec/unit/semver_spec.rb +241 -0
- data/spec/unit/settings/directory_setting_spec.rb +0 -0
- data/spec/unit/settings/duration_setting_spec.rb +0 -0
- data/spec/unit/settings/environment_conf_spec.rb +18 -1
- data/spec/unit/settings/file_setting_spec.rb +37 -0
- data/spec/unit/settings/ini_file_spec.rb +58 -1
- data/spec/unit/settings/path_setting_spec.rb +0 -0
- data/spec/unit/settings/priority_setting_spec.rb +0 -0
- data/spec/unit/settings_spec.rb +105 -3
- data/spec/unit/ssl/base_spec.rb +9 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +180 -13
- data/spec/unit/ssl/certificate_authority_spec.rb +82 -28
- data/spec/unit/ssl/certificate_factory_spec.rb +2 -2
- data/spec/unit/ssl/certificate_request_attributes_spec.rb +6 -0
- data/spec/unit/ssl/certificate_request_spec.rb +4 -5
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +3 -3
- data/spec/unit/ssl/certificate_spec.rb +1 -1
- data/spec/unit/ssl/configuration_spec.rb +11 -2
- data/spec/unit/ssl/host_spec.rb +3 -3
- data/spec/unit/ssl/inventory_spec.rb +27 -3
- data/spec/unit/ssl/key_spec.rb +7 -7
- data/spec/unit/ssl/oids_spec.rb +24 -13
- data/spec/unit/status_spec.rb +0 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +160 -31
- data/spec/unit/transaction/event_manager_spec.rb +0 -0
- data/spec/unit/transaction/event_spec.rb +3 -1
- data/spec/unit/transaction/persistence_spec.rb +178 -0
- data/spec/unit/transaction/report_spec.rb +138 -2
- data/spec/unit/transaction/resource_harness_spec.rb +81 -37
- data/spec/unit/transaction_spec.rb +50 -0
- data/spec/unit/type/augeas_spec.rb +0 -0
- data/spec/unit/type/component_spec.rb +0 -0
- data/spec/unit/type/computer_spec.rb +0 -0
- data/spec/unit/type/cron_spec.rb +0 -0
- data/spec/unit/type/exec_spec.rb +57 -12
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/checksum_value_spec.rb +286 -0
- data/spec/unit/type/file/content_spec.rb +59 -208
- data/spec/unit/type/file/ctime_spec.rb +0 -0
- data/spec/unit/type/file/ensure_spec.rb +0 -0
- data/spec/unit/type/file/group_spec.rb +0 -0
- data/spec/unit/type/file/mode_spec.rb +0 -0
- data/spec/unit/type/file/mtime_spec.rb +0 -0
- data/spec/unit/type/file/owner_spec.rb +0 -0
- data/spec/unit/type/file/selinux_spec.rb +0 -0
- data/spec/unit/type/file/source_spec.rb +211 -119
- data/spec/unit/type/file/type_spec.rb +0 -0
- data/spec/unit/type/file_spec.rb +165 -35
- data/spec/unit/type/filebucket_spec.rb +0 -0
- data/spec/unit/type/group_spec.rb +0 -0
- data/spec/unit/type/host_spec.rb +4 -4
- data/spec/unit/type/interface_spec.rb +32 -0
- data/spec/unit/type/k5login_spec.rb +0 -0
- data/spec/unit/type/macauthorization_spec.rb +4 -1
- data/spec/unit/type/mailalias_spec.rb +0 -0
- data/spec/unit/type/maillist_spec.rb +0 -0
- data/spec/unit/type/mcx_spec.rb +0 -0
- data/spec/unit/type/mount_spec.rb +50 -8
- data/spec/unit/type/nagios_spec.rb +0 -0
- data/spec/unit/type/noop_metaparam_spec.rb +0 -0
- data/spec/unit/type/package/package_settings_spec.rb +0 -0
- data/spec/unit/type/package_spec.rb +1 -0
- data/spec/unit/type/resources_spec.rb +0 -0
- data/spec/unit/type/schedule_spec.rb +0 -0
- data/spec/unit/type/selboolean_spec.rb +0 -0
- data/spec/unit/type/selmodule_spec.rb +0 -0
- data/spec/unit/type/service_spec.rb +21 -0
- data/spec/unit/type/ssh_authorized_key_spec.rb +0 -0
- data/spec/unit/type/sshkey_spec.rb +0 -0
- data/spec/unit/type/stage_spec.rb +0 -0
- data/spec/unit/type/tidy_spec.rb +4 -4
- data/spec/unit/type/user_spec.rb +40 -7
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/type/whit_spec.rb +0 -0
- data/spec/unit/type/yumrepo_spec.rb +3 -7
- data/spec/unit/type/zfs_spec.rb +0 -0
- data/spec/unit/type/zone_spec.rb +0 -0
- data/spec/unit/type/zpool_spec.rb +0 -0
- data/spec/unit/type_spec.rb +119 -1
- data/spec/unit/util/autoload_spec.rb +0 -0
- data/spec/unit/util/backups_spec.rb +0 -0
- data/spec/unit/util/character_encoding_spec.rb +88 -0
- data/spec/unit/util/checksums_spec.rb +0 -0
- data/spec/unit/util/colors_spec.rb +0 -0
- data/spec/unit/util/command_line_spec.rb +11 -0
- data/spec/unit/util/constant_inflector_spec.rb +0 -0
- data/spec/unit/util/diff_spec.rb +0 -0
- data/spec/unit/util/errors_spec.rb +0 -0
- data/spec/unit/util/execution_spec.rb +13 -1
- data/spec/unit/util/execution_stub_spec.rb +0 -0
- data/spec/unit/util/feature_spec.rb +1 -1
- data/spec/unit/util/filetype_spec.rb +4 -4
- data/spec/unit/util/http_proxy_spec.rb +91 -0
- data/spec/unit/util/ldap/connection_spec.rb +0 -0
- data/spec/unit/util/ldap/generator_spec.rb +1 -1
- data/spec/unit/util/ldap/manager_spec.rb +0 -0
- data/spec/unit/util/log/destinations_spec.rb +0 -2
- data/spec/unit/util/log_spec.rb +12 -1
- data/spec/unit/util/logging_spec.rb +69 -0
- data/spec/unit/util/metric_spec.rb +0 -0
- data/spec/unit/util/monkey_patches_spec.rb +95 -3
- data/spec/unit/util/multi_match_spec.rb +39 -0
- data/spec/unit/util/nagios_maker_spec.rb +0 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +253 -216
- data/spec/unit/util/network_device/cisco/facts_spec.rb +0 -0
- data/spec/unit/util/network_device/cisco/interface_spec.rb +0 -0
- data/spec/unit/util/network_device/config_spec.rb +0 -0
- data/spec/unit/util/network_device/ipcalc_spec.rb +0 -0
- data/spec/unit/util/network_device/transport/base_spec.rb +0 -0
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -1
- data/spec/unit/util/network_device/transport/telnet_spec.rb +60 -58
- data/spec/unit/util/network_device_spec.rb +1 -1
- data/spec/unit/util/package_spec.rb +0 -0
- data/spec/unit/util/plist_spec.rb +135 -0
- data/spec/unit/util/posix_spec.rb +0 -0
- data/spec/unit/util/rdoc_spec.rb +0 -0
- data/spec/unit/util/resource_template_spec.rb +2 -2
- data/spec/unit/util/retry_action_spec.rb +0 -0
- data/spec/unit/util/run_mode_spec.rb +27 -3
- data/spec/unit/util/selinux_spec.rb +0 -0
- data/spec/unit/util/splayer_spec.rb +45 -0
- data/spec/unit/util/storage_spec.rb +8 -1
- data/spec/unit/util/suidmanager_spec.rb +0 -0
- data/spec/unit/util/symbolic_file_mode_spec.rb +0 -0
- data/spec/unit/util/tagging_spec.rb +4 -0
- data/spec/unit/util/user_attr_spec.rb +0 -0
- data/spec/unit/util/warnings_spec.rb +0 -0
- data/spec/unit/util/windows/adsi_spec.rb +82 -40
- data/spec/unit/util/windows/api_types_spec.rb +42 -0
- data/spec/unit/util/windows/file_spec.rb +89 -0
- data/spec/unit/util/windows/root_certs_spec.rb +0 -0
- data/spec/unit/util/windows/security_descriptor_spec.rb +3 -3
- data/spec/unit/util/windows/sid_spec.rb +76 -14
- data/spec/unit/util/yaml_spec.rb +13 -1
- data/spec/unit/util_spec.rb +219 -15
- data/spec/unit/version_spec.rb +19 -0
- data/spec/watchr.rb +0 -0
- data/tasks/cfpropertylist.rake +15 -0
- metadata +724 -115
- data/ext/puppet-nm-dispatcher +0 -13
- data/ext/puppetlisten/puppetlisten.rb +0 -77
- data/ext/puppetlisten/puppetrun.rb +0 -38
- data/ext/systemd/puppetmaster.service +0 -11
- data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
- data/lib/puppet/pops/types/types_meta.rb +0 -234
- data/lib/puppet/resource/type_collection_helper.rb +0 -7
- data/lib/puppet/vendor/load_plist.rb +0 -1
- data/lib/puppet/vendor/plist/CHANGELOG +0 -82
- data/lib/puppet/vendor/plist/MIT-LICENSE +0 -21
- data/lib/puppet/vendor/plist/PUPPET_README.md +0 -6
- data/lib/puppet/vendor/plist/README +0 -36
- data/lib/puppet/vendor/plist/Rakefile +0 -144
- data/lib/puppet/vendor/plist/docs/USAGE +0 -104
- data/lib/puppet/vendor/plist/docs/jamis-template.rb +0 -591
- data/lib/puppet/vendor/plist/lib/plist/generator.rb +0 -224
- data/lib/puppet/vendor/plist/lib/plist/parser.rb +0 -225
- data/lib/puppet/vendor/plist/lib/plist.rb +0 -22
- data/lib/puppet/vendor/plist/test/assets/AlbumData.xml +0 -203
- data/lib/puppet/vendor/plist/test/assets/Cookies.plist +0 -104
- data/lib/puppet/vendor/plist/test/assets/commented.plist +0 -9
- data/lib/puppet/vendor/plist/test/assets/example_data.bin +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.jpg +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.plist +0 -259
- data/lib/puppet/vendor/plist/test/assets/test_data_elements.plist +0 -24
- data/lib/puppet/vendor/plist/test/assets/test_empty_key.plist +0 -13
- data/lib/puppet/vendor/plist/test/test_data_elements.rb +0 -115
- data/lib/puppet/vendor/plist/test/test_generator.rb +0 -59
- data/lib/puppet/vendor/plist/test/test_generator_basic_types.rb +0 -58
- data/lib/puppet/vendor/plist/test/test_generator_collections.rb +0 -82
- data/lib/puppet/vendor/plist/test/test_parser.rb +0 -90
- data/lib/puppet/vendor/semantic/Gemfile +0 -20
- data/lib/puppet/vendor/semantic/PUPPET_README.md +0 -6
- data/lib/puppet/vendor/semantic/Rakefile +0 -69
- data/lib/puppet/vendor/semantic/spec/spec_helper.rb +0 -24
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +0 -141
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +0 -162
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +0 -143
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +0 -5
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +0 -44
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +0 -383
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +0 -307
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +0 -608
- data/spec/fixtures/unit/data_providers/environments/sample/manifests/site.pp +0 -6
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/manifests/init.pp +0 -3
- data/spec/integration/data_binding.rb +0 -104
- data/spec/integration/parser/functions/require_spec.rb +0 -43
- data/spec/integration/provider/package_spec.rb +0 -33
- data/spec/unit/parser/functions/defined_spec.rb +0 -120
- data/spec/unit/parser/functions/include_spec.rb +0 -55
- data/spec/unit/parser/functions/require_spec.rb +0 -68
- data/spec/unit/resource/type_collection_helper_spec.rb +0 -24
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/environment.conf +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/lib/puppet/functions/environment/data.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/abc/lib/puppet/bindings/abc/default.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/abc/manifests/init.pp +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bad_data/lib/puppet/bindings/bad_data/default.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/lib/puppet/bindings/bca/default.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/lib/puppet/functions/bca/data.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/manifests/init.pp +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/no_provider/manifests/init.pp +0 -0
- /data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{usee → modules/usee}/lib/puppet/functions/usee/callee.rb +0 -0
- /data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/lib/puppet/functions/user/caller.rb +0 -0
|
@@ -1,373 +1,385 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
require 'puppet/pops'
|
|
3
3
|
|
|
4
|
+
module Puppet::Pops
|
|
5
|
+
module Types
|
|
4
6
|
describe 'The type calculator' do
|
|
5
|
-
let(:calculator) {
|
|
7
|
+
let(:calculator) { TypeCalculator.new }
|
|
6
8
|
|
|
7
9
|
def range_t(from, to)
|
|
8
|
-
|
|
9
|
-
t.from = from
|
|
10
|
-
t.to = to
|
|
11
|
-
t
|
|
12
|
-
end
|
|
13
|
-
def constrained_t(t, from, to)
|
|
14
|
-
Puppet::Pops::Types::TypeFactory.constrain_size(t, from, to)
|
|
10
|
+
PIntegerType.new(from, to)
|
|
15
11
|
end
|
|
16
12
|
|
|
17
13
|
def pattern_t(*patterns)
|
|
18
|
-
|
|
14
|
+
TypeFactory.pattern(*patterns)
|
|
19
15
|
end
|
|
20
16
|
|
|
21
17
|
def regexp_t(pattern)
|
|
22
|
-
|
|
18
|
+
TypeFactory.regexp(pattern)
|
|
23
19
|
end
|
|
24
20
|
|
|
25
|
-
def string_t(
|
|
26
|
-
|
|
21
|
+
def string_t(string = nil)
|
|
22
|
+
TypeFactory.string(string)
|
|
27
23
|
end
|
|
28
24
|
|
|
29
|
-
def
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
def all_callables_t(*params)
|
|
33
|
-
Puppet::Pops::Types::TypeFactory.all_callables()
|
|
25
|
+
def constrained_string_t(size_type)
|
|
26
|
+
TypeFactory.string(size_type)
|
|
34
27
|
end
|
|
35
28
|
|
|
36
|
-
def
|
|
37
|
-
|
|
29
|
+
def callable_t(*params)
|
|
30
|
+
TypeFactory.callable(*params)
|
|
38
31
|
end
|
|
39
32
|
|
|
40
|
-
def
|
|
41
|
-
|
|
33
|
+
def all_callables_t
|
|
34
|
+
TypeFactory.all_callables
|
|
42
35
|
end
|
|
43
36
|
|
|
44
37
|
def enum_t(*strings)
|
|
45
|
-
|
|
38
|
+
TypeFactory.enum(*strings)
|
|
46
39
|
end
|
|
47
40
|
|
|
48
41
|
def variant_t(*types)
|
|
49
|
-
|
|
42
|
+
TypeFactory.variant(*types)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def type_alias_t(name, type_string)
|
|
46
|
+
type_expr = Parser::EvaluatingParser.new.parse_string(type_string).current
|
|
47
|
+
TypeFactory.type_alias(name, type_expr)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def type_reference_t(type_string)
|
|
51
|
+
TypeFactory.type_reference(type_string)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def integer_t
|
|
55
|
+
TypeFactory.integer
|
|
50
56
|
end
|
|
51
57
|
|
|
52
|
-
def
|
|
53
|
-
|
|
58
|
+
def array_t(t, s = nil)
|
|
59
|
+
TypeFactory.array_of(t, s)
|
|
54
60
|
end
|
|
55
61
|
|
|
56
|
-
def
|
|
57
|
-
|
|
62
|
+
def empty_array_t
|
|
63
|
+
empty_array = array_t(unit_t, range_t(0,0))
|
|
58
64
|
end
|
|
59
65
|
|
|
60
|
-
def hash_t(k,v)
|
|
61
|
-
|
|
66
|
+
def hash_t(k,v,s = nil)
|
|
67
|
+
TypeFactory.hash_of(v, k, s)
|
|
62
68
|
end
|
|
63
69
|
|
|
64
|
-
def data_t
|
|
65
|
-
|
|
70
|
+
def data_t
|
|
71
|
+
TypeFactory.data
|
|
66
72
|
end
|
|
67
73
|
|
|
68
|
-
def factory
|
|
69
|
-
|
|
74
|
+
def factory
|
|
75
|
+
TypeFactory
|
|
70
76
|
end
|
|
71
77
|
|
|
72
|
-
def collection_t()
|
|
73
|
-
|
|
78
|
+
def collection_t(size_type = nil)
|
|
79
|
+
TypeFactory.collection(size_type)
|
|
74
80
|
end
|
|
75
81
|
|
|
76
82
|
def tuple_t(*types)
|
|
77
|
-
|
|
83
|
+
TypeFactory.tuple(types)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def constrained_tuple_t(size_type, *types)
|
|
87
|
+
TypeFactory.tuple(types, size_type)
|
|
78
88
|
end
|
|
79
89
|
|
|
80
90
|
def struct_t(type_hash)
|
|
81
|
-
|
|
91
|
+
TypeFactory.struct(type_hash)
|
|
82
92
|
end
|
|
83
93
|
|
|
84
94
|
def object_t
|
|
85
|
-
|
|
95
|
+
TypeFactory.any
|
|
86
96
|
end
|
|
87
97
|
|
|
88
98
|
def optional_t(t)
|
|
89
|
-
|
|
99
|
+
TypeFactory.optional(t)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def type_t(t)
|
|
103
|
+
TypeFactory.type_type(t)
|
|
90
104
|
end
|
|
91
105
|
|
|
92
106
|
def not_undef_t(t = nil)
|
|
93
|
-
|
|
107
|
+
TypeFactory.not_undef(t)
|
|
94
108
|
end
|
|
95
109
|
|
|
96
110
|
def undef_t
|
|
97
|
-
|
|
111
|
+
TypeFactory.undef
|
|
98
112
|
end
|
|
99
113
|
|
|
100
114
|
def unit_t
|
|
101
115
|
# Cannot be created via factory, the type is private to the type system
|
|
102
|
-
|
|
116
|
+
PUnitType::DEFAULT
|
|
103
117
|
end
|
|
104
118
|
|
|
105
119
|
def types
|
|
106
|
-
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
shared_context "types_setup" do
|
|
110
|
-
|
|
111
|
-
# Do not include the special type Unit in this list
|
|
112
|
-
def all_types
|
|
113
|
-
[ Puppet::Pops::Types::PAnyType,
|
|
114
|
-
Puppet::Pops::Types::PUndefType,
|
|
115
|
-
Puppet::Pops::Types::PNotUndefType,
|
|
116
|
-
Puppet::Pops::Types::PDataType,
|
|
117
|
-
Puppet::Pops::Types::PScalarType,
|
|
118
|
-
Puppet::Pops::Types::PStringType,
|
|
119
|
-
Puppet::Pops::Types::PNumericType,
|
|
120
|
-
Puppet::Pops::Types::PIntegerType,
|
|
121
|
-
Puppet::Pops::Types::PFloatType,
|
|
122
|
-
Puppet::Pops::Types::PRegexpType,
|
|
123
|
-
Puppet::Pops::Types::PBooleanType,
|
|
124
|
-
Puppet::Pops::Types::PCollectionType,
|
|
125
|
-
Puppet::Pops::Types::PArrayType,
|
|
126
|
-
Puppet::Pops::Types::PHashType,
|
|
127
|
-
Puppet::Pops::Types::PRuntimeType,
|
|
128
|
-
Puppet::Pops::Types::PHostClassType,
|
|
129
|
-
Puppet::Pops::Types::PResourceType,
|
|
130
|
-
Puppet::Pops::Types::PPatternType,
|
|
131
|
-
Puppet::Pops::Types::PEnumType,
|
|
132
|
-
Puppet::Pops::Types::PVariantType,
|
|
133
|
-
Puppet::Pops::Types::PStructType,
|
|
134
|
-
Puppet::Pops::Types::PTupleType,
|
|
135
|
-
Puppet::Pops::Types::PCallableType,
|
|
136
|
-
Puppet::Pops::Types::PType,
|
|
137
|
-
Puppet::Pops::Types::POptionalType,
|
|
138
|
-
Puppet::Pops::Types::PDefaultType,
|
|
139
|
-
]
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def scalar_types
|
|
143
|
-
# PVariantType is also scalar, if its types are all Scalar
|
|
144
|
-
[
|
|
145
|
-
Puppet::Pops::Types::PScalarType,
|
|
146
|
-
Puppet::Pops::Types::PStringType,
|
|
147
|
-
Puppet::Pops::Types::PNumericType,
|
|
148
|
-
Puppet::Pops::Types::PIntegerType,
|
|
149
|
-
Puppet::Pops::Types::PFloatType,
|
|
150
|
-
Puppet::Pops::Types::PRegexpType,
|
|
151
|
-
Puppet::Pops::Types::PBooleanType,
|
|
152
|
-
Puppet::Pops::Types::PPatternType,
|
|
153
|
-
Puppet::Pops::Types::PEnumType,
|
|
154
|
-
]
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def numeric_types
|
|
158
|
-
# PVariantType is also numeric, if its types are all numeric
|
|
159
|
-
[
|
|
160
|
-
Puppet::Pops::Types::PNumericType,
|
|
161
|
-
Puppet::Pops::Types::PIntegerType,
|
|
162
|
-
Puppet::Pops::Types::PFloatType,
|
|
163
|
-
]
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def string_types
|
|
167
|
-
# PVariantType is also string type, if its types are all compatible
|
|
168
|
-
[
|
|
169
|
-
Puppet::Pops::Types::PStringType,
|
|
170
|
-
Puppet::Pops::Types::PPatternType,
|
|
171
|
-
Puppet::Pops::Types::PEnumType,
|
|
172
|
-
]
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def collection_types
|
|
176
|
-
# PVariantType is also string type, if its types are all compatible
|
|
177
|
-
[
|
|
178
|
-
Puppet::Pops::Types::PCollectionType,
|
|
179
|
-
Puppet::Pops::Types::PHashType,
|
|
180
|
-
Puppet::Pops::Types::PArrayType,
|
|
181
|
-
Puppet::Pops::Types::PStructType,
|
|
182
|
-
Puppet::Pops::Types::PTupleType,
|
|
183
|
-
]
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def data_compatible_types
|
|
187
|
-
result = scalar_types
|
|
188
|
-
result << Puppet::Pops::Types::PDataType
|
|
189
|
-
result << array_t(types::PDataType.new)
|
|
190
|
-
result << types::TypeFactory.hash_of_data
|
|
191
|
-
result << Puppet::Pops::Types::PUndefType
|
|
192
|
-
result << not_undef_t(types::PDataType.new)
|
|
193
|
-
tmp = tuple_t(types::PDataType.new)
|
|
194
|
-
result << (tmp)
|
|
195
|
-
tmp.size_type = range_t(0, nil)
|
|
196
|
-
result
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def type_from_class(c)
|
|
200
|
-
c.is_a?(Class) ? c.new : c
|
|
201
|
-
end
|
|
120
|
+
Types
|
|
202
121
|
end
|
|
203
122
|
|
|
204
123
|
context 'when inferring ruby' do
|
|
205
124
|
|
|
206
125
|
it 'fixnum translates to PIntegerType' do
|
|
207
|
-
expect(calculator.infer(1).class).to eq(
|
|
126
|
+
expect(calculator.infer(1).class).to eq(PIntegerType)
|
|
208
127
|
end
|
|
209
128
|
|
|
210
129
|
it 'large fixnum (or bignum depending on architecture) translates to PIntegerType' do
|
|
211
|
-
expect(calculator.infer(2**33).class).to eq(
|
|
130
|
+
expect(calculator.infer(2**33).class).to eq(PIntegerType)
|
|
212
131
|
end
|
|
213
132
|
|
|
214
133
|
it 'float translates to PFloatType' do
|
|
215
|
-
expect(calculator.infer(1.3).class).to eq(
|
|
134
|
+
expect(calculator.infer(1.3).class).to eq(PFloatType)
|
|
216
135
|
end
|
|
217
136
|
|
|
218
137
|
it 'string translates to PStringType' do
|
|
219
|
-
expect(calculator.infer('foo').class).to eq(
|
|
138
|
+
expect(calculator.infer('foo').class).to eq(PStringType)
|
|
220
139
|
end
|
|
221
140
|
|
|
222
141
|
it 'inferred string type knows the string value' do
|
|
223
142
|
t = calculator.infer('foo')
|
|
224
|
-
expect(t.class).to eq(
|
|
225
|
-
expect(t.
|
|
143
|
+
expect(t.class).to eq(PStringType)
|
|
144
|
+
expect(t.value).to eq('foo')
|
|
226
145
|
end
|
|
227
146
|
|
|
228
147
|
it 'boolean true translates to PBooleanType' do
|
|
229
|
-
expect(calculator.infer(true).class).to eq(
|
|
148
|
+
expect(calculator.infer(true).class).to eq(PBooleanType)
|
|
230
149
|
end
|
|
231
150
|
|
|
232
151
|
it 'boolean false translates to PBooleanType' do
|
|
233
|
-
expect(calculator.infer(false).class).to eq(
|
|
152
|
+
expect(calculator.infer(false).class).to eq(PBooleanType)
|
|
234
153
|
end
|
|
235
154
|
|
|
236
155
|
it 'regexp translates to PRegexpType' do
|
|
237
|
-
expect(calculator.infer(/^a regular expression$/).class).to eq(
|
|
156
|
+
expect(calculator.infer(/^a regular expression$/).class).to eq(PRegexpType)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'iterable translates to PIteratorType' do
|
|
160
|
+
expect(calculator.infer(Iterable.on(1))).to be_a(PIteratorType)
|
|
238
161
|
end
|
|
239
162
|
|
|
240
163
|
it 'nil translates to PUndefType' do
|
|
241
|
-
expect(calculator.infer(nil).class).to eq(
|
|
164
|
+
expect(calculator.infer(nil).class).to eq(PUndefType)
|
|
242
165
|
end
|
|
243
166
|
|
|
244
|
-
it ':undef translates to
|
|
245
|
-
expect(calculator.infer(:undef).class).to eq(
|
|
167
|
+
it ':undef translates to PUndefType' do
|
|
168
|
+
expect(calculator.infer(:undef).class).to eq(PUndefType)
|
|
246
169
|
end
|
|
247
170
|
|
|
248
171
|
it 'an instance of class Foo translates to PRuntimeType[ruby, Foo]' do
|
|
249
|
-
|
|
172
|
+
::Foo = Class.new
|
|
173
|
+
begin
|
|
174
|
+
t = calculator.infer(::Foo.new)
|
|
175
|
+
expect(t.class).to eq(PRuntimeType)
|
|
176
|
+
expect(t.runtime).to eq(:ruby)
|
|
177
|
+
expect(t.runtime_type_name).to eq('Foo')
|
|
178
|
+
ensure
|
|
179
|
+
Object.send(:remove_const, :Foo)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it 'Class Foo translates to PType[PRuntimeType[ruby, Foo]]' do
|
|
184
|
+
::Foo = Class.new
|
|
185
|
+
begin
|
|
186
|
+
t = calculator.infer(::Foo)
|
|
187
|
+
expect(t.class).to eq(PType)
|
|
188
|
+
tt = t.type
|
|
189
|
+
expect(tt.class).to eq(PRuntimeType)
|
|
190
|
+
expect(tt.runtime).to eq(:ruby)
|
|
191
|
+
expect(tt.runtime_type_name).to eq('Foo')
|
|
192
|
+
ensure
|
|
193
|
+
Object.send(:remove_const, :Foo)
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it 'Module FooModule translates to PType[PRuntimeType[ruby, FooModule]]' do
|
|
198
|
+
::FooModule = Module.new
|
|
199
|
+
begin
|
|
200
|
+
t = calculator.infer(::FooModule)
|
|
201
|
+
expect(t.class).to eq(PType)
|
|
202
|
+
tt = t.type
|
|
203
|
+
expect(tt.class).to eq(PRuntimeType)
|
|
204
|
+
expect(tt.runtime).to eq(:ruby)
|
|
205
|
+
expect(tt.runtime_type_name).to eq('FooModule')
|
|
206
|
+
ensure
|
|
207
|
+
Object.send(:remove_const, :FooModule)
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
context 'sensitive' do
|
|
212
|
+
it 'translates to PSensitiveType' do
|
|
213
|
+
expect(calculator.infer(PSensitiveType::Sensitive.new("hunter2")).class).to eq(PSensitiveType)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
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
|
+
|
|
223
|
+
context 'version' do
|
|
224
|
+
it 'translates to PVersionType' do
|
|
225
|
+
expect(calculator.infer(SemanticPuppet::Version.new(1,0,0)).class).to eq(PSemVerType)
|
|
250
226
|
end
|
|
251
227
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
228
|
+
it 'range translates to PVersionRangeType' do
|
|
229
|
+
expect(calculator.infer(SemanticPuppet::VersionRange.parse('1.x')).class).to eq(PSemVerRangeType)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it 'translates to a limited PVersionType by infer_set' do
|
|
233
|
+
v = SemanticPuppet::Version.new(1,0,0)
|
|
234
|
+
t = calculator.infer_set(v)
|
|
235
|
+
expect(t.class).to eq(PSemVerType)
|
|
236
|
+
expect(t.ranges.size).to eq(1)
|
|
237
|
+
expect(t.ranges[0].min).to eq(v)
|
|
238
|
+
expect(t.ranges[0].max).to eq(v)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
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
|
|
256
268
|
end
|
|
257
269
|
|
|
258
270
|
context 'array' do
|
|
259
271
|
it 'translates to PArrayType' do
|
|
260
|
-
expect(calculator.infer([1,2]).class).to eq(
|
|
272
|
+
expect(calculator.infer([1,2]).class).to eq(PArrayType)
|
|
261
273
|
end
|
|
262
274
|
|
|
263
275
|
it 'with fixnum values translates to PArrayType[PIntegerType]' do
|
|
264
|
-
expect(calculator.infer([1,2]).element_type.class).to eq(
|
|
276
|
+
expect(calculator.infer([1,2]).element_type.class).to eq(PIntegerType)
|
|
265
277
|
end
|
|
266
278
|
|
|
267
279
|
it 'with 32 and 64 bit integer values translates to PArrayType[PIntegerType]' do
|
|
268
|
-
expect(calculator.infer([1,2**33]).element_type.class).to eq(
|
|
280
|
+
expect(calculator.infer([1,2**33]).element_type.class).to eq(PIntegerType)
|
|
269
281
|
end
|
|
270
282
|
|
|
271
283
|
it 'Range of integer values are computed' do
|
|
272
284
|
t = calculator.infer([-3,0,42]).element_type
|
|
273
|
-
expect(t.class).to eq(
|
|
285
|
+
expect(t.class).to eq(PIntegerType)
|
|
274
286
|
expect(t.from).to eq(-3)
|
|
275
287
|
expect(t.to).to eq(42)
|
|
276
288
|
end
|
|
277
289
|
|
|
278
|
-
it
|
|
290
|
+
it 'Compound string values are converted to enums' do
|
|
279
291
|
t = calculator.infer(['a','b', 'c']).element_type
|
|
280
|
-
expect(t.class).to eq(
|
|
292
|
+
expect(t.class).to eq(PEnumType)
|
|
281
293
|
expect(t.values).to eq(['a', 'b', 'c'])
|
|
282
294
|
end
|
|
283
295
|
|
|
284
296
|
it 'with fixnum and float values translates to PArrayType[PNumericType]' do
|
|
285
|
-
expect(calculator.infer([1,2.0]).element_type.class).to eq(
|
|
297
|
+
expect(calculator.infer([1,2.0]).element_type.class).to eq(PNumericType)
|
|
286
298
|
end
|
|
287
299
|
|
|
288
300
|
it 'with fixnum and string values translates to PArrayType[PScalarType]' do
|
|
289
|
-
expect(calculator.infer([1,'two']).element_type.class).to eq(
|
|
301
|
+
expect(calculator.infer([1,'two']).element_type.class).to eq(PScalarType)
|
|
290
302
|
end
|
|
291
303
|
|
|
292
304
|
it 'with float and string values translates to PArrayType[PScalarType]' do
|
|
293
|
-
expect(calculator.infer([1.0,'two']).element_type.class).to eq(
|
|
305
|
+
expect(calculator.infer([1.0,'two']).element_type.class).to eq(PScalarType)
|
|
294
306
|
end
|
|
295
307
|
|
|
296
308
|
it 'with fixnum, float, and string values translates to PArrayType[PScalarType]' do
|
|
297
|
-
expect(calculator.infer([1, 2.0,'two']).element_type.class).to eq(
|
|
309
|
+
expect(calculator.infer([1, 2.0,'two']).element_type.class).to eq(PScalarType)
|
|
298
310
|
end
|
|
299
311
|
|
|
300
312
|
it 'with fixnum and regexp values translates to PArrayType[PScalarType]' do
|
|
301
|
-
expect(calculator.infer([1, /two/]).element_type.class).to eq(
|
|
313
|
+
expect(calculator.infer([1, /two/]).element_type.class).to eq(PScalarType)
|
|
302
314
|
end
|
|
303
315
|
|
|
304
316
|
it 'with string and regexp values translates to PArrayType[PScalarType]' do
|
|
305
|
-
expect(calculator.infer(['one', /two/]).element_type.class).to eq(
|
|
317
|
+
expect(calculator.infer(['one', /two/]).element_type.class).to eq(PScalarType)
|
|
306
318
|
end
|
|
307
319
|
|
|
308
320
|
it 'with string and symbol values translates to PArrayType[PAnyType]' do
|
|
309
|
-
expect(calculator.infer(['one', :two]).element_type.class).to eq(
|
|
321
|
+
expect(calculator.infer(['one', :two]).element_type.class).to eq(PAnyType)
|
|
310
322
|
end
|
|
311
323
|
|
|
312
324
|
it 'with fixnum and nil values translates to PArrayType[PIntegerType]' do
|
|
313
|
-
expect(calculator.infer([1, nil]).element_type.class).to eq(
|
|
325
|
+
expect(calculator.infer([1, nil]).element_type.class).to eq(PIntegerType)
|
|
314
326
|
end
|
|
315
327
|
|
|
316
328
|
it 'with arrays of string values translates to PArrayType[PArrayType[PStringType]]' do
|
|
317
|
-
et = calculator.infer([['first' 'array'], ['second','array']])
|
|
318
|
-
expect(et.class).to eq(
|
|
329
|
+
et = calculator.infer([['first', 'array'], ['second','array']])
|
|
330
|
+
expect(et.class).to eq(PArrayType)
|
|
319
331
|
et = et.element_type
|
|
320
|
-
expect(et.class).to eq(
|
|
332
|
+
expect(et.class).to eq(PArrayType)
|
|
321
333
|
et = et.element_type
|
|
322
|
-
expect(et.class).to eq(
|
|
334
|
+
expect(et.class).to eq(PEnumType)
|
|
323
335
|
end
|
|
324
336
|
|
|
325
337
|
it 'with array of string values and array of fixnums translates to PArrayType[PArrayType[PScalarType]]' do
|
|
326
|
-
et = calculator.infer([['first' 'array'], [1,2]])
|
|
327
|
-
expect(et.class).to eq(
|
|
338
|
+
et = calculator.infer([['first', 'array'], [1,2]])
|
|
339
|
+
expect(et.class).to eq(PArrayType)
|
|
328
340
|
et = et.element_type
|
|
329
|
-
expect(et.class).to eq(
|
|
341
|
+
expect(et.class).to eq(PArrayType)
|
|
330
342
|
et = et.element_type
|
|
331
|
-
expect(et.class).to eq(
|
|
343
|
+
expect(et.class).to eq(PScalarType)
|
|
332
344
|
end
|
|
333
345
|
|
|
334
|
-
it 'with hashes of string values translates to PArrayType[PHashType[
|
|
346
|
+
it 'with hashes of string values translates to PArrayType[PHashType[PEnumType]]' do
|
|
335
347
|
et = calculator.infer([{:first => 'first', :second => 'second' }, {:first => 'first', :second => 'second' }])
|
|
336
|
-
expect(et.class).to eq(
|
|
337
|
-
et = et.element_type
|
|
338
|
-
expect(et.class).to eq(Puppet::Pops::Types::PHashType)
|
|
348
|
+
expect(et.class).to eq(PArrayType)
|
|
339
349
|
et = et.element_type
|
|
340
|
-
expect(et.class).to eq(
|
|
350
|
+
expect(et.class).to eq(PHashType)
|
|
351
|
+
et = et.value_type
|
|
352
|
+
expect(et.class).to eq(PEnumType)
|
|
341
353
|
end
|
|
342
354
|
|
|
343
355
|
it 'with hash of string values and hash of fixnums translates to PArrayType[PHashType[PScalarType]]' do
|
|
344
356
|
et = calculator.infer([{:first => 'first', :second => 'second' }, {:first => 1, :second => 2 }])
|
|
345
|
-
expect(et.class).to eq(
|
|
357
|
+
expect(et.class).to eq(PArrayType)
|
|
346
358
|
et = et.element_type
|
|
347
|
-
expect(et.class).to eq(
|
|
348
|
-
et = et.
|
|
349
|
-
expect(et.class).to eq(
|
|
359
|
+
expect(et.class).to eq(PHashType)
|
|
360
|
+
et = et.value_type
|
|
361
|
+
expect(et.class).to eq(PScalarType)
|
|
350
362
|
end
|
|
351
363
|
end
|
|
352
364
|
|
|
353
365
|
context 'hash' do
|
|
354
366
|
it 'translates to PHashType' do
|
|
355
|
-
expect(calculator.infer({:first => 1, :second => 2}).class).to eq(
|
|
367
|
+
expect(calculator.infer({:first => 1, :second => 2}).class).to eq(PHashType)
|
|
356
368
|
end
|
|
357
369
|
|
|
358
370
|
it 'with symbolic keys translates to PHashType[PRuntimeType[ruby, Symbol], value]' do
|
|
359
371
|
k = calculator.infer({:first => 1, :second => 2}).key_type
|
|
360
|
-
expect(k.class).to eq(
|
|
372
|
+
expect(k.class).to eq(PRuntimeType)
|
|
361
373
|
expect(k.runtime).to eq(:ruby)
|
|
362
374
|
expect(k.runtime_type_name).to eq('Symbol')
|
|
363
375
|
end
|
|
364
376
|
|
|
365
|
-
it 'with string keys translates to PHashType[
|
|
366
|
-
expect(calculator.infer({'first' => 1, 'second' => 2}).key_type.class).to eq(
|
|
377
|
+
it 'with string keys translates to PHashType[PEnumType, value]' do
|
|
378
|
+
expect(calculator.infer({'first' => 1, 'second' => 2}).key_type.class).to eq(PEnumType)
|
|
367
379
|
end
|
|
368
380
|
|
|
369
381
|
it 'with fixnum values translates to PHashType[key, PIntegerType]' do
|
|
370
|
-
expect(calculator.infer({:first => 1, :second => 2}).
|
|
382
|
+
expect(calculator.infer({:first => 1, :second => 2}).value_type.class).to eq(PIntegerType)
|
|
371
383
|
end
|
|
372
384
|
|
|
373
385
|
it 'when empty infers a type that answers true to is_the_empty_hash?' do
|
|
@@ -380,101 +392,89 @@ describe 'The type calculator' do
|
|
|
380
392
|
end
|
|
381
393
|
|
|
382
394
|
it 'when empty is not assignable to a PHashType with from size > 0' do
|
|
383
|
-
expect(calculator.assignable?(
|
|
395
|
+
expect(calculator.assignable?(hash_t(string_t,string_t,range_t(1, 1)), calculator.infer({}))).to eq(false)
|
|
384
396
|
end
|
|
385
397
|
|
|
386
398
|
context 'using infer_set' do
|
|
387
399
|
it "with 'first' and 'second' keys translates to PStructType[{first=>value,second=>value}]" do
|
|
388
400
|
t = calculator.infer_set({'first' => 1, 'second' => 2})
|
|
389
|
-
expect(t.class).to eq(
|
|
401
|
+
expect(t.class).to eq(PStructType)
|
|
390
402
|
expect(t.elements.size).to eq(2)
|
|
391
403
|
expect(t.elements.map { |e| e.name }.sort).to eq(['first', 'second'])
|
|
392
404
|
end
|
|
393
405
|
|
|
394
406
|
it 'with string keys and string and array values translates to PStructType[{key1=>PStringType,key2=>PTupleType}]' do
|
|
395
407
|
t = calculator.infer_set({ 'mode' => 'read', 'path' => ['foo', 'fee' ] })
|
|
396
|
-
expect(t.class).to eq(
|
|
408
|
+
expect(t.class).to eq(PStructType)
|
|
397
409
|
expect(t.elements.size).to eq(2)
|
|
398
410
|
els = t.elements.map { |e| e.value_type }.sort {|a,b| a.to_s <=> b.to_s }
|
|
399
|
-
expect(els[0].class).to eq(
|
|
400
|
-
expect(els[1].class).to eq(
|
|
411
|
+
expect(els[0].class).to eq(PStringType)
|
|
412
|
+
expect(els[1].class).to eq(PTupleType)
|
|
401
413
|
end
|
|
402
414
|
|
|
403
415
|
it 'with mixed string and non-string keys translates to PHashType' do
|
|
404
416
|
t = calculator.infer_set({ 1 => 'first', 'second' => 'second' })
|
|
405
|
-
expect(t.class).to eq(
|
|
417
|
+
expect(t.class).to eq(PHashType)
|
|
406
418
|
end
|
|
407
419
|
|
|
408
420
|
it 'with empty string keys translates to PHashType' do
|
|
409
421
|
t = calculator.infer_set({ '' => 'first', 'second' => 'second' })
|
|
410
|
-
expect(t.class).to eq(
|
|
422
|
+
expect(t.class).to eq(PHashType)
|
|
411
423
|
end
|
|
412
424
|
end
|
|
413
425
|
end
|
|
414
426
|
end
|
|
415
427
|
|
|
416
428
|
context 'patterns' do
|
|
417
|
-
it
|
|
429
|
+
it 'constructs a PPatternType' do
|
|
418
430
|
t = pattern_t('a(b)c')
|
|
419
|
-
expect(t.class).to eq(
|
|
431
|
+
expect(t.class).to eq(PPatternType)
|
|
420
432
|
expect(t.patterns.size).to eq(1)
|
|
421
|
-
expect(t.patterns[0].class).to eq(
|
|
433
|
+
expect(t.patterns[0].class).to eq(PRegexpType)
|
|
422
434
|
expect(t.patterns[0].pattern).to eq('a(b)c')
|
|
423
435
|
expect(t.patterns[0].regexp.match('abc')[1]).to eq('b')
|
|
424
436
|
end
|
|
425
437
|
|
|
426
|
-
it
|
|
427
|
-
t =
|
|
428
|
-
expect(t.values).to eq(['a', 'b', 'c', 'abc'])
|
|
438
|
+
it 'constructs a PEnumType with multiple strings' do
|
|
439
|
+
t = enum_t('a', 'b', 'c', 'abc')
|
|
440
|
+
expect(t.values).to eq(['a', 'b', 'c', 'abc'].sort)
|
|
429
441
|
end
|
|
430
442
|
end
|
|
431
443
|
|
|
432
444
|
# Deal with cases not covered by computing common type
|
|
433
445
|
context 'when computing common type' do
|
|
434
446
|
it 'computes given resource type commonality' do
|
|
435
|
-
r1 =
|
|
436
|
-
|
|
437
|
-
r2
|
|
438
|
-
|
|
439
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("File")
|
|
447
|
+
r1 = PResourceType.new('File', nil)
|
|
448
|
+
r2 = PResourceType.new('File', nil)
|
|
449
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('File')
|
|
450
|
+
|
|
440
451
|
|
|
441
|
-
r2 =
|
|
442
|
-
r2.
|
|
443
|
-
r2.title = '/tmp/foo'
|
|
444
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("File")
|
|
452
|
+
r2 = PResourceType.new('File', '/tmp/foo')
|
|
453
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('File')
|
|
445
454
|
|
|
446
|
-
r1 =
|
|
447
|
-
r1.
|
|
448
|
-
r1.title = '/tmp/foo'
|
|
449
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("File['/tmp/foo']")
|
|
455
|
+
r1 = PResourceType.new('File', '/tmp/foo')
|
|
456
|
+
expect(calculator.common_type(r1, r2).to_s).to eq("File['/tmp/foo']")
|
|
450
457
|
|
|
451
|
-
r1 =
|
|
452
|
-
r1.
|
|
453
|
-
r1.title = '/tmp/bar'
|
|
454
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("File")
|
|
458
|
+
r1 = PResourceType.new('File', '/tmp/bar')
|
|
459
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('File')
|
|
455
460
|
|
|
456
|
-
r2 =
|
|
457
|
-
r2.
|
|
458
|
-
r2.title = 'apache'
|
|
459
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("Resource")
|
|
461
|
+
r2 = PResourceType.new('Package', 'apache')
|
|
462
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Resource')
|
|
460
463
|
end
|
|
461
464
|
|
|
462
465
|
it 'computes given hostclass type commonality' do
|
|
463
|
-
r1 =
|
|
464
|
-
|
|
465
|
-
r2
|
|
466
|
-
r2.class_name = 'foo'
|
|
467
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("Class[foo]")
|
|
466
|
+
r1 = PHostClassType.new('foo')
|
|
467
|
+
r2 = PHostClassType.new('foo')
|
|
468
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class[foo]')
|
|
468
469
|
|
|
469
|
-
r2 =
|
|
470
|
-
r2.
|
|
471
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("Class")
|
|
470
|
+
r2 = PHostClassType.new('bar')
|
|
471
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class')
|
|
472
472
|
|
|
473
|
-
r2 =
|
|
474
|
-
expect(calculator.
|
|
473
|
+
r2 = PHostClassType.new(nil)
|
|
474
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class')
|
|
475
475
|
|
|
476
|
-
r1 =
|
|
477
|
-
expect(calculator.
|
|
476
|
+
r1 = PHostClassType.new(nil)
|
|
477
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class')
|
|
478
478
|
end
|
|
479
479
|
|
|
480
480
|
context 'of strings' do
|
|
@@ -482,37 +482,32 @@ describe 'The type calculator' do
|
|
|
482
482
|
t1 = string_t('abc')
|
|
483
483
|
t2 = string_t('xyz')
|
|
484
484
|
common_t = calculator.common_type(t1,t2)
|
|
485
|
-
expect(common_t.class).to eq(
|
|
485
|
+
expect(common_t.class).to eq(PEnumType)
|
|
486
486
|
expect(common_t.values).to eq(['abc', 'xyz'])
|
|
487
487
|
end
|
|
488
488
|
|
|
489
489
|
it 'computes common size_type' do
|
|
490
|
-
t1 =
|
|
491
|
-
|
|
492
|
-
t2 = string_t
|
|
493
|
-
t2.size_type = range_t(2,4)
|
|
490
|
+
t1 = constrained_string_t(range_t(3,6))
|
|
491
|
+
t2 = constrained_string_t(range_t(2,4))
|
|
494
492
|
common_t = calculator.common_type(t1,t2)
|
|
495
|
-
expect(common_t.class).to eq(
|
|
493
|
+
expect(common_t.class).to eq(PStringType)
|
|
496
494
|
expect(common_t.size_type).to eq(range_t(2,6))
|
|
497
495
|
end
|
|
498
496
|
|
|
499
497
|
it 'computes common size_type to be undef when one of the types has no size_type' do
|
|
500
498
|
t1 = string_t
|
|
501
|
-
t2 =
|
|
502
|
-
t2.size_type = range_t(2,4)
|
|
499
|
+
t2 = constrained_string_t(range_t(2,4))
|
|
503
500
|
common_t = calculator.common_type(t1,t2)
|
|
504
|
-
expect(common_t.class).to eq(
|
|
501
|
+
expect(common_t.class).to eq(PStringType)
|
|
505
502
|
expect(common_t.size_type).to be_nil
|
|
506
503
|
end
|
|
507
504
|
|
|
508
505
|
it 'computes values to be empty if the one has empty values' do
|
|
509
506
|
t1 = string_t('apa')
|
|
510
|
-
|
|
511
|
-
t2 = string_t
|
|
512
|
-
t2.size_type = range_t(2,4)
|
|
507
|
+
t2 = constrained_string_t(range_t(2,4))
|
|
513
508
|
common_t = calculator.common_type(t1,t2)
|
|
514
|
-
expect(common_t.class).to eq(
|
|
515
|
-
expect(common_t.
|
|
509
|
+
expect(common_t.class).to eq(PStringType)
|
|
510
|
+
expect(common_t.value).to be_nil
|
|
516
511
|
end
|
|
517
512
|
end
|
|
518
513
|
|
|
@@ -520,9 +515,9 @@ describe 'The type calculator' do
|
|
|
520
515
|
t1 = pattern_t('abc')
|
|
521
516
|
t2 = pattern_t('xyz')
|
|
522
517
|
common_t = calculator.common_type(t1,t2)
|
|
523
|
-
expect(common_t.class).to eq(
|
|
518
|
+
expect(common_t.class).to eq(PPatternType)
|
|
524
519
|
expect(common_t.patterns.map { |pr| pr.pattern }).to eq(['abc', 'xyz'])
|
|
525
|
-
expect(
|
|
520
|
+
expect(common_t.to_s).to eq('Pattern[/abc/, /xyz/]')
|
|
526
521
|
end
|
|
527
522
|
|
|
528
523
|
it 'computes enum commonality to value set sum' do
|
|
@@ -533,116 +528,140 @@ describe 'The type calculator' do
|
|
|
533
528
|
end
|
|
534
529
|
|
|
535
530
|
it 'computed variant commonality to type union where added types are not sub-types' do
|
|
536
|
-
a_t1 = integer_t
|
|
531
|
+
a_t1 = integer_t
|
|
537
532
|
a_t2 = enum_t('b')
|
|
538
533
|
v_a = variant_t(a_t1, a_t2)
|
|
539
|
-
b_t1 =
|
|
540
|
-
|
|
534
|
+
b_t1 = integer_t
|
|
535
|
+
b_t2 = enum_t('a')
|
|
536
|
+
v_b = variant_t(b_t1, b_t2)
|
|
541
537
|
common_t = calculator.common_type(v_a, v_b)
|
|
542
|
-
expect(common_t.class).to eq(
|
|
543
|
-
expect(Set.new(common_t.types)).to eq(Set.new([a_t1, a_t2, b_t1]))
|
|
538
|
+
expect(common_t.class).to eq(PVariantType)
|
|
539
|
+
expect(Set.new(common_t.types)).to eq(Set.new([a_t1, a_t2, b_t1, b_t2]))
|
|
544
540
|
end
|
|
545
541
|
|
|
546
542
|
it 'computed variant commonality to type union where added types are sub-types' do
|
|
547
|
-
a_t1 = integer_t
|
|
548
|
-
a_t2 = string_t
|
|
543
|
+
a_t1 = integer_t
|
|
544
|
+
a_t2 = string_t
|
|
549
545
|
v_a = variant_t(a_t1, a_t2)
|
|
550
|
-
b_t1 =
|
|
551
|
-
|
|
546
|
+
b_t1 = integer_t
|
|
547
|
+
b_t2 = enum_t('a')
|
|
548
|
+
v_b = variant_t(b_t1, b_t2)
|
|
552
549
|
common_t = calculator.common_type(v_a, v_b)
|
|
553
|
-
expect(common_t.class).to eq(
|
|
550
|
+
expect(common_t.class).to eq(PVariantType)
|
|
554
551
|
expect(Set.new(common_t.types)).to eq(Set.new([a_t1, a_t2]))
|
|
555
552
|
end
|
|
556
553
|
|
|
557
|
-
context
|
|
554
|
+
context 'of callables' do
|
|
558
555
|
it 'incompatible instances => generic callable' do
|
|
559
556
|
t1 = callable_t(String)
|
|
560
557
|
t2 = callable_t(Integer)
|
|
561
558
|
common_t = calculator.common_type(t1, t2)
|
|
562
|
-
expect(common_t.class).to be(
|
|
559
|
+
expect(common_t.class).to be(PCallableType)
|
|
563
560
|
expect(common_t.param_types).to be_nil
|
|
564
561
|
expect(common_t.block_type).to be_nil
|
|
565
562
|
end
|
|
566
563
|
|
|
567
564
|
it 'compatible instances => the most specific' do
|
|
568
565
|
t1 = callable_t(String)
|
|
569
|
-
scalar_t =
|
|
566
|
+
scalar_t = PScalarType.new
|
|
570
567
|
t2 = callable_t(scalar_t)
|
|
571
568
|
common_t = calculator.common_type(t1, t2)
|
|
572
|
-
expect(common_t.class).to be(
|
|
573
|
-
expect(common_t.param_types.class).to be(
|
|
569
|
+
expect(common_t.class).to be(PCallableType)
|
|
570
|
+
expect(common_t.param_types.class).to be(PTupleType)
|
|
574
571
|
expect(common_t.param_types.types).to eql([string_t])
|
|
575
572
|
expect(common_t.block_type).to be_nil
|
|
576
573
|
end
|
|
577
574
|
|
|
578
575
|
it 'block_type is included in the check (incompatible block)' do
|
|
579
|
-
|
|
580
|
-
|
|
576
|
+
b1 = callable_t(String)
|
|
577
|
+
b2 = callable_t(Integer)
|
|
578
|
+
t1 = callable_t(String, b1)
|
|
579
|
+
t2 = callable_t(String, b2)
|
|
581
580
|
common_t = calculator.common_type(t1, t2)
|
|
582
|
-
expect(common_t.class).to be(
|
|
581
|
+
expect(common_t.class).to be(PCallableType)
|
|
583
582
|
expect(common_t.param_types).to be_nil
|
|
584
583
|
expect(common_t.block_type).to be_nil
|
|
585
584
|
end
|
|
586
585
|
|
|
587
586
|
it 'block_type is included in the check (compatible block)' do
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
587
|
+
b1 = callable_t(String)
|
|
588
|
+
t1 = callable_t(String, b1)
|
|
589
|
+
scalar_t = PScalarType::DEFAULT
|
|
590
|
+
b2 = callable_t(scalar_t)
|
|
591
|
+
t2 = callable_t(String, b2)
|
|
591
592
|
common_t = calculator.common_type(t1, t2)
|
|
592
|
-
expect(common_t.param_types.class).to be(
|
|
593
|
+
expect(common_t.param_types.class).to be(PTupleType)
|
|
593
594
|
expect(common_t.block_type).to eql(callable_t(scalar_t))
|
|
594
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
|
|
595
614
|
end
|
|
596
615
|
end
|
|
597
616
|
|
|
598
617
|
context 'computes assignability' do
|
|
599
|
-
include_context
|
|
618
|
+
include_context 'types_setup'
|
|
600
619
|
|
|
601
620
|
it 'such that all types are assignable to themselves' do
|
|
602
621
|
all_types.each do |tc|
|
|
603
|
-
t = tc
|
|
622
|
+
t = tc::DEFAULT
|
|
604
623
|
expect(t).to be_assignable_to(t)
|
|
605
624
|
end
|
|
606
625
|
end
|
|
607
626
|
|
|
608
627
|
context 'for Unit, such that' do
|
|
609
628
|
it 'all types are assignable to Unit' do
|
|
610
|
-
t =
|
|
611
|
-
all_types.each { |t2| expect(t2
|
|
629
|
+
t = PUnitType::DEFAULT
|
|
630
|
+
all_types.each { |t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
612
631
|
end
|
|
613
632
|
|
|
614
633
|
it 'Unit is assignable to all other types' do
|
|
615
|
-
t =
|
|
616
|
-
all_types.each { |t2| expect(t).to be_assignable_to(t2
|
|
634
|
+
t = PUnitType::DEFAULT
|
|
635
|
+
all_types.each { |t2| expect(t).to be_assignable_to(t2::DEFAULT) }
|
|
617
636
|
end
|
|
618
637
|
|
|
619
638
|
it 'Unit is assignable to Unit' do
|
|
620
|
-
t =
|
|
621
|
-
t2 =
|
|
639
|
+
t = PUnitType::DEFAULT
|
|
640
|
+
t2 = PUnitType::DEFAULT
|
|
622
641
|
expect(t).to be_assignable_to(t2)
|
|
623
642
|
end
|
|
624
643
|
end
|
|
625
644
|
|
|
626
|
-
context
|
|
645
|
+
context 'for Any, such that' do
|
|
627
646
|
it 'all types are assignable to Any' do
|
|
628
|
-
t =
|
|
629
|
-
all_types.each { |t2| expect(t2
|
|
647
|
+
t = PAnyType::DEFAULT
|
|
648
|
+
all_types.each { |t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
630
649
|
end
|
|
631
650
|
|
|
632
651
|
it 'Any is not assignable to anything but Any and Optional (implied Optional[Any])' do
|
|
633
|
-
tested_types = all_types() - [
|
|
634
|
-
t =
|
|
635
|
-
tested_types.each { |t2| expect(t).not_to be_assignable_to(t2
|
|
652
|
+
tested_types = all_types() - [PAnyType, POptionalType]
|
|
653
|
+
t = PAnyType::DEFAULT
|
|
654
|
+
tested_types.each { |t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
636
655
|
end
|
|
637
656
|
end
|
|
638
657
|
|
|
639
658
|
context "for NotUndef, such that" do
|
|
640
659
|
it 'all types except types assignable from Undef are assignable to NotUndef' do
|
|
641
660
|
t = not_undef_t
|
|
642
|
-
tc =
|
|
643
|
-
undef_t =
|
|
644
|
-
all_types
|
|
645
|
-
t2 = c
|
|
661
|
+
tc = TypeCalculator.singleton
|
|
662
|
+
undef_t = PUndefType::DEFAULT
|
|
663
|
+
all_types.each do |c|
|
|
664
|
+
t2 = c::DEFAULT
|
|
646
665
|
if tc.assignable?(t2, undef_t)
|
|
647
666
|
expect(t2).not_to be_assignable_to(t)
|
|
648
667
|
else
|
|
@@ -652,10 +671,10 @@ describe 'The type calculator' do
|
|
|
652
671
|
end
|
|
653
672
|
|
|
654
673
|
it 'type NotUndef[T] is assignable from T unless T is assignable from Undef ' do
|
|
655
|
-
tc =
|
|
656
|
-
undef_t =
|
|
674
|
+
tc = TypeCalculator.singleton
|
|
675
|
+
undef_t = PUndefType::DEFAULT
|
|
657
676
|
all_types().select do |c|
|
|
658
|
-
t2 = c
|
|
677
|
+
t2 = c::DEFAULT
|
|
659
678
|
not_undef_t = not_undef_t(t2)
|
|
660
679
|
if tc.assignable?(t2, undef_t)
|
|
661
680
|
expect(t2).not_to be_assignable_to(not_undef_t)
|
|
@@ -666,10 +685,10 @@ describe 'The type calculator' do
|
|
|
666
685
|
end
|
|
667
686
|
|
|
668
687
|
it 'type T is assignable from NotUndef[T] unless T is assignable from Undef' do
|
|
669
|
-
tc =
|
|
670
|
-
undef_t =
|
|
688
|
+
tc = TypeCalculator.singleton
|
|
689
|
+
undef_t = PUndefType::DEFAULT
|
|
671
690
|
all_types().select do |c|
|
|
672
|
-
t2 = c
|
|
691
|
+
t2 = c::DEFAULT
|
|
673
692
|
not_undef_t = not_undef_t(t2)
|
|
674
693
|
unless tc.assignable?(t2, undef_t)
|
|
675
694
|
expect(not_undef_t).to be_assignable_to(t2)
|
|
@@ -678,35 +697,59 @@ describe 'The type calculator' do
|
|
|
678
697
|
end
|
|
679
698
|
end
|
|
680
699
|
|
|
681
|
-
context "for
|
|
700
|
+
context "for TypeReference, such that" do
|
|
701
|
+
it 'no other type is assignable' do
|
|
702
|
+
t = PTypeReferenceType::DEFAULT
|
|
703
|
+
all_instances = (all_types - [
|
|
704
|
+
PTypeReferenceType, # Avoid comparison with t
|
|
705
|
+
PVariantType, # DEFAULT contains no variants, so assignability is never tested and always true
|
|
706
|
+
PTypeAliasType # DEFAULT resolves to PTypeReferenceType::DEFAULT, i.e. t
|
|
707
|
+
]).map {|c| c::DEFAULT }
|
|
708
|
+
|
|
709
|
+
# Add a non-empty variant
|
|
710
|
+
all_instances << variant_t(PAnyType::DEFAULT, PUnitType::DEFAULT)
|
|
711
|
+
# Add a type alias that doesn't resolve to 't'
|
|
712
|
+
all_instances << type_alias_t('MyInt', 'Integer').resolve(TypeParser.singleton, nil)
|
|
713
|
+
|
|
714
|
+
all_instances.each { |i| expect(i).not_to be_assignable_to(t) }
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
it 'a TypeReference to the exact same type is assignable' do
|
|
718
|
+
expect(type_reference_t('Integer[0,10]')).to be_assignable_to(type_reference_t('Integer[0,10]'))
|
|
719
|
+
end
|
|
720
|
+
|
|
721
|
+
it 'a TypeReference to the different type is not assignable' do
|
|
722
|
+
expect(type_reference_t('String')).not_to be_assignable_to(type_reference_t('Integer'))
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
it 'a TypeReference to the different type is not assignable even if the referenced type is' do
|
|
726
|
+
expect(type_reference_t('Integer[1,2]')).not_to be_assignable_to(type_reference_t('Integer[0,3]'))
|
|
727
|
+
end
|
|
728
|
+
end
|
|
729
|
+
|
|
730
|
+
context 'for Data, such that' do
|
|
682
731
|
it 'all scalars + array and hash are assignable to Data' do
|
|
683
|
-
t =
|
|
732
|
+
t = PDataType::DEFAULT
|
|
684
733
|
data_compatible_types.each { |t2|
|
|
685
734
|
expect(type_from_class(t2)).to be_assignable_to(t)
|
|
686
735
|
}
|
|
687
736
|
end
|
|
688
737
|
|
|
689
|
-
it 'a
|
|
690
|
-
t =
|
|
691
|
-
data_compatible_types.each { |t2| expect(
|
|
738
|
+
it 'a scalar, hash, or array is assignable to Data' do
|
|
739
|
+
t = PDataType::DEFAULT
|
|
740
|
+
data_compatible_types.each { |t2| expect(type_from_class(t2)).to be_assignable_to(t) }
|
|
692
741
|
end
|
|
693
742
|
|
|
694
743
|
it 'Data is not assignable to any of its subtypes' do
|
|
695
|
-
t =
|
|
696
|
-
types_to_test = data_compatible_types- [
|
|
744
|
+
t = PDataType::DEFAULT
|
|
745
|
+
types_to_test = data_compatible_types- [PDataType]
|
|
697
746
|
types_to_test.each {|t2| expect(t).not_to be_assignable_to(type_from_class(t2)) }
|
|
698
747
|
end
|
|
699
748
|
|
|
700
|
-
it 'Data is not assignable to a Variant of Data subtype' do
|
|
701
|
-
t = Puppet::Pops::Types::PDataType.new()
|
|
702
|
-
types_to_test = data_compatible_types- [Puppet::Pops::Types::PDataType]
|
|
703
|
-
types_to_test.each { |t2| expect(t).not_to be_assignable_to(variant_t(type_from_class(t2))) }
|
|
704
|
-
end
|
|
705
|
-
|
|
706
749
|
it 'Data is not assignable to any disjunct type' do
|
|
707
|
-
tested_types = all_types - [
|
|
708
|
-
t =
|
|
709
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
750
|
+
tested_types = all_types - [PAnyType, POptionalType, PDataType] - scalar_types
|
|
751
|
+
t = PDataType::DEFAULT
|
|
752
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
710
753
|
end
|
|
711
754
|
end
|
|
712
755
|
|
|
@@ -728,109 +771,132 @@ describe 'The type calculator' do
|
|
|
728
771
|
end
|
|
729
772
|
end
|
|
730
773
|
|
|
731
|
-
context
|
|
732
|
-
it
|
|
733
|
-
t =
|
|
734
|
-
scalar_types.each {|t2| expect(t2
|
|
774
|
+
context 'for Scalar, such that' do
|
|
775
|
+
it 'all scalars are assignable to Scalar' do
|
|
776
|
+
t = PScalarType::DEFAULT
|
|
777
|
+
scalar_types.each {|t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
735
778
|
end
|
|
736
779
|
|
|
737
780
|
it 'Scalar is not assignable to any of its subtypes' do
|
|
738
|
-
t =
|
|
739
|
-
types_to_test = scalar_types - [
|
|
740
|
-
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
781
|
+
t = PScalarType::DEFAULT
|
|
782
|
+
types_to_test = scalar_types - [PScalarType]
|
|
783
|
+
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
741
784
|
end
|
|
742
785
|
|
|
743
786
|
it 'Scalar is not assignable to any disjunct type' do
|
|
744
|
-
tested_types = all_types - [
|
|
745
|
-
t =
|
|
746
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
787
|
+
tested_types = all_types - [PAnyType, POptionalType, PNotUndefType, PDataType] - scalar_types
|
|
788
|
+
t = PScalarType::DEFAULT
|
|
789
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
747
790
|
end
|
|
748
791
|
end
|
|
749
792
|
|
|
750
|
-
context
|
|
751
|
-
it
|
|
752
|
-
t =
|
|
753
|
-
numeric_types.each {|t2| expect(t2
|
|
793
|
+
context 'for Numeric, such that' do
|
|
794
|
+
it 'all numerics are assignable to Numeric' do
|
|
795
|
+
t = PNumericType::DEFAULT
|
|
796
|
+
numeric_types.each {|t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
754
797
|
end
|
|
755
798
|
|
|
756
799
|
it 'Numeric is not assignable to any of its subtypes' do
|
|
757
|
-
t =
|
|
758
|
-
types_to_test = numeric_types - [
|
|
759
|
-
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
800
|
+
t = PNumericType::DEFAULT
|
|
801
|
+
types_to_test = numeric_types - [PNumericType]
|
|
802
|
+
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
760
803
|
end
|
|
761
804
|
|
|
762
805
|
it 'Numeric is not assignable to any disjunct type' do
|
|
763
806
|
tested_types = all_types - [
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
807
|
+
PAnyType,
|
|
808
|
+
POptionalType,
|
|
809
|
+
PNotUndefType,
|
|
810
|
+
PDataType,
|
|
811
|
+
PScalarType,
|
|
769
812
|
] - numeric_types
|
|
770
|
-
t =
|
|
771
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
813
|
+
t = PNumericType::DEFAULT
|
|
814
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
772
815
|
end
|
|
773
816
|
end
|
|
774
817
|
|
|
775
|
-
context
|
|
776
|
-
it
|
|
777
|
-
t =
|
|
778
|
-
collection_types.each {|t2| expect(t2
|
|
818
|
+
context 'for Collection, such that' do
|
|
819
|
+
it 'all collections are assignable to Collection' do
|
|
820
|
+
t = PCollectionType::DEFAULT
|
|
821
|
+
collection_types.each {|t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
779
822
|
end
|
|
780
823
|
|
|
781
824
|
it 'Collection is not assignable to any of its subtypes' do
|
|
782
|
-
t =
|
|
783
|
-
types_to_test = collection_types - [
|
|
784
|
-
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
825
|
+
t = PCollectionType::DEFAULT
|
|
826
|
+
types_to_test = collection_types - [PCollectionType]
|
|
827
|
+
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
785
828
|
end
|
|
786
829
|
|
|
787
830
|
it 'Collection is not assignable to any disjunct type' do
|
|
788
|
-
tested_types = all_types - [
|
|
789
|
-
|
|
790
|
-
|
|
831
|
+
tested_types = all_types - [
|
|
832
|
+
PAnyType,
|
|
833
|
+
POptionalType,
|
|
834
|
+
PNotUndefType,
|
|
835
|
+
PIterableType] - collection_types
|
|
836
|
+
t = PCollectionType::DEFAULT
|
|
837
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
791
838
|
end
|
|
792
839
|
end
|
|
793
840
|
|
|
794
|
-
context
|
|
795
|
-
it
|
|
796
|
-
t =
|
|
841
|
+
context 'for Array, such that' do
|
|
842
|
+
it 'Array is not assignable to non Array based Collection type' do
|
|
843
|
+
t = PArrayType::DEFAULT
|
|
797
844
|
tested_types = collection_types - [
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
845
|
+
PCollectionType,
|
|
846
|
+
PNotUndefType,
|
|
847
|
+
PArrayType,
|
|
848
|
+
PTupleType]
|
|
849
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
803
850
|
end
|
|
804
851
|
|
|
805
852
|
it 'Array is not assignable to any disjunct type' do
|
|
806
853
|
tested_types = all_types - [
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
854
|
+
PAnyType,
|
|
855
|
+
POptionalType,
|
|
856
|
+
PNotUndefType,
|
|
857
|
+
PIterableType,
|
|
858
|
+
PDataType] - collection_types
|
|
859
|
+
t = PArrayType::DEFAULT
|
|
860
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
861
|
+
end
|
|
862
|
+
|
|
863
|
+
it 'Empty Array is assignable to an array that accepts 0 entries' do
|
|
864
|
+
expect(empty_array_t).to be_assignable_to(array_t(string_t))
|
|
865
|
+
expect(empty_array_t).to be_assignable_to(array_t(integer_t))
|
|
866
|
+
end
|
|
867
|
+
|
|
868
|
+
it 'A Tuple is assignable to an array' do
|
|
869
|
+
expect(tuple_t(String)).to be_assignable_to(array_t(String))
|
|
870
|
+
end
|
|
871
|
+
|
|
872
|
+
it 'A Tuple with <n> elements is assignable to an array with min size <n>' do
|
|
873
|
+
expect(tuple_t(String,String)).to be_assignable_to(array_t(String, range_t(2, :default)))
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
it 'A Tuple with <n> elements where the last 2 are optional is assignable to an array with size <n> - 2' do
|
|
877
|
+
expect(constrained_tuple_t(range_t(2, :default), String,String,String,String)).to be_assignable_to(array_t(String, range_t(2, :default)))
|
|
813
878
|
end
|
|
814
879
|
end
|
|
815
880
|
|
|
816
|
-
context
|
|
817
|
-
it
|
|
818
|
-
t =
|
|
881
|
+
context 'for Hash, such that' do
|
|
882
|
+
it 'Hash is not assignable to any other Collection type' do
|
|
883
|
+
t = PHashType::DEFAULT
|
|
819
884
|
tested_types = collection_types - [
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
885
|
+
PCollectionType,
|
|
886
|
+
PStructType,
|
|
887
|
+
PHashType]
|
|
888
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
824
889
|
end
|
|
825
890
|
|
|
826
891
|
it 'Hash is not assignable to any disjunct type' do
|
|
827
892
|
tested_types = all_types - [
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
893
|
+
PAnyType,
|
|
894
|
+
POptionalType,
|
|
895
|
+
PNotUndefType,
|
|
896
|
+
PIterableType,
|
|
897
|
+
PDataType] - collection_types
|
|
898
|
+
t = PHashType::DEFAULT
|
|
899
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
834
900
|
end
|
|
835
901
|
|
|
836
902
|
it 'Struct is assignable to Hash with Pattern that matches all keys' do
|
|
@@ -850,45 +916,81 @@ describe 'The type calculator' do
|
|
|
850
916
|
end
|
|
851
917
|
end
|
|
852
918
|
|
|
853
|
-
context
|
|
854
|
-
it
|
|
855
|
-
|
|
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
|
+
|
|
947
|
+
context 'for Tuple, such that' do
|
|
948
|
+
it 'Tuple is not assignable to any other non Array based Collection type' do
|
|
949
|
+
t = PTupleType::DEFAULT
|
|
856
950
|
tested_types = collection_types - [
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
951
|
+
PCollectionType,
|
|
952
|
+
PTupleType,
|
|
953
|
+
PArrayType]
|
|
954
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
955
|
+
end
|
|
956
|
+
|
|
957
|
+
it 'A tuple with parameters is assignable to the default Tuple' do
|
|
958
|
+
t = PTupleType::DEFAULT
|
|
959
|
+
t2 = PTupleType.new([PStringType::DEFAULT])
|
|
960
|
+
expect(t2).to be_assignable_to(t)
|
|
861
961
|
end
|
|
862
962
|
|
|
863
963
|
it 'Tuple is not assignable to any disjunct type' do
|
|
864
964
|
tested_types = all_types - [
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
965
|
+
PAnyType,
|
|
966
|
+
POptionalType,
|
|
967
|
+
PNotUndefType,
|
|
968
|
+
PIterableType,
|
|
969
|
+
PDataType] - collection_types
|
|
970
|
+
t = PTupleType::DEFAULT
|
|
971
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
871
972
|
end
|
|
872
973
|
end
|
|
873
974
|
|
|
874
|
-
context
|
|
875
|
-
it
|
|
876
|
-
t =
|
|
975
|
+
context 'for Struct, such that' do
|
|
976
|
+
it 'Struct is not assignable to any other non Hashed based Collection type' do
|
|
977
|
+
t = PStructType::DEFAULT
|
|
877
978
|
tested_types = collection_types - [
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
979
|
+
PCollectionType,
|
|
980
|
+
PStructType,
|
|
981
|
+
PHashType]
|
|
982
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
882
983
|
end
|
|
883
984
|
|
|
884
985
|
it 'Struct is not assignable to any disjunct type' do
|
|
885
986
|
tested_types = all_types - [
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
987
|
+
PAnyType,
|
|
988
|
+
POptionalType,
|
|
989
|
+
PNotUndefType,
|
|
990
|
+
PIterableType,
|
|
991
|
+
PDataType] - collection_types
|
|
992
|
+
t = PStructType::DEFAULT
|
|
993
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
892
994
|
end
|
|
893
995
|
|
|
894
996
|
it 'Default key optionality is controlled by value assignability to undef' do
|
|
@@ -919,34 +1021,82 @@ describe 'The type calculator' do
|
|
|
919
1021
|
t2 = struct_t({not_undef_t('other_member') => string_t})
|
|
920
1022
|
expect(t2).not_to be_assignable_to(t1)
|
|
921
1023
|
end
|
|
1024
|
+
|
|
1025
|
+
it 'A hash of string is not assignable to struct with integer value' do
|
|
1026
|
+
t1 = struct_t({'foo' => integer_t, 'bar' => string_t})
|
|
1027
|
+
t2 = hash_t(string_t, string_t, range_t(2, 2))
|
|
1028
|
+
expect(t1.assignable?(t2)).to eql(false)
|
|
1029
|
+
end
|
|
1030
|
+
|
|
1031
|
+
it 'A hash of with integer key is not assignable to struct with string key' do
|
|
1032
|
+
t1 = struct_t({'foo' => string_t, 'bar' => string_t})
|
|
1033
|
+
t2 = hash_t(integer_t, string_t, range_t(2, 2))
|
|
1034
|
+
expect(t1.assignable?(t2)).to eql(false)
|
|
1035
|
+
end
|
|
922
1036
|
end
|
|
923
1037
|
|
|
924
|
-
context
|
|
925
|
-
it
|
|
926
|
-
t =
|
|
1038
|
+
context 'for Callable, such that' do
|
|
1039
|
+
it 'Callable is not assignable to any disjunct type' do
|
|
1040
|
+
t = PCallableType::DEFAULT
|
|
927
1041
|
tested_types = all_types - [
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
tested_types.each {|t2| expect(t).to_not be_assignable_to(t2
|
|
1042
|
+
PCallableType,
|
|
1043
|
+
PAnyType,
|
|
1044
|
+
POptionalType,
|
|
1045
|
+
PNotUndefType]
|
|
1046
|
+
tested_types.each {|t2| expect(t).to_not be_assignable_to(t2::DEFAULT) }
|
|
1047
|
+
end
|
|
1048
|
+
|
|
1049
|
+
it 'a callable with parameter is assignable to the default callable' do
|
|
1050
|
+
expect(callable_t(string_t)).to be_assignable_to(PCallableType::DEFAULT)
|
|
1051
|
+
end
|
|
1052
|
+
|
|
1053
|
+
it 'the default callable is not assignable to a callable with parameter' do
|
|
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))
|
|
933
1083
|
end
|
|
934
1084
|
end
|
|
935
1085
|
|
|
936
1086
|
it 'should recognize mapped ruby types' do
|
|
937
|
-
{ Integer =>
|
|
938
|
-
Fixnum =>
|
|
939
|
-
Bignum =>
|
|
940
|
-
Float =>
|
|
941
|
-
Numeric =>
|
|
942
|
-
NilClass =>
|
|
943
|
-
TrueClass =>
|
|
944
|
-
FalseClass =>
|
|
945
|
-
String =>
|
|
946
|
-
Regexp =>
|
|
947
|
-
Regexp =>
|
|
948
|
-
Array =>
|
|
949
|
-
Hash =>
|
|
1087
|
+
{ Integer => PIntegerType::DEFAULT,
|
|
1088
|
+
Fixnum => PIntegerType::DEFAULT,
|
|
1089
|
+
Bignum => PIntegerType::DEFAULT,
|
|
1090
|
+
Float => PFloatType::DEFAULT,
|
|
1091
|
+
Numeric => PNumericType::DEFAULT,
|
|
1092
|
+
NilClass => PUndefType::DEFAULT,
|
|
1093
|
+
TrueClass => PBooleanType::DEFAULT,
|
|
1094
|
+
FalseClass => PBooleanType::DEFAULT,
|
|
1095
|
+
String => PStringType::DEFAULT,
|
|
1096
|
+
Regexp => PRegexpType::DEFAULT,
|
|
1097
|
+
Regexp => PRegexpType::DEFAULT,
|
|
1098
|
+
Array => TypeFactory.array_of_data,
|
|
1099
|
+
Hash => TypeFactory.hash_of_data
|
|
950
1100
|
}.each do |ruby_type, puppet_type |
|
|
951
1101
|
expect(ruby_type).to be_assignable_to(puppet_type)
|
|
952
1102
|
end
|
|
@@ -957,35 +1107,18 @@ describe 'The type calculator' do
|
|
|
957
1107
|
expect(calculator.assignable?(range_t(2,5), range_t(2,5))).to eq(true)
|
|
958
1108
|
end
|
|
959
1109
|
|
|
960
|
-
it 'should accept an equal reverse range' do
|
|
961
|
-
expect(calculator.assignable?(range_t(2,5), range_t(5,2))).to eq(true)
|
|
962
|
-
end
|
|
963
|
-
|
|
964
1110
|
it 'should accept a narrower range' do
|
|
965
1111
|
expect(calculator.assignable?(range_t(2,10), range_t(3,5))).to eq(true)
|
|
966
1112
|
end
|
|
967
1113
|
|
|
968
|
-
it 'should accept a narrower reverse range' do
|
|
969
|
-
expect(calculator.assignable?(range_t(2,10), range_t(5,3))).to eq(true)
|
|
970
|
-
end
|
|
971
|
-
|
|
972
1114
|
it 'should reject a wider range' do
|
|
973
1115
|
expect(calculator.assignable?(range_t(3,5), range_t(2,10))).to eq(false)
|
|
974
1116
|
end
|
|
975
1117
|
|
|
976
|
-
it 'should reject a wider reverse range' do
|
|
977
|
-
expect(calculator.assignable?(range_t(3,5), range_t(10,2))).to eq(false)
|
|
978
|
-
end
|
|
979
|
-
|
|
980
1118
|
it 'should reject a partially overlapping range' do
|
|
981
1119
|
expect(calculator.assignable?(range_t(3,5), range_t(2,4))).to eq(false)
|
|
982
1120
|
expect(calculator.assignable?(range_t(3,5), range_t(4,6))).to eq(false)
|
|
983
1121
|
end
|
|
984
|
-
|
|
985
|
-
it 'should reject a partially overlapping reverse range' do
|
|
986
|
-
expect(calculator.assignable?(range_t(3,5), range_t(4,2))).to eq(false)
|
|
987
|
-
expect(calculator.assignable?(range_t(3,5), range_t(6,4))).to eq(false)
|
|
988
|
-
end
|
|
989
1122
|
end
|
|
990
1123
|
|
|
991
1124
|
context 'when dealing with patterns' do
|
|
@@ -1021,7 +1154,7 @@ describe 'The type calculator' do
|
|
|
1021
1154
|
|
|
1022
1155
|
it 'should accept multiple strings if they all match any patterns' do
|
|
1023
1156
|
p_t = pattern_t('X', 'Y', 'abc')
|
|
1024
|
-
p_s =
|
|
1157
|
+
p_s = enum_t('Xa', 'aY', 'abc')
|
|
1025
1158
|
expect(calculator.assignable?(p_t, p_s)).to eq(true)
|
|
1026
1159
|
end
|
|
1027
1160
|
|
|
@@ -1033,7 +1166,7 @@ describe 'The type calculator' do
|
|
|
1033
1166
|
|
|
1034
1167
|
it 'should reject multiple strings if not all match any patterns' do
|
|
1035
1168
|
p_t = pattern_t('abc', 'ab', 'c', 'q')
|
|
1036
|
-
p_s =
|
|
1169
|
+
p_s = enum_t('X', 'Y', 'Z')
|
|
1037
1170
|
expect(calculator.assignable?(p_t, p_s)).to eq(false)
|
|
1038
1171
|
end
|
|
1039
1172
|
|
|
@@ -1049,18 +1182,18 @@ describe 'The type calculator' do
|
|
|
1049
1182
|
end
|
|
1050
1183
|
|
|
1051
1184
|
it 'pattern representing all patterns should accept any pattern' do
|
|
1052
|
-
expect(calculator.assignable?(pattern_t
|
|
1053
|
-
expect(calculator.assignable?(pattern_t
|
|
1185
|
+
expect(calculator.assignable?(pattern_t, pattern_t('a'))).to eq(true)
|
|
1186
|
+
expect(calculator.assignable?(pattern_t, pattern_t)).to eq(true)
|
|
1054
1187
|
end
|
|
1055
1188
|
|
|
1056
1189
|
it 'pattern representing all patterns should accept any enum' do
|
|
1057
|
-
expect(calculator.assignable?(pattern_t
|
|
1058
|
-
expect(calculator.assignable?(pattern_t
|
|
1190
|
+
expect(calculator.assignable?(pattern_t, enum_t('a'))).to eq(true)
|
|
1191
|
+
expect(calculator.assignable?(pattern_t, enum_t)).to eq(true)
|
|
1059
1192
|
end
|
|
1060
1193
|
|
|
1061
1194
|
it 'pattern representing all patterns should accept any string' do
|
|
1062
|
-
expect(calculator.assignable?(pattern_t
|
|
1063
|
-
expect(calculator.assignable?(pattern_t
|
|
1195
|
+
expect(calculator.assignable?(pattern_t, string_t('a'))).to eq(true)
|
|
1196
|
+
expect(calculator.assignable?(pattern_t, string_t)).to eq(true)
|
|
1064
1197
|
end
|
|
1065
1198
|
|
|
1066
1199
|
end
|
|
@@ -1079,8 +1212,8 @@ describe 'The type calculator' do
|
|
|
1079
1212
|
end
|
|
1080
1213
|
|
|
1081
1214
|
it 'non parameterized enum accepts any other enum but not the reverse' do
|
|
1082
|
-
expect(calculator.assignable?(enum_t
|
|
1083
|
-
expect(calculator.assignable?(enum_t('a'), enum_t
|
|
1215
|
+
expect(calculator.assignable?(enum_t, enum_t('a'))).to eq(true)
|
|
1216
|
+
expect(calculator.assignable?(enum_t('a'), enum_t)).to eq(false)
|
|
1084
1217
|
end
|
|
1085
1218
|
|
|
1086
1219
|
it 'enum should accept a variant where all variants are acceptable' do
|
|
@@ -1091,54 +1224,53 @@ describe 'The type calculator' do
|
|
|
1091
1224
|
|
|
1092
1225
|
context 'when dealing with string and enum combinations' do
|
|
1093
1226
|
it 'should accept assigning any enum to unrestricted string' do
|
|
1094
|
-
expect(calculator.assignable?(string_t
|
|
1095
|
-
expect(calculator.assignable?(string_t
|
|
1227
|
+
expect(calculator.assignable?(string_t, enum_t('blue'))).to eq(true)
|
|
1228
|
+
expect(calculator.assignable?(string_t, enum_t('blue', 'red'))).to eq(true)
|
|
1096
1229
|
end
|
|
1097
1230
|
|
|
1098
1231
|
it 'should not accept assigning longer enum value to size restricted string' do
|
|
1099
|
-
expect(calculator.assignable?(
|
|
1232
|
+
expect(calculator.assignable?(constrained_string_t(range_t(2,2)), enum_t('a','blue'))).to eq(false)
|
|
1100
1233
|
end
|
|
1101
1234
|
|
|
1102
1235
|
it 'should accept assigning any string to empty enum' do
|
|
1103
|
-
expect(calculator.assignable?(enum_t
|
|
1236
|
+
expect(calculator.assignable?(enum_t, string_t)).to eq(true)
|
|
1104
1237
|
end
|
|
1105
1238
|
|
|
1106
1239
|
it 'should accept assigning empty enum to any string' do
|
|
1107
|
-
expect(calculator.assignable?(string_t
|
|
1240
|
+
expect(calculator.assignable?(string_t, enum_t)).to eq(true)
|
|
1108
1241
|
end
|
|
1109
1242
|
|
|
1110
1243
|
it 'should not accept assigning empty enum to size constrained string' do
|
|
1111
|
-
expect(calculator.assignable?(
|
|
1244
|
+
expect(calculator.assignable?(constrained_string_t(range_t(2,2)), enum_t)).to eq(false)
|
|
1112
1245
|
end
|
|
1113
1246
|
end
|
|
1114
1247
|
|
|
1115
1248
|
context 'when dealing with string/pattern/enum combinations' do
|
|
1116
1249
|
it 'any string is equal to any enum is equal to any pattern' do
|
|
1117
|
-
expect(calculator.assignable?(string_t
|
|
1118
|
-
expect(calculator.assignable?(string_t
|
|
1119
|
-
expect(calculator.assignable?(enum_t
|
|
1120
|
-
expect(calculator.assignable?(enum_t
|
|
1121
|
-
expect(calculator.assignable?(pattern_t
|
|
1122
|
-
expect(calculator.assignable?(pattern_t
|
|
1250
|
+
expect(calculator.assignable?(string_t, enum_t)).to eq(true)
|
|
1251
|
+
expect(calculator.assignable?(string_t, pattern_t)).to eq(true)
|
|
1252
|
+
expect(calculator.assignable?(enum_t, string_t)).to eq(true)
|
|
1253
|
+
expect(calculator.assignable?(enum_t, pattern_t)).to eq(true)
|
|
1254
|
+
expect(calculator.assignable?(pattern_t, string_t)).to eq(true)
|
|
1255
|
+
expect(calculator.assignable?(pattern_t, enum_t)).to eq(true)
|
|
1123
1256
|
end
|
|
1124
1257
|
end
|
|
1125
1258
|
|
|
1126
1259
|
context 'when dealing with tuples' do
|
|
1127
1260
|
it 'matches empty tuples' do
|
|
1128
|
-
tuple1 = tuple_t
|
|
1129
|
-
tuple2 = tuple_t
|
|
1261
|
+
tuple1 = tuple_t
|
|
1262
|
+
tuple2 = tuple_t
|
|
1130
1263
|
|
|
1131
1264
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1132
1265
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1133
1266
|
end
|
|
1134
1267
|
|
|
1135
1268
|
it 'accepts an empty tuple as assignable to a tuple with a min size of 0' do
|
|
1136
|
-
tuple1 =
|
|
1137
|
-
factory.constrain_size(tuple1, 0, :default)
|
|
1269
|
+
tuple1 = constrained_tuple_t(range_t(0, :default))
|
|
1138
1270
|
tuple2 = tuple_t()
|
|
1139
1271
|
|
|
1140
1272
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1141
|
-
expect(calculator.assignable?(tuple2, tuple1)).to eq(
|
|
1273
|
+
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1142
1274
|
end
|
|
1143
1275
|
|
|
1144
1276
|
it 'should accept matching tuples' do
|
|
@@ -1156,62 +1288,51 @@ describe 'The type calculator' do
|
|
|
1156
1288
|
end
|
|
1157
1289
|
|
|
1158
1290
|
it 'should accept ranged tuples' do
|
|
1159
|
-
tuple1 =
|
|
1160
|
-
factory.constrain_size(tuple1, 5, 5)
|
|
1291
|
+
tuple1 = constrained_tuple_t(range_t(5,5), 1)
|
|
1161
1292
|
tuple2 = tuple_t(Integer,Integer, Integer, Integer, Integer)
|
|
1162
1293
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1163
1294
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1164
1295
|
end
|
|
1165
1296
|
|
|
1166
1297
|
it 'should reject ranged tuples when ranges does not match' do
|
|
1167
|
-
tuple1 =
|
|
1168
|
-
factory.constrain_size(tuple1, 4, 5)
|
|
1298
|
+
tuple1 = constrained_tuple_t(range_t(4, 5), 1)
|
|
1169
1299
|
tuple2 = tuple_t(Integer,Integer, Integer, Integer, Integer)
|
|
1170
1300
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1171
1301
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(false)
|
|
1172
1302
|
end
|
|
1173
1303
|
|
|
1174
1304
|
it 'should reject ranged tuples when ranges does not match (using infinite upper bound)' do
|
|
1175
|
-
tuple1 =
|
|
1176
|
-
factory.constrain_size(tuple1, 4, :default)
|
|
1305
|
+
tuple1 = constrained_tuple_t(range_t(4, :default), 1)
|
|
1177
1306
|
tuple2 = tuple_t(Integer,Integer, Integer, Integer, Integer)
|
|
1178
1307
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1179
1308
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(false)
|
|
1180
1309
|
end
|
|
1181
1310
|
|
|
1182
1311
|
it 'should accept matching tuples with optional entries by repeating last' do
|
|
1183
|
-
tuple1 =
|
|
1184
|
-
|
|
1185
|
-
tuple2 = tuple_t(Numeric,Numeric)
|
|
1186
|
-
factory.constrain_size(tuple2, 0, :default)
|
|
1312
|
+
tuple1 = constrained_tuple_t(range_t(0, :default), 1,2)
|
|
1313
|
+
tuple2 = constrained_tuple_t(range_t(0, :default), Numeric,Numeric)
|
|
1187
1314
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(false)
|
|
1188
1315
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1189
1316
|
end
|
|
1190
1317
|
|
|
1191
1318
|
it 'should accept matching tuples with optional entries' do
|
|
1192
|
-
tuple1 =
|
|
1193
|
-
|
|
1194
|
-
array2 = factory.constrain_size(array_t(Integer),2,2)
|
|
1319
|
+
tuple1 = constrained_tuple_t(range_t(1, 3), Integer, Integer, String)
|
|
1320
|
+
array2 = array_t(Integer, range_t(2,2))
|
|
1195
1321
|
expect(calculator.assignable?(tuple1, array2)).to eq(true)
|
|
1196
|
-
|
|
1322
|
+
tuple1 = constrained_tuple_t(range_t(3, 3), tuple1.types)
|
|
1197
1323
|
expect(calculator.assignable?(tuple1, array2)).to eq(false)
|
|
1198
1324
|
end
|
|
1199
1325
|
|
|
1200
1326
|
it 'should accept matching array' do
|
|
1201
1327
|
tuple1 = tuple_t(1,2)
|
|
1202
|
-
array = array_t(Integer)
|
|
1203
|
-
factory.constrain_size(array, 2, 2)
|
|
1328
|
+
array = array_t(Integer, range_t(2, 2))
|
|
1204
1329
|
expect(calculator.assignable?(tuple1, array)).to eq(true)
|
|
1205
1330
|
expect(calculator.assignable?(array, tuple1)).to eq(true)
|
|
1206
1331
|
end
|
|
1207
1332
|
|
|
1208
1333
|
it 'should accept empty array when tuple allows min of 0' do
|
|
1209
|
-
tuple1 =
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
array = array_t(Integer)
|
|
1213
|
-
factory.constrain_size(array, 0, 0)
|
|
1214
|
-
|
|
1334
|
+
tuple1 = constrained_tuple_t(range_t(0, 1), Integer)
|
|
1335
|
+
array = array_t(unit_t, range_t(0, 0))
|
|
1215
1336
|
expect(calculator.assignable?(tuple1, array)).to eq(true)
|
|
1216
1337
|
expect(calculator.assignable?(array, tuple1)).to eq(false)
|
|
1217
1338
|
end
|
|
@@ -1258,18 +1379,15 @@ describe 'The type calculator' do
|
|
|
1258
1379
|
|
|
1259
1380
|
it 'should accept matching hash' do
|
|
1260
1381
|
struct1 = struct_t({'a'=>Integer, 'b'=>Integer})
|
|
1261
|
-
non_empty_string =
|
|
1262
|
-
|
|
1263
|
-
hsh = hash_t(non_empty_string, Integer)
|
|
1264
|
-
factory.constrain_size(hsh, 2, 2)
|
|
1382
|
+
non_empty_string = constrained_string_t(range_t(1, nil))
|
|
1383
|
+
hsh = hash_t(non_empty_string, Integer, range_t(2,2))
|
|
1265
1384
|
expect(calculator.assignable?(struct1, hsh)).to eq(true)
|
|
1266
1385
|
expect(calculator.assignable?(hsh, struct1)).to eq(true)
|
|
1267
1386
|
end
|
|
1268
1387
|
|
|
1269
|
-
it 'should accept empty hash with key_type
|
|
1388
|
+
it 'should accept empty hash with key_type unit' do
|
|
1270
1389
|
struct1 = struct_t({'a'=>optional_t(Integer)})
|
|
1271
|
-
hsh = hash_t(
|
|
1272
|
-
factory.constrain_size(hsh, 0, 0)
|
|
1390
|
+
hsh = hash_t(unit_t, unit_t, range_t(0, 0))
|
|
1273
1391
|
expect(calculator.assignable?(struct1, hsh)).to eq(true)
|
|
1274
1392
|
end
|
|
1275
1393
|
end
|
|
@@ -1294,108 +1412,225 @@ describe 'The type calculator' do
|
|
|
1294
1412
|
expect(calculator.assignable?(Bar, fooType)).to eq(false)
|
|
1295
1413
|
end
|
|
1296
1414
|
|
|
1297
|
-
it
|
|
1298
|
-
hc1 =
|
|
1299
|
-
hc2 =
|
|
1415
|
+
it 'should allow host class with same name' do
|
|
1416
|
+
hc1 = TypeFactory.host_class('the_name')
|
|
1417
|
+
hc2 = TypeFactory.host_class('the_name')
|
|
1300
1418
|
expect(calculator.assignable?(hc1, hc2)).to eq(true)
|
|
1301
1419
|
end
|
|
1302
1420
|
|
|
1303
|
-
it
|
|
1304
|
-
hc1 =
|
|
1305
|
-
hc2 =
|
|
1421
|
+
it 'should allow host class with name assigned to hostclass without name' do
|
|
1422
|
+
hc1 = TypeFactory.host_class
|
|
1423
|
+
hc2 = TypeFactory.host_class('the_name')
|
|
1306
1424
|
expect(calculator.assignable?(hc1, hc2)).to eq(true)
|
|
1307
1425
|
end
|
|
1308
1426
|
|
|
1309
|
-
it
|
|
1310
|
-
hc1 =
|
|
1311
|
-
hc2 =
|
|
1427
|
+
it 'should reject host classes with different names' do
|
|
1428
|
+
hc1 = TypeFactory.host_class('the_name')
|
|
1429
|
+
hc2 = TypeFactory.host_class('another_name')
|
|
1312
1430
|
expect(calculator.assignable?(hc1, hc2)).to eq(false)
|
|
1313
1431
|
end
|
|
1314
1432
|
|
|
1315
|
-
it
|
|
1316
|
-
hc1 =
|
|
1317
|
-
hc2 =
|
|
1433
|
+
it 'should reject host classes without name assigned to host class with name' do
|
|
1434
|
+
hc1 = TypeFactory.host_class('the_name')
|
|
1435
|
+
hc2 = TypeFactory.host_class
|
|
1318
1436
|
expect(calculator.assignable?(hc1, hc2)).to eq(false)
|
|
1319
1437
|
end
|
|
1320
1438
|
|
|
1321
|
-
it
|
|
1322
|
-
r1 =
|
|
1323
|
-
r2 =
|
|
1439
|
+
it 'should allow resource with same type_name and title' do
|
|
1440
|
+
r1 = TypeFactory.resource('file', 'foo')
|
|
1441
|
+
r2 = TypeFactory.resource('file', 'foo')
|
|
1324
1442
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1325
1443
|
end
|
|
1326
1444
|
|
|
1327
|
-
it
|
|
1328
|
-
r1 =
|
|
1329
|
-
r2 =
|
|
1445
|
+
it 'should allow more specific resource assignment' do
|
|
1446
|
+
r1 = TypeFactory.resource
|
|
1447
|
+
r2 = TypeFactory.resource('file')
|
|
1330
1448
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1331
|
-
r2 =
|
|
1449
|
+
r2 = TypeFactory.resource('file', '/tmp/foo')
|
|
1332
1450
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1333
|
-
r1 =
|
|
1451
|
+
r1 = TypeFactory.resource('file')
|
|
1334
1452
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1335
1453
|
end
|
|
1336
1454
|
|
|
1337
|
-
it
|
|
1338
|
-
r1 =
|
|
1339
|
-
r2 =
|
|
1455
|
+
it 'should reject less specific resource assignment' do
|
|
1456
|
+
r1 = TypeFactory.resource('file', '/tmp/foo')
|
|
1457
|
+
r2 = TypeFactory.resource('file')
|
|
1340
1458
|
expect(calculator.assignable?(r1, r2)).to eq(false)
|
|
1341
|
-
r2 =
|
|
1459
|
+
r2 = TypeFactory.resource
|
|
1342
1460
|
expect(calculator.assignable?(r1, r2)).to eq(false)
|
|
1343
1461
|
end
|
|
1344
1462
|
|
|
1463
|
+
context 'for TypeAlias, such that' do
|
|
1464
|
+
let!(:parser) { TypeParser.singleton }
|
|
1465
|
+
|
|
1466
|
+
it 'it is assignable to the type that it is an alias for' do
|
|
1467
|
+
t = type_alias_t('Alias', 'Integer').resolve(parser, nil)
|
|
1468
|
+
expect(calculator.assignable?(integer_t, t)).to be_truthy
|
|
1469
|
+
end
|
|
1470
|
+
|
|
1471
|
+
it 'the type that it is an alias for is assignable to it' do
|
|
1472
|
+
t = type_alias_t('Alias', 'Integer').resolve(parser, nil)
|
|
1473
|
+
expect(calculator.assignable?(t, integer_t)).to be_truthy
|
|
1474
|
+
end
|
|
1475
|
+
|
|
1476
|
+
it 'a recursive alias can be assignable from a conformant type with any depth' do
|
|
1477
|
+
scope = Object.new
|
|
1478
|
+
|
|
1479
|
+
t = type_alias_t('Tree', 'Hash[String,Variant[String,Tree]]')
|
|
1480
|
+
loader = Object.new
|
|
1481
|
+
loader.expects(:load).with(:type, 'tree').returns t
|
|
1482
|
+
|
|
1483
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1484
|
+
|
|
1485
|
+
t.resolve(parser, scope)
|
|
1486
|
+
expect(calculator.assignable?(t, parser.parse('Hash[String,Variant[String,Hash[String,Variant[String,String]]]]'))).to be_truthy
|
|
1487
|
+
end
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
it 'similar recursive aliases are assignable' do
|
|
1491
|
+
scope = Object.new
|
|
1492
|
+
|
|
1493
|
+
t1 = type_alias_t('Tree1', 'Hash[String,Variant[String,Tree1]]')
|
|
1494
|
+
t2 = type_alias_t('Tree2', 'Hash[String,Variant[String,Tree2]]')
|
|
1495
|
+
loader = Object.new
|
|
1496
|
+
loader.expects(:load).with(:type, 'tree1').returns t1
|
|
1497
|
+
loader.expects(:load).with(:type, 'tree2').returns t2
|
|
1498
|
+
|
|
1499
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1500
|
+
|
|
1501
|
+
t1.resolve(parser, scope)
|
|
1502
|
+
t2.resolve(parser, scope)
|
|
1503
|
+
expect(calculator.assignable?(t1, t2)).to be_truthy
|
|
1504
|
+
end
|
|
1505
|
+
|
|
1506
|
+
it 'crossing recursive aliases are assignable' do
|
|
1507
|
+
t1 = type_alias_t('Tree1', 'Hash[String,Variant[String,Tree2]]')
|
|
1508
|
+
t2 = type_alias_t('Tree2', 'Hash[String,Variant[String,Tree1]]')
|
|
1509
|
+
loader = Object.new
|
|
1510
|
+
loader.expects(:load).with(:type, 'tree1').returns t1
|
|
1511
|
+
loader.expects(:load).with(:type, 'tree2').returns t2
|
|
1512
|
+
|
|
1513
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1514
|
+
|
|
1515
|
+
t1.resolve(parser, loader)
|
|
1516
|
+
t2.resolve(parser, loader)
|
|
1517
|
+
expect(calculator.assignable?(t1, t2)).to be_truthy
|
|
1518
|
+
end
|
|
1519
|
+
|
|
1520
|
+
it 'Type[T] is assignable to Type[AT] when AT is an alias for T' do
|
|
1521
|
+
scope = Object.new
|
|
1522
|
+
|
|
1523
|
+
ta = type_alias_t('PositiveInteger', 'Integer[0,default]')
|
|
1524
|
+
loader = Object.new
|
|
1525
|
+
loader.expects(:load).with(:type, 'positiveinteger').returns ta
|
|
1526
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1527
|
+
|
|
1528
|
+
t1 = type_t(range_t(0, :default))
|
|
1529
|
+
t2 = parser.parse('Type[PositiveInteger]', scope)
|
|
1530
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1531
|
+
end
|
|
1532
|
+
|
|
1533
|
+
it 'Type[T] is assignable to AT when AT is an alias for Type[T]' do
|
|
1534
|
+
scope = Object.new
|
|
1535
|
+
|
|
1536
|
+
ta = type_alias_t('PositiveIntegerType', 'Type[Integer[0,default]]')
|
|
1537
|
+
loader = Object.new
|
|
1538
|
+
loader.expects(:load).with(:type, 'positiveintegertype').returns ta
|
|
1539
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1540
|
+
|
|
1541
|
+
t1 = type_t(range_t(0, :default))
|
|
1542
|
+
t2 = parser.parse('PositiveIntegerType', scope)
|
|
1543
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1544
|
+
end
|
|
1545
|
+
|
|
1546
|
+
it 'Type[Type[T]] is assignable to Type[Type[AT]] when AT is an alias for T' do
|
|
1547
|
+
scope = Object.new
|
|
1548
|
+
|
|
1549
|
+
ta = type_alias_t('PositiveInteger', 'Integer[0,default]')
|
|
1550
|
+
loader = Object.new
|
|
1551
|
+
loader.expects(:load).with(:type, 'positiveinteger').returns ta
|
|
1552
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1553
|
+
|
|
1554
|
+
t1 = type_t(type_t(range_t(0, :default)))
|
|
1555
|
+
t2 = parser.parse('Type[Type[PositiveInteger]]', scope)
|
|
1556
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1557
|
+
end
|
|
1558
|
+
|
|
1559
|
+
it 'Type[Type[T]] is assignable to Type[AT] when AT is an alias for Type[T]' do
|
|
1560
|
+
scope = Object.new
|
|
1561
|
+
|
|
1562
|
+
ta = type_alias_t('PositiveIntegerType', 'Type[Integer[0,default]]')
|
|
1563
|
+
loader = Object.new
|
|
1564
|
+
loader.expects(:load).with(:type, 'positiveintegertype').returns ta
|
|
1565
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1566
|
+
|
|
1567
|
+
t1 = type_t(type_t(range_t(0, :default)))
|
|
1568
|
+
t2 = parser.parse('Type[PositiveIntegerType]', scope)
|
|
1569
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1570
|
+
end
|
|
1571
|
+
end
|
|
1345
1572
|
end
|
|
1346
1573
|
|
|
1347
1574
|
context 'when testing if x is instance of type t' do
|
|
1348
|
-
include_context
|
|
1575
|
+
include_context 'types_setup'
|
|
1349
1576
|
|
|
1350
1577
|
it 'should consider undef to be instance of Any, NilType, and optional' do
|
|
1351
|
-
expect(calculator.instance?(
|
|
1352
|
-
expect(calculator.instance?(
|
|
1353
|
-
expect(calculator.instance?(
|
|
1578
|
+
expect(calculator.instance?(PUndefType::DEFAULT, nil)).to eq(true)
|
|
1579
|
+
expect(calculator.instance?(PAnyType::DEFAULT, nil)).to eq(true)
|
|
1580
|
+
expect(calculator.instance?(POptionalType::DEFAULT, nil)).to eq(true)
|
|
1354
1581
|
end
|
|
1355
1582
|
|
|
1356
1583
|
it 'all types should be (ruby) instance of PAnyType' do
|
|
1357
1584
|
all_types.each do |t|
|
|
1358
|
-
expect(t.
|
|
1585
|
+
expect(t::DEFAULT.is_a?(PAnyType)).to eq(true)
|
|
1359
1586
|
end
|
|
1360
1587
|
end
|
|
1361
1588
|
|
|
1362
|
-
it "should
|
|
1363
|
-
expect(calculator.
|
|
1589
|
+
it "should infer :undef to be Undef" do
|
|
1590
|
+
expect(calculator.infer(:undef)).to be_assignable_to(undef_t)
|
|
1591
|
+
end
|
|
1592
|
+
|
|
1593
|
+
it "should not consider :default to be instance of Runtime['ruby', 'Symbol]" do
|
|
1594
|
+
expect(calculator.instance?(PRuntimeType.new(:ruby, 'Symbol'), :default)).to eq(false)
|
|
1364
1595
|
end
|
|
1365
1596
|
|
|
1366
|
-
it "should consider :undef to be instance of
|
|
1367
|
-
expect(calculator.instance?(
|
|
1597
|
+
it "should not consider :undef to be instance of Runtime['ruby', 'Symbol]" do
|
|
1598
|
+
expect(calculator.instance?(PRuntimeType.new(:ruby, 'Symbol'), :undef)).to eq(false)
|
|
1599
|
+
end
|
|
1600
|
+
|
|
1601
|
+
it 'should consider :undef to be instance of an Optional type' do
|
|
1602
|
+
expect(calculator.instance?(POptionalType::DEFAULT, :undef)).to eq(true)
|
|
1368
1603
|
end
|
|
1369
1604
|
|
|
1370
1605
|
it 'should not consider undef to be an instance of any other type than Any, UndefType and Data' do
|
|
1371
1606
|
types_to_test = all_types - [
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1607
|
+
PAnyType,
|
|
1608
|
+
PUndefType,
|
|
1609
|
+
PDataType,
|
|
1610
|
+
POptionalType,
|
|
1376
1611
|
]
|
|
1377
1612
|
|
|
1378
|
-
types_to_test.each {|t| expect(calculator.instance?(t
|
|
1379
|
-
types_to_test.each {|t| expect(calculator.instance?(t
|
|
1613
|
+
types_to_test.each {|t| expect(calculator.instance?(t::DEFAULT, nil)).to eq(false) }
|
|
1614
|
+
types_to_test.each {|t| expect(calculator.instance?(t::DEFAULT, :undef)).to eq(false) }
|
|
1380
1615
|
end
|
|
1381
1616
|
|
|
1382
1617
|
it 'should consider default to be instance of Default and Any' do
|
|
1383
|
-
expect(calculator.instance?(
|
|
1384
|
-
expect(calculator.instance?(
|
|
1618
|
+
expect(calculator.instance?(PDefaultType::DEFAULT, :default)).to eq(true)
|
|
1619
|
+
expect(calculator.instance?(PAnyType::DEFAULT, :default)).to eq(true)
|
|
1385
1620
|
end
|
|
1386
1621
|
|
|
1387
1622
|
it 'should not consider "default" to be an instance of anything but Default, NotUndef, and Any' do
|
|
1388
1623
|
types_to_test = all_types - [
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1624
|
+
PAnyType,
|
|
1625
|
+
PNotUndefType,
|
|
1626
|
+
PDefaultType,
|
|
1392
1627
|
]
|
|
1393
1628
|
|
|
1394
|
-
types_to_test.each {|t| expect(calculator.instance?(t
|
|
1629
|
+
types_to_test.each {|t| expect(calculator.instance?(t::DEFAULT, :default)).to eq(false) }
|
|
1395
1630
|
end
|
|
1396
1631
|
|
|
1397
1632
|
it 'should consider fixnum instanceof PIntegerType' do
|
|
1398
|
-
expect(calculator.instance?(
|
|
1633
|
+
expect(calculator.instance?(PIntegerType::DEFAULT, 1)).to eq(true)
|
|
1399
1634
|
end
|
|
1400
1635
|
|
|
1401
1636
|
it 'should consider fixnum instanceof Fixnum' do
|
|
@@ -1411,7 +1646,7 @@ describe 'The type calculator' do
|
|
|
1411
1646
|
end
|
|
1412
1647
|
|
|
1413
1648
|
it 'should consider string in length range' do
|
|
1414
|
-
range =
|
|
1649
|
+
range = constrained_string_t(range_t(1,3))
|
|
1415
1650
|
expect(calculator.instance?(range, 'a')).to eq(true)
|
|
1416
1651
|
expect(calculator.instance?(range, 'abc')).to eq(true)
|
|
1417
1652
|
expect(calculator.instance?(range, '')).to eq(false)
|
|
@@ -1419,14 +1654,13 @@ describe 'The type calculator' do
|
|
|
1419
1654
|
end
|
|
1420
1655
|
|
|
1421
1656
|
it 'should consider string values' do
|
|
1422
|
-
string = string_t('a'
|
|
1657
|
+
string = string_t('a')
|
|
1423
1658
|
expect(calculator.instance?(string, 'a')).to eq(true)
|
|
1424
|
-
expect(calculator.instance?(string, 'b')).to eq(true)
|
|
1425
1659
|
expect(calculator.instance?(string, 'c')).to eq(false)
|
|
1426
1660
|
end
|
|
1427
1661
|
|
|
1428
1662
|
it 'should consider array in length range' do
|
|
1429
|
-
range =
|
|
1663
|
+
range = array_t(integer_t, range_t(1,3))
|
|
1430
1664
|
expect(calculator.instance?(range, [1])).to eq(true)
|
|
1431
1665
|
expect(calculator.instance?(range, [1,2,3])).to eq(true)
|
|
1432
1666
|
expect(calculator.instance?(range, [])).to eq(false)
|
|
@@ -1434,7 +1668,7 @@ describe 'The type calculator' do
|
|
|
1434
1668
|
end
|
|
1435
1669
|
|
|
1436
1670
|
it 'should consider hash in length range' do
|
|
1437
|
-
range =
|
|
1671
|
+
range = hash_t(integer_t, integer_t, range_t(1,2))
|
|
1438
1672
|
expect(calculator.instance?(range, {1=>1})).to eq(true)
|
|
1439
1673
|
expect(calculator.instance?(range, {1=>1, 2=>2})).to eq(true)
|
|
1440
1674
|
expect(calculator.instance?(range, {})).to eq(false)
|
|
@@ -1442,7 +1676,7 @@ describe 'The type calculator' do
|
|
|
1442
1676
|
end
|
|
1443
1677
|
|
|
1444
1678
|
it 'should consider collection in length range for array ' do
|
|
1445
|
-
range =
|
|
1679
|
+
range = collection_t(range_t(1,3))
|
|
1446
1680
|
expect(calculator.instance?(range, [1])).to eq(true)
|
|
1447
1681
|
expect(calculator.instance?(range, [1,2,3])).to eq(true)
|
|
1448
1682
|
expect(calculator.instance?(range, [])).to eq(false)
|
|
@@ -1450,7 +1684,7 @@ describe 'The type calculator' do
|
|
|
1450
1684
|
end
|
|
1451
1685
|
|
|
1452
1686
|
it 'should consider collection in length range for hash' do
|
|
1453
|
-
range =
|
|
1687
|
+
range = collection_t(range_t(1,2))
|
|
1454
1688
|
expect(calculator.instance?(range, {1=>1})).to eq(true)
|
|
1455
1689
|
expect(calculator.instance?(range, {1=>1, 2=>2})).to eq(true)
|
|
1456
1690
|
expect(calculator.instance?(range, {})).to eq(false)
|
|
@@ -1581,13 +1815,13 @@ describe 'The type calculator' do
|
|
|
1581
1815
|
end
|
|
1582
1816
|
end
|
|
1583
1817
|
|
|
1584
|
-
context
|
|
1818
|
+
context 'and t is something Callable' do
|
|
1585
1819
|
|
|
1586
1820
|
it 'a Closure should be considered a Callable' do
|
|
1587
|
-
factory =
|
|
1821
|
+
factory = Model::Factory
|
|
1588
1822
|
params = [factory.PARAM('a')]
|
|
1589
|
-
the_block = factory.LAMBDA(params,factory.literal(42))
|
|
1590
|
-
the_closure =
|
|
1823
|
+
the_block = factory.LAMBDA(params,factory.literal(42), nil)
|
|
1824
|
+
the_closure = Evaluator::Closure::Dynamic.new(:fake_evaluator, the_block, :fake_scope)
|
|
1591
1825
|
expect(calculator.instance?(all_callables_t, the_closure)).to be_truthy
|
|
1592
1826
|
expect(calculator.instance?(callable_t(object_t), the_closure)).to be_truthy
|
|
1593
1827
|
expect(calculator.instance?(callable_t(object_t, object_t), the_closure)).to be_falsey
|
|
@@ -1610,485 +1844,282 @@ describe 'The type calculator' do
|
|
|
1610
1844
|
expect(calculator.instance?(callable_t(String), f)).to be_truthy
|
|
1611
1845
|
end
|
|
1612
1846
|
end
|
|
1847
|
+
|
|
1848
|
+
context 'and t is a TypeAlias' do
|
|
1849
|
+
let!(:parser) { TypeParser.singleton }
|
|
1850
|
+
|
|
1851
|
+
it 'should consider x an instance of the aliased simple type' do
|
|
1852
|
+
t = type_alias_t('Alias', 'Integer').resolve(parser, nil)
|
|
1853
|
+
expect(calculator.instance?(t, 15)).to be_truthy
|
|
1854
|
+
end
|
|
1855
|
+
|
|
1856
|
+
it 'should consider x an instance of the aliased parameterized type' do
|
|
1857
|
+
t = type_alias_t('Alias', 'Integer[0,20]').resolve(parser, nil)
|
|
1858
|
+
expect(calculator.instance?(t, 15)).to be_truthy
|
|
1859
|
+
end
|
|
1860
|
+
|
|
1861
|
+
it 'should consider x an instance of the aliased type that uses self recursion' do
|
|
1862
|
+
t = type_alias_t('Tree', 'Hash[String,Variant[String,Tree]]')
|
|
1863
|
+
loader = Object.new
|
|
1864
|
+
loader.expects(:load).with(:type, 'tree').returns t
|
|
1865
|
+
|
|
1866
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1867
|
+
|
|
1868
|
+
t.resolve(parser, loader)
|
|
1869
|
+
expect(calculator.instance?(t, {'a'=>{'aa'=>{'aaa'=>'aaaa'}}, 'b'=>'bb'})).to be_truthy
|
|
1870
|
+
end
|
|
1871
|
+
|
|
1872
|
+
it 'should consider x an instance of the aliased type that uses contains an alias that causes self recursion' do
|
|
1873
|
+
t1 = type_alias_t('Tree', 'Hash[String,Variant[String,OtherTree]]')
|
|
1874
|
+
t2 = type_alias_t('OtherTree', 'Hash[String,Tree]')
|
|
1875
|
+
loader = Object.new
|
|
1876
|
+
loader.expects(:load).with(:type, 'tree').returns t1
|
|
1877
|
+
loader.expects(:load).with(:type, 'othertree').returns t2
|
|
1878
|
+
|
|
1879
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1880
|
+
|
|
1881
|
+
t1.resolve(parser, loader)
|
|
1882
|
+
expect(calculator.instance?(t1, {'a'=>{'aa'=>{'aaa'=>'aaaa'}}, 'b'=>'bb'})).to be_truthy
|
|
1883
|
+
end
|
|
1884
|
+
end
|
|
1613
1885
|
end
|
|
1614
1886
|
|
|
1615
1887
|
context 'when converting a ruby class' do
|
|
1616
1888
|
it 'should yield \'PIntegerType\' for Integer, Fixnum, and Bignum' do
|
|
1617
1889
|
[Integer,Fixnum,Bignum].each do |c|
|
|
1618
|
-
expect(calculator.type(c).class).to eq(
|
|
1890
|
+
expect(calculator.type(c).class).to eq(PIntegerType)
|
|
1619
1891
|
end
|
|
1620
1892
|
end
|
|
1621
1893
|
|
|
1622
1894
|
it 'should yield \'PFloatType\' for Float' do
|
|
1623
|
-
expect(calculator.type(Float).class).to eq(
|
|
1895
|
+
expect(calculator.type(Float).class).to eq(PFloatType)
|
|
1624
1896
|
end
|
|
1625
1897
|
|
|
1626
1898
|
it 'should yield \'PBooleanType\' for FalseClass and TrueClass' do
|
|
1627
1899
|
[FalseClass,TrueClass].each do |c|
|
|
1628
|
-
expect(calculator.type(c).class).to eq(
|
|
1900
|
+
expect(calculator.type(c).class).to eq(PBooleanType)
|
|
1629
1901
|
end
|
|
1630
1902
|
end
|
|
1631
1903
|
|
|
1632
1904
|
it 'should yield \'PUndefType\' for NilClass' do
|
|
1633
|
-
expect(calculator.type(NilClass).class).to eq(
|
|
1905
|
+
expect(calculator.type(NilClass).class).to eq(PUndefType)
|
|
1634
1906
|
end
|
|
1635
1907
|
|
|
1636
1908
|
it 'should yield \'PStringType\' for String' do
|
|
1637
|
-
expect(calculator.type(String).class).to eq(
|
|
1909
|
+
expect(calculator.type(String).class).to eq(PStringType)
|
|
1638
1910
|
end
|
|
1639
1911
|
|
|
1640
1912
|
it 'should yield \'PRegexpType\' for Regexp' do
|
|
1641
|
-
expect(calculator.type(Regexp).class).to eq(
|
|
1913
|
+
expect(calculator.type(Regexp).class).to eq(PRegexpType)
|
|
1642
1914
|
end
|
|
1643
1915
|
|
|
1644
1916
|
it 'should yield \'PArrayType[PDataType]\' for Array' do
|
|
1645
1917
|
t = calculator.type(Array)
|
|
1646
|
-
expect(t.class).to eq(
|
|
1647
|
-
expect(t.element_type.class).to eq(
|
|
1918
|
+
expect(t.class).to eq(PArrayType)
|
|
1919
|
+
expect(t.element_type.class).to eq(PDataType)
|
|
1648
1920
|
end
|
|
1649
1921
|
|
|
1650
1922
|
it 'should yield \'PHashType[PScalarType,PDataType]\' for Hash' do
|
|
1651
1923
|
t = calculator.type(Hash)
|
|
1652
|
-
expect(t.class).to eq(
|
|
1653
|
-
expect(t.key_type.class).to eq(
|
|
1654
|
-
expect(t.
|
|
1655
|
-
end
|
|
1656
|
-
end
|
|
1657
|
-
|
|
1658
|
-
context 'when representing the type as string' do
|
|
1659
|
-
it 'should yield \'Type\' for PType' do
|
|
1660
|
-
expect(calculator.string(Puppet::Pops::Types::PType.new())).to eq('Type')
|
|
1661
|
-
end
|
|
1662
|
-
|
|
1663
|
-
it 'should yield \'Object\' for PAnyType' do
|
|
1664
|
-
expect(calculator.string(Puppet::Pops::Types::PAnyType.new())).to eq('Any')
|
|
1665
|
-
end
|
|
1666
|
-
|
|
1667
|
-
it 'should yield \'Scalar\' for PScalarType' do
|
|
1668
|
-
expect(calculator.string(Puppet::Pops::Types::PScalarType.new())).to eq('Scalar')
|
|
1669
|
-
end
|
|
1670
|
-
|
|
1671
|
-
it 'should yield \'Boolean\' for PBooleanType' do
|
|
1672
|
-
expect(calculator.string(Puppet::Pops::Types::PBooleanType.new())).to eq('Boolean')
|
|
1673
|
-
end
|
|
1674
|
-
|
|
1675
|
-
it 'should yield \'Data\' for PDataType' do
|
|
1676
|
-
expect(calculator.string(Puppet::Pops::Types::PDataType.new())).to eq('Data')
|
|
1677
|
-
end
|
|
1678
|
-
|
|
1679
|
-
it 'should yield \'Numeric\' for PNumericType' do
|
|
1680
|
-
expect(calculator.string(Puppet::Pops::Types::PNumericType.new())).to eq('Numeric')
|
|
1681
|
-
end
|
|
1682
|
-
|
|
1683
|
-
it 'should yield \'Integer\' and from/to for PIntegerType' do
|
|
1684
|
-
int_T = Puppet::Pops::Types::PIntegerType
|
|
1685
|
-
expect(calculator.string(int_T.new())).to eq('Integer')
|
|
1686
|
-
int = int_T.new()
|
|
1687
|
-
int.from = 1
|
|
1688
|
-
int.to = 1
|
|
1689
|
-
expect(calculator.string(int)).to eq('Integer[1, 1]')
|
|
1690
|
-
int = int_T.new()
|
|
1691
|
-
int.from = 1
|
|
1692
|
-
int.to = 2
|
|
1693
|
-
expect(calculator.string(int)).to eq('Integer[1, 2]')
|
|
1694
|
-
int = int_T.new()
|
|
1695
|
-
int.from = nil
|
|
1696
|
-
int.to = 2
|
|
1697
|
-
expect(calculator.string(int)).to eq('Integer[default, 2]')
|
|
1698
|
-
int = int_T.new()
|
|
1699
|
-
int.from = 2
|
|
1700
|
-
int.to = nil
|
|
1701
|
-
expect(calculator.string(int)).to eq('Integer[2, default]')
|
|
1702
|
-
end
|
|
1703
|
-
|
|
1704
|
-
it 'should yield \'Float\' for PFloatType' do
|
|
1705
|
-
expect(calculator.string(Puppet::Pops::Types::PFloatType.new())).to eq('Float')
|
|
1706
|
-
end
|
|
1707
|
-
|
|
1708
|
-
it 'should yield \'Regexp\' for PRegexpType' do
|
|
1709
|
-
expect(calculator.string(Puppet::Pops::Types::PRegexpType.new())).to eq('Regexp')
|
|
1710
|
-
end
|
|
1711
|
-
|
|
1712
|
-
it 'should yield \'Regexp[/pat/]\' for parameterized PRegexpType' do
|
|
1713
|
-
t = Puppet::Pops::Types::PRegexpType.new()
|
|
1714
|
-
t.pattern = ('a/b')
|
|
1715
|
-
expect(calculator.string(Puppet::Pops::Types::PRegexpType.new())).to eq('Regexp')
|
|
1716
|
-
end
|
|
1717
|
-
|
|
1718
|
-
it 'should yield \'String\' for PStringType' do
|
|
1719
|
-
expect(calculator.string(Puppet::Pops::Types::PStringType.new())).to eq('String')
|
|
1720
|
-
end
|
|
1721
|
-
|
|
1722
|
-
it 'should yield \'String\' for PStringType with multiple values' do
|
|
1723
|
-
expect(calculator.string(string_t('a', 'b', 'c'))).to eq('String')
|
|
1724
|
-
end
|
|
1725
|
-
|
|
1726
|
-
it 'should yield \'String\' and from/to for PStringType' do
|
|
1727
|
-
string_T = Puppet::Pops::Types::PStringType
|
|
1728
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), 1,1))).to eq('String[1, 1]')
|
|
1729
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), 1,2))).to eq('String[1, 2]')
|
|
1730
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), :default, 2))).to eq('String[default, 2]')
|
|
1731
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), 2, :default))).to eq('String[2, default]')
|
|
1732
|
-
end
|
|
1733
|
-
|
|
1734
|
-
it 'should yield \'Array[Integer]\' for PArrayType[PIntegerType]' do
|
|
1735
|
-
t = Puppet::Pops::Types::PArrayType.new()
|
|
1736
|
-
t.element_type = Puppet::Pops::Types::PIntegerType.new()
|
|
1737
|
-
expect(calculator.string(t)).to eq('Array[Integer]')
|
|
1738
|
-
end
|
|
1739
|
-
|
|
1740
|
-
it 'should yield \'Collection\' and from/to for PCollectionType' do
|
|
1741
|
-
col = collection_t()
|
|
1742
|
-
expect(calculator.string(factory.constrain_size(col.copy, 1,1))).to eq('Collection[1, 1]')
|
|
1743
|
-
expect(calculator.string(factory.constrain_size(col.copy, 1,2))).to eq('Collection[1, 2]')
|
|
1744
|
-
expect(calculator.string(factory.constrain_size(col.copy, :default, 2))).to eq('Collection[default, 2]')
|
|
1745
|
-
expect(calculator.string(factory.constrain_size(col.copy, 2, :default))).to eq('Collection[2, default]')
|
|
1746
|
-
end
|
|
1747
|
-
|
|
1748
|
-
it 'should yield \'Array\' and from/to for PArrayType' do
|
|
1749
|
-
arr = array_t(string_t)
|
|
1750
|
-
expect(calculator.string(factory.constrain_size(arr.copy, 1,1))).to eq('Array[String, 1, 1]')
|
|
1751
|
-
expect(calculator.string(factory.constrain_size(arr.copy, 1,2))).to eq('Array[String, 1, 2]')
|
|
1752
|
-
expect(calculator.string(factory.constrain_size(arr.copy, :default, 2))).to eq('Array[String, default, 2]')
|
|
1753
|
-
expect(calculator.string(factory.constrain_size(arr.copy, 2, :default))).to eq('Array[String, 2, default]')
|
|
1754
|
-
end
|
|
1755
|
-
|
|
1756
|
-
it 'should yield \'Tuple[Integer]\' for PTupleType[PIntegerType]' do
|
|
1757
|
-
t = Puppet::Pops::Types::PTupleType.new()
|
|
1758
|
-
t.addTypes(Puppet::Pops::Types::PIntegerType.new())
|
|
1759
|
-
expect(calculator.string(t)).to eq('Tuple[Integer]')
|
|
1760
|
-
end
|
|
1761
|
-
|
|
1762
|
-
it 'should yield \'Tuple[T, T,..]\' for PTupleType[T, T, ...]' do
|
|
1763
|
-
t = Puppet::Pops::Types::PTupleType.new()
|
|
1764
|
-
t.addTypes(Puppet::Pops::Types::PIntegerType.new())
|
|
1765
|
-
t.addTypes(Puppet::Pops::Types::PIntegerType.new())
|
|
1766
|
-
t.addTypes(Puppet::Pops::Types::PStringType.new())
|
|
1767
|
-
expect(calculator.string(t)).to eq('Tuple[Integer, Integer, String]')
|
|
1768
|
-
end
|
|
1769
|
-
|
|
1770
|
-
it 'should yield \'Tuple\' and from/to for PTupleType' do
|
|
1771
|
-
tuple_t = tuple_t(string_t)
|
|
1772
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, 1,1))).to eq('Tuple[String, 1, 1]')
|
|
1773
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, 1,2))).to eq('Tuple[String, 1, 2]')
|
|
1774
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, :default, 2))).to eq('Tuple[String, default, 2]')
|
|
1775
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, 2, :default))).to eq('Tuple[String, 2, default]')
|
|
1776
|
-
end
|
|
1777
|
-
|
|
1778
|
-
it 'should yield \'Struct\' and details for PStructType' do
|
|
1779
|
-
struct_t = struct_t({'a'=>Integer, 'b'=>String})
|
|
1780
|
-
expect(calculator.string(struct_t)).to eq("Struct[{'a'=>Integer, 'b'=>String}]")
|
|
1781
|
-
struct_t = struct_t({})
|
|
1782
|
-
expect(calculator.string(struct_t)).to eq("Struct")
|
|
1783
|
-
end
|
|
1784
|
-
|
|
1785
|
-
it 'should yield \'Hash[String, Integer]\' for PHashType[PStringType, PIntegerType]' do
|
|
1786
|
-
t = Puppet::Pops::Types::PHashType.new()
|
|
1787
|
-
t.key_type = Puppet::Pops::Types::PStringType.new()
|
|
1788
|
-
t.element_type = Puppet::Pops::Types::PIntegerType.new()
|
|
1789
|
-
expect(calculator.string(t)).to eq('Hash[String, Integer]')
|
|
1790
|
-
end
|
|
1791
|
-
|
|
1792
|
-
it 'should yield \'Hash\' and from/to for PHashType' do
|
|
1793
|
-
hsh = hash_t(string_t, string_t)
|
|
1794
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, 1,1))).to eq('Hash[String, String, 1, 1]')
|
|
1795
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, 1,2))).to eq('Hash[String, String, 1, 2]')
|
|
1796
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, :default, 2))).to eq('Hash[String, String, default, 2]')
|
|
1797
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, 2, :default))).to eq('Hash[String, String, 2, default]')
|
|
1798
|
-
end
|
|
1799
|
-
|
|
1800
|
-
it "should yield 'Class' for a PHostClassType" do
|
|
1801
|
-
t = Puppet::Pops::Types::PHostClassType.new()
|
|
1802
|
-
expect(calculator.string(t)).to eq('Class')
|
|
1803
|
-
end
|
|
1804
|
-
|
|
1805
|
-
it "should yield 'Class[x]' for a PHostClassType[x]" do
|
|
1806
|
-
t = Puppet::Pops::Types::PHostClassType.new()
|
|
1807
|
-
t.class_name = 'x'
|
|
1808
|
-
expect(calculator.string(t)).to eq('Class[x]')
|
|
1809
|
-
end
|
|
1810
|
-
|
|
1811
|
-
it "should yield 'Resource' for a PResourceType" do
|
|
1812
|
-
t = Puppet::Pops::Types::PResourceType.new()
|
|
1813
|
-
expect(calculator.string(t)).to eq('Resource')
|
|
1814
|
-
end
|
|
1815
|
-
|
|
1816
|
-
it 'should yield \'File\' for a PResourceType[\'File\']' do
|
|
1817
|
-
t = Puppet::Pops::Types::PResourceType.new()
|
|
1818
|
-
t.type_name = 'File'
|
|
1819
|
-
expect(calculator.string(t)).to eq('File')
|
|
1820
|
-
end
|
|
1821
|
-
|
|
1822
|
-
it "should yield 'File['/tmp/foo']' for a PResourceType['File', '/tmp/foo']" do
|
|
1823
|
-
t = Puppet::Pops::Types::PResourceType.new()
|
|
1824
|
-
t.type_name = 'File'
|
|
1825
|
-
t.title = '/tmp/foo'
|
|
1826
|
-
expect(calculator.string(t)).to eq("File['/tmp/foo']")
|
|
1827
|
-
end
|
|
1828
|
-
|
|
1829
|
-
it "should yield 'Enum[s,...]' for a PEnumType[s,...]" do
|
|
1830
|
-
t = enum_t('a', 'b', 'c')
|
|
1831
|
-
expect(calculator.string(t)).to eq("Enum['a', 'b', 'c']")
|
|
1832
|
-
end
|
|
1833
|
-
|
|
1834
|
-
it "should yield 'Pattern[/pat/,...]' for a PPatternType['pat',...]" do
|
|
1835
|
-
t = pattern_t('a')
|
|
1836
|
-
t2 = pattern_t('a', 'b', 'c')
|
|
1837
|
-
expect(calculator.string(t)).to eq("Pattern[/a/]")
|
|
1838
|
-
expect(calculator.string(t2)).to eq("Pattern[/a/, /b/, /c/]")
|
|
1839
|
-
end
|
|
1840
|
-
|
|
1841
|
-
it "should escape special characters in the string for a PPatternType['pat',...]" do
|
|
1842
|
-
t = pattern_t('a/b')
|
|
1843
|
-
expect(calculator.string(t)).to eq("Pattern[/a\\/b/]")
|
|
1844
|
-
end
|
|
1845
|
-
|
|
1846
|
-
it "should yield 'Variant[t1,t2,...]' for a PVariantType[t1, t2,...]" do
|
|
1847
|
-
t1 = string_t()
|
|
1848
|
-
t2 = integer_t()
|
|
1849
|
-
t3 = pattern_t('a')
|
|
1850
|
-
t = variant_t(t1, t2, t3)
|
|
1851
|
-
expect(calculator.string(t)).to eq("Variant[String, Integer, Pattern[/a/]]")
|
|
1852
|
-
end
|
|
1853
|
-
|
|
1854
|
-
it "should yield 'Callable' for generic callable" do
|
|
1855
|
-
expect(calculator.string(all_callables_t)).to eql("Callable")
|
|
1856
|
-
end
|
|
1857
|
-
|
|
1858
|
-
it "should yield 'Callable[0,0]' for callable without params" do
|
|
1859
|
-
expect(calculator.string(callable_t)).to eql("Callable[0, 0]")
|
|
1860
|
-
end
|
|
1861
|
-
|
|
1862
|
-
it "should yield 'Callable[t,t]' for callable with typed parameters" do
|
|
1863
|
-
expect(calculator.string(callable_t(String, Integer))).to eql("Callable[String, Integer]")
|
|
1864
|
-
end
|
|
1865
|
-
|
|
1866
|
-
it "should yield 'Callable[t,min,max]' for callable with size constraint (infinite max)" do
|
|
1867
|
-
expect(calculator.string(callable_t(String, 0))).to eql("Callable[String, 0, default]")
|
|
1868
|
-
end
|
|
1869
|
-
|
|
1870
|
-
it "should yield 'Callable[t,min,max]' for callable with size constraint (capped max)" do
|
|
1871
|
-
expect(calculator.string(callable_t(String, 0, 3))).to eql("Callable[String, 0, 3]")
|
|
1872
|
-
end
|
|
1873
|
-
|
|
1874
|
-
it "should yield 'Callable[min,max]' callable with size > 0" do
|
|
1875
|
-
expect(calculator.string(callable_t(0, 0))).to eql("Callable[0, 0]")
|
|
1876
|
-
expect(calculator.string(callable_t(0, 1))).to eql("Callable[0, 1]")
|
|
1877
|
-
expect(calculator.string(callable_t(0, :default))).to eql("Callable[0, default]")
|
|
1878
|
-
end
|
|
1879
|
-
|
|
1880
|
-
it "should yield 'Callable[Callable]' for callable with block" do
|
|
1881
|
-
expect(calculator.string(callable_t(all_callables_t))).to eql("Callable[0, 0, Callable]")
|
|
1882
|
-
expect(calculator.string(callable_t(string_t, all_callables_t))).to eql("Callable[String, Callable]")
|
|
1883
|
-
expect(calculator.string(callable_t(string_t, 1,1, all_callables_t))).to eql("Callable[String, 1, 1, Callable]")
|
|
1884
|
-
end
|
|
1885
|
-
|
|
1886
|
-
it "should yield Unit for a Unit type" do
|
|
1887
|
-
expect(calculator.string(unit_t)).to eql('Unit')
|
|
1888
|
-
end
|
|
1889
|
-
|
|
1890
|
-
it "should yield 'NotUndef' for a PNotUndefType" do
|
|
1891
|
-
t = not_undef_t
|
|
1892
|
-
expect(calculator.string(t)).to eq('NotUndef')
|
|
1893
|
-
end
|
|
1894
|
-
|
|
1895
|
-
it "should yield 'NotUndef[T]' for a PNotUndefType[T]" do
|
|
1896
|
-
t = not_undef_t(data_t)
|
|
1897
|
-
expect(calculator.string(t)).to eq('NotUndef[Data]')
|
|
1898
|
-
end
|
|
1899
|
-
|
|
1900
|
-
it "should yield 'NotUndef['string']' for a PNotUndefType['string']" do
|
|
1901
|
-
t = not_undef_t('hey')
|
|
1902
|
-
expect(calculator.string(t)).to eq("NotUndef['hey']")
|
|
1924
|
+
expect(t.class).to eq(PHashType)
|
|
1925
|
+
expect(t.key_type.class).to eq(PScalarType)
|
|
1926
|
+
expect(t.value_type.class).to eq(PDataType)
|
|
1903
1927
|
end
|
|
1904
1928
|
end
|
|
1905
1929
|
|
|
1906
1930
|
context 'when processing meta type' do
|
|
1907
1931
|
it 'should infer PType as the type of all other types' do
|
|
1908
|
-
ptype =
|
|
1909
|
-
expect(calculator.infer(
|
|
1910
|
-
expect(calculator.infer(
|
|
1911
|
-
expect(calculator.infer(
|
|
1912
|
-
expect(calculator.infer(
|
|
1913
|
-
expect(calculator.infer(
|
|
1914
|
-
expect(calculator.infer(
|
|
1915
|
-
expect(calculator.infer(
|
|
1916
|
-
expect(calculator.infer(
|
|
1917
|
-
expect(calculator.infer(
|
|
1918
|
-
expect(calculator.infer(
|
|
1919
|
-
expect(calculator.infer(
|
|
1920
|
-
expect(calculator.infer(
|
|
1921
|
-
expect(calculator.infer(
|
|
1922
|
-
expect(calculator.infer(
|
|
1923
|
-
expect(calculator.infer(
|
|
1924
|
-
expect(calculator.infer(
|
|
1925
|
-
expect(calculator.infer(
|
|
1926
|
-
expect(calculator.infer(
|
|
1927
|
-
expect(calculator.infer(
|
|
1928
|
-
expect(calculator.infer(
|
|
1929
|
-
expect(calculator.infer(
|
|
1932
|
+
ptype = PType
|
|
1933
|
+
expect(calculator.infer(PUndefType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1934
|
+
expect(calculator.infer(PDataType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1935
|
+
expect(calculator.infer(PScalarType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1936
|
+
expect(calculator.infer(PStringType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1937
|
+
expect(calculator.infer(PNumericType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1938
|
+
expect(calculator.infer(PIntegerType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1939
|
+
expect(calculator.infer(PFloatType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1940
|
+
expect(calculator.infer(PRegexpType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1941
|
+
expect(calculator.infer(PBooleanType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1942
|
+
expect(calculator.infer(PCollectionType::DEFAULT).is_a?(ptype)).to eq(true)
|
|
1943
|
+
expect(calculator.infer(PArrayType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1944
|
+
expect(calculator.infer(PHashType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1945
|
+
expect(calculator.infer(PIterableType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1946
|
+
expect(calculator.infer(PRuntimeType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1947
|
+
expect(calculator.infer(PHostClassType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1948
|
+
expect(calculator.infer(PResourceType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1949
|
+
expect(calculator.infer(PEnumType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1950
|
+
expect(calculator.infer(PPatternType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1951
|
+
expect(calculator.infer(PVariantType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1952
|
+
expect(calculator.infer(PTupleType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1953
|
+
expect(calculator.infer(POptionalType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1954
|
+
expect(calculator.infer(PCallableType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1930
1955
|
end
|
|
1931
1956
|
|
|
1932
1957
|
it 'should infer PType as the type of all other types' do
|
|
1933
|
-
|
|
1934
|
-
expect(calculator.
|
|
1935
|
-
expect(calculator.
|
|
1936
|
-
expect(calculator.
|
|
1937
|
-
expect(calculator.
|
|
1938
|
-
expect(calculator.
|
|
1939
|
-
expect(calculator.
|
|
1940
|
-
expect(calculator.
|
|
1941
|
-
expect(calculator.
|
|
1942
|
-
expect(calculator.
|
|
1943
|
-
expect(calculator.
|
|
1944
|
-
expect(calculator.
|
|
1945
|
-
expect(calculator.
|
|
1946
|
-
expect(calculator.
|
|
1947
|
-
expect(calculator.
|
|
1948
|
-
expect(calculator.
|
|
1949
|
-
expect(calculator.
|
|
1950
|
-
expect(calculator.
|
|
1951
|
-
expect(calculator.
|
|
1952
|
-
expect(calculator.
|
|
1953
|
-
expect(calculator.
|
|
1954
|
-
expect(calculator.
|
|
1955
|
-
|
|
1956
|
-
expect(calculator.infer(
|
|
1957
|
-
expect(calculator.
|
|
1958
|
-
expect(calculator.infer(
|
|
1958
|
+
expect(calculator.infer(PUndefType::DEFAULT ).to_s).to eq('Type[Undef]')
|
|
1959
|
+
expect(calculator.infer(PDataType::DEFAULT ).to_s).to eq('Type[Data]')
|
|
1960
|
+
expect(calculator.infer(PScalarType::DEFAULT ).to_s).to eq('Type[Scalar]')
|
|
1961
|
+
expect(calculator.infer(PStringType::DEFAULT ).to_s).to eq('Type[String]')
|
|
1962
|
+
expect(calculator.infer(PNumericType::DEFAULT ).to_s).to eq('Type[Numeric]')
|
|
1963
|
+
expect(calculator.infer(PIntegerType::DEFAULT ).to_s).to eq('Type[Integer]')
|
|
1964
|
+
expect(calculator.infer(PFloatType::DEFAULT ).to_s).to eq('Type[Float]')
|
|
1965
|
+
expect(calculator.infer(PRegexpType::DEFAULT ).to_s).to eq('Type[Regexp]')
|
|
1966
|
+
expect(calculator.infer(PBooleanType::DEFAULT ).to_s).to eq('Type[Boolean]')
|
|
1967
|
+
expect(calculator.infer(PCollectionType::DEFAULT).to_s).to eq('Type[Collection]')
|
|
1968
|
+
expect(calculator.infer(PArrayType::DEFAULT ).to_s).to eq('Type[Array[?]]')
|
|
1969
|
+
expect(calculator.infer(PHashType::DEFAULT ).to_s).to eq('Type[Hash[?, ?]]')
|
|
1970
|
+
expect(calculator.infer(PIterableType::DEFAULT ).to_s).to eq('Type[Iterable]')
|
|
1971
|
+
expect(calculator.infer(PRuntimeType::DEFAULT ).to_s).to eq('Type[Runtime[?, ?]]')
|
|
1972
|
+
expect(calculator.infer(PHostClassType::DEFAULT ).to_s).to eq('Type[Class]')
|
|
1973
|
+
expect(calculator.infer(PResourceType::DEFAULT ).to_s).to eq('Type[Resource]')
|
|
1974
|
+
expect(calculator.infer(PEnumType::DEFAULT ).to_s).to eq('Type[Enum]')
|
|
1975
|
+
expect(calculator.infer(PVariantType::DEFAULT ).to_s).to eq('Type[Variant]')
|
|
1976
|
+
expect(calculator.infer(PPatternType::DEFAULT ).to_s).to eq('Type[Pattern]')
|
|
1977
|
+
expect(calculator.infer(PTupleType::DEFAULT ).to_s).to eq('Type[Tuple]')
|
|
1978
|
+
expect(calculator.infer(POptionalType::DEFAULT ).to_s).to eq('Type[Optional]')
|
|
1979
|
+
expect(calculator.infer(PCallableType::DEFAULT ).to_s).to eq('Type[Callable]')
|
|
1980
|
+
|
|
1981
|
+
expect(calculator.infer(PResourceType.new('foo::fee::fum')).to_s).to eq('Type[Foo::Fee::Fum]')
|
|
1982
|
+
expect(calculator.infer(PResourceType.new('foo::fee::fum')).to_s).to eq('Type[Foo::Fee::Fum]')
|
|
1983
|
+
expect(calculator.infer(PResourceType.new('Foo::Fee::Fum')).to_s).to eq('Type[Foo::Fee::Fum]')
|
|
1959
1984
|
end
|
|
1960
1985
|
|
|
1961
1986
|
it "computes the common type of PType's type parameter" do
|
|
1962
|
-
int_t =
|
|
1963
|
-
string_t =
|
|
1964
|
-
expect(calculator.
|
|
1965
|
-
expect(calculator.
|
|
1987
|
+
int_t = PIntegerType::DEFAULT
|
|
1988
|
+
string_t = PStringType::DEFAULT
|
|
1989
|
+
expect(calculator.infer([int_t]).to_s).to eq('Array[Type[Integer], 1, 1]')
|
|
1990
|
+
expect(calculator.infer([int_t, string_t]).to_s).to eq('Array[Type[Scalar], 2, 2]')
|
|
1966
1991
|
end
|
|
1967
1992
|
|
|
1968
1993
|
it 'should infer PType as the type of ruby classes' do
|
|
1969
1994
|
class Foo
|
|
1970
1995
|
end
|
|
1971
1996
|
[Object, Numeric, Integer, Fixnum, Bignum, Float, String, Regexp, Array, Hash, Foo].each do |c|
|
|
1972
|
-
expect(calculator.infer(c).is_a?(
|
|
1997
|
+
expect(calculator.infer(c).is_a?(PType)).to eq(true)
|
|
1973
1998
|
end
|
|
1974
1999
|
end
|
|
1975
2000
|
|
|
1976
2001
|
it 'should infer PType as the type of PType (meta regression short-circuit)' do
|
|
1977
|
-
expect(calculator.infer(
|
|
2002
|
+
expect(calculator.infer(PType::DEFAULT).is_a?(PType)).to eq(true)
|
|
1978
2003
|
end
|
|
1979
2004
|
|
|
1980
2005
|
it 'computes instance? to be true if parameterized and type match' do
|
|
1981
|
-
int_t =
|
|
1982
|
-
type_t =
|
|
1983
|
-
type_type_t =
|
|
2006
|
+
int_t = PIntegerType::DEFAULT
|
|
2007
|
+
type_t = TypeFactory.type_type(int_t)
|
|
2008
|
+
type_type_t = TypeFactory.type_type(type_t)
|
|
1984
2009
|
expect(calculator.instance?(type_type_t, type_t)).to eq(true)
|
|
1985
2010
|
end
|
|
1986
2011
|
|
|
1987
2012
|
it 'computes instance? to be false if parameterized and type do not match' do
|
|
1988
|
-
int_t =
|
|
1989
|
-
string_t =
|
|
1990
|
-
type_t =
|
|
1991
|
-
type_t2 =
|
|
1992
|
-
type_type_t =
|
|
2013
|
+
int_t = PIntegerType::DEFAULT
|
|
2014
|
+
string_t = PStringType::DEFAULT
|
|
2015
|
+
type_t = TypeFactory.type_type(int_t)
|
|
2016
|
+
type_t2 = TypeFactory.type_type(string_t)
|
|
2017
|
+
type_type_t = TypeFactory.type_type(type_t)
|
|
1993
2018
|
# i.e. Type[Integer] =~ Type[Type[Integer]] # false
|
|
1994
2019
|
expect(calculator.instance?(type_type_t, type_t2)).to eq(false)
|
|
1995
2020
|
end
|
|
1996
2021
|
|
|
1997
2022
|
it 'computes instance? to be true if unparameterized and matched against a type[?]' do
|
|
1998
|
-
int_t =
|
|
1999
|
-
type_t =
|
|
2000
|
-
expect(calculator.instance?(
|
|
2023
|
+
int_t = PIntegerType::DEFAULT
|
|
2024
|
+
type_t = TypeFactory.type_type(int_t)
|
|
2025
|
+
expect(calculator.instance?(PType::DEFAULT, type_t)).to eq(true)
|
|
2001
2026
|
end
|
|
2002
2027
|
end
|
|
2003
2028
|
|
|
2004
|
-
context
|
|
2005
|
-
it
|
|
2006
|
-
t =
|
|
2007
|
-
t.
|
|
2008
|
-
t.to = 10
|
|
2009
|
-
expect(calculator.enumerable(t).respond_to?(:each)).to eq(true)
|
|
2029
|
+
context 'when asking for an iterable ' do
|
|
2030
|
+
it 'should produce an iterable for an Integer range that is finite' do
|
|
2031
|
+
t = PIntegerType.new(1, 10)
|
|
2032
|
+
expect(calculator.iterable(t).respond_to?(:each)).to eq(true)
|
|
2010
2033
|
end
|
|
2011
2034
|
|
|
2012
|
-
it
|
|
2013
|
-
t =
|
|
2014
|
-
t.
|
|
2015
|
-
t.to = 10
|
|
2016
|
-
expect(calculator.enumerable(t)).to eq(nil)
|
|
2035
|
+
it 'should not produce an iterable for an Integer range that has an infinite side' do
|
|
2036
|
+
t = PIntegerType.new(nil, 10)
|
|
2037
|
+
expect(calculator.iterable(t)).to eq(nil)
|
|
2017
2038
|
|
|
2018
|
-
t =
|
|
2019
|
-
t.
|
|
2020
|
-
t.to = nil
|
|
2021
|
-
expect(calculator.enumerable(t)).to eq(nil)
|
|
2039
|
+
t = PIntegerType.new(1, nil)
|
|
2040
|
+
expect(calculator.iterable(t)).to eq(nil)
|
|
2022
2041
|
end
|
|
2023
2042
|
|
|
2024
|
-
it
|
|
2043
|
+
it 'all but Integer range are not iterable' do
|
|
2025
2044
|
[Object, Numeric, Float, String, Regexp, Array, Hash].each do |t|
|
|
2026
|
-
expect(calculator.
|
|
2045
|
+
expect(calculator.iterable(calculator.type(t))).to eq(nil)
|
|
2027
2046
|
end
|
|
2028
2047
|
end
|
|
2029
2048
|
end
|
|
2030
2049
|
|
|
2031
|
-
context
|
|
2032
|
-
it
|
|
2050
|
+
context 'when dealing with different types of inference' do
|
|
2051
|
+
it 'an instance specific inference is produced by infer' do
|
|
2033
2052
|
expect(calculator.infer(['a','b']).element_type.values).to eq(['a', 'b'])
|
|
2034
2053
|
end
|
|
2035
2054
|
|
|
2036
|
-
it
|
|
2037
|
-
expect(calculator.infer_generic(['a','b']).element_type
|
|
2055
|
+
it 'a generic inference is produced using infer_generic' do
|
|
2056
|
+
expect(calculator.infer_generic(['a','b']).element_type).to eql(string_t(range_t(1,1)))
|
|
2038
2057
|
end
|
|
2039
2058
|
|
|
2040
|
-
it
|
|
2059
|
+
it 'a generic result is created by generalize given an instance specific result for an Array' do
|
|
2041
2060
|
generic = calculator.infer(['a','b'])
|
|
2042
|
-
expect(generic.element_type.values).to eq(['a',
|
|
2043
|
-
|
|
2044
|
-
expect(generic.element_type
|
|
2061
|
+
expect(generic.element_type.values).to eq(['a','b'])
|
|
2062
|
+
generic = generic.generalize
|
|
2063
|
+
expect(generic.element_type).to eql(string_t(range_t(1,1)))
|
|
2045
2064
|
end
|
|
2046
2065
|
|
|
2047
|
-
it 'a generic result is created by generalize
|
|
2048
|
-
generic = calculator.infer({'a' =>1,'
|
|
2049
|
-
expect(generic.key_type.values.sort).to eq(['a', '
|
|
2050
|
-
expect(generic.
|
|
2051
|
-
expect(generic.
|
|
2052
|
-
|
|
2053
|
-
expect(generic.key_type.
|
|
2054
|
-
expect(generic.
|
|
2055
|
-
expect(generic.
|
|
2066
|
+
it 'a generic result is created by generalize given an instance specific result for a Hash' do
|
|
2067
|
+
generic = calculator.infer({'a' =>1,'bcd' => 2})
|
|
2068
|
+
expect(generic.key_type.values.sort).to eq(['a', 'bcd'])
|
|
2069
|
+
expect(generic.value_type.from).to eq(1)
|
|
2070
|
+
expect(generic.value_type.to).to eq(2)
|
|
2071
|
+
generic = generic.generalize
|
|
2072
|
+
expect(generic.key_type.size_type).to eq(range_t(1,3))
|
|
2073
|
+
expect(generic.value_type.from).to eq(nil)
|
|
2074
|
+
expect(generic.value_type.to).to eq(nil)
|
|
2056
2075
|
end
|
|
2057
2076
|
|
|
2058
2077
|
it 'ensures that Struct key types are not generalized' do
|
|
2059
|
-
generic =
|
|
2060
|
-
expect(
|
|
2061
|
-
generic =
|
|
2062
|
-
expect(
|
|
2063
|
-
generic =
|
|
2064
|
-
expect(
|
|
2078
|
+
generic = struct_t({'a' => object_t}).generalize
|
|
2079
|
+
expect(generic.to_s).to eq("Struct[{'a' => Any}]")
|
|
2080
|
+
generic = struct_t({not_undef_t('a') => object_t}).generalize
|
|
2081
|
+
expect(generic.to_s).to eq("Struct[{NotUndef['a'] => Any}]")
|
|
2082
|
+
generic = struct_t({optional_t('a') => string_t}).generalize
|
|
2083
|
+
expect(generic.to_s).to eq("Struct[{Optional['a'] => String}]")
|
|
2065
2084
|
end
|
|
2066
2085
|
|
|
2067
2086
|
it 'ensures that Struct value types are generalized' do
|
|
2068
|
-
generic =
|
|
2069
|
-
expect(
|
|
2087
|
+
generic = struct_t({'a' => range_t(1, 3)}).generalize
|
|
2088
|
+
expect(generic.to_s).to eq("Struct[{'a' => Integer}]")
|
|
2070
2089
|
end
|
|
2071
2090
|
|
|
2072
2091
|
it "does not reduce by combining types when using infer_set" do
|
|
2073
2092
|
element_type = calculator.infer(['a','b',1,2]).element_type
|
|
2074
|
-
expect(element_type.class).to eq(
|
|
2093
|
+
expect(element_type.class).to eq(PScalarType)
|
|
2075
2094
|
inferred_type = calculator.infer_set(['a','b',1,2])
|
|
2076
|
-
expect(inferred_type.class).to eq(
|
|
2095
|
+
expect(inferred_type.class).to eq(PTupleType)
|
|
2077
2096
|
element_types = inferred_type.types
|
|
2078
|
-
expect(element_types[0].class).to eq(
|
|
2079
|
-
expect(element_types[1].class).to eq(
|
|
2080
|
-
expect(element_types[2].class).to eq(
|
|
2081
|
-
expect(element_types[3].class).to eq(
|
|
2097
|
+
expect(element_types[0].class).to eq(PStringType)
|
|
2098
|
+
expect(element_types[1].class).to eq(PStringType)
|
|
2099
|
+
expect(element_types[2].class).to eq(PIntegerType)
|
|
2100
|
+
expect(element_types[3].class).to eq(PIntegerType)
|
|
2082
2101
|
end
|
|
2083
2102
|
|
|
2084
|
-
it
|
|
2103
|
+
it 'does not reduce by combining types when using infer_set and values are undef' do
|
|
2085
2104
|
element_type = calculator.infer(['a',nil]).element_type
|
|
2086
|
-
expect(element_type.class).to eq(
|
|
2105
|
+
expect(element_type.class).to eq(PStringType)
|
|
2087
2106
|
inferred_type = calculator.infer_set(['a',nil])
|
|
2088
|
-
expect(inferred_type.class).to eq(
|
|
2107
|
+
expect(inferred_type.class).to eq(PTupleType)
|
|
2089
2108
|
element_types = inferred_type.types
|
|
2090
|
-
expect(element_types[0].class).to eq(
|
|
2091
|
-
expect(element_types[1].class).to eq(
|
|
2109
|
+
expect(element_types[0].class).to eq(PStringType)
|
|
2110
|
+
expect(element_types[1].class).to eq(PUndefType)
|
|
2111
|
+
end
|
|
2112
|
+
|
|
2113
|
+
it 'infers on an empty Array produces Array[Unit,0,0]' do
|
|
2114
|
+
inferred_type = calculator.infer([])
|
|
2115
|
+
expect(inferred_type.element_type.class).to eq(PUnitType)
|
|
2116
|
+
expect(inferred_type.size_range).to eq([0, 0])
|
|
2117
|
+
end
|
|
2118
|
+
|
|
2119
|
+
it 'infer_set on an empty Array produces Array[Unit,0,0]' do
|
|
2120
|
+
inferred_type = calculator.infer_set([])
|
|
2121
|
+
expect(inferred_type.element_type.class).to eq(PUnitType)
|
|
2122
|
+
expect(inferred_type.size_range).to eq([0, 0])
|
|
2092
2123
|
end
|
|
2093
2124
|
end
|
|
2094
2125
|
|
|
@@ -2114,8 +2145,7 @@ describe 'The type calculator' do
|
|
|
2114
2145
|
|
|
2115
2146
|
it 'with args array' do
|
|
2116
2147
|
required = callable_t(string_t)
|
|
2117
|
-
given = array_t(string_t)
|
|
2118
|
-
factory.constrain_size(given, 1, 1)
|
|
2148
|
+
given = array_t(string_t, range_t(1, 1))
|
|
2119
2149
|
expect(calculator.callable?(required, given)).to eq(true)
|
|
2120
2150
|
end
|
|
2121
2151
|
end
|
|
@@ -2174,7 +2204,7 @@ describe 'The type calculator' do
|
|
|
2174
2204
|
end
|
|
2175
2205
|
|
|
2176
2206
|
matcher :be_assignable_to do |type|
|
|
2177
|
-
calc =
|
|
2207
|
+
calc = TypeCalculator.singleton
|
|
2178
2208
|
|
|
2179
2209
|
match do |actual|
|
|
2180
2210
|
calc.assignable?(type, actual)
|
|
@@ -2188,5 +2218,6 @@ describe 'The type calculator' do
|
|
|
2188
2218
|
"#{calc.string(actual)} is assignable to #{calc.string(type)} when it should not"
|
|
2189
2219
|
end
|
|
2190
2220
|
end
|
|
2191
|
-
|
|
2221
|
+
end
|
|
2222
|
+
end
|
|
2192
2223
|
end
|