puppet 4.0.0 → 4.9.1
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.
- data/COMMITTERS.md +2 -2
- data/CONTRIBUTING.md +34 -10
- data/Gemfile +25 -9
- data/LICENSE +3 -3
- data/MAINTAINERS +71 -0
- data/README.md +9 -11
- data/Rakefile +29 -0
- data/conf/auth.conf +2 -2
- data/conf/puppet.conf +1 -1
- data/ext/README.environment +1 -1
- data/ext/build_defaults.yaml +10 -37
- data/ext/debian/README.source +1 -1
- data/ext/debian/control +3 -5
- data/ext/debian/copyright +4 -4
- data/ext/debian/puppet.default +0 -5
- data/ext/debian/puppet.init +1 -16
- 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 +29 -13
- 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 +27 -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 +40 -19
- data/lib/puppet/application/apply.rb +69 -16
- data/lib/puppet/application/ca.rb +1 -0
- data/lib/puppet/application/cert.rb +52 -3
- data/lib/puppet/application/device.rb +10 -5
- 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 +2 -2
- data/lib/puppet/application/lookup.rb +344 -0
- data/lib/puppet/application/master.rb +22 -7
- data/lib/puppet/application/resource.rb +2 -6
- data/lib/puppet/application.rb +6 -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 +184 -42
- 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 +279 -57
- data/lib/puppet/environments.rb +105 -10
- data/lib/puppet/error.rb +31 -1
- 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/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 +30 -9
- data/lib/puppet/file_serving/terminus_helper.rb +7 -8
- data/lib/puppet/file_serving/terminus_selector.rb +2 -0
- data/lib/puppet/file_system/file_impl.rb +11 -2
- data/lib/puppet/file_system/memory_impl.rb +9 -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 +36 -13
- data/lib/puppet/file_system.rb +46 -5
- data/lib/puppet/forge/repository.rb +2 -34
- data/lib/puppet/forge.rb +7 -7
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/assert_type.rb +57 -21
- 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 +160 -0
- 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/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 +24 -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 +18 -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 +23 -26
- 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 +3 -3
- 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 +21 -0
- data/lib/puppet/functions.rb +164 -31
- 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 +196 -9
- 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 +9 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +68 -3
- 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/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/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 +6 -0
- data/lib/puppet/metatype/manager.rb +25 -8
- data/lib/puppet/module.rb +48 -20
- 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/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 +53 -14
- data/lib/puppet/node/facts.rb +1 -1
- data/lib/puppet/node.rb +39 -8
- 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 +101 -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 +343 -28
- 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 -69
- 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/file.rb +3 -1
- 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 +296 -73
- data/lib/puppet/parser/templatewrapper.rb +2 -1
- 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 +115 -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 +261 -142
- data/lib/puppet/pops/evaluator/closure.rb +251 -109
- data/lib/puppet/pops/evaluator/collector_transformer.rb +45 -26
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +4 -0
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +5 -2
- data/lib/puppet/pops/evaluator/compare_operator.rb +110 -10
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +16 -10
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +239 -117
- 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 +119 -82
- data/lib/puppet/pops/functions/dispatch.rb +15 -3
- data/lib/puppet/pops/functions/dispatcher.rb +13 -5
- data/lib/puppet/pops/functions/function.rb +30 -4
- data/lib/puppet/pops/issue_reporter.rb +48 -20
- data/lib/puppet/pops/issues.rb +208 -18
- data/lib/puppet/pops/label_provider.rb +18 -4
- data/lib/puppet/pops/loader/base_loader.rb +64 -18
- data/lib/puppet/pops/loader/dependency_loader.rb +27 -2
- data/lib/puppet/pops/loader/loader.rb +53 -48
- data/lib/puppet/pops/loader/loader_paths.rb +110 -6
- data/lib/puppet/pops/loader/module_loaders.rb +72 -28
- 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 +84 -0
- 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 +207 -29
- data/lib/puppet/pops/lookup/configured_data_provider.rb +87 -0
- data/lib/puppet/pops/lookup/context.rb +136 -0
- data/lib/puppet/pops/lookup/data_adapter.rb +27 -0
- data/lib/puppet/pops/lookup/data_dig_function_provider.rb +55 -0
- data/lib/puppet/pops/lookup/data_hash_function_provider.rb +111 -0
- data/lib/puppet/pops/lookup/data_provider.rb +102 -0
- data/lib/puppet/pops/lookup/environment_data_provider.rb +27 -0
- data/lib/puppet/pops/lookup/explainer.rb +593 -0
- data/lib/puppet/pops/lookup/function_provider.rb +82 -0
- data/lib/puppet/pops/lookup/global_data_provider.rb +49 -0
- data/lib/puppet/pops/lookup/hiera_config.rb +601 -0
- data/lib/puppet/pops/lookup/interpolation.rb +136 -0
- data/lib/puppet/pops/lookup/invocation.rb +212 -0
- data/lib/puppet/pops/lookup/location_resolver.rb +72 -0
- data/lib/puppet/pops/lookup/lookup_adapter.rb +451 -0
- data/lib/puppet/pops/lookup/lookup_key.rb +99 -0
- data/lib/puppet/pops/lookup/lookup_key_function_provider.rb +119 -0
- data/lib/puppet/pops/lookup/module_data_provider.rb +58 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +90 -0
- data/lib/puppet/pops/lookup.rb +45 -49
- data/lib/puppet/pops/merge_strategy.rb +183 -47
- data/lib/puppet/pops/migration/migration_checker.rb +58 -0
- data/lib/puppet/pops/model/ast_transformer.rb +8 -1
- data/lib/puppet/pops/model/factory.rb +257 -161
- data/lib/puppet/pops/model/model.rb +25 -8
- data/lib/puppet/pops/model/model_label_provider.rb +30 -6
- data/lib/puppet/pops/model/model_meta.rb +50 -3
- 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 +155 -38
- data/lib/puppet/pops/parser/eparser.rb +1894 -1314
- data/lib/puppet/pops/parser/epp_support.rb +27 -12
- data/lib/puppet/pops/parser/evaluating_parser.rb +27 -13
- data/lib/puppet/pops/parser/heredoc_support.rb +20 -16
- data/lib/puppet/pops/parser/interpolation_support.rb +14 -1
- data/lib/puppet/pops/parser/lexer2.rb +465 -379
- data/lib/puppet/pops/parser/lexer_support.rb +132 -25
- data/lib/puppet/pops/parser/locator.rb +63 -9
- data/lib/puppet/pops/parser/parser_support.rb +49 -40
- data/lib/puppet/pops/parser/slurp_support.rb +37 -12
- 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 +888 -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 -1186
- data/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/lib/puppet/pops/types/type_factory.rb +270 -164
- data/lib/puppet/pops/types/type_formatter.rb +686 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1087 -0
- data/lib/puppet/pops/types/type_parser.rb +376 -278
- data/lib/puppet/pops/types/type_set_reference.rb +59 -0
- data/lib/puppet/pops/types/types.rb +3247 -287
- data/lib/puppet/pops/utils.rb +11 -10
- data/lib/puppet/pops/validation/checker4_0.rb +289 -75
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +13 -5
- data/lib/puppet/pops/validation.rb +56 -18
- data/lib/puppet/pops/visitor.rb +9 -6
- data/lib/puppet/pops.rb +44 -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 +6 -1
- 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 +23 -7
- 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 +159 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +55 -62
- data/lib/puppet/provider/nameservice.rb +15 -0
- data/lib/puppet/provider/package/appdmg.rb +7 -6
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/apt.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 +83 -22
- 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 +143 -0
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +48 -8
- data/lib/puppet/provider/package/ports.rb +0 -3
- data/lib/puppet/provider/package/puppet_gem.rb +0 -0
- data/lib/puppet/provider/package/rpm.rb +122 -16
- 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 -9
- data/lib/puppet/provider/package/windows/msi_package.rb +4 -4
- 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 +69 -15
- 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 +39 -7
- 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 +27 -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 +27 -0
- 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 +4 -3
- data/lib/puppet/provider/user/directoryservice.rb +43 -66
- data/lib/puppet/provider/user/hpux.rb +1 -1
- data/lib/puppet/provider/user/openbsd.rb +1 -0
- 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 +51 -2
- 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 +2 -2
- 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 -40
- 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 +212 -146
- 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 +87 -28
- data/lib/puppet/ssl/certificate_authority/interface.rb +166 -26
- data/lib/puppet/ssl/certificate_authority.rb +45 -11
- data/lib/puppet/ssl/certificate_factory.rb +3 -3
- data/lib/puppet/ssl/certificate_request.rb +4 -4
- data/lib/puppet/ssl/certificate_signer.rb +1 -1
- data/lib/puppet/ssl/host.rb +26 -4
- 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 +18 -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 +27 -18
- 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 +22 -19
- 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 +146 -46
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +15 -3
- 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 +25 -2
- 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 +14 -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 +10 -5
- data/lib/puppet/type/user.rb +80 -25
- data/lib/puppet/type/yumrepo.rb +28 -8
- data/lib/puppet/type/zone.rb +6 -6
- data/lib/puppet/type.rb +162 -40
- data/lib/puppet/util/autoload.rb +16 -11
- 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 +26 -10
- 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/destinations.rb +23 -2
- data/lib/puppet/util/log.rb +78 -9
- data/lib/puppet/util/logging.rb +82 -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/resource_template.rb +1 -1
- data/lib/puppet/util/rubygems.rb +1 -1
- data/lib/puppet/util/run_mode.rb +3 -16
- 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 +212 -75
- 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 +107 -18
- 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 +124 -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 +2 -2
- data/lib/puppet.rb +85 -2
- data/lib/puppet_x.rb +7 -1
- data/lib/semver.rb +36 -13
- data/locales/config.yaml +29 -0
- data/locales/puppet.pot +79 -0
- data/man/man5/puppet.conf.5 +61 -19
- data/man/man8/extlookup2hiera.8 +2 -2
- data/man/man8/puppet-agent.8 +6 -3
- data/man/man8/puppet-apply.8 +6 -3
- data/man/man8/puppet-ca.8 +3 -3
- data/man/man8/puppet-catalog.8 +3 -3
- data/man/man8/puppet-cert.8 +3 -3
- data/man/man8/puppet-certificate.8 +3 -3
- data/man/man8/puppet-certificate_request.8 +3 -3
- data/man/man8/puppet-certificate_revocation_list.8 +3 -3
- data/man/man8/puppet-config.8 +4 -4
- data/man/man8/puppet-describe.8 +2 -2
- data/man/man8/puppet-device.8 +7 -4
- data/man/man8/puppet-doc.8 +2 -2
- data/man/man8/puppet-epp.8 +3 -3
- data/man/man8/puppet-facts.8 +3 -3
- data/man/man8/puppet-file.8 +3 -3
- data/man/man8/puppet-filebucket.8 +3 -3
- data/man/man8/puppet-help.8 +3 -3
- data/man/man8/puppet-inspect.8 +3 -3
- data/man/man8/puppet-key.8 +3 -3
- data/man/man8/puppet-man.8 +3 -3
- data/man/man8/puppet-master.8 +6 -3
- data/man/man8/puppet-module.8 +10 -10
- data/man/man8/puppet-node.8 +3 -3
- data/man/man8/puppet-parser.8 +3 -3
- data/man/man8/puppet-plugin.8 +3 -3
- data/man/man8/puppet-report.8 +3 -3
- data/man/man8/puppet-resource.8 +3 -3
- data/man/man8/puppet-resource_type.8 +3 -3
- data/man/man8/puppet-status.8 +4 -4
- data/man/man8/puppet.8 +2 -2
- 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/lib/puppet/functions/environment/data.rb +3 -1
- 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/production/modules/xyz/functions/data.pp +6 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +9 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp +9 -0
- 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/mix_4x_and_3x_functions/user/functions/puppetcalled.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json +10 -0
- data/spec/fixtures/unit/pops/loaders/loaders/no_modules/manifests/site.pp +10 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +1 -10
- data/spec/fixtures/unit/pops/parser/lexer/subclass_name_duplication.pp +0 -0
- data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
- data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
- data/spec/fixtures/unit/provider/package/pkgng/pkg.info +8 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query +1 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +1 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.version +3 -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/package/zypper/zypper-list-updates-empty.out +3 -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 +432 -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/faces/plugin_spec.rb +0 -4
- 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 +97 -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 +877 -666
- 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 +10 -5
- data/spec/integration/parser/scope_spec.rb +46 -7
- 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/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/test/test_helper_spec.rb +32 -0
- data/spec/integration/transaction/report_spec.rb +682 -0
- data/spec/integration/transaction_spec.rb +126 -2
- data/spec/integration/type/exec_spec.rb +0 -0
- data/spec/integration/type/file_spec.rb +553 -51
- data/spec/integration/type/package_spec.rb +72 -1
- data/spec/integration/type/tidy_spec.rb +21 -9
- 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 +75 -21
- 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/matchers/resource.rb +22 -1
- 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/matchers.rb +6 -4
- 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 +16 -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 +19 -8
- data/spec/unit/application/lookup_spec.rb +532 -0
- data/spec/unit/application/master_spec.rb +33 -7
- 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 +30 -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/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 +0 -0
- 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/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 +51 -1
- 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 +2 -3
- 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 +373 -6
- 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 +289 -0
- 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 +261 -49
- 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 +1352 -272
- 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 +30 -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 +11 -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 +321 -71
- 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 +7 -7
- 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 +53 -2
- 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 +0 -0
- 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 +1 -1
- 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 +84 -33
- 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 +1 -1
- 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 +14 -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 +41 -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 +120 -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 +7 -1
- 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 +1 -1
- 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 +85 -18
- data/spec/unit/parser/templatewrapper_spec.rb +1 -1
- 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 +133 -18
- 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 +155 -41
- data/spec/unit/pops/evaluator/evaluator_rspec_helper.rb +4 -4
- 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 +2 -2
- data/spec/unit/pops/issues_spec.rb +16 -16
- 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 +292 -51
- data/spec/unit/pops/loaders/module_loaders_spec.rb +2 -2
- data/spec/unit/pops/loaders/static_loader_spec.rb +83 -18
- data/spec/unit/pops/lookup/context_spec.rb +178 -0
- data/spec/unit/pops/lookup/interpolation_spec.rb +333 -0
- data/spec/unit/pops/lookup/lookup_spec.rb +197 -0
- data/spec/unit/pops/merge_strategy_spec.rb +18 -0
- data/spec/unit/pops/migration_spec.rb +53 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +369 -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_heredoc_spec.rb +26 -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 +577 -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 +1107 -871
- 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 +219 -0
- data/spec/unit/pops/types/type_parser_spec.rb +206 -36
- data/spec/unit/pops/types/types_spec.rb +600 -0
- data/spec/unit/pops/validation_spec.rb +66 -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 +88 -18
- 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 +31 -5
- 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 +42 -0
- 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 +5 -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 +173 -46
- data/spec/unit/provider/package/pkg_spec.rb +137 -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 +186 -0
- 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 +168 -11
- 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/exe_package_spec.rb +0 -1
- data/spec/unit/provider/package/windows/msi_package_spec.rb +0 -1
- 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 +64 -19
- data/spec/unit/provider/parsedfile_spec.rb +0 -0
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +523 -70
- 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 +44 -27
- 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 +38 -0
- data/spec/unit/provider/service/freebsd_spec.rb +17 -0
- data/spec/unit/provider/service/gentoo_spec.rb +8 -0
- data/spec/unit/provider/service/init_spec.rb +42 -1
- data/spec/unit/provider/service/launchd_spec.rb +124 -25
- data/spec/unit/provider/service/openbsd_spec.rb +1 -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 +9 -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 +26 -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 +160 -7
- 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 +161 -10
- data/spec/unit/resource_spec.rb +137 -48
- data/spec/unit/semver_spec.rb +14 -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 +116 -3
- data/spec/unit/ssl/base_spec.rb +0 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +180 -13
- data/spec/unit/ssl/certificate_authority_spec.rb +80 -26
- data/spec/unit/ssl/certificate_factory_spec.rb +0 -0
- data/spec/unit/ssl/certificate_request_spec.rb +1 -1
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +3 -3
- data/spec/unit/ssl/certificate_spec.rb +0 -0
- data/spec/unit/ssl/configuration_spec.rb +0 -0
- data/spec/unit/ssl/host_spec.rb +3 -3
- data/spec/unit/ssl/inventory_spec.rb +0 -0
- data/spec/unit/ssl/key_spec.rb +0 -0
- 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 +16 -8
- 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 +161 -34
- 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/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 +1 -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 +87 -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 +125 -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 +196 -60
- 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 -24
- data/spec/unit/util/yaml_spec.rb +13 -1
- data/spec/unit/util_spec.rb +219 -15
- data/spec/unit/version_spec.rb +15 -0
- data/spec/watchr.rb +0 -0
- data/tasks/cfpropertylist.rake +15 -0
- data/tasks/i18n.rake +20 -0
- metadata +3701 -3043
- checksums.yaml +0 -7
- 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 -223
- 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,367 +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)
|
|
50
48
|
end
|
|
51
49
|
|
|
52
|
-
def
|
|
53
|
-
|
|
50
|
+
def type_reference_t(type_string)
|
|
51
|
+
TypeFactory.type_reference(type_string)
|
|
54
52
|
end
|
|
55
53
|
|
|
56
|
-
def
|
|
57
|
-
|
|
54
|
+
def integer_t
|
|
55
|
+
TypeFactory.integer
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
def
|
|
61
|
-
|
|
58
|
+
def array_t(t, s = nil)
|
|
59
|
+
TypeFactory.array_of(t, s)
|
|
62
60
|
end
|
|
63
61
|
|
|
64
|
-
def
|
|
65
|
-
|
|
62
|
+
def empty_array_t
|
|
63
|
+
empty_array = array_t(unit_t, range_t(0,0))
|
|
66
64
|
end
|
|
67
65
|
|
|
68
|
-
def
|
|
69
|
-
|
|
66
|
+
def hash_t(k,v,s = nil)
|
|
67
|
+
TypeFactory.hash_of(v, k, s)
|
|
70
68
|
end
|
|
71
69
|
|
|
72
|
-
def
|
|
73
|
-
|
|
70
|
+
def data_t
|
|
71
|
+
TypeFactory.data
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def factory
|
|
75
|
+
TypeFactory
|
|
76
|
+
end
|
|
77
|
+
|
|
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)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def not_undef_t(t = nil)
|
|
107
|
+
TypeFactory.not_undef(t)
|
|
90
108
|
end
|
|
91
109
|
|
|
92
110
|
def undef_t
|
|
93
|
-
|
|
111
|
+
TypeFactory.undef
|
|
94
112
|
end
|
|
95
113
|
|
|
96
114
|
def unit_t
|
|
97
115
|
# Cannot be created via factory, the type is private to the type system
|
|
98
|
-
|
|
116
|
+
PUnitType::DEFAULT
|
|
99
117
|
end
|
|
100
118
|
|
|
101
119
|
def types
|
|
102
|
-
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
shared_context "types_setup" do
|
|
106
|
-
|
|
107
|
-
# Do not include the special type Unit in this list
|
|
108
|
-
def all_types
|
|
109
|
-
[ Puppet::Pops::Types::PAnyType,
|
|
110
|
-
Puppet::Pops::Types::PUndefType,
|
|
111
|
-
Puppet::Pops::Types::PDataType,
|
|
112
|
-
Puppet::Pops::Types::PScalarType,
|
|
113
|
-
Puppet::Pops::Types::PStringType,
|
|
114
|
-
Puppet::Pops::Types::PNumericType,
|
|
115
|
-
Puppet::Pops::Types::PIntegerType,
|
|
116
|
-
Puppet::Pops::Types::PFloatType,
|
|
117
|
-
Puppet::Pops::Types::PRegexpType,
|
|
118
|
-
Puppet::Pops::Types::PBooleanType,
|
|
119
|
-
Puppet::Pops::Types::PCollectionType,
|
|
120
|
-
Puppet::Pops::Types::PArrayType,
|
|
121
|
-
Puppet::Pops::Types::PHashType,
|
|
122
|
-
Puppet::Pops::Types::PRuntimeType,
|
|
123
|
-
Puppet::Pops::Types::PHostClassType,
|
|
124
|
-
Puppet::Pops::Types::PResourceType,
|
|
125
|
-
Puppet::Pops::Types::PPatternType,
|
|
126
|
-
Puppet::Pops::Types::PEnumType,
|
|
127
|
-
Puppet::Pops::Types::PVariantType,
|
|
128
|
-
Puppet::Pops::Types::PStructType,
|
|
129
|
-
Puppet::Pops::Types::PTupleType,
|
|
130
|
-
Puppet::Pops::Types::PCallableType,
|
|
131
|
-
Puppet::Pops::Types::PType,
|
|
132
|
-
Puppet::Pops::Types::POptionalType,
|
|
133
|
-
Puppet::Pops::Types::PDefaultType,
|
|
134
|
-
]
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def scalar_types
|
|
138
|
-
# PVariantType is also scalar, if its types are all Scalar
|
|
139
|
-
[
|
|
140
|
-
Puppet::Pops::Types::PScalarType,
|
|
141
|
-
Puppet::Pops::Types::PStringType,
|
|
142
|
-
Puppet::Pops::Types::PNumericType,
|
|
143
|
-
Puppet::Pops::Types::PIntegerType,
|
|
144
|
-
Puppet::Pops::Types::PFloatType,
|
|
145
|
-
Puppet::Pops::Types::PRegexpType,
|
|
146
|
-
Puppet::Pops::Types::PBooleanType,
|
|
147
|
-
Puppet::Pops::Types::PPatternType,
|
|
148
|
-
Puppet::Pops::Types::PEnumType,
|
|
149
|
-
]
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def numeric_types
|
|
153
|
-
# PVariantType is also numeric, if its types are all numeric
|
|
154
|
-
[
|
|
155
|
-
Puppet::Pops::Types::PNumericType,
|
|
156
|
-
Puppet::Pops::Types::PIntegerType,
|
|
157
|
-
Puppet::Pops::Types::PFloatType,
|
|
158
|
-
]
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def string_types
|
|
162
|
-
# PVariantType is also string type, if its types are all compatible
|
|
163
|
-
[
|
|
164
|
-
Puppet::Pops::Types::PStringType,
|
|
165
|
-
Puppet::Pops::Types::PPatternType,
|
|
166
|
-
Puppet::Pops::Types::PEnumType,
|
|
167
|
-
]
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def collection_types
|
|
171
|
-
# PVariantType is also string type, if its types are all compatible
|
|
172
|
-
[
|
|
173
|
-
Puppet::Pops::Types::PCollectionType,
|
|
174
|
-
Puppet::Pops::Types::PHashType,
|
|
175
|
-
Puppet::Pops::Types::PArrayType,
|
|
176
|
-
Puppet::Pops::Types::PStructType,
|
|
177
|
-
Puppet::Pops::Types::PTupleType,
|
|
178
|
-
]
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def data_compatible_types
|
|
182
|
-
result = scalar_types
|
|
183
|
-
result << Puppet::Pops::Types::PDataType
|
|
184
|
-
result << array_t(types::PDataType.new)
|
|
185
|
-
result << types::TypeFactory.hash_of_data
|
|
186
|
-
result << Puppet::Pops::Types::PUndefType
|
|
187
|
-
tmp = tuple_t(types::PDataType.new)
|
|
188
|
-
result << (tmp)
|
|
189
|
-
tmp.size_type = range_t(0, nil)
|
|
190
|
-
result
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
def type_from_class(c)
|
|
194
|
-
c.is_a?(Class) ? c.new : c
|
|
195
|
-
end
|
|
120
|
+
Types
|
|
196
121
|
end
|
|
197
122
|
|
|
198
123
|
context 'when inferring ruby' do
|
|
199
124
|
|
|
200
125
|
it 'fixnum translates to PIntegerType' do
|
|
201
|
-
expect(calculator.infer(1).class).to eq(
|
|
126
|
+
expect(calculator.infer(1).class).to eq(PIntegerType)
|
|
202
127
|
end
|
|
203
128
|
|
|
204
129
|
it 'large fixnum (or bignum depending on architecture) translates to PIntegerType' do
|
|
205
|
-
expect(calculator.infer(2**33).class).to eq(
|
|
130
|
+
expect(calculator.infer(2**33).class).to eq(PIntegerType)
|
|
206
131
|
end
|
|
207
132
|
|
|
208
133
|
it 'float translates to PFloatType' do
|
|
209
|
-
expect(calculator.infer(1.3).class).to eq(
|
|
134
|
+
expect(calculator.infer(1.3).class).to eq(PFloatType)
|
|
210
135
|
end
|
|
211
136
|
|
|
212
137
|
it 'string translates to PStringType' do
|
|
213
|
-
expect(calculator.infer('foo').class).to eq(
|
|
138
|
+
expect(calculator.infer('foo').class).to eq(PStringType)
|
|
214
139
|
end
|
|
215
140
|
|
|
216
141
|
it 'inferred string type knows the string value' do
|
|
217
142
|
t = calculator.infer('foo')
|
|
218
|
-
expect(t.class).to eq(
|
|
219
|
-
expect(t.
|
|
143
|
+
expect(t.class).to eq(PStringType)
|
|
144
|
+
expect(t.value).to eq('foo')
|
|
220
145
|
end
|
|
221
146
|
|
|
222
147
|
it 'boolean true translates to PBooleanType' do
|
|
223
|
-
expect(calculator.infer(true).class).to eq(
|
|
148
|
+
expect(calculator.infer(true).class).to eq(PBooleanType)
|
|
224
149
|
end
|
|
225
150
|
|
|
226
151
|
it 'boolean false translates to PBooleanType' do
|
|
227
|
-
expect(calculator.infer(false).class).to eq(
|
|
152
|
+
expect(calculator.infer(false).class).to eq(PBooleanType)
|
|
228
153
|
end
|
|
229
154
|
|
|
230
155
|
it 'regexp translates to PRegexpType' do
|
|
231
|
-
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)
|
|
232
161
|
end
|
|
233
162
|
|
|
234
163
|
it 'nil translates to PUndefType' do
|
|
235
|
-
expect(calculator.infer(nil).class).to eq(
|
|
164
|
+
expect(calculator.infer(nil).class).to eq(PUndefType)
|
|
236
165
|
end
|
|
237
166
|
|
|
238
|
-
it ':undef translates to
|
|
239
|
-
expect(calculator.infer(:undef).class).to eq(
|
|
167
|
+
it ':undef translates to PUndefType' do
|
|
168
|
+
expect(calculator.infer(:undef).class).to eq(PUndefType)
|
|
240
169
|
end
|
|
241
170
|
|
|
242
171
|
it 'an instance of class Foo translates to PRuntimeType[ruby, Foo]' do
|
|
243
|
-
|
|
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)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it 'range translates to PVersionRangeType' do
|
|
229
|
+
expect(calculator.infer(SemanticPuppet::VersionRange.parse('1.x')).class).to eq(PSemVerRangeType)
|
|
244
230
|
end
|
|
245
231
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
|
250
268
|
end
|
|
251
269
|
|
|
252
270
|
context 'array' do
|
|
253
271
|
it 'translates to PArrayType' do
|
|
254
|
-
expect(calculator.infer([1,2]).class).to eq(
|
|
272
|
+
expect(calculator.infer([1,2]).class).to eq(PArrayType)
|
|
255
273
|
end
|
|
256
274
|
|
|
257
275
|
it 'with fixnum values translates to PArrayType[PIntegerType]' do
|
|
258
|
-
expect(calculator.infer([1,2]).element_type.class).to eq(
|
|
276
|
+
expect(calculator.infer([1,2]).element_type.class).to eq(PIntegerType)
|
|
259
277
|
end
|
|
260
278
|
|
|
261
279
|
it 'with 32 and 64 bit integer values translates to PArrayType[PIntegerType]' do
|
|
262
|
-
expect(calculator.infer([1,2**33]).element_type.class).to eq(
|
|
280
|
+
expect(calculator.infer([1,2**33]).element_type.class).to eq(PIntegerType)
|
|
263
281
|
end
|
|
264
282
|
|
|
265
283
|
it 'Range of integer values are computed' do
|
|
266
284
|
t = calculator.infer([-3,0,42]).element_type
|
|
267
|
-
expect(t.class).to eq(
|
|
285
|
+
expect(t.class).to eq(PIntegerType)
|
|
268
286
|
expect(t.from).to eq(-3)
|
|
269
287
|
expect(t.to).to eq(42)
|
|
270
288
|
end
|
|
271
289
|
|
|
272
|
-
it
|
|
290
|
+
it 'Compound string values are converted to enums' do
|
|
273
291
|
t = calculator.infer(['a','b', 'c']).element_type
|
|
274
|
-
expect(t.class).to eq(
|
|
292
|
+
expect(t.class).to eq(PEnumType)
|
|
275
293
|
expect(t.values).to eq(['a', 'b', 'c'])
|
|
276
294
|
end
|
|
277
295
|
|
|
278
296
|
it 'with fixnum and float values translates to PArrayType[PNumericType]' do
|
|
279
|
-
expect(calculator.infer([1,2.0]).element_type.class).to eq(
|
|
297
|
+
expect(calculator.infer([1,2.0]).element_type.class).to eq(PNumericType)
|
|
280
298
|
end
|
|
281
299
|
|
|
282
300
|
it 'with fixnum and string values translates to PArrayType[PScalarType]' do
|
|
283
|
-
expect(calculator.infer([1,'two']).element_type.class).to eq(
|
|
301
|
+
expect(calculator.infer([1,'two']).element_type.class).to eq(PScalarType)
|
|
284
302
|
end
|
|
285
303
|
|
|
286
304
|
it 'with float and string values translates to PArrayType[PScalarType]' do
|
|
287
|
-
expect(calculator.infer([1.0,'two']).element_type.class).to eq(
|
|
305
|
+
expect(calculator.infer([1.0,'two']).element_type.class).to eq(PScalarType)
|
|
288
306
|
end
|
|
289
307
|
|
|
290
308
|
it 'with fixnum, float, and string values translates to PArrayType[PScalarType]' do
|
|
291
|
-
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)
|
|
292
310
|
end
|
|
293
311
|
|
|
294
312
|
it 'with fixnum and regexp values translates to PArrayType[PScalarType]' do
|
|
295
|
-
expect(calculator.infer([1, /two/]).element_type.class).to eq(
|
|
313
|
+
expect(calculator.infer([1, /two/]).element_type.class).to eq(PScalarType)
|
|
296
314
|
end
|
|
297
315
|
|
|
298
316
|
it 'with string and regexp values translates to PArrayType[PScalarType]' do
|
|
299
|
-
expect(calculator.infer(['one', /two/]).element_type.class).to eq(
|
|
317
|
+
expect(calculator.infer(['one', /two/]).element_type.class).to eq(PScalarType)
|
|
300
318
|
end
|
|
301
319
|
|
|
302
320
|
it 'with string and symbol values translates to PArrayType[PAnyType]' do
|
|
303
|
-
expect(calculator.infer(['one', :two]).element_type.class).to eq(
|
|
321
|
+
expect(calculator.infer(['one', :two]).element_type.class).to eq(PAnyType)
|
|
304
322
|
end
|
|
305
323
|
|
|
306
324
|
it 'with fixnum and nil values translates to PArrayType[PIntegerType]' do
|
|
307
|
-
expect(calculator.infer([1, nil]).element_type.class).to eq(
|
|
325
|
+
expect(calculator.infer([1, nil]).element_type.class).to eq(PIntegerType)
|
|
308
326
|
end
|
|
309
327
|
|
|
310
328
|
it 'with arrays of string values translates to PArrayType[PArrayType[PStringType]]' do
|
|
311
|
-
et = calculator.infer([['first' 'array'], ['second','array']])
|
|
312
|
-
expect(et.class).to eq(
|
|
329
|
+
et = calculator.infer([['first', 'array'], ['second','array']])
|
|
330
|
+
expect(et.class).to eq(PArrayType)
|
|
313
331
|
et = et.element_type
|
|
314
|
-
expect(et.class).to eq(
|
|
332
|
+
expect(et.class).to eq(PArrayType)
|
|
315
333
|
et = et.element_type
|
|
316
|
-
expect(et.class).to eq(
|
|
334
|
+
expect(et.class).to eq(PEnumType)
|
|
317
335
|
end
|
|
318
336
|
|
|
319
337
|
it 'with array of string values and array of fixnums translates to PArrayType[PArrayType[PScalarType]]' do
|
|
320
|
-
et = calculator.infer([['first' 'array'], [1,2]])
|
|
321
|
-
expect(et.class).to eq(
|
|
338
|
+
et = calculator.infer([['first', 'array'], [1,2]])
|
|
339
|
+
expect(et.class).to eq(PArrayType)
|
|
322
340
|
et = et.element_type
|
|
323
|
-
expect(et.class).to eq(
|
|
341
|
+
expect(et.class).to eq(PArrayType)
|
|
324
342
|
et = et.element_type
|
|
325
|
-
expect(et.class).to eq(
|
|
343
|
+
expect(et.class).to eq(PScalarType)
|
|
326
344
|
end
|
|
327
345
|
|
|
328
|
-
it 'with hashes of string values translates to PArrayType[PHashType[
|
|
346
|
+
it 'with hashes of string values translates to PArrayType[PHashType[PEnumType]]' do
|
|
329
347
|
et = calculator.infer([{:first => 'first', :second => 'second' }, {:first => 'first', :second => 'second' }])
|
|
330
|
-
expect(et.class).to eq(
|
|
331
|
-
et = et.element_type
|
|
332
|
-
expect(et.class).to eq(Puppet::Pops::Types::PHashType)
|
|
348
|
+
expect(et.class).to eq(PArrayType)
|
|
333
349
|
et = et.element_type
|
|
334
|
-
expect(et.class).to eq(
|
|
350
|
+
expect(et.class).to eq(PHashType)
|
|
351
|
+
et = et.value_type
|
|
352
|
+
expect(et.class).to eq(PEnumType)
|
|
335
353
|
end
|
|
336
354
|
|
|
337
355
|
it 'with hash of string values and hash of fixnums translates to PArrayType[PHashType[PScalarType]]' do
|
|
338
356
|
et = calculator.infer([{:first => 'first', :second => 'second' }, {:first => 1, :second => 2 }])
|
|
339
|
-
expect(et.class).to eq(
|
|
357
|
+
expect(et.class).to eq(PArrayType)
|
|
340
358
|
et = et.element_type
|
|
341
|
-
expect(et.class).to eq(
|
|
342
|
-
et = et.
|
|
343
|
-
expect(et.class).to eq(
|
|
359
|
+
expect(et.class).to eq(PHashType)
|
|
360
|
+
et = et.value_type
|
|
361
|
+
expect(et.class).to eq(PScalarType)
|
|
344
362
|
end
|
|
345
363
|
end
|
|
346
364
|
|
|
347
365
|
context 'hash' do
|
|
348
366
|
it 'translates to PHashType' do
|
|
349
|
-
expect(calculator.infer({:first => 1, :second => 2}).class).to eq(
|
|
367
|
+
expect(calculator.infer({:first => 1, :second => 2}).class).to eq(PHashType)
|
|
350
368
|
end
|
|
351
369
|
|
|
352
370
|
it 'with symbolic keys translates to PHashType[PRuntimeType[ruby, Symbol], value]' do
|
|
353
371
|
k = calculator.infer({:first => 1, :second => 2}).key_type
|
|
354
|
-
expect(k.class).to eq(
|
|
372
|
+
expect(k.class).to eq(PRuntimeType)
|
|
355
373
|
expect(k.runtime).to eq(:ruby)
|
|
356
374
|
expect(k.runtime_type_name).to eq('Symbol')
|
|
357
375
|
end
|
|
358
376
|
|
|
359
|
-
it 'with string keys translates to PHashType[
|
|
360
|
-
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)
|
|
361
379
|
end
|
|
362
380
|
|
|
363
381
|
it 'with fixnum values translates to PHashType[key, PIntegerType]' do
|
|
364
|
-
expect(calculator.infer({:first => 1, :second => 2}).
|
|
382
|
+
expect(calculator.infer({:first => 1, :second => 2}).value_type.class).to eq(PIntegerType)
|
|
365
383
|
end
|
|
366
384
|
|
|
367
385
|
it 'when empty infers a type that answers true to is_the_empty_hash?' do
|
|
@@ -374,110 +392,132 @@ describe 'The type calculator' do
|
|
|
374
392
|
end
|
|
375
393
|
|
|
376
394
|
it 'when empty is not assignable to a PHashType with from size > 0' do
|
|
377
|
-
expect(calculator.assignable?(
|
|
395
|
+
expect(calculator.assignable?(hash_t(string_t,string_t,range_t(1, 1)), calculator.infer({}))).to eq(false)
|
|
378
396
|
end
|
|
379
397
|
|
|
380
398
|
context 'using infer_set' do
|
|
381
399
|
it "with 'first' and 'second' keys translates to PStructType[{first=>value,second=>value}]" do
|
|
382
400
|
t = calculator.infer_set({'first' => 1, 'second' => 2})
|
|
383
|
-
expect(t.class).to eq(
|
|
401
|
+
expect(t.class).to eq(PStructType)
|
|
384
402
|
expect(t.elements.size).to eq(2)
|
|
385
403
|
expect(t.elements.map { |e| e.name }.sort).to eq(['first', 'second'])
|
|
386
404
|
end
|
|
387
405
|
|
|
388
406
|
it 'with string keys and string and array values translates to PStructType[{key1=>PStringType,key2=>PTupleType}]' do
|
|
389
407
|
t = calculator.infer_set({ 'mode' => 'read', 'path' => ['foo', 'fee' ] })
|
|
390
|
-
expect(t.class).to eq(
|
|
408
|
+
expect(t.class).to eq(PStructType)
|
|
391
409
|
expect(t.elements.size).to eq(2)
|
|
392
|
-
els = t.elements.map { |e| e.
|
|
393
|
-
expect(els[0].class).to eq(
|
|
394
|
-
expect(els[1].class).to eq(
|
|
410
|
+
els = t.elements.map { |e| e.value_type }.sort {|a,b| a.to_s <=> b.to_s }
|
|
411
|
+
expect(els[0].class).to eq(PStringType)
|
|
412
|
+
expect(els[1].class).to eq(PTupleType)
|
|
395
413
|
end
|
|
396
414
|
|
|
397
415
|
it 'with mixed string and non-string keys translates to PHashType' do
|
|
398
416
|
t = calculator.infer_set({ 1 => 'first', 'second' => 'second' })
|
|
399
|
-
expect(t.class).to eq(
|
|
417
|
+
expect(t.class).to eq(PHashType)
|
|
400
418
|
end
|
|
401
419
|
|
|
402
420
|
it 'with empty string keys translates to PHashType' do
|
|
403
421
|
t = calculator.infer_set({ '' => 'first', 'second' => 'second' })
|
|
404
|
-
expect(t.class).to eq(
|
|
422
|
+
expect(t.class).to eq(PHashType)
|
|
405
423
|
end
|
|
406
424
|
end
|
|
407
425
|
end
|
|
408
426
|
end
|
|
409
427
|
|
|
410
428
|
context 'patterns' do
|
|
411
|
-
it
|
|
429
|
+
it 'constructs a PPatternType' do
|
|
412
430
|
t = pattern_t('a(b)c')
|
|
413
|
-
expect(t.class).to eq(
|
|
431
|
+
expect(t.class).to eq(PPatternType)
|
|
414
432
|
expect(t.patterns.size).to eq(1)
|
|
415
|
-
expect(t.patterns[0].class).to eq(
|
|
433
|
+
expect(t.patterns[0].class).to eq(PRegexpType)
|
|
416
434
|
expect(t.patterns[0].pattern).to eq('a(b)c')
|
|
417
435
|
expect(t.patterns[0].regexp.match('abc')[1]).to eq('b')
|
|
418
436
|
end
|
|
419
437
|
|
|
420
|
-
it
|
|
421
|
-
t =
|
|
422
|
-
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)
|
|
423
441
|
end
|
|
424
442
|
end
|
|
425
443
|
|
|
426
444
|
# Deal with cases not covered by computing common type
|
|
427
445
|
context 'when computing common type' do
|
|
428
446
|
it 'computes given resource type commonality' do
|
|
429
|
-
r1 =
|
|
430
|
-
|
|
431
|
-
r2
|
|
432
|
-
|
|
433
|
-
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
|
+
|
|
434
451
|
|
|
435
|
-
r2 =
|
|
436
|
-
r2.
|
|
437
|
-
r2.title = '/tmp/foo'
|
|
438
|
-
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')
|
|
439
454
|
|
|
440
|
-
r1 =
|
|
441
|
-
r1.
|
|
442
|
-
r1.title = '/tmp/foo'
|
|
443
|
-
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']")
|
|
444
457
|
|
|
445
|
-
r1 =
|
|
446
|
-
r1.
|
|
447
|
-
r1.title = '/tmp/bar'
|
|
448
|
-
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')
|
|
449
460
|
|
|
450
|
-
r2 =
|
|
451
|
-
r2.
|
|
452
|
-
r2.title = 'apache'
|
|
453
|
-
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')
|
|
454
463
|
end
|
|
455
464
|
|
|
456
465
|
it 'computes given hostclass type commonality' do
|
|
457
|
-
r1 =
|
|
458
|
-
|
|
459
|
-
r2
|
|
460
|
-
|
|
461
|
-
|
|
466
|
+
r1 = PHostClassType.new('foo')
|
|
467
|
+
r2 = PHostClassType.new('foo')
|
|
468
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class[foo]')
|
|
469
|
+
|
|
470
|
+
r2 = PHostClassType.new('bar')
|
|
471
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class')
|
|
472
|
+
|
|
473
|
+
r2 = PHostClassType.new(nil)
|
|
474
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class')
|
|
475
|
+
|
|
476
|
+
r1 = PHostClassType.new(nil)
|
|
477
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class')
|
|
478
|
+
end
|
|
462
479
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
480
|
+
context 'of strings' do
|
|
481
|
+
it 'computes commonality' do
|
|
482
|
+
t1 = string_t('abc')
|
|
483
|
+
t2 = string_t('xyz')
|
|
484
|
+
common_t = calculator.common_type(t1,t2)
|
|
485
|
+
expect(common_t.class).to eq(PEnumType)
|
|
486
|
+
expect(common_t.values).to eq(['abc', 'xyz'])
|
|
487
|
+
end
|
|
466
488
|
|
|
467
|
-
|
|
468
|
-
|
|
489
|
+
it 'computes common size_type' do
|
|
490
|
+
t1 = constrained_string_t(range_t(3,6))
|
|
491
|
+
t2 = constrained_string_t(range_t(2,4))
|
|
492
|
+
common_t = calculator.common_type(t1,t2)
|
|
493
|
+
expect(common_t.class).to eq(PStringType)
|
|
494
|
+
expect(common_t.size_type).to eq(range_t(2,6))
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
it 'computes common size_type to be undef when one of the types has no size_type' do
|
|
498
|
+
t1 = string_t
|
|
499
|
+
t2 = constrained_string_t(range_t(2,4))
|
|
500
|
+
common_t = calculator.common_type(t1,t2)
|
|
501
|
+
expect(common_t.class).to eq(PStringType)
|
|
502
|
+
expect(common_t.size_type).to be_nil
|
|
503
|
+
end
|
|
469
504
|
|
|
470
|
-
|
|
471
|
-
|
|
505
|
+
it 'computes values to be empty if the one has empty values' do
|
|
506
|
+
t1 = string_t('apa')
|
|
507
|
+
t2 = constrained_string_t(range_t(2,4))
|
|
508
|
+
common_t = calculator.common_type(t1,t2)
|
|
509
|
+
expect(common_t.class).to eq(PStringType)
|
|
510
|
+
expect(common_t.value).to be_nil
|
|
511
|
+
end
|
|
472
512
|
end
|
|
473
513
|
|
|
474
514
|
it 'computes pattern commonality' do
|
|
475
515
|
t1 = pattern_t('abc')
|
|
476
516
|
t2 = pattern_t('xyz')
|
|
477
517
|
common_t = calculator.common_type(t1,t2)
|
|
478
|
-
expect(common_t.class).to eq(
|
|
518
|
+
expect(common_t.class).to eq(PPatternType)
|
|
479
519
|
expect(common_t.patterns.map { |pr| pr.pattern }).to eq(['abc', 'xyz'])
|
|
480
|
-
expect(
|
|
520
|
+
expect(common_t.to_s).to eq('Pattern[/abc/, /xyz/]')
|
|
481
521
|
end
|
|
482
522
|
|
|
483
523
|
it 'computes enum commonality to value set sum' do
|
|
@@ -488,131 +528,228 @@ describe 'The type calculator' do
|
|
|
488
528
|
end
|
|
489
529
|
|
|
490
530
|
it 'computed variant commonality to type union where added types are not sub-types' do
|
|
491
|
-
a_t1 = integer_t
|
|
531
|
+
a_t1 = integer_t
|
|
492
532
|
a_t2 = enum_t('b')
|
|
493
533
|
v_a = variant_t(a_t1, a_t2)
|
|
494
|
-
b_t1 =
|
|
495
|
-
|
|
534
|
+
b_t1 = integer_t
|
|
535
|
+
b_t2 = enum_t('a')
|
|
536
|
+
v_b = variant_t(b_t1, b_t2)
|
|
496
537
|
common_t = calculator.common_type(v_a, v_b)
|
|
497
|
-
expect(common_t.class).to eq(
|
|
498
|
-
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]))
|
|
499
540
|
end
|
|
500
541
|
|
|
501
542
|
it 'computed variant commonality to type union where added types are sub-types' do
|
|
502
|
-
a_t1 = integer_t
|
|
503
|
-
a_t2 = string_t
|
|
543
|
+
a_t1 = integer_t
|
|
544
|
+
a_t2 = string_t
|
|
504
545
|
v_a = variant_t(a_t1, a_t2)
|
|
505
|
-
b_t1 =
|
|
506
|
-
|
|
546
|
+
b_t1 = integer_t
|
|
547
|
+
b_t2 = enum_t('a')
|
|
548
|
+
v_b = variant_t(b_t1, b_t2)
|
|
507
549
|
common_t = calculator.common_type(v_a, v_b)
|
|
508
|
-
expect(common_t.class).to eq(
|
|
550
|
+
expect(common_t.class).to eq(PVariantType)
|
|
509
551
|
expect(Set.new(common_t.types)).to eq(Set.new([a_t1, a_t2]))
|
|
510
552
|
end
|
|
511
553
|
|
|
512
|
-
context
|
|
554
|
+
context 'of callables' do
|
|
513
555
|
it 'incompatible instances => generic callable' do
|
|
514
556
|
t1 = callable_t(String)
|
|
515
557
|
t2 = callable_t(Integer)
|
|
516
558
|
common_t = calculator.common_type(t1, t2)
|
|
517
|
-
expect(common_t.class).to be(
|
|
559
|
+
expect(common_t.class).to be(PCallableType)
|
|
518
560
|
expect(common_t.param_types).to be_nil
|
|
519
561
|
expect(common_t.block_type).to be_nil
|
|
520
562
|
end
|
|
521
563
|
|
|
522
564
|
it 'compatible instances => the most specific' do
|
|
523
565
|
t1 = callable_t(String)
|
|
524
|
-
scalar_t =
|
|
566
|
+
scalar_t = PScalarType.new
|
|
525
567
|
t2 = callable_t(scalar_t)
|
|
526
568
|
common_t = calculator.common_type(t1, t2)
|
|
527
|
-
expect(common_t.class).to be(
|
|
528
|
-
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)
|
|
529
571
|
expect(common_t.param_types.types).to eql([string_t])
|
|
530
572
|
expect(common_t.block_type).to be_nil
|
|
531
573
|
end
|
|
532
574
|
|
|
533
575
|
it 'block_type is included in the check (incompatible block)' do
|
|
534
|
-
|
|
535
|
-
|
|
576
|
+
b1 = callable_t(String)
|
|
577
|
+
b2 = callable_t(Integer)
|
|
578
|
+
t1 = callable_t(String, b1)
|
|
579
|
+
t2 = callable_t(String, b2)
|
|
536
580
|
common_t = calculator.common_type(t1, t2)
|
|
537
|
-
expect(common_t.class).to be(
|
|
581
|
+
expect(common_t.class).to be(PCallableType)
|
|
538
582
|
expect(common_t.param_types).to be_nil
|
|
539
583
|
expect(common_t.block_type).to be_nil
|
|
540
584
|
end
|
|
541
585
|
|
|
542
586
|
it 'block_type is included in the check (compatible block)' do
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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)
|
|
546
592
|
common_t = calculator.common_type(t1, t2)
|
|
547
|
-
expect(common_t.param_types.class).to be(
|
|
593
|
+
expect(common_t.param_types.class).to be(PTupleType)
|
|
548
594
|
expect(common_t.block_type).to eql(callable_t(scalar_t))
|
|
549
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
|
|
550
614
|
end
|
|
551
615
|
end
|
|
552
616
|
|
|
553
617
|
context 'computes assignability' do
|
|
554
|
-
include_context
|
|
618
|
+
include_context 'types_setup'
|
|
619
|
+
|
|
620
|
+
it 'such that all types are assignable to themselves' do
|
|
621
|
+
all_types.each do |tc|
|
|
622
|
+
t = tc::DEFAULT
|
|
623
|
+
expect(t).to be_assignable_to(t)
|
|
624
|
+
end
|
|
625
|
+
end
|
|
555
626
|
|
|
556
627
|
context 'for Unit, such that' do
|
|
557
628
|
it 'all types are assignable to Unit' do
|
|
558
|
-
t =
|
|
559
|
-
all_types.each { |t2| expect(t2
|
|
629
|
+
t = PUnitType::DEFAULT
|
|
630
|
+
all_types.each { |t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
560
631
|
end
|
|
561
632
|
|
|
562
633
|
it 'Unit is assignable to all other types' do
|
|
563
|
-
t =
|
|
564
|
-
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) }
|
|
565
636
|
end
|
|
566
637
|
|
|
567
638
|
it 'Unit is assignable to Unit' do
|
|
568
|
-
t =
|
|
569
|
-
t2 =
|
|
639
|
+
t = PUnitType::DEFAULT
|
|
640
|
+
t2 = PUnitType::DEFAULT
|
|
570
641
|
expect(t).to be_assignable_to(t2)
|
|
571
642
|
end
|
|
572
643
|
end
|
|
573
644
|
|
|
574
|
-
context
|
|
645
|
+
context 'for Any, such that' do
|
|
575
646
|
it 'all types are assignable to Any' do
|
|
576
|
-
t =
|
|
577
|
-
all_types.each { |t2| expect(t2
|
|
647
|
+
t = PAnyType::DEFAULT
|
|
648
|
+
all_types.each { |t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
it 'Any is not assignable to anything but Any and Optional (implied Optional[Any])' do
|
|
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) }
|
|
655
|
+
end
|
|
656
|
+
end
|
|
657
|
+
|
|
658
|
+
context "for NotUndef, such that" do
|
|
659
|
+
it 'all types except types assignable from Undef are assignable to NotUndef' do
|
|
660
|
+
t = not_undef_t
|
|
661
|
+
tc = TypeCalculator.singleton
|
|
662
|
+
undef_t = PUndefType::DEFAULT
|
|
663
|
+
all_types.each do |c|
|
|
664
|
+
t2 = c::DEFAULT
|
|
665
|
+
if tc.assignable?(t2, undef_t)
|
|
666
|
+
expect(t2).not_to be_assignable_to(t)
|
|
667
|
+
else
|
|
668
|
+
expect(t2).to be_assignable_to(t)
|
|
669
|
+
end
|
|
670
|
+
end
|
|
671
|
+
end
|
|
672
|
+
|
|
673
|
+
it 'type NotUndef[T] is assignable from T unless T is assignable from Undef ' do
|
|
674
|
+
tc = TypeCalculator.singleton
|
|
675
|
+
undef_t = PUndefType::DEFAULT
|
|
676
|
+
all_types().select do |c|
|
|
677
|
+
t2 = c::DEFAULT
|
|
678
|
+
not_undef_t = not_undef_t(t2)
|
|
679
|
+
if tc.assignable?(t2, undef_t)
|
|
680
|
+
expect(t2).not_to be_assignable_to(not_undef_t)
|
|
681
|
+
else
|
|
682
|
+
expect(t2).to be_assignable_to(not_undef_t)
|
|
683
|
+
end
|
|
684
|
+
end
|
|
578
685
|
end
|
|
579
686
|
|
|
580
|
-
it '
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
687
|
+
it 'type T is assignable from NotUndef[T] unless T is assignable from Undef' do
|
|
688
|
+
tc = TypeCalculator.singleton
|
|
689
|
+
undef_t = PUndefType::DEFAULT
|
|
690
|
+
all_types().select do |c|
|
|
691
|
+
t2 = c::DEFAULT
|
|
692
|
+
not_undef_t = not_undef_t(t2)
|
|
693
|
+
unless tc.assignable?(t2, undef_t)
|
|
694
|
+
expect(not_undef_t).to be_assignable_to(t2)
|
|
695
|
+
end
|
|
696
|
+
end
|
|
584
697
|
end
|
|
585
698
|
end
|
|
586
699
|
|
|
587
|
-
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
|
|
588
731
|
it 'all scalars + array and hash are assignable to Data' do
|
|
589
|
-
t =
|
|
732
|
+
t = PDataType::DEFAULT
|
|
590
733
|
data_compatible_types.each { |t2|
|
|
591
734
|
expect(type_from_class(t2)).to be_assignable_to(t)
|
|
592
735
|
}
|
|
593
736
|
end
|
|
594
737
|
|
|
595
|
-
it 'a
|
|
596
|
-
t =
|
|
597
|
-
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) }
|
|
598
741
|
end
|
|
599
742
|
|
|
600
743
|
it 'Data is not assignable to any of its subtypes' do
|
|
601
|
-
t =
|
|
602
|
-
types_to_test = data_compatible_types- [
|
|
744
|
+
t = PDataType::DEFAULT
|
|
745
|
+
types_to_test = data_compatible_types- [PDataType]
|
|
603
746
|
types_to_test.each {|t2| expect(t).not_to be_assignable_to(type_from_class(t2)) }
|
|
604
747
|
end
|
|
605
748
|
|
|
606
|
-
it 'Data is not assignable to a Variant of Data subtype' do
|
|
607
|
-
t = Puppet::Pops::Types::PDataType.new()
|
|
608
|
-
types_to_test = data_compatible_types- [Puppet::Pops::Types::PDataType]
|
|
609
|
-
types_to_test.each { |t2| expect(t).not_to be_assignable_to(variant_t(type_from_class(t2))) }
|
|
610
|
-
end
|
|
611
|
-
|
|
612
749
|
it 'Data is not assignable to any disjunct type' do
|
|
613
|
-
tested_types = all_types - [
|
|
614
|
-
t =
|
|
615
|
-
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) }
|
|
616
753
|
end
|
|
617
754
|
end
|
|
618
755
|
|
|
@@ -634,102 +771,132 @@ describe 'The type calculator' do
|
|
|
634
771
|
end
|
|
635
772
|
end
|
|
636
773
|
|
|
637
|
-
context
|
|
638
|
-
it
|
|
639
|
-
t =
|
|
640
|
-
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) }
|
|
641
778
|
end
|
|
642
779
|
|
|
643
780
|
it 'Scalar is not assignable to any of its subtypes' do
|
|
644
|
-
t =
|
|
645
|
-
types_to_test = scalar_types - [
|
|
646
|
-
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) }
|
|
647
784
|
end
|
|
648
785
|
|
|
649
786
|
it 'Scalar is not assignable to any disjunct type' do
|
|
650
|
-
tested_types = all_types - [
|
|
651
|
-
t =
|
|
652
|
-
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) }
|
|
653
790
|
end
|
|
654
791
|
end
|
|
655
792
|
|
|
656
|
-
context
|
|
657
|
-
it
|
|
658
|
-
t =
|
|
659
|
-
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) }
|
|
660
797
|
end
|
|
661
798
|
|
|
662
799
|
it 'Numeric is not assignable to any of its subtypes' do
|
|
663
|
-
t =
|
|
664
|
-
types_to_test = numeric_types - [
|
|
665
|
-
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) }
|
|
666
803
|
end
|
|
667
804
|
|
|
668
805
|
it 'Numeric is not assignable to any disjunct type' do
|
|
669
806
|
tested_types = all_types - [
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
807
|
+
PAnyType,
|
|
808
|
+
POptionalType,
|
|
809
|
+
PNotUndefType,
|
|
810
|
+
PDataType,
|
|
811
|
+
PScalarType,
|
|
673
812
|
] - numeric_types
|
|
674
|
-
t =
|
|
675
|
-
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) }
|
|
676
815
|
end
|
|
677
816
|
end
|
|
678
817
|
|
|
679
|
-
context
|
|
680
|
-
it
|
|
681
|
-
t =
|
|
682
|
-
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) }
|
|
683
822
|
end
|
|
684
823
|
|
|
685
824
|
it 'Collection is not assignable to any of its subtypes' do
|
|
686
|
-
t =
|
|
687
|
-
types_to_test = collection_types - [
|
|
688
|
-
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) }
|
|
689
828
|
end
|
|
690
829
|
|
|
691
830
|
it 'Collection is not assignable to any disjunct type' do
|
|
692
|
-
tested_types = all_types - [
|
|
693
|
-
|
|
694
|
-
|
|
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) }
|
|
695
838
|
end
|
|
696
839
|
end
|
|
697
840
|
|
|
698
|
-
context
|
|
699
|
-
it
|
|
700
|
-
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
|
|
701
844
|
tested_types = collection_types - [
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
845
|
+
PCollectionType,
|
|
846
|
+
PNotUndefType,
|
|
847
|
+
PArrayType,
|
|
848
|
+
PTupleType]
|
|
849
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
706
850
|
end
|
|
707
851
|
|
|
708
852
|
it 'Array is not assignable to any disjunct type' do
|
|
709
853
|
tested_types = all_types - [
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
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)))
|
|
714
878
|
end
|
|
715
879
|
end
|
|
716
880
|
|
|
717
|
-
context
|
|
718
|
-
it
|
|
719
|
-
t =
|
|
881
|
+
context 'for Hash, such that' do
|
|
882
|
+
it 'Hash is not assignable to any other Collection type' do
|
|
883
|
+
t = PHashType::DEFAULT
|
|
720
884
|
tested_types = collection_types - [
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
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) }
|
|
725
889
|
end
|
|
726
890
|
|
|
727
891
|
it 'Hash is not assignable to any disjunct type' do
|
|
728
892
|
tested_types = all_types - [
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
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) }
|
|
733
900
|
end
|
|
734
901
|
|
|
735
902
|
it 'Struct is assignable to Hash with Pattern that matches all keys' do
|
|
@@ -749,68 +916,187 @@ describe 'The type calculator' do
|
|
|
749
916
|
end
|
|
750
917
|
end
|
|
751
918
|
|
|
752
|
-
context
|
|
753
|
-
it
|
|
754
|
-
|
|
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
|
|
755
950
|
tested_types = collection_types - [
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
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)
|
|
760
961
|
end
|
|
761
962
|
|
|
762
963
|
it 'Tuple is not assignable to any disjunct type' do
|
|
763
964
|
tested_types = all_types - [
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
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) }
|
|
768
972
|
end
|
|
769
973
|
end
|
|
770
974
|
|
|
771
|
-
context
|
|
772
|
-
it
|
|
773
|
-
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
|
|
774
978
|
tested_types = collection_types - [
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
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) }
|
|
779
983
|
end
|
|
780
984
|
|
|
781
985
|
it 'Struct is not assignable to any disjunct type' do
|
|
782
986
|
tested_types = all_types - [
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
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) }
|
|
994
|
+
end
|
|
995
|
+
|
|
996
|
+
it 'Default key optionality is controlled by value assignability to undef' do
|
|
997
|
+
t1 = struct_t({'member' => string_t})
|
|
998
|
+
expect(t1.elements[0].key_type).to eq(string_t('member'))
|
|
999
|
+
t1 = struct_t({'member' => object_t})
|
|
1000
|
+
expect(t1.elements[0].key_type).to eq(optional_t(string_t('member')))
|
|
1001
|
+
end
|
|
1002
|
+
|
|
1003
|
+
it "NotUndef['key'] becomes String['key'] (since its implied that String is required)" do
|
|
1004
|
+
t1 = struct_t({not_undef_t('member') => string_t})
|
|
1005
|
+
expect(t1.elements[0].key_type).to eq(string_t('member'))
|
|
1006
|
+
end
|
|
1007
|
+
|
|
1008
|
+
it "Optional['key'] becomes Optional[String['key']]" do
|
|
1009
|
+
t1 = struct_t({optional_t('member') => string_t})
|
|
1010
|
+
expect(t1.elements[0].key_type).to eq(optional_t(string_t('member')))
|
|
1011
|
+
end
|
|
1012
|
+
|
|
1013
|
+
it 'Optional members are not required' do
|
|
1014
|
+
t1 = struct_t({optional_t('optional_member') => string_t, not_undef_t('other_member') => string_t})
|
|
1015
|
+
t2 = struct_t({not_undef_t('other_member') => string_t})
|
|
1016
|
+
expect(t2).to be_assignable_to(t1)
|
|
1017
|
+
end
|
|
1018
|
+
|
|
1019
|
+
it 'Required members not optional even when value is' do
|
|
1020
|
+
t1 = struct_t({not_undef_t('required_member') => object_t, not_undef_t('other_member') => string_t})
|
|
1021
|
+
t2 = struct_t({not_undef_t('other_member') => string_t})
|
|
1022
|
+
expect(t2).not_to be_assignable_to(t1)
|
|
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)
|
|
787
1035
|
end
|
|
788
1036
|
end
|
|
789
1037
|
|
|
790
|
-
context
|
|
791
|
-
it
|
|
792
|
-
t =
|
|
1038
|
+
context 'for Callable, such that' do
|
|
1039
|
+
it 'Callable is not assignable to any disjunct type' do
|
|
1040
|
+
t = PCallableType::DEFAULT
|
|
793
1041
|
tested_types = all_types - [
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
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))
|
|
797
1083
|
end
|
|
798
1084
|
end
|
|
799
1085
|
|
|
800
1086
|
it 'should recognize mapped ruby types' do
|
|
801
|
-
{ Integer =>
|
|
802
|
-
Fixnum =>
|
|
803
|
-
Bignum =>
|
|
804
|
-
Float =>
|
|
805
|
-
Numeric =>
|
|
806
|
-
NilClass =>
|
|
807
|
-
TrueClass =>
|
|
808
|
-
FalseClass =>
|
|
809
|
-
String =>
|
|
810
|
-
Regexp =>
|
|
811
|
-
Regexp =>
|
|
812
|
-
Array =>
|
|
813
|
-
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
|
|
814
1100
|
}.each do |ruby_type, puppet_type |
|
|
815
1101
|
expect(ruby_type).to be_assignable_to(puppet_type)
|
|
816
1102
|
end
|
|
@@ -821,35 +1107,18 @@ describe 'The type calculator' do
|
|
|
821
1107
|
expect(calculator.assignable?(range_t(2,5), range_t(2,5))).to eq(true)
|
|
822
1108
|
end
|
|
823
1109
|
|
|
824
|
-
it 'should accept an equal reverse range' do
|
|
825
|
-
expect(calculator.assignable?(range_t(2,5), range_t(5,2))).to eq(true)
|
|
826
|
-
end
|
|
827
|
-
|
|
828
1110
|
it 'should accept a narrower range' do
|
|
829
1111
|
expect(calculator.assignable?(range_t(2,10), range_t(3,5))).to eq(true)
|
|
830
1112
|
end
|
|
831
1113
|
|
|
832
|
-
it 'should accept a narrower reverse range' do
|
|
833
|
-
expect(calculator.assignable?(range_t(2,10), range_t(5,3))).to eq(true)
|
|
834
|
-
end
|
|
835
|
-
|
|
836
1114
|
it 'should reject a wider range' do
|
|
837
1115
|
expect(calculator.assignable?(range_t(3,5), range_t(2,10))).to eq(false)
|
|
838
1116
|
end
|
|
839
1117
|
|
|
840
|
-
it 'should reject a wider reverse range' do
|
|
841
|
-
expect(calculator.assignable?(range_t(3,5), range_t(10,2))).to eq(false)
|
|
842
|
-
end
|
|
843
|
-
|
|
844
1118
|
it 'should reject a partially overlapping range' do
|
|
845
1119
|
expect(calculator.assignable?(range_t(3,5), range_t(2,4))).to eq(false)
|
|
846
1120
|
expect(calculator.assignable?(range_t(3,5), range_t(4,6))).to eq(false)
|
|
847
1121
|
end
|
|
848
|
-
|
|
849
|
-
it 'should reject a partially overlapping reverse range' do
|
|
850
|
-
expect(calculator.assignable?(range_t(3,5), range_t(4,2))).to eq(false)
|
|
851
|
-
expect(calculator.assignable?(range_t(3,5), range_t(6,4))).to eq(false)
|
|
852
|
-
end
|
|
853
1122
|
end
|
|
854
1123
|
|
|
855
1124
|
context 'when dealing with patterns' do
|
|
@@ -885,7 +1154,7 @@ describe 'The type calculator' do
|
|
|
885
1154
|
|
|
886
1155
|
it 'should accept multiple strings if they all match any patterns' do
|
|
887
1156
|
p_t = pattern_t('X', 'Y', 'abc')
|
|
888
|
-
p_s =
|
|
1157
|
+
p_s = enum_t('Xa', 'aY', 'abc')
|
|
889
1158
|
expect(calculator.assignable?(p_t, p_s)).to eq(true)
|
|
890
1159
|
end
|
|
891
1160
|
|
|
@@ -897,7 +1166,7 @@ describe 'The type calculator' do
|
|
|
897
1166
|
|
|
898
1167
|
it 'should reject multiple strings if not all match any patterns' do
|
|
899
1168
|
p_t = pattern_t('abc', 'ab', 'c', 'q')
|
|
900
|
-
p_s =
|
|
1169
|
+
p_s = enum_t('X', 'Y', 'Z')
|
|
901
1170
|
expect(calculator.assignable?(p_t, p_s)).to eq(false)
|
|
902
1171
|
end
|
|
903
1172
|
|
|
@@ -913,18 +1182,18 @@ describe 'The type calculator' do
|
|
|
913
1182
|
end
|
|
914
1183
|
|
|
915
1184
|
it 'pattern representing all patterns should accept any pattern' do
|
|
916
|
-
expect(calculator.assignable?(pattern_t
|
|
917
|
-
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)
|
|
918
1187
|
end
|
|
919
1188
|
|
|
920
1189
|
it 'pattern representing all patterns should accept any enum' do
|
|
921
|
-
expect(calculator.assignable?(pattern_t
|
|
922
|
-
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)
|
|
923
1192
|
end
|
|
924
1193
|
|
|
925
1194
|
it 'pattern representing all patterns should accept any string' do
|
|
926
|
-
expect(calculator.assignable?(pattern_t
|
|
927
|
-
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)
|
|
928
1197
|
end
|
|
929
1198
|
|
|
930
1199
|
end
|
|
@@ -943,8 +1212,8 @@ describe 'The type calculator' do
|
|
|
943
1212
|
end
|
|
944
1213
|
|
|
945
1214
|
it 'non parameterized enum accepts any other enum but not the reverse' do
|
|
946
|
-
expect(calculator.assignable?(enum_t
|
|
947
|
-
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)
|
|
948
1217
|
end
|
|
949
1218
|
|
|
950
1219
|
it 'enum should accept a variant where all variants are acceptable' do
|
|
@@ -955,54 +1224,53 @@ describe 'The type calculator' do
|
|
|
955
1224
|
|
|
956
1225
|
context 'when dealing with string and enum combinations' do
|
|
957
1226
|
it 'should accept assigning any enum to unrestricted string' do
|
|
958
|
-
expect(calculator.assignable?(string_t
|
|
959
|
-
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)
|
|
960
1229
|
end
|
|
961
1230
|
|
|
962
1231
|
it 'should not accept assigning longer enum value to size restricted string' do
|
|
963
|
-
expect(calculator.assignable?(
|
|
1232
|
+
expect(calculator.assignable?(constrained_string_t(range_t(2,2)), enum_t('a','blue'))).to eq(false)
|
|
964
1233
|
end
|
|
965
1234
|
|
|
966
1235
|
it 'should accept assigning any string to empty enum' do
|
|
967
|
-
expect(calculator.assignable?(enum_t
|
|
1236
|
+
expect(calculator.assignable?(enum_t, string_t)).to eq(true)
|
|
968
1237
|
end
|
|
969
1238
|
|
|
970
1239
|
it 'should accept assigning empty enum to any string' do
|
|
971
|
-
expect(calculator.assignable?(string_t
|
|
1240
|
+
expect(calculator.assignable?(string_t, enum_t)).to eq(true)
|
|
972
1241
|
end
|
|
973
1242
|
|
|
974
1243
|
it 'should not accept assigning empty enum to size constrained string' do
|
|
975
|
-
expect(calculator.assignable?(
|
|
1244
|
+
expect(calculator.assignable?(constrained_string_t(range_t(2,2)), enum_t)).to eq(false)
|
|
976
1245
|
end
|
|
977
1246
|
end
|
|
978
1247
|
|
|
979
1248
|
context 'when dealing with string/pattern/enum combinations' do
|
|
980
1249
|
it 'any string is equal to any enum is equal to any pattern' do
|
|
981
|
-
expect(calculator.assignable?(string_t
|
|
982
|
-
expect(calculator.assignable?(string_t
|
|
983
|
-
expect(calculator.assignable?(enum_t
|
|
984
|
-
expect(calculator.assignable?(enum_t
|
|
985
|
-
expect(calculator.assignable?(pattern_t
|
|
986
|
-
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)
|
|
987
1256
|
end
|
|
988
1257
|
end
|
|
989
1258
|
|
|
990
1259
|
context 'when dealing with tuples' do
|
|
991
1260
|
it 'matches empty tuples' do
|
|
992
|
-
tuple1 = tuple_t
|
|
993
|
-
tuple2 = tuple_t
|
|
1261
|
+
tuple1 = tuple_t
|
|
1262
|
+
tuple2 = tuple_t
|
|
994
1263
|
|
|
995
1264
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
996
1265
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
997
1266
|
end
|
|
998
1267
|
|
|
999
1268
|
it 'accepts an empty tuple as assignable to a tuple with a min size of 0' do
|
|
1000
|
-
tuple1 =
|
|
1001
|
-
factory.constrain_size(tuple1, 0, :default)
|
|
1269
|
+
tuple1 = constrained_tuple_t(range_t(0, :default))
|
|
1002
1270
|
tuple2 = tuple_t()
|
|
1003
1271
|
|
|
1004
1272
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1005
|
-
expect(calculator.assignable?(tuple2, tuple1)).to eq(
|
|
1273
|
+
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1006
1274
|
end
|
|
1007
1275
|
|
|
1008
1276
|
it 'should accept matching tuples' do
|
|
@@ -1020,62 +1288,51 @@ describe 'The type calculator' do
|
|
|
1020
1288
|
end
|
|
1021
1289
|
|
|
1022
1290
|
it 'should accept ranged tuples' do
|
|
1023
|
-
tuple1 =
|
|
1024
|
-
factory.constrain_size(tuple1, 5, 5)
|
|
1291
|
+
tuple1 = constrained_tuple_t(range_t(5,5), 1)
|
|
1025
1292
|
tuple2 = tuple_t(Integer,Integer, Integer, Integer, Integer)
|
|
1026
1293
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1027
1294
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1028
1295
|
end
|
|
1029
1296
|
|
|
1030
1297
|
it 'should reject ranged tuples when ranges does not match' do
|
|
1031
|
-
tuple1 =
|
|
1032
|
-
factory.constrain_size(tuple1, 4, 5)
|
|
1298
|
+
tuple1 = constrained_tuple_t(range_t(4, 5), 1)
|
|
1033
1299
|
tuple2 = tuple_t(Integer,Integer, Integer, Integer, Integer)
|
|
1034
1300
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1035
1301
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(false)
|
|
1036
1302
|
end
|
|
1037
1303
|
|
|
1038
1304
|
it 'should reject ranged tuples when ranges does not match (using infinite upper bound)' do
|
|
1039
|
-
tuple1 =
|
|
1040
|
-
factory.constrain_size(tuple1, 4, :default)
|
|
1305
|
+
tuple1 = constrained_tuple_t(range_t(4, :default), 1)
|
|
1041
1306
|
tuple2 = tuple_t(Integer,Integer, Integer, Integer, Integer)
|
|
1042
1307
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1043
1308
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(false)
|
|
1044
1309
|
end
|
|
1045
1310
|
|
|
1046
1311
|
it 'should accept matching tuples with optional entries by repeating last' do
|
|
1047
|
-
tuple1 =
|
|
1048
|
-
|
|
1049
|
-
tuple2 = tuple_t(Numeric,Numeric)
|
|
1050
|
-
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)
|
|
1051
1314
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(false)
|
|
1052
1315
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1053
1316
|
end
|
|
1054
1317
|
|
|
1055
1318
|
it 'should accept matching tuples with optional entries' do
|
|
1056
|
-
tuple1 =
|
|
1057
|
-
|
|
1058
|
-
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))
|
|
1059
1321
|
expect(calculator.assignable?(tuple1, array2)).to eq(true)
|
|
1060
|
-
|
|
1322
|
+
tuple1 = constrained_tuple_t(range_t(3, 3), tuple1.types)
|
|
1061
1323
|
expect(calculator.assignable?(tuple1, array2)).to eq(false)
|
|
1062
1324
|
end
|
|
1063
1325
|
|
|
1064
1326
|
it 'should accept matching array' do
|
|
1065
1327
|
tuple1 = tuple_t(1,2)
|
|
1066
|
-
array = array_t(Integer)
|
|
1067
|
-
factory.constrain_size(array, 2, 2)
|
|
1328
|
+
array = array_t(Integer, range_t(2, 2))
|
|
1068
1329
|
expect(calculator.assignable?(tuple1, array)).to eq(true)
|
|
1069
1330
|
expect(calculator.assignable?(array, tuple1)).to eq(true)
|
|
1070
1331
|
end
|
|
1071
1332
|
|
|
1072
1333
|
it 'should accept empty array when tuple allows min of 0' do
|
|
1073
|
-
tuple1 =
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
array = array_t(Integer)
|
|
1077
|
-
factory.constrain_size(array, 0, 0)
|
|
1078
|
-
|
|
1334
|
+
tuple1 = constrained_tuple_t(range_t(0, 1), Integer)
|
|
1335
|
+
array = array_t(unit_t, range_t(0, 0))
|
|
1079
1336
|
expect(calculator.assignable?(tuple1, array)).to eq(true)
|
|
1080
1337
|
expect(calculator.assignable?(array, tuple1)).to eq(false)
|
|
1081
1338
|
end
|
|
@@ -1122,18 +1379,15 @@ describe 'The type calculator' do
|
|
|
1122
1379
|
|
|
1123
1380
|
it 'should accept matching hash' do
|
|
1124
1381
|
struct1 = struct_t({'a'=>Integer, 'b'=>Integer})
|
|
1125
|
-
non_empty_string =
|
|
1126
|
-
|
|
1127
|
-
hsh = hash_t(non_empty_string, Integer)
|
|
1128
|
-
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))
|
|
1129
1384
|
expect(calculator.assignable?(struct1, hsh)).to eq(true)
|
|
1130
1385
|
expect(calculator.assignable?(hsh, struct1)).to eq(true)
|
|
1131
1386
|
end
|
|
1132
1387
|
|
|
1133
|
-
it 'should accept empty hash with key_type
|
|
1388
|
+
it 'should accept empty hash with key_type unit' do
|
|
1134
1389
|
struct1 = struct_t({'a'=>optional_t(Integer)})
|
|
1135
|
-
hsh = hash_t(
|
|
1136
|
-
factory.constrain_size(hsh, 0, 0)
|
|
1390
|
+
hsh = hash_t(unit_t, unit_t, range_t(0, 0))
|
|
1137
1391
|
expect(calculator.assignable?(struct1, hsh)).to eq(true)
|
|
1138
1392
|
end
|
|
1139
1393
|
end
|
|
@@ -1158,107 +1412,232 @@ describe 'The type calculator' do
|
|
|
1158
1412
|
expect(calculator.assignable?(Bar, fooType)).to eq(false)
|
|
1159
1413
|
end
|
|
1160
1414
|
|
|
1161
|
-
it
|
|
1162
|
-
hc1 =
|
|
1163
|
-
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')
|
|
1164
1418
|
expect(calculator.assignable?(hc1, hc2)).to eq(true)
|
|
1165
1419
|
end
|
|
1166
1420
|
|
|
1167
|
-
it
|
|
1168
|
-
hc1 =
|
|
1169
|
-
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')
|
|
1170
1424
|
expect(calculator.assignable?(hc1, hc2)).to eq(true)
|
|
1171
1425
|
end
|
|
1172
1426
|
|
|
1173
|
-
it
|
|
1174
|
-
hc1 =
|
|
1175
|
-
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')
|
|
1176
1430
|
expect(calculator.assignable?(hc1, hc2)).to eq(false)
|
|
1177
1431
|
end
|
|
1178
1432
|
|
|
1179
|
-
it
|
|
1180
|
-
hc1 =
|
|
1181
|
-
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
|
|
1182
1436
|
expect(calculator.assignable?(hc1, hc2)).to eq(false)
|
|
1183
1437
|
end
|
|
1184
1438
|
|
|
1185
|
-
it
|
|
1186
|
-
r1 =
|
|
1187
|
-
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')
|
|
1188
1442
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1189
1443
|
end
|
|
1190
1444
|
|
|
1191
|
-
it
|
|
1192
|
-
r1 =
|
|
1193
|
-
r2 =
|
|
1445
|
+
it 'should allow more specific resource assignment' do
|
|
1446
|
+
r1 = TypeFactory.resource
|
|
1447
|
+
r2 = TypeFactory.resource('file')
|
|
1194
1448
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1195
|
-
r2 =
|
|
1449
|
+
r2 = TypeFactory.resource('file', '/tmp/foo')
|
|
1196
1450
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1197
|
-
r1 =
|
|
1451
|
+
r1 = TypeFactory.resource('file')
|
|
1198
1452
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1199
1453
|
end
|
|
1200
1454
|
|
|
1201
|
-
it
|
|
1202
|
-
r1 =
|
|
1203
|
-
r2 =
|
|
1455
|
+
it 'should reject less specific resource assignment' do
|
|
1456
|
+
r1 = TypeFactory.resource('file', '/tmp/foo')
|
|
1457
|
+
r2 = TypeFactory.resource('file')
|
|
1204
1458
|
expect(calculator.assignable?(r1, r2)).to eq(false)
|
|
1205
|
-
r2 =
|
|
1459
|
+
r2 = TypeFactory.resource
|
|
1206
1460
|
expect(calculator.assignable?(r1, r2)).to eq(false)
|
|
1207
1461
|
end
|
|
1208
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).with(instance_of(Model::QualifiedReference), scope).at_most_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).with(instance_of(Model::QualifiedReference), scope).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
|
+
scope = Object.new
|
|
1508
|
+
|
|
1509
|
+
t1 = type_alias_t('Tree1', 'Hash[String,Variant[String,Tree2]]')
|
|
1510
|
+
t2 = type_alias_t('Tree2', 'Hash[String,Variant[String,Tree1]]')
|
|
1511
|
+
loader = Object.new
|
|
1512
|
+
loader.expects(:load).with(:type, 'tree1').returns t1
|
|
1513
|
+
loader.expects(:load).with(:type, 'tree2').returns t2
|
|
1514
|
+
loader.expects(:is_a?).with(Loader::Loader).returns true
|
|
1515
|
+
|
|
1516
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).with(instance_of(Model::QualifiedReference), scope).at_least_once.returns loader
|
|
1517
|
+
|
|
1518
|
+
t1.resolve(parser, scope)
|
|
1519
|
+
t2.resolve(parser, scope)
|
|
1520
|
+
expect(calculator.assignable?(t1, t2)).to be_truthy
|
|
1521
|
+
end
|
|
1522
|
+
|
|
1523
|
+
it 'Type[T] is assignable to Type[AT] when AT is an alias for T' do
|
|
1524
|
+
scope = Object.new
|
|
1525
|
+
|
|
1526
|
+
ta = type_alias_t('PositiveInteger', 'Integer[0,default]')
|
|
1527
|
+
loader = Object.new
|
|
1528
|
+
loader.expects(:load).with(:type, 'positiveinteger').returns ta
|
|
1529
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object)
|
|
1530
|
+
.with(instance_of(Model::QualifiedReference), scope).returns loader
|
|
1531
|
+
|
|
1532
|
+
t1 = type_t(range_t(0, :default))
|
|
1533
|
+
t2 = parser.parse('Type[PositiveInteger]', scope)
|
|
1534
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1535
|
+
end
|
|
1536
|
+
|
|
1537
|
+
it 'Type[T] is assignable to AT when AT is an alias for Type[T]' do
|
|
1538
|
+
scope = Object.new
|
|
1539
|
+
|
|
1540
|
+
ta = type_alias_t('PositiveIntegerType', 'Type[Integer[0,default]]')
|
|
1541
|
+
loader = Object.new
|
|
1542
|
+
loader.expects(:load).with(:type, 'positiveintegertype').returns ta
|
|
1543
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object)
|
|
1544
|
+
.with(instance_of(Model::QualifiedReference), scope).returns loader
|
|
1545
|
+
|
|
1546
|
+
t1 = type_t(range_t(0, :default))
|
|
1547
|
+
t2 = parser.parse('PositiveIntegerType', scope)
|
|
1548
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1549
|
+
end
|
|
1550
|
+
|
|
1551
|
+
it 'Type[Type[T]] is assignable to Type[Type[AT]] when AT is an alias for T' do
|
|
1552
|
+
scope = Object.new
|
|
1553
|
+
|
|
1554
|
+
ta = type_alias_t('PositiveInteger', 'Integer[0,default]')
|
|
1555
|
+
loader = Object.new
|
|
1556
|
+
loader.expects(:load).with(:type, 'positiveinteger').returns ta
|
|
1557
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object)
|
|
1558
|
+
.with(instance_of(Model::QualifiedReference), scope).returns loader
|
|
1559
|
+
|
|
1560
|
+
t1 = type_t(type_t(range_t(0, :default)))
|
|
1561
|
+
t2 = parser.parse('Type[Type[PositiveInteger]]', scope)
|
|
1562
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1563
|
+
end
|
|
1564
|
+
|
|
1565
|
+
it 'Type[Type[T]] is assignable to Type[AT] when AT is an alias for Type[T]' do
|
|
1566
|
+
scope = Object.new
|
|
1567
|
+
|
|
1568
|
+
ta = type_alias_t('PositiveIntegerType', 'Type[Integer[0,default]]')
|
|
1569
|
+
loader = Object.new
|
|
1570
|
+
loader.expects(:load).with(:type, 'positiveintegertype').returns ta
|
|
1571
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object)
|
|
1572
|
+
.with(instance_of(Model::QualifiedReference), scope).returns loader
|
|
1573
|
+
|
|
1574
|
+
t1 = type_t(type_t(range_t(0, :default)))
|
|
1575
|
+
t2 = parser.parse('Type[PositiveIntegerType]', scope)
|
|
1576
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1577
|
+
end
|
|
1578
|
+
end
|
|
1209
1579
|
end
|
|
1210
1580
|
|
|
1211
1581
|
context 'when testing if x is instance of type t' do
|
|
1212
|
-
include_context
|
|
1582
|
+
include_context 'types_setup'
|
|
1213
1583
|
|
|
1214
1584
|
it 'should consider undef to be instance of Any, NilType, and optional' do
|
|
1215
|
-
expect(calculator.instance?(
|
|
1216
|
-
expect(calculator.instance?(
|
|
1217
|
-
expect(calculator.instance?(
|
|
1585
|
+
expect(calculator.instance?(PUndefType::DEFAULT, nil)).to eq(true)
|
|
1586
|
+
expect(calculator.instance?(PAnyType::DEFAULT, nil)).to eq(true)
|
|
1587
|
+
expect(calculator.instance?(POptionalType::DEFAULT, nil)).to eq(true)
|
|
1218
1588
|
end
|
|
1219
1589
|
|
|
1220
1590
|
it 'all types should be (ruby) instance of PAnyType' do
|
|
1221
1591
|
all_types.each do |t|
|
|
1222
|
-
expect(t.
|
|
1592
|
+
expect(t::DEFAULT.is_a?(PAnyType)).to eq(true)
|
|
1223
1593
|
end
|
|
1224
1594
|
end
|
|
1225
1595
|
|
|
1226
|
-
it "should
|
|
1227
|
-
expect(calculator.
|
|
1596
|
+
it "should infer :undef to be Undef" do
|
|
1597
|
+
expect(calculator.infer(:undef)).to be_assignable_to(undef_t)
|
|
1228
1598
|
end
|
|
1229
1599
|
|
|
1230
|
-
it "should consider :
|
|
1231
|
-
expect(calculator.instance?(
|
|
1600
|
+
it "should not consider :default to be instance of Runtime['ruby', 'Symbol]" do
|
|
1601
|
+
expect(calculator.instance?(PRuntimeType.new(:ruby, 'Symbol'), :default)).to eq(false)
|
|
1232
1602
|
end
|
|
1233
1603
|
|
|
1234
|
-
it
|
|
1604
|
+
it "should not consider :undef to be instance of Runtime['ruby', 'Symbol]" do
|
|
1605
|
+
expect(calculator.instance?(PRuntimeType.new(:ruby, 'Symbol'), :undef)).to eq(false)
|
|
1606
|
+
end
|
|
1607
|
+
|
|
1608
|
+
it 'should consider :undef to be instance of an Optional type' do
|
|
1609
|
+
expect(calculator.instance?(POptionalType::DEFAULT, :undef)).to eq(true)
|
|
1610
|
+
end
|
|
1611
|
+
|
|
1612
|
+
it 'should not consider undef to be an instance of any other type than Any, UndefType and Data' do
|
|
1235
1613
|
types_to_test = all_types - [
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1614
|
+
PAnyType,
|
|
1615
|
+
PUndefType,
|
|
1616
|
+
PDataType,
|
|
1617
|
+
POptionalType,
|
|
1240
1618
|
]
|
|
1241
1619
|
|
|
1242
|
-
types_to_test.each {|t| expect(calculator.instance?(t
|
|
1243
|
-
types_to_test.each {|t| expect(calculator.instance?(t
|
|
1620
|
+
types_to_test.each {|t| expect(calculator.instance?(t::DEFAULT, nil)).to eq(false) }
|
|
1621
|
+
types_to_test.each {|t| expect(calculator.instance?(t::DEFAULT, :undef)).to eq(false) }
|
|
1244
1622
|
end
|
|
1245
1623
|
|
|
1246
1624
|
it 'should consider default to be instance of Default and Any' do
|
|
1247
|
-
expect(calculator.instance?(
|
|
1248
|
-
expect(calculator.instance?(
|
|
1625
|
+
expect(calculator.instance?(PDefaultType::DEFAULT, :default)).to eq(true)
|
|
1626
|
+
expect(calculator.instance?(PAnyType::DEFAULT, :default)).to eq(true)
|
|
1249
1627
|
end
|
|
1250
1628
|
|
|
1251
|
-
it 'should not consider "default" to be an instance of anything but Default, and Any' do
|
|
1629
|
+
it 'should not consider "default" to be an instance of anything but Default, NotUndef, and Any' do
|
|
1252
1630
|
types_to_test = all_types - [
|
|
1253
|
-
|
|
1254
|
-
|
|
1631
|
+
PAnyType,
|
|
1632
|
+
PNotUndefType,
|
|
1633
|
+
PDefaultType,
|
|
1255
1634
|
]
|
|
1256
1635
|
|
|
1257
|
-
types_to_test.each {|t| expect(calculator.instance?(t
|
|
1636
|
+
types_to_test.each {|t| expect(calculator.instance?(t::DEFAULT, :default)).to eq(false) }
|
|
1258
1637
|
end
|
|
1259
1638
|
|
|
1260
1639
|
it 'should consider fixnum instanceof PIntegerType' do
|
|
1261
|
-
expect(calculator.instance?(
|
|
1640
|
+
expect(calculator.instance?(PIntegerType::DEFAULT, 1)).to eq(true)
|
|
1262
1641
|
end
|
|
1263
1642
|
|
|
1264
1643
|
it 'should consider fixnum instanceof Fixnum' do
|
|
@@ -1274,15 +1653,21 @@ describe 'The type calculator' do
|
|
|
1274
1653
|
end
|
|
1275
1654
|
|
|
1276
1655
|
it 'should consider string in length range' do
|
|
1277
|
-
range =
|
|
1656
|
+
range = constrained_string_t(range_t(1,3))
|
|
1278
1657
|
expect(calculator.instance?(range, 'a')).to eq(true)
|
|
1279
1658
|
expect(calculator.instance?(range, 'abc')).to eq(true)
|
|
1280
1659
|
expect(calculator.instance?(range, '')).to eq(false)
|
|
1281
1660
|
expect(calculator.instance?(range, 'abcd')).to eq(false)
|
|
1282
1661
|
end
|
|
1283
1662
|
|
|
1663
|
+
it 'should consider string values' do
|
|
1664
|
+
string = string_t('a')
|
|
1665
|
+
expect(calculator.instance?(string, 'a')).to eq(true)
|
|
1666
|
+
expect(calculator.instance?(string, 'c')).to eq(false)
|
|
1667
|
+
end
|
|
1668
|
+
|
|
1284
1669
|
it 'should consider array in length range' do
|
|
1285
|
-
range =
|
|
1670
|
+
range = array_t(integer_t, range_t(1,3))
|
|
1286
1671
|
expect(calculator.instance?(range, [1])).to eq(true)
|
|
1287
1672
|
expect(calculator.instance?(range, [1,2,3])).to eq(true)
|
|
1288
1673
|
expect(calculator.instance?(range, [])).to eq(false)
|
|
@@ -1290,7 +1675,7 @@ describe 'The type calculator' do
|
|
|
1290
1675
|
end
|
|
1291
1676
|
|
|
1292
1677
|
it 'should consider hash in length range' do
|
|
1293
|
-
range =
|
|
1678
|
+
range = hash_t(integer_t, integer_t, range_t(1,2))
|
|
1294
1679
|
expect(calculator.instance?(range, {1=>1})).to eq(true)
|
|
1295
1680
|
expect(calculator.instance?(range, {1=>1, 2=>2})).to eq(true)
|
|
1296
1681
|
expect(calculator.instance?(range, {})).to eq(false)
|
|
@@ -1298,7 +1683,7 @@ describe 'The type calculator' do
|
|
|
1298
1683
|
end
|
|
1299
1684
|
|
|
1300
1685
|
it 'should consider collection in length range for array ' do
|
|
1301
|
-
range =
|
|
1686
|
+
range = collection_t(range_t(1,3))
|
|
1302
1687
|
expect(calculator.instance?(range, [1])).to eq(true)
|
|
1303
1688
|
expect(calculator.instance?(range, [1,2,3])).to eq(true)
|
|
1304
1689
|
expect(calculator.instance?(range, [])).to eq(false)
|
|
@@ -1306,7 +1691,7 @@ describe 'The type calculator' do
|
|
|
1306
1691
|
end
|
|
1307
1692
|
|
|
1308
1693
|
it 'should consider collection in length range for hash' do
|
|
1309
|
-
range =
|
|
1694
|
+
range = collection_t(range_t(1,2))
|
|
1310
1695
|
expect(calculator.instance?(range, {1=>1})).to eq(true)
|
|
1311
1696
|
expect(calculator.instance?(range, {1=>1, 2=>2})).to eq(true)
|
|
1312
1697
|
expect(calculator.instance?(range, {})).to eq(false)
|
|
@@ -1380,6 +1765,26 @@ describe 'The type calculator' do
|
|
|
1380
1765
|
struct = struct_t({'a'=>Integer, 'b'=>String, 'c'=>optional_t(Float)})
|
|
1381
1766
|
expect(calculator.instance?(struct, {'a'=>1, 'b'=>'a', 'c'=>'x'})).to eq(false)
|
|
1382
1767
|
end
|
|
1768
|
+
|
|
1769
|
+
it 'should consider nil to be a valid element value' do
|
|
1770
|
+
struct = struct_t({not_undef_t('a') => object_t, 'b'=>String})
|
|
1771
|
+
expect(calculator.instance?(struct, {'a'=>nil , 'b'=>'a'})).to eq(true)
|
|
1772
|
+
end
|
|
1773
|
+
|
|
1774
|
+
it 'should consider nil to be a valid element value but subject to value type' do
|
|
1775
|
+
struct = struct_t({not_undef_t('a') => String, 'b'=>String})
|
|
1776
|
+
expect(calculator.instance?(struct, {'a'=>nil , 'b'=>'a'})).to eq(false)
|
|
1777
|
+
end
|
|
1778
|
+
|
|
1779
|
+
it 'should consider nil to be a valid element value but subject to value type even when key is optional' do
|
|
1780
|
+
struct = struct_t({optional_t('a') => String, 'b'=>String})
|
|
1781
|
+
expect(calculator.instance?(struct, {'a'=>nil , 'b'=>'a'})).to eq(false)
|
|
1782
|
+
end
|
|
1783
|
+
|
|
1784
|
+
it 'should consider a hash where optional key is missing as assignable even if value of optional key is required' do
|
|
1785
|
+
struct = struct_t({optional_t('a') => String, 'b'=>String})
|
|
1786
|
+
expect(calculator.instance?(struct, {'b'=>'a'})).to eq(true)
|
|
1787
|
+
end
|
|
1383
1788
|
end
|
|
1384
1789
|
|
|
1385
1790
|
context 'and t is Data' do
|
|
@@ -1417,13 +1822,13 @@ describe 'The type calculator' do
|
|
|
1417
1822
|
end
|
|
1418
1823
|
end
|
|
1419
1824
|
|
|
1420
|
-
context
|
|
1825
|
+
context 'and t is something Callable' do
|
|
1421
1826
|
|
|
1422
1827
|
it 'a Closure should be considered a Callable' do
|
|
1423
|
-
factory =
|
|
1828
|
+
factory = Model::Factory
|
|
1424
1829
|
params = [factory.PARAM('a')]
|
|
1425
|
-
the_block = factory.LAMBDA(params,factory.literal(42))
|
|
1426
|
-
the_closure =
|
|
1830
|
+
the_block = factory.LAMBDA(params,factory.literal(42), nil)
|
|
1831
|
+
the_closure = Evaluator::Closure::Dynamic.new(:fake_evaluator, the_block, :fake_scope)
|
|
1427
1832
|
expect(calculator.instance?(all_callables_t, the_closure)).to be_truthy
|
|
1428
1833
|
expect(calculator.instance?(callable_t(object_t), the_closure)).to be_truthy
|
|
1429
1834
|
expect(calculator.instance?(callable_t(object_t, object_t), the_closure)).to be_falsey
|
|
@@ -1446,456 +1851,287 @@ describe 'The type calculator' do
|
|
|
1446
1851
|
expect(calculator.instance?(callable_t(String), f)).to be_truthy
|
|
1447
1852
|
end
|
|
1448
1853
|
end
|
|
1854
|
+
|
|
1855
|
+
context 'and t is a TypeAlias' do
|
|
1856
|
+
let!(:parser) { TypeParser.singleton }
|
|
1857
|
+
|
|
1858
|
+
it 'should consider x an instance of the aliased simple type' do
|
|
1859
|
+
t = type_alias_t('Alias', 'Integer').resolve(parser, nil)
|
|
1860
|
+
expect(calculator.instance?(t, 15)).to be_truthy
|
|
1861
|
+
end
|
|
1862
|
+
|
|
1863
|
+
it 'should consider x an instance of the aliased parameterized type' do
|
|
1864
|
+
t = type_alias_t('Alias', 'Integer[0,20]').resolve(parser, nil)
|
|
1865
|
+
expect(calculator.instance?(t, 15)).to be_truthy
|
|
1866
|
+
end
|
|
1867
|
+
|
|
1868
|
+
it 'should consider x an instance of the aliased type that uses self recursion' do
|
|
1869
|
+
scope = Object.new
|
|
1870
|
+
|
|
1871
|
+
t = type_alias_t('Tree', 'Hash[String,Variant[String,Tree]]')
|
|
1872
|
+
loader = Object.new
|
|
1873
|
+
loader.expects(:load).with(:type, 'tree').returns t
|
|
1874
|
+
|
|
1875
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).with(instance_of(Model::QualifiedReference), scope).at_most_once.returns loader
|
|
1876
|
+
|
|
1877
|
+
t.resolve(parser, scope)
|
|
1878
|
+
expect(calculator.instance?(t, {'a'=>{'aa'=>{'aaa'=>'aaaa'}}, 'b'=>'bb'})).to be_truthy
|
|
1879
|
+
end
|
|
1880
|
+
|
|
1881
|
+
it 'should consider x an instance of the aliased type that uses contains an alias that causes self recursion' do
|
|
1882
|
+
scope = Object.new
|
|
1883
|
+
|
|
1884
|
+
t1 = type_alias_t('Tree', 'Hash[String,Variant[String,OtherTree]]')
|
|
1885
|
+
t2 = type_alias_t('OtherTree', 'Hash[String,Tree]')
|
|
1886
|
+
loader = Object.new
|
|
1887
|
+
loader.expects(:load).with(:type, 'tree').returns t1
|
|
1888
|
+
loader.expects(:load).with(:type, 'othertree').returns t2
|
|
1889
|
+
loader.expects(:is_a?).with(Loader::Loader).returns true
|
|
1890
|
+
|
|
1891
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).with(instance_of(Model::QualifiedReference), scope).at_least_once.returns loader
|
|
1892
|
+
|
|
1893
|
+
t1.resolve(parser, scope)
|
|
1894
|
+
expect(calculator.instance?(t1, {'a'=>{'aa'=>{'aaa'=>'aaaa'}}, 'b'=>'bb'})).to be_truthy
|
|
1895
|
+
end
|
|
1896
|
+
end
|
|
1449
1897
|
end
|
|
1450
1898
|
|
|
1451
1899
|
context 'when converting a ruby class' do
|
|
1452
1900
|
it 'should yield \'PIntegerType\' for Integer, Fixnum, and Bignum' do
|
|
1453
1901
|
[Integer,Fixnum,Bignum].each do |c|
|
|
1454
|
-
expect(calculator.type(c).class).to eq(
|
|
1902
|
+
expect(calculator.type(c).class).to eq(PIntegerType)
|
|
1455
1903
|
end
|
|
1456
1904
|
end
|
|
1457
1905
|
|
|
1458
1906
|
it 'should yield \'PFloatType\' for Float' do
|
|
1459
|
-
expect(calculator.type(Float).class).to eq(
|
|
1907
|
+
expect(calculator.type(Float).class).to eq(PFloatType)
|
|
1460
1908
|
end
|
|
1461
1909
|
|
|
1462
1910
|
it 'should yield \'PBooleanType\' for FalseClass and TrueClass' do
|
|
1463
1911
|
[FalseClass,TrueClass].each do |c|
|
|
1464
|
-
expect(calculator.type(c).class).to eq(
|
|
1912
|
+
expect(calculator.type(c).class).to eq(PBooleanType)
|
|
1465
1913
|
end
|
|
1466
1914
|
end
|
|
1467
1915
|
|
|
1468
1916
|
it 'should yield \'PUndefType\' for NilClass' do
|
|
1469
|
-
expect(calculator.type(NilClass).class).to eq(
|
|
1917
|
+
expect(calculator.type(NilClass).class).to eq(PUndefType)
|
|
1470
1918
|
end
|
|
1471
1919
|
|
|
1472
1920
|
it 'should yield \'PStringType\' for String' do
|
|
1473
|
-
expect(calculator.type(String).class).to eq(
|
|
1921
|
+
expect(calculator.type(String).class).to eq(PStringType)
|
|
1474
1922
|
end
|
|
1475
1923
|
|
|
1476
1924
|
it 'should yield \'PRegexpType\' for Regexp' do
|
|
1477
|
-
expect(calculator.type(Regexp).class).to eq(
|
|
1925
|
+
expect(calculator.type(Regexp).class).to eq(PRegexpType)
|
|
1478
1926
|
end
|
|
1479
1927
|
|
|
1480
1928
|
it 'should yield \'PArrayType[PDataType]\' for Array' do
|
|
1481
1929
|
t = calculator.type(Array)
|
|
1482
|
-
expect(t.class).to eq(
|
|
1483
|
-
expect(t.element_type.class).to eq(
|
|
1930
|
+
expect(t.class).to eq(PArrayType)
|
|
1931
|
+
expect(t.element_type.class).to eq(PDataType)
|
|
1484
1932
|
end
|
|
1485
1933
|
|
|
1486
1934
|
it 'should yield \'PHashType[PScalarType,PDataType]\' for Hash' do
|
|
1487
1935
|
t = calculator.type(Hash)
|
|
1488
|
-
expect(t.class).to eq(
|
|
1489
|
-
expect(t.key_type.class).to eq(
|
|
1490
|
-
expect(t.
|
|
1491
|
-
end
|
|
1492
|
-
end
|
|
1493
|
-
|
|
1494
|
-
context 'when representing the type as string' do
|
|
1495
|
-
it 'should yield \'Type\' for PType' do
|
|
1496
|
-
expect(calculator.string(Puppet::Pops::Types::PType.new())).to eq('Type')
|
|
1497
|
-
end
|
|
1498
|
-
|
|
1499
|
-
it 'should yield \'Object\' for PAnyType' do
|
|
1500
|
-
expect(calculator.string(Puppet::Pops::Types::PAnyType.new())).to eq('Any')
|
|
1501
|
-
end
|
|
1502
|
-
|
|
1503
|
-
it 'should yield \'Scalar\' for PScalarType' do
|
|
1504
|
-
expect(calculator.string(Puppet::Pops::Types::PScalarType.new())).to eq('Scalar')
|
|
1505
|
-
end
|
|
1506
|
-
|
|
1507
|
-
it 'should yield \'Boolean\' for PBooleanType' do
|
|
1508
|
-
expect(calculator.string(Puppet::Pops::Types::PBooleanType.new())).to eq('Boolean')
|
|
1509
|
-
end
|
|
1510
|
-
|
|
1511
|
-
it 'should yield \'Data\' for PDataType' do
|
|
1512
|
-
expect(calculator.string(Puppet::Pops::Types::PDataType.new())).to eq('Data')
|
|
1513
|
-
end
|
|
1514
|
-
|
|
1515
|
-
it 'should yield \'Numeric\' for PNumericType' do
|
|
1516
|
-
expect(calculator.string(Puppet::Pops::Types::PNumericType.new())).to eq('Numeric')
|
|
1517
|
-
end
|
|
1518
|
-
|
|
1519
|
-
it 'should yield \'Integer\' and from/to for PIntegerType' do
|
|
1520
|
-
int_T = Puppet::Pops::Types::PIntegerType
|
|
1521
|
-
expect(calculator.string(int_T.new())).to eq('Integer')
|
|
1522
|
-
int = int_T.new()
|
|
1523
|
-
int.from = 1
|
|
1524
|
-
int.to = 1
|
|
1525
|
-
expect(calculator.string(int)).to eq('Integer[1, 1]')
|
|
1526
|
-
int = int_T.new()
|
|
1527
|
-
int.from = 1
|
|
1528
|
-
int.to = 2
|
|
1529
|
-
expect(calculator.string(int)).to eq('Integer[1, 2]')
|
|
1530
|
-
int = int_T.new()
|
|
1531
|
-
int.from = nil
|
|
1532
|
-
int.to = 2
|
|
1533
|
-
expect(calculator.string(int)).to eq('Integer[default, 2]')
|
|
1534
|
-
int = int_T.new()
|
|
1535
|
-
int.from = 2
|
|
1536
|
-
int.to = nil
|
|
1537
|
-
expect(calculator.string(int)).to eq('Integer[2, default]')
|
|
1538
|
-
end
|
|
1539
|
-
|
|
1540
|
-
it 'should yield \'Float\' for PFloatType' do
|
|
1541
|
-
expect(calculator.string(Puppet::Pops::Types::PFloatType.new())).to eq('Float')
|
|
1542
|
-
end
|
|
1543
|
-
|
|
1544
|
-
it 'should yield \'Regexp\' for PRegexpType' do
|
|
1545
|
-
expect(calculator.string(Puppet::Pops::Types::PRegexpType.new())).to eq('Regexp')
|
|
1546
|
-
end
|
|
1547
|
-
|
|
1548
|
-
it 'should yield \'Regexp[/pat/]\' for parameterized PRegexpType' do
|
|
1549
|
-
t = Puppet::Pops::Types::PRegexpType.new()
|
|
1550
|
-
t.pattern = ('a/b')
|
|
1551
|
-
expect(calculator.string(Puppet::Pops::Types::PRegexpType.new())).to eq('Regexp')
|
|
1552
|
-
end
|
|
1553
|
-
|
|
1554
|
-
it 'should yield \'String\' for PStringType' do
|
|
1555
|
-
expect(calculator.string(Puppet::Pops::Types::PStringType.new())).to eq('String')
|
|
1556
|
-
end
|
|
1557
|
-
|
|
1558
|
-
it 'should yield \'String\' for PStringType with multiple values' do
|
|
1559
|
-
expect(calculator.string(string_t('a', 'b', 'c'))).to eq('String')
|
|
1560
|
-
end
|
|
1561
|
-
|
|
1562
|
-
it 'should yield \'String\' and from/to for PStringType' do
|
|
1563
|
-
string_T = Puppet::Pops::Types::PStringType
|
|
1564
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), 1,1))).to eq('String[1, 1]')
|
|
1565
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), 1,2))).to eq('String[1, 2]')
|
|
1566
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), :default, 2))).to eq('String[default, 2]')
|
|
1567
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), 2, :default))).to eq('String[2, default]')
|
|
1568
|
-
end
|
|
1569
|
-
|
|
1570
|
-
it 'should yield \'Array[Integer]\' for PArrayType[PIntegerType]' do
|
|
1571
|
-
t = Puppet::Pops::Types::PArrayType.new()
|
|
1572
|
-
t.element_type = Puppet::Pops::Types::PIntegerType.new()
|
|
1573
|
-
expect(calculator.string(t)).to eq('Array[Integer]')
|
|
1574
|
-
end
|
|
1575
|
-
|
|
1576
|
-
it 'should yield \'Collection\' and from/to for PCollectionType' do
|
|
1577
|
-
col = collection_t()
|
|
1578
|
-
expect(calculator.string(factory.constrain_size(col.copy, 1,1))).to eq('Collection[1, 1]')
|
|
1579
|
-
expect(calculator.string(factory.constrain_size(col.copy, 1,2))).to eq('Collection[1, 2]')
|
|
1580
|
-
expect(calculator.string(factory.constrain_size(col.copy, :default, 2))).to eq('Collection[default, 2]')
|
|
1581
|
-
expect(calculator.string(factory.constrain_size(col.copy, 2, :default))).to eq('Collection[2, default]')
|
|
1582
|
-
end
|
|
1583
|
-
|
|
1584
|
-
it 'should yield \'Array\' and from/to for PArrayType' do
|
|
1585
|
-
arr = array_t(string_t)
|
|
1586
|
-
expect(calculator.string(factory.constrain_size(arr.copy, 1,1))).to eq('Array[String, 1, 1]')
|
|
1587
|
-
expect(calculator.string(factory.constrain_size(arr.copy, 1,2))).to eq('Array[String, 1, 2]')
|
|
1588
|
-
expect(calculator.string(factory.constrain_size(arr.copy, :default, 2))).to eq('Array[String, default, 2]')
|
|
1589
|
-
expect(calculator.string(factory.constrain_size(arr.copy, 2, :default))).to eq('Array[String, 2, default]')
|
|
1590
|
-
end
|
|
1591
|
-
|
|
1592
|
-
it 'should yield \'Tuple[Integer]\' for PTupleType[PIntegerType]' do
|
|
1593
|
-
t = Puppet::Pops::Types::PTupleType.new()
|
|
1594
|
-
t.addTypes(Puppet::Pops::Types::PIntegerType.new())
|
|
1595
|
-
expect(calculator.string(t)).to eq('Tuple[Integer]')
|
|
1596
|
-
end
|
|
1597
|
-
|
|
1598
|
-
it 'should yield \'Tuple[T, T,..]\' for PTupleType[T, T, ...]' do
|
|
1599
|
-
t = Puppet::Pops::Types::PTupleType.new()
|
|
1600
|
-
t.addTypes(Puppet::Pops::Types::PIntegerType.new())
|
|
1601
|
-
t.addTypes(Puppet::Pops::Types::PIntegerType.new())
|
|
1602
|
-
t.addTypes(Puppet::Pops::Types::PStringType.new())
|
|
1603
|
-
expect(calculator.string(t)).to eq('Tuple[Integer, Integer, String]')
|
|
1604
|
-
end
|
|
1605
|
-
|
|
1606
|
-
it 'should yield \'Tuple\' and from/to for PTupleType' do
|
|
1607
|
-
tuple_t = tuple_t(string_t)
|
|
1608
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, 1,1))).to eq('Tuple[String, 1, 1]')
|
|
1609
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, 1,2))).to eq('Tuple[String, 1, 2]')
|
|
1610
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, :default, 2))).to eq('Tuple[String, default, 2]')
|
|
1611
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, 2, :default))).to eq('Tuple[String, 2, default]')
|
|
1612
|
-
end
|
|
1613
|
-
|
|
1614
|
-
it 'should yield \'Struct\' and details for PStructType' do
|
|
1615
|
-
struct_t = struct_t({'a'=>Integer, 'b'=>String})
|
|
1616
|
-
expect(calculator.string(struct_t)).to eq("Struct[{'a'=>Integer, 'b'=>String}]")
|
|
1617
|
-
struct_t = struct_t({})
|
|
1618
|
-
expect(calculator.string(struct_t)).to eq("Struct")
|
|
1619
|
-
end
|
|
1620
|
-
|
|
1621
|
-
it 'should yield \'Hash[String, Integer]\' for PHashType[PStringType, PIntegerType]' do
|
|
1622
|
-
t = Puppet::Pops::Types::PHashType.new()
|
|
1623
|
-
t.key_type = Puppet::Pops::Types::PStringType.new()
|
|
1624
|
-
t.element_type = Puppet::Pops::Types::PIntegerType.new()
|
|
1625
|
-
expect(calculator.string(t)).to eq('Hash[String, Integer]')
|
|
1626
|
-
end
|
|
1627
|
-
|
|
1628
|
-
it 'should yield \'Hash\' and from/to for PHashType' do
|
|
1629
|
-
hsh = hash_t(string_t, string_t)
|
|
1630
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, 1,1))).to eq('Hash[String, String, 1, 1]')
|
|
1631
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, 1,2))).to eq('Hash[String, String, 1, 2]')
|
|
1632
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, :default, 2))).to eq('Hash[String, String, default, 2]')
|
|
1633
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, 2, :default))).to eq('Hash[String, String, 2, default]')
|
|
1634
|
-
end
|
|
1635
|
-
|
|
1636
|
-
it "should yield 'Class' for a PHostClassType" do
|
|
1637
|
-
t = Puppet::Pops::Types::PHostClassType.new()
|
|
1638
|
-
expect(calculator.string(t)).to eq('Class')
|
|
1639
|
-
end
|
|
1640
|
-
|
|
1641
|
-
it "should yield 'Class[x]' for a PHostClassType[x]" do
|
|
1642
|
-
t = Puppet::Pops::Types::PHostClassType.new()
|
|
1643
|
-
t.class_name = 'x'
|
|
1644
|
-
expect(calculator.string(t)).to eq('Class[x]')
|
|
1645
|
-
end
|
|
1646
|
-
|
|
1647
|
-
it "should yield 'Resource' for a PResourceType" do
|
|
1648
|
-
t = Puppet::Pops::Types::PResourceType.new()
|
|
1649
|
-
expect(calculator.string(t)).to eq('Resource')
|
|
1650
|
-
end
|
|
1651
|
-
|
|
1652
|
-
it 'should yield \'File\' for a PResourceType[\'File\']' do
|
|
1653
|
-
t = Puppet::Pops::Types::PResourceType.new()
|
|
1654
|
-
t.type_name = 'File'
|
|
1655
|
-
expect(calculator.string(t)).to eq('File')
|
|
1656
|
-
end
|
|
1657
|
-
|
|
1658
|
-
it "should yield 'File['/tmp/foo']' for a PResourceType['File', '/tmp/foo']" do
|
|
1659
|
-
t = Puppet::Pops::Types::PResourceType.new()
|
|
1660
|
-
t.type_name = 'File'
|
|
1661
|
-
t.title = '/tmp/foo'
|
|
1662
|
-
expect(calculator.string(t)).to eq("File['/tmp/foo']")
|
|
1663
|
-
end
|
|
1664
|
-
|
|
1665
|
-
it "should yield 'Enum[s,...]' for a PEnumType[s,...]" do
|
|
1666
|
-
t = enum_t('a', 'b', 'c')
|
|
1667
|
-
expect(calculator.string(t)).to eq("Enum['a', 'b', 'c']")
|
|
1668
|
-
end
|
|
1669
|
-
|
|
1670
|
-
it "should yield 'Pattern[/pat/,...]' for a PPatternType['pat',...]" do
|
|
1671
|
-
t = pattern_t('a')
|
|
1672
|
-
t2 = pattern_t('a', 'b', 'c')
|
|
1673
|
-
expect(calculator.string(t)).to eq("Pattern[/a/]")
|
|
1674
|
-
expect(calculator.string(t2)).to eq("Pattern[/a/, /b/, /c/]")
|
|
1675
|
-
end
|
|
1676
|
-
|
|
1677
|
-
it "should escape special characters in the string for a PPatternType['pat',...]" do
|
|
1678
|
-
t = pattern_t('a/b')
|
|
1679
|
-
expect(calculator.string(t)).to eq("Pattern[/a\\/b/]")
|
|
1680
|
-
end
|
|
1681
|
-
|
|
1682
|
-
it "should yield 'Variant[t1,t2,...]' for a PVariantType[t1, t2,...]" do
|
|
1683
|
-
t1 = string_t()
|
|
1684
|
-
t2 = integer_t()
|
|
1685
|
-
t3 = pattern_t('a')
|
|
1686
|
-
t = variant_t(t1, t2, t3)
|
|
1687
|
-
expect(calculator.string(t)).to eq("Variant[String, Integer, Pattern[/a/]]")
|
|
1688
|
-
end
|
|
1689
|
-
|
|
1690
|
-
it "should yield 'Callable' for generic callable" do
|
|
1691
|
-
expect(calculator.string(all_callables_t)).to eql("Callable")
|
|
1692
|
-
end
|
|
1693
|
-
|
|
1694
|
-
it "should yield 'Callable[0,0]' for callable without params" do
|
|
1695
|
-
expect(calculator.string(callable_t)).to eql("Callable[0, 0]")
|
|
1696
|
-
end
|
|
1697
|
-
|
|
1698
|
-
it "should yield 'Callable[t,t]' for callable with typed parameters" do
|
|
1699
|
-
expect(calculator.string(callable_t(String, Integer))).to eql("Callable[String, Integer]")
|
|
1700
|
-
end
|
|
1701
|
-
|
|
1702
|
-
it "should yield 'Callable[t,min,max]' for callable with size constraint (infinite max)" do
|
|
1703
|
-
expect(calculator.string(callable_t(String, 0))).to eql("Callable[String, 0, default]")
|
|
1704
|
-
end
|
|
1705
|
-
|
|
1706
|
-
it "should yield 'Callable[t,min,max]' for callable with size constraint (capped max)" do
|
|
1707
|
-
expect(calculator.string(callable_t(String, 0, 3))).to eql("Callable[String, 0, 3]")
|
|
1708
|
-
end
|
|
1709
|
-
|
|
1710
|
-
it "should yield 'Callable[min,max]' callable with size > 0" do
|
|
1711
|
-
expect(calculator.string(callable_t(0, 0))).to eql("Callable[0, 0]")
|
|
1712
|
-
expect(calculator.string(callable_t(0, 1))).to eql("Callable[0, 1]")
|
|
1713
|
-
expect(calculator.string(callable_t(0, :default))).to eql("Callable[0, default]")
|
|
1714
|
-
end
|
|
1715
|
-
|
|
1716
|
-
it "should yield 'Callable[Callable]' for callable with block" do
|
|
1717
|
-
expect(calculator.string(callable_t(all_callables_t))).to eql("Callable[0, 0, Callable]")
|
|
1718
|
-
expect(calculator.string(callable_t(string_t, all_callables_t))).to eql("Callable[String, Callable]")
|
|
1719
|
-
expect(calculator.string(callable_t(string_t, 1,1, all_callables_t))).to eql("Callable[String, 1, 1, Callable]")
|
|
1720
|
-
end
|
|
1721
|
-
|
|
1722
|
-
it "should yield Unit for a Unit type" do
|
|
1723
|
-
expect(calculator.string(unit_t)).to eql('Unit')
|
|
1936
|
+
expect(t.class).to eq(PHashType)
|
|
1937
|
+
expect(t.key_type.class).to eq(PScalarType)
|
|
1938
|
+
expect(t.value_type.class).to eq(PDataType)
|
|
1724
1939
|
end
|
|
1725
1940
|
end
|
|
1726
1941
|
|
|
1727
1942
|
context 'when processing meta type' do
|
|
1728
1943
|
it 'should infer PType as the type of all other types' do
|
|
1729
|
-
ptype =
|
|
1730
|
-
expect(calculator.infer(
|
|
1731
|
-
expect(calculator.infer(
|
|
1732
|
-
expect(calculator.infer(
|
|
1733
|
-
expect(calculator.infer(
|
|
1734
|
-
expect(calculator.infer(
|
|
1735
|
-
expect(calculator.infer(
|
|
1736
|
-
expect(calculator.infer(
|
|
1737
|
-
expect(calculator.infer(
|
|
1738
|
-
expect(calculator.infer(
|
|
1739
|
-
expect(calculator.infer(
|
|
1740
|
-
expect(calculator.infer(
|
|
1741
|
-
expect(calculator.infer(
|
|
1742
|
-
expect(calculator.infer(
|
|
1743
|
-
expect(calculator.infer(
|
|
1744
|
-
expect(calculator.infer(
|
|
1745
|
-
expect(calculator.infer(
|
|
1746
|
-
expect(calculator.infer(
|
|
1747
|
-
expect(calculator.infer(
|
|
1748
|
-
expect(calculator.infer(
|
|
1749
|
-
expect(calculator.infer(
|
|
1750
|
-
expect(calculator.infer(
|
|
1944
|
+
ptype = PType
|
|
1945
|
+
expect(calculator.infer(PUndefType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1946
|
+
expect(calculator.infer(PDataType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1947
|
+
expect(calculator.infer(PScalarType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1948
|
+
expect(calculator.infer(PStringType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1949
|
+
expect(calculator.infer(PNumericType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1950
|
+
expect(calculator.infer(PIntegerType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1951
|
+
expect(calculator.infer(PFloatType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1952
|
+
expect(calculator.infer(PRegexpType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1953
|
+
expect(calculator.infer(PBooleanType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1954
|
+
expect(calculator.infer(PCollectionType::DEFAULT).is_a?(ptype)).to eq(true)
|
|
1955
|
+
expect(calculator.infer(PArrayType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1956
|
+
expect(calculator.infer(PHashType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1957
|
+
expect(calculator.infer(PIterableType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1958
|
+
expect(calculator.infer(PRuntimeType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1959
|
+
expect(calculator.infer(PHostClassType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1960
|
+
expect(calculator.infer(PResourceType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1961
|
+
expect(calculator.infer(PEnumType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1962
|
+
expect(calculator.infer(PPatternType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1963
|
+
expect(calculator.infer(PVariantType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1964
|
+
expect(calculator.infer(PTupleType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1965
|
+
expect(calculator.infer(POptionalType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1966
|
+
expect(calculator.infer(PCallableType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1751
1967
|
end
|
|
1752
1968
|
|
|
1753
1969
|
it 'should infer PType as the type of all other types' do
|
|
1754
|
-
|
|
1755
|
-
expect(calculator.
|
|
1756
|
-
expect(calculator.
|
|
1757
|
-
expect(calculator.
|
|
1758
|
-
expect(calculator.
|
|
1759
|
-
expect(calculator.
|
|
1760
|
-
expect(calculator.
|
|
1761
|
-
expect(calculator.
|
|
1762
|
-
expect(calculator.
|
|
1763
|
-
expect(calculator.
|
|
1764
|
-
expect(calculator.
|
|
1765
|
-
expect(calculator.
|
|
1766
|
-
expect(calculator.
|
|
1767
|
-
expect(calculator.
|
|
1768
|
-
expect(calculator.
|
|
1769
|
-
expect(calculator.
|
|
1770
|
-
expect(calculator.
|
|
1771
|
-
expect(calculator.
|
|
1772
|
-
expect(calculator.
|
|
1773
|
-
expect(calculator.
|
|
1774
|
-
expect(calculator.
|
|
1775
|
-
expect(calculator.
|
|
1776
|
-
|
|
1777
|
-
expect(calculator.infer(
|
|
1778
|
-
expect(calculator.
|
|
1779
|
-
expect(calculator.infer(
|
|
1970
|
+
expect(calculator.infer(PUndefType::DEFAULT ).to_s).to eq('Type[Undef]')
|
|
1971
|
+
expect(calculator.infer(PDataType::DEFAULT ).to_s).to eq('Type[Data]')
|
|
1972
|
+
expect(calculator.infer(PScalarType::DEFAULT ).to_s).to eq('Type[Scalar]')
|
|
1973
|
+
expect(calculator.infer(PStringType::DEFAULT ).to_s).to eq('Type[String]')
|
|
1974
|
+
expect(calculator.infer(PNumericType::DEFAULT ).to_s).to eq('Type[Numeric]')
|
|
1975
|
+
expect(calculator.infer(PIntegerType::DEFAULT ).to_s).to eq('Type[Integer]')
|
|
1976
|
+
expect(calculator.infer(PFloatType::DEFAULT ).to_s).to eq('Type[Float]')
|
|
1977
|
+
expect(calculator.infer(PRegexpType::DEFAULT ).to_s).to eq('Type[Regexp]')
|
|
1978
|
+
expect(calculator.infer(PBooleanType::DEFAULT ).to_s).to eq('Type[Boolean]')
|
|
1979
|
+
expect(calculator.infer(PCollectionType::DEFAULT).to_s).to eq('Type[Collection]')
|
|
1980
|
+
expect(calculator.infer(PArrayType::DEFAULT ).to_s).to eq('Type[Array[?]]')
|
|
1981
|
+
expect(calculator.infer(PHashType::DEFAULT ).to_s).to eq('Type[Hash[?, ?]]')
|
|
1982
|
+
expect(calculator.infer(PIterableType::DEFAULT ).to_s).to eq('Type[Iterable]')
|
|
1983
|
+
expect(calculator.infer(PRuntimeType::DEFAULT ).to_s).to eq('Type[Runtime[?, ?]]')
|
|
1984
|
+
expect(calculator.infer(PHostClassType::DEFAULT ).to_s).to eq('Type[Class]')
|
|
1985
|
+
expect(calculator.infer(PResourceType::DEFAULT ).to_s).to eq('Type[Resource]')
|
|
1986
|
+
expect(calculator.infer(PEnumType::DEFAULT ).to_s).to eq('Type[Enum]')
|
|
1987
|
+
expect(calculator.infer(PVariantType::DEFAULT ).to_s).to eq('Type[Variant]')
|
|
1988
|
+
expect(calculator.infer(PPatternType::DEFAULT ).to_s).to eq('Type[Pattern]')
|
|
1989
|
+
expect(calculator.infer(PTupleType::DEFAULT ).to_s).to eq('Type[Tuple]')
|
|
1990
|
+
expect(calculator.infer(POptionalType::DEFAULT ).to_s).to eq('Type[Optional]')
|
|
1991
|
+
expect(calculator.infer(PCallableType::DEFAULT ).to_s).to eq('Type[Callable]')
|
|
1992
|
+
|
|
1993
|
+
expect(calculator.infer(PResourceType.new('foo::fee::fum')).to_s).to eq('Type[Foo::Fee::Fum]')
|
|
1994
|
+
expect(calculator.infer(PResourceType.new('foo::fee::fum')).to_s).to eq('Type[Foo::Fee::Fum]')
|
|
1995
|
+
expect(calculator.infer(PResourceType.new('Foo::Fee::Fum')).to_s).to eq('Type[Foo::Fee::Fum]')
|
|
1780
1996
|
end
|
|
1781
1997
|
|
|
1782
1998
|
it "computes the common type of PType's type parameter" do
|
|
1783
|
-
int_t =
|
|
1784
|
-
string_t =
|
|
1785
|
-
expect(calculator.
|
|
1786
|
-
expect(calculator.
|
|
1999
|
+
int_t = PIntegerType::DEFAULT
|
|
2000
|
+
string_t = PStringType::DEFAULT
|
|
2001
|
+
expect(calculator.infer([int_t]).to_s).to eq('Array[Type[Integer], 1, 1]')
|
|
2002
|
+
expect(calculator.infer([int_t, string_t]).to_s).to eq('Array[Type[Scalar], 2, 2]')
|
|
1787
2003
|
end
|
|
1788
2004
|
|
|
1789
2005
|
it 'should infer PType as the type of ruby classes' do
|
|
1790
2006
|
class Foo
|
|
1791
2007
|
end
|
|
1792
2008
|
[Object, Numeric, Integer, Fixnum, Bignum, Float, String, Regexp, Array, Hash, Foo].each do |c|
|
|
1793
|
-
expect(calculator.infer(c).is_a?(
|
|
2009
|
+
expect(calculator.infer(c).is_a?(PType)).to eq(true)
|
|
1794
2010
|
end
|
|
1795
2011
|
end
|
|
1796
2012
|
|
|
1797
2013
|
it 'should infer PType as the type of PType (meta regression short-circuit)' do
|
|
1798
|
-
expect(calculator.infer(
|
|
2014
|
+
expect(calculator.infer(PType::DEFAULT).is_a?(PType)).to eq(true)
|
|
1799
2015
|
end
|
|
1800
2016
|
|
|
1801
2017
|
it 'computes instance? to be true if parameterized and type match' do
|
|
1802
|
-
int_t =
|
|
1803
|
-
type_t =
|
|
1804
|
-
type_type_t =
|
|
2018
|
+
int_t = PIntegerType::DEFAULT
|
|
2019
|
+
type_t = TypeFactory.type_type(int_t)
|
|
2020
|
+
type_type_t = TypeFactory.type_type(type_t)
|
|
1805
2021
|
expect(calculator.instance?(type_type_t, type_t)).to eq(true)
|
|
1806
2022
|
end
|
|
1807
2023
|
|
|
1808
2024
|
it 'computes instance? to be false if parameterized and type do not match' do
|
|
1809
|
-
int_t =
|
|
1810
|
-
string_t =
|
|
1811
|
-
type_t =
|
|
1812
|
-
type_t2 =
|
|
1813
|
-
type_type_t =
|
|
2025
|
+
int_t = PIntegerType::DEFAULT
|
|
2026
|
+
string_t = PStringType::DEFAULT
|
|
2027
|
+
type_t = TypeFactory.type_type(int_t)
|
|
2028
|
+
type_t2 = TypeFactory.type_type(string_t)
|
|
2029
|
+
type_type_t = TypeFactory.type_type(type_t)
|
|
1814
2030
|
# i.e. Type[Integer] =~ Type[Type[Integer]] # false
|
|
1815
2031
|
expect(calculator.instance?(type_type_t, type_t2)).to eq(false)
|
|
1816
2032
|
end
|
|
1817
2033
|
|
|
1818
2034
|
it 'computes instance? to be true if unparameterized and matched against a type[?]' do
|
|
1819
|
-
int_t =
|
|
1820
|
-
type_t =
|
|
1821
|
-
expect(calculator.instance?(
|
|
2035
|
+
int_t = PIntegerType::DEFAULT
|
|
2036
|
+
type_t = TypeFactory.type_type(int_t)
|
|
2037
|
+
expect(calculator.instance?(PType::DEFAULT, type_t)).to eq(true)
|
|
1822
2038
|
end
|
|
1823
2039
|
end
|
|
1824
2040
|
|
|
1825
|
-
context
|
|
1826
|
-
it
|
|
1827
|
-
t =
|
|
1828
|
-
t.
|
|
1829
|
-
t.to = 10
|
|
1830
|
-
expect(calculator.enumerable(t).respond_to?(:each)).to eq(true)
|
|
2041
|
+
context 'when asking for an iterable ' do
|
|
2042
|
+
it 'should produce an iterable for an Integer range that is finite' do
|
|
2043
|
+
t = PIntegerType.new(1, 10)
|
|
2044
|
+
expect(calculator.iterable(t).respond_to?(:each)).to eq(true)
|
|
1831
2045
|
end
|
|
1832
2046
|
|
|
1833
|
-
it
|
|
1834
|
-
t =
|
|
1835
|
-
t.
|
|
1836
|
-
t.to = 10
|
|
1837
|
-
expect(calculator.enumerable(t)).to eq(nil)
|
|
2047
|
+
it 'should not produce an iterable for an Integer range that has an infinite side' do
|
|
2048
|
+
t = PIntegerType.new(nil, 10)
|
|
2049
|
+
expect(calculator.iterable(t)).to eq(nil)
|
|
1838
2050
|
|
|
1839
|
-
t =
|
|
1840
|
-
t.
|
|
1841
|
-
t.to = nil
|
|
1842
|
-
expect(calculator.enumerable(t)).to eq(nil)
|
|
2051
|
+
t = PIntegerType.new(1, nil)
|
|
2052
|
+
expect(calculator.iterable(t)).to eq(nil)
|
|
1843
2053
|
end
|
|
1844
2054
|
|
|
1845
|
-
it
|
|
2055
|
+
it 'all but Integer range are not iterable' do
|
|
1846
2056
|
[Object, Numeric, Float, String, Regexp, Array, Hash].each do |t|
|
|
1847
|
-
expect(calculator.
|
|
2057
|
+
expect(calculator.iterable(calculator.type(t))).to eq(nil)
|
|
1848
2058
|
end
|
|
1849
2059
|
end
|
|
1850
2060
|
end
|
|
1851
2061
|
|
|
1852
|
-
context
|
|
1853
|
-
it
|
|
2062
|
+
context 'when dealing with different types of inference' do
|
|
2063
|
+
it 'an instance specific inference is produced by infer' do
|
|
1854
2064
|
expect(calculator.infer(['a','b']).element_type.values).to eq(['a', 'b'])
|
|
1855
2065
|
end
|
|
1856
2066
|
|
|
1857
|
-
it
|
|
1858
|
-
expect(calculator.infer_generic(['a','b']).element_type
|
|
2067
|
+
it 'a generic inference is produced using infer_generic' do
|
|
2068
|
+
expect(calculator.infer_generic(['a','b']).element_type).to eql(string_t(range_t(1,1)))
|
|
1859
2069
|
end
|
|
1860
2070
|
|
|
1861
|
-
it
|
|
2071
|
+
it 'a generic result is created by generalize given an instance specific result for an Array' do
|
|
1862
2072
|
generic = calculator.infer(['a','b'])
|
|
1863
|
-
expect(generic.element_type.values).to eq(['a',
|
|
1864
|
-
|
|
1865
|
-
expect(generic.element_type
|
|
2073
|
+
expect(generic.element_type.values).to eq(['a','b'])
|
|
2074
|
+
generic = generic.generalize
|
|
2075
|
+
expect(generic.element_type).to eql(string_t(range_t(1,1)))
|
|
2076
|
+
end
|
|
2077
|
+
|
|
2078
|
+
it 'a generic result is created by generalize given an instance specific result for a Hash' do
|
|
2079
|
+
generic = calculator.infer({'a' =>1,'bcd' => 2})
|
|
2080
|
+
expect(generic.key_type.values.sort).to eq(['a', 'bcd'])
|
|
2081
|
+
expect(generic.value_type.from).to eq(1)
|
|
2082
|
+
expect(generic.value_type.to).to eq(2)
|
|
2083
|
+
generic = generic.generalize
|
|
2084
|
+
expect(generic.key_type.size_type).to eq(range_t(1,3))
|
|
2085
|
+
expect(generic.value_type.from).to eq(nil)
|
|
2086
|
+
expect(generic.value_type.to).to eq(nil)
|
|
2087
|
+
end
|
|
2088
|
+
|
|
2089
|
+
it 'ensures that Struct key types are not generalized' do
|
|
2090
|
+
generic = struct_t({'a' => object_t}).generalize
|
|
2091
|
+
expect(generic.to_s).to eq("Struct[{'a' => Any}]")
|
|
2092
|
+
generic = struct_t({not_undef_t('a') => object_t}).generalize
|
|
2093
|
+
expect(generic.to_s).to eq("Struct[{NotUndef['a'] => Any}]")
|
|
2094
|
+
generic = struct_t({optional_t('a') => string_t}).generalize
|
|
2095
|
+
expect(generic.to_s).to eq("Struct[{Optional['a'] => String}]")
|
|
1866
2096
|
end
|
|
1867
2097
|
|
|
1868
|
-
it
|
|
1869
|
-
generic =
|
|
1870
|
-
expect(generic.
|
|
1871
|
-
expect(generic.element_type.from).to eq(1)
|
|
1872
|
-
expect(generic.element_type.to).to eq(2)
|
|
1873
|
-
calculator.generalize!(generic)
|
|
1874
|
-
expect(generic.key_type.values).to eq([])
|
|
1875
|
-
expect(generic.element_type.from).to eq(nil)
|
|
1876
|
-
expect(generic.element_type.to).to eq(nil)
|
|
2098
|
+
it 'ensures that Struct value types are generalized' do
|
|
2099
|
+
generic = struct_t({'a' => range_t(1, 3)}).generalize
|
|
2100
|
+
expect(generic.to_s).to eq("Struct[{'a' => Integer}]")
|
|
1877
2101
|
end
|
|
1878
2102
|
|
|
1879
2103
|
it "does not reduce by combining types when using infer_set" do
|
|
1880
2104
|
element_type = calculator.infer(['a','b',1,2]).element_type
|
|
1881
|
-
expect(element_type.class).to eq(
|
|
2105
|
+
expect(element_type.class).to eq(PScalarType)
|
|
1882
2106
|
inferred_type = calculator.infer_set(['a','b',1,2])
|
|
1883
|
-
expect(inferred_type.class).to eq(
|
|
2107
|
+
expect(inferred_type.class).to eq(PTupleType)
|
|
1884
2108
|
element_types = inferred_type.types
|
|
1885
|
-
expect(element_types[0].class).to eq(
|
|
1886
|
-
expect(element_types[1].class).to eq(
|
|
1887
|
-
expect(element_types[2].class).to eq(
|
|
1888
|
-
expect(element_types[3].class).to eq(
|
|
2109
|
+
expect(element_types[0].class).to eq(PStringType)
|
|
2110
|
+
expect(element_types[1].class).to eq(PStringType)
|
|
2111
|
+
expect(element_types[2].class).to eq(PIntegerType)
|
|
2112
|
+
expect(element_types[3].class).to eq(PIntegerType)
|
|
1889
2113
|
end
|
|
1890
2114
|
|
|
1891
|
-
it
|
|
2115
|
+
it 'does not reduce by combining types when using infer_set and values are undef' do
|
|
1892
2116
|
element_type = calculator.infer(['a',nil]).element_type
|
|
1893
|
-
expect(element_type.class).to eq(
|
|
2117
|
+
expect(element_type.class).to eq(PStringType)
|
|
1894
2118
|
inferred_type = calculator.infer_set(['a',nil])
|
|
1895
|
-
expect(inferred_type.class).to eq(
|
|
2119
|
+
expect(inferred_type.class).to eq(PTupleType)
|
|
1896
2120
|
element_types = inferred_type.types
|
|
1897
|
-
expect(element_types[0].class).to eq(
|
|
1898
|
-
expect(element_types[1].class).to eq(
|
|
2121
|
+
expect(element_types[0].class).to eq(PStringType)
|
|
2122
|
+
expect(element_types[1].class).to eq(PUndefType)
|
|
2123
|
+
end
|
|
2124
|
+
|
|
2125
|
+
it 'infers on an empty Array produces Array[Unit,0,0]' do
|
|
2126
|
+
inferred_type = calculator.infer([])
|
|
2127
|
+
expect(inferred_type.element_type.class).to eq(PUnitType)
|
|
2128
|
+
expect(inferred_type.size_range).to eq([0, 0])
|
|
2129
|
+
end
|
|
2130
|
+
|
|
2131
|
+
it 'infer_set on an empty Array produces Array[Unit,0,0]' do
|
|
2132
|
+
inferred_type = calculator.infer_set([])
|
|
2133
|
+
expect(inferred_type.element_type.class).to eq(PUnitType)
|
|
2134
|
+
expect(inferred_type.size_range).to eq([0, 0])
|
|
1899
2135
|
end
|
|
1900
2136
|
end
|
|
1901
2137
|
|
|
@@ -1921,8 +2157,7 @@ describe 'The type calculator' do
|
|
|
1921
2157
|
|
|
1922
2158
|
it 'with args array' do
|
|
1923
2159
|
required = callable_t(string_t)
|
|
1924
|
-
given = array_t(string_t)
|
|
1925
|
-
factory.constrain_size(given, 1, 1)
|
|
2160
|
+
given = array_t(string_t, range_t(1, 1))
|
|
1926
2161
|
expect(calculator.callable?(required, given)).to eq(true)
|
|
1927
2162
|
end
|
|
1928
2163
|
end
|
|
@@ -1981,7 +2216,7 @@ describe 'The type calculator' do
|
|
|
1981
2216
|
end
|
|
1982
2217
|
|
|
1983
2218
|
matcher :be_assignable_to do |type|
|
|
1984
|
-
calc =
|
|
2219
|
+
calc = TypeCalculator.singleton
|
|
1985
2220
|
|
|
1986
2221
|
match do |actual|
|
|
1987
2222
|
calc.assignable?(type, actual)
|
|
@@ -1995,5 +2230,6 @@ describe 'The type calculator' do
|
|
|
1995
2230
|
"#{calc.string(actual)} is assignable to #{calc.string(type)} when it should not"
|
|
1996
2231
|
end
|
|
1997
2232
|
end
|
|
1998
|
-
|
|
2233
|
+
end
|
|
2234
|
+
end
|
|
1999
2235
|
end
|