puppet 4.1.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COMMITTERS.md +2 -2
- data/CONTRIBUTING.md +51 -10
- data/Gemfile +27 -14
- data/LICENSE +3 -3
- data/MAINTAINERS +66 -0
- data/README.md +9 -11
- data/Rakefile +36 -0
- data/conf/auth.conf +23 -2
- data/conf/fileserver.conf +7 -12
- data/conf/hiera.yaml +11 -0
- data/conf/puppet.conf +1 -1
- data/ext/README.environment +1 -1
- data/ext/build_defaults.yaml +2 -2
- data/ext/debian/README.source +1 -1
- data/ext/debian/control +3 -5
- data/ext/debian/copyright +4 -4
- data/ext/debian/puppet-common.install +0 -1
- data/ext/debian/puppet-common.manpages +0 -2
- data/ext/debian/puppet.init +0 -1
- data/ext/debian/puppet.logrotate +14 -5
- data/ext/debian/puppetmaster.README.debian +11 -9
- data/ext/envpuppet +2 -2
- data/ext/hiera/hiera.yaml +15 -0
- data/ext/ips/puppetagent.xml +1 -1
- data/ext/ips/puppetmaster.xml +1 -1
- data/ext/logcheck/puppet +1 -1
- data/ext/osx/puppet.plist +30 -0
- data/ext/project_data.yaml +29 -16
- data/ext/puppet-test +3 -27
- data/ext/rack/config.ru +2 -2
- 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 -14
- 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 +10 -15
- data/ext/yaml_nodes.rb +1 -1
- data/install.rb +99 -66
- data/lib/hiera/puppet_function.rb +17 -18
- data/lib/hiera/scope.rb +12 -14
- data/lib/hiera_puppet.rb +6 -14
- data/lib/puppet/agent/disabler.rb +3 -3
- data/lib/puppet/agent/locker.rb +12 -3
- data/lib/puppet/agent.rb +35 -39
- data/lib/puppet/application/agent.rb +48 -25
- data/lib/puppet/application/apply.rb +63 -29
- data/lib/puppet/application/ca.rb +1 -0
- data/lib/puppet/application/cert.rb +54 -5
- data/lib/puppet/application/describe.rb +2 -2
- data/lib/puppet/application/device.rb +72 -47
- data/lib/puppet/application/doc.rb +9 -9
- data/lib/puppet/application/face_base.rb +11 -12
- data/lib/puppet/application/filebucket.rb +84 -10
- data/lib/puppet/application/generate.rb +5 -0
- data/lib/puppet/application/lookup.rb +357 -0
- data/lib/puppet/application/master.rb +21 -25
- data/lib/puppet/application/resource.rb +22 -23
- data/lib/puppet/application.rb +31 -15
- data/lib/puppet/application_support.rb +1 -1
- data/lib/puppet/compilable_resource_type.rb +15 -0
- data/lib/puppet/configurer/downloader.rb +2 -2
- data/lib/puppet/configurer/fact_handler.rb +13 -4
- data/lib/puppet/configurer/plugin_handler.rb +7 -5
- data/lib/puppet/configurer.rb +192 -51
- data/lib/puppet/context/trusted_information.rb +22 -2
- data/lib/puppet/context.rb +20 -5
- data/lib/puppet/daemon.rb +17 -13
- data/lib/puppet/data_binding.rb +4 -2
- data/lib/puppet/defaults.rb +298 -130
- data/lib/puppet/environments.rb +104 -9
- data/lib/puppet/error.rb +5 -1
- data/lib/puppet/etc.rb +161 -0
- data/lib/puppet/external/dot.rb +1 -1
- data/lib/puppet/external/pson/common.rb +4 -0
- data/lib/puppet/face/ca.rb +56 -44
- data/lib/puppet/face/catalog/select.rb +4 -4
- data/lib/puppet/face/catalog.rb +3 -3
- data/lib/puppet/face/certificate.rb +28 -22
- data/lib/puppet/face/certificate_request.rb +3 -1
- data/lib/puppet/face/certificate_revocation_list.rb +3 -1
- data/lib/puppet/face/config.rb +12 -12
- data/lib/puppet/face/epp.rb +96 -50
- data/lib/puppet/face/facts.rb +5 -5
- 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 +37 -29
- data/lib/puppet/face/key.rb +4 -3
- data/lib/puppet/face/man.rb +12 -10
- data/lib/puppet/face/module/build.rb +7 -7
- data/lib/puppet/face/module/changes.rb +8 -7
- data/lib/puppet/face/module/generate.rb +25 -25
- data/lib/puppet/face/module/install.rb +19 -15
- data/lib/puppet/face/module/list.rb +16 -12
- data/lib/puppet/face/module/search.rb +4 -4
- data/lib/puppet/face/module/uninstall.rb +13 -10
- data/lib/puppet/face/module/upgrade.rb +11 -7
- data/lib/puppet/face/module.rb +3 -3
- data/lib/puppet/face/node/clean.rb +8 -8
- data/lib/puppet/face/node.rb +6 -6
- data/lib/puppet/face/parser.rb +28 -25
- data/lib/puppet/face/plugin.rb +14 -21
- data/lib/puppet/face/report.rb +10 -10
- data/lib/puppet/face/resource.rb +13 -13
- data/lib/puppet/face/status.rb +9 -6
- data/lib/puppet/feature/base.rb +13 -5
- data/lib/puppet/feature/cfpropertylist.rb +3 -0
- data/lib/puppet/feature/eventlog.rb +1 -1
- data/lib/puppet/feature/hiera_eyaml.rb +3 -0
- data/lib/puppet/feature/hocon.rb +3 -0
- data/lib/puppet/feature/telnet.rb +9 -0
- data/lib/puppet/file_bucket/dipper.rb +62 -6
- data/lib/puppet/file_bucket/file.rb +4 -17
- data/lib/puppet/file_serving/base.rb +3 -3
- data/lib/puppet/file_serving/configuration/parser.rb +12 -12
- data/lib/puppet/file_serving/configuration.rb +3 -3
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/file_serving/fileset.rb +7 -5
- data/lib/puppet/file_serving/http_metadata.rb +46 -0
- data/lib/puppet/file_serving/metadata.rb +22 -6
- data/lib/puppet/file_serving/mount/file.rb +6 -6
- data/lib/puppet/file_serving/mount/modules.rb +1 -1
- data/lib/puppet/file_serving/mount.rb +1 -1
- data/lib/puppet/file_serving/terminus_selector.rb +3 -1
- data/lib/puppet/file_system/file_impl.rb +9 -4
- data/lib/puppet/file_system/memory_impl.rb +6 -2
- data/lib/puppet/file_system/path_pattern.rb +7 -6
- data/lib/puppet/file_system/uniquefile.rb +5 -5
- data/lib/puppet/file_system/windows.rb +31 -16
- data/lib/puppet/file_system.rb +33 -5
- data/lib/puppet/forge/cache.rb +1 -0
- data/lib/puppet/forge/errors.rb +12 -12
- data/lib/puppet/forge/repository.rb +5 -36
- data/lib/puppet/forge.rb +17 -15
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/annotate.rb +108 -0
- data/lib/puppet/functions/assert_type.rb +53 -19
- data/lib/puppet/functions/binary_file.rb +19 -0
- data/lib/puppet/functions/break.rb +22 -0
- data/lib/puppet/functions/call.rb +42 -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 +92 -62
- data/lib/puppet/functions/dig.rb +23 -0
- data/lib/puppet/functions/each.rb +89 -39
- data/lib/puppet/functions/emerg.rb +14 -0
- data/lib/puppet/functions/epp.rb +29 -37
- data/lib/puppet/functions/err.rb +14 -0
- data/lib/puppet/functions/eyaml_lookup_key.rb +94 -0
- data/lib/puppet/functions/filter.rb +64 -38
- data/lib/puppet/functions/find_file.rb +31 -0
- data/lib/puppet/functions/hiera.rb +83 -3
- data/lib/puppet/functions/hiera_array.rb +73 -4
- data/lib/puppet/functions/hiera_hash.rb +82 -2
- data/lib/puppet/functions/hiera_include.rb +93 -6
- data/lib/puppet/functions/hocon_data.rb +41 -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 +33 -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 +32 -14
- 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 +112 -71
- data/lib/puppet/functions/regsubst.rb +22 -25
- data/lib/puppet/functions/require.rb +37 -0
- data/lib/puppet/functions/return.rb +22 -0
- data/lib/puppet/functions/reverse_each.rb +25 -0
- data/lib/puppet/functions/scanf.rb +15 -18
- data/lib/puppet/functions/slice.rb +25 -39
- data/lib/puppet/functions/split.rb +2 -2
- data/lib/puppet/functions/step.rb +26 -0
- data/lib/puppet/functions/strftime.rb +43 -0
- data/lib/puppet/functions/then.rb +14 -0
- data/lib/puppet/functions/type.rb +31 -0
- data/lib/puppet/functions/unique.rb +132 -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 +42 -0
- data/lib/puppet/functions.rb +194 -74
- data/lib/puppet/generate/models/type/property.rb +70 -0
- data/lib/puppet/generate/models/type/type.rb +62 -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/relationship_graph.rb +4 -1
- data/lib/puppet/graph/simple_graph.rb +51 -74
- data/lib/puppet/indirector/catalog/compiler.rb +241 -37
- data/lib/puppet/indirector/catalog/json.rb +18 -0
- data/lib/puppet/indirector/certificate/disabled_ca.rb +1 -1
- data/lib/puppet/indirector/certificate_request/ca.rb +3 -3
- data/lib/puppet/indirector/certificate_request/disabled_ca.rb +1 -1
- data/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +1 -1
- data/lib/puppet/indirector/certificate_status/file.rb +6 -6
- data/lib/puppet/indirector/data_binding/none.rb +4 -1
- data/lib/puppet/indirector/exec.rb +2 -2
- data/lib/puppet/indirector/face.rb +24 -19
- data/lib/puppet/indirector/facts/facter.rb +3 -6
- data/lib/puppet/indirector/file_bucket_file/file.rb +142 -29
- data/lib/puppet/indirector/file_content/http.rb +15 -0
- data/lib/puppet/indirector/file_metadata/http.rb +27 -0
- data/lib/puppet/indirector/file_server.rb +10 -2
- data/lib/puppet/indirector/generic_http.rb +16 -0
- data/lib/puppet/indirector/hiera.rb +12 -4
- data/lib/puppet/indirector/indirection.rb +25 -18
- data/lib/puppet/indirector/json.rb +11 -12
- data/lib/puppet/indirector/key/ca.rb +2 -2
- data/lib/puppet/indirector/key/disabled_ca.rb +1 -1
- data/lib/puppet/indirector/key/file.rb +4 -3
- data/lib/puppet/indirector/ldap.rb +6 -5
- data/lib/puppet/indirector/memory.rb +1 -1
- data/lib/puppet/indirector/msgpack.rb +9 -8
- data/lib/puppet/indirector/node/exec.rb +9 -7
- data/lib/puppet/indirector/node/ldap.rb +10 -8
- data/lib/puppet/indirector/node/plain.rb +2 -1
- data/lib/puppet/indirector/node/write_only_yaml.rb +6 -1
- data/lib/puppet/indirector/node/yaml.rb +0 -9
- data/lib/puppet/indirector/report/processor.rb +2 -2
- data/lib/puppet/indirector/report/rest.rb +13 -0
- data/lib/puppet/indirector/request.rb +40 -23
- data/lib/puppet/indirector/resource/ral.rb +1 -1
- data/lib/puppet/indirector/resource/validator.rb +1 -1
- data/lib/puppet/indirector/rest.rb +103 -10
- data/lib/puppet/indirector/ssl_file.rb +33 -12
- data/lib/puppet/indirector/terminus.rb +7 -7
- data/lib/puppet/indirector/yaml.rb +5 -5
- data/lib/puppet/indirector.rb +2 -2
- data/lib/puppet/info_service/class_information_service.rb +110 -0
- data/lib/puppet/info_service.rb +7 -0
- data/lib/puppet/interface/documentation.rb +1 -1
- data/lib/puppet/interface/face_collection.rb +7 -2
- data/lib/puppet/interface.rb +12 -4
- data/lib/puppet/loaders.rb +5 -0
- data/lib/puppet/metatype/manager.rb +25 -8
- data/lib/puppet/module.rb +73 -34
- data/lib/puppet/module_tool/applications/application.rb +8 -9
- data/lib/puppet/module_tool/applications/builder.rb +9 -9
- data/lib/puppet/module_tool/applications/checksummer.rb +2 -2
- data/lib/puppet/module_tool/applications/installer.rb +21 -20
- data/lib/puppet/module_tool/applications/searcher.rb +1 -1
- data/lib/puppet/module_tool/applications/uninstaller.rb +2 -1
- data/lib/puppet/module_tool/applications/unpacker.rb +4 -4
- data/lib/puppet/module_tool/applications/upgrader.rb +19 -18
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/contents_description.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +0 -1
- data/lib/puppet/module_tool/errors/installer.rb +23 -23
- data/lib/puppet/module_tool/errors/shared.rb +44 -42
- data/lib/puppet/module_tool/errors/uninstaller.rb +13 -9
- data/lib/puppet/module_tool/errors/upgrader.rb +11 -11
- data/lib/puppet/module_tool/install_directory.rb +1 -1
- data/lib/puppet/module_tool/installed_modules.rb +10 -10
- data/lib/puppet/module_tool/local_tarball.rb +7 -7
- data/lib/puppet/module_tool/metadata.rb +47 -21
- data/lib/puppet/module_tool/shared_behaviors.rb +6 -6
- data/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +14 -3
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +48 -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 +3 -3
- 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/tar.rb +5 -4
- data/lib/puppet/module_tool.rb +11 -7
- data/lib/puppet/network/auth_config_parser.rb +13 -12
- data/lib/puppet/network/authconfig.rb +23 -3
- data/lib/puppet/network/authorization.rb +8 -1
- data/lib/puppet/network/authstore.rb +2 -2
- data/lib/puppet/network/format.rb +7 -7
- data/lib/puppet/network/format_handler.rb +12 -9
- data/lib/puppet/network/format_support.rb +11 -5
- data/lib/puppet/network/formats.rb +38 -27
- data/lib/puppet/network/http/api/indirected_routes.rb +86 -58
- data/lib/puppet/network/http/api/master/v3/environment.rb +82 -0
- data/lib/puppet/network/http/api/master/v3.rb +7 -1
- data/lib/puppet/network/http/compression.rb +12 -8
- data/lib/puppet/network/http/connection.rb +21 -15
- data/lib/puppet/network/http/error.rb +14 -10
- data/lib/puppet/network/http/factory.rb +8 -4
- data/lib/puppet/network/http/handler.rb +11 -6
- data/lib/puppet/network/http/issues.rb +1 -0
- data/lib/puppet/network/http/pool.rb +10 -1
- data/lib/puppet/network/http/rack/rest.rb +27 -3
- data/lib/puppet/network/http/rack.rb +2 -2
- data/lib/puppet/network/http/request.rb +34 -20
- data/lib/puppet/network/http/response.rb +13 -1
- data/lib/puppet/network/http/webrick/rest.rb +2 -2
- data/lib/puppet/network/http/webrick.rb +7 -6
- data/lib/puppet/network/rights.rb +7 -17
- data/lib/puppet/network/server.rb +2 -2
- data/lib/puppet/node/environment.rb +69 -17
- data/lib/puppet/node/facts.rb +1 -6
- data/lib/puppet/node.rb +45 -18
- data/lib/puppet/parameter/boolean.rb +1 -1
- data/lib/puppet/parameter/package_options.rb +1 -1
- data/lib/puppet/parameter/path.rb +3 -3
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parameter/value_collection.rb +4 -4
- data/lib/puppet/parameter.rb +24 -29
- data/lib/puppet/parser/ast/node.rb +1 -1
- data/lib/puppet/parser/ast/pops_bridge.rb +99 -29
- 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 +57 -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 +345 -131
- data/lib/puppet/parser/e4_parser_adapter.rb +14 -14
- data/lib/puppet/parser/environment_compiler.rb +199 -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 +49 -25
- data/lib/puppet/parser/functions/defined.rb +106 -93
- data/lib/puppet/parser/functions/dig.rb +29 -0
- data/lib/puppet/parser/functions/each.rb +86 -28
- data/lib/puppet/parser/functions/epp.rb +30 -38
- data/lib/puppet/parser/functions/file.rb +1 -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/generate.rb +5 -4
- 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 +5 -8
- data/lib/puppet/parser/functions/inline_epp.rb +36 -61
- data/lib/puppet/parser/functions/inline_template.rb +3 -3
- 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 +939 -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 +39 -21
- data/lib/puppet/parser/parser_factory.rb +0 -30
- data/lib/puppet/parser/relationship.rb +49 -20
- data/lib/puppet/parser/resource/param.rb +0 -3
- data/lib/puppet/parser/resource.rb +165 -50
- data/lib/puppet/parser/scope.rb +412 -202
- data/lib/puppet/parser/templatewrapper.rb +2 -2
- data/lib/puppet/parser/type_loader.rb +2 -2
- data/lib/puppet/parser.rb +3 -1
- data/lib/puppet/plugins/configuration.rb +15 -58
- data/lib/puppet/plugins/syntax_checkers.rb +6 -11
- data/lib/puppet/pops/adaptable.rb +12 -7
- data/lib/puppet/pops/adapters.rb +102 -73
- data/lib/puppet/pops/evaluator/access_operator.rb +233 -163
- data/lib/puppet/pops/evaluator/callable_signature.rb +7 -0
- data/lib/puppet/pops/evaluator/closure.rb +231 -115
- data/lib/puppet/pops/evaluator/collector_transformer.rb +50 -26
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +2 -2
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +4 -5
- data/lib/puppet/pops/evaluator/compare_operator.rb +72 -15
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +10 -9
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +236 -140
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +2 -9
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +82 -0
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
- data/lib/puppet/pops/evaluator/puppet_proc.rb +1 -1
- data/lib/puppet/pops/evaluator/relationship_operator.rb +44 -20
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +74 -49
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +117 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +134 -88
- data/lib/puppet/pops/functions/dispatch.rb +28 -13
- data/lib/puppet/pops/functions/dispatcher.rb +15 -20
- data/lib/puppet/pops/functions/function.rb +30 -4
- data/lib/puppet/pops/issue_reporter.rb +7 -5
- data/lib/puppet/pops/issues.rb +319 -131
- data/lib/puppet/pops/label_provider.rb +18 -4
- data/lib/puppet/pops/loader/base_loader.rb +74 -20
- data/lib/puppet/pops/loader/dependency_loader.rb +27 -2
- data/lib/puppet/pops/loader/gem_support.rb +2 -2
- data/lib/puppet/pops/loader/loader.rb +47 -49
- data/lib/puppet/pops/loader/loader_paths.rb +48 -2
- data/lib/puppet/pops/loader/module_loaders.rb +109 -27
- data/lib/puppet/pops/loader/null_loader.rb +17 -1
- data/lib/puppet/pops/loader/predefined_loader.rb +24 -0
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +34 -28
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +79 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +19 -7
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +96 -0
- data/lib/puppet/pops/loader/static_loader.rb +111 -41
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +93 -0
- data/lib/puppet/pops/loader/typed_name.rb +54 -0
- data/lib/puppet/pops/loaders.rb +208 -28
- data/lib/puppet/pops/lookup/configured_data_provider.rb +93 -0
- data/lib/puppet/pops/lookup/context.rb +200 -0
- data/lib/puppet/pops/lookup/data_adapter.rb +27 -0
- data/lib/puppet/pops/lookup/data_dig_function_provider.rb +145 -0
- data/lib/puppet/pops/lookup/data_hash_function_provider.rb +126 -0
- data/lib/puppet/pops/lookup/data_provider.rb +92 -0
- data/lib/puppet/pops/lookup/environment_data_provider.rb +35 -0
- data/lib/puppet/pops/lookup/explainer.rb +594 -0
- data/lib/puppet/pops/lookup/function_provider.rb +110 -0
- data/lib/puppet/pops/lookup/global_data_provider.rb +75 -0
- data/lib/puppet/pops/lookup/hiera_config.rb +761 -0
- data/lib/puppet/pops/lookup/interpolation.rb +154 -0
- data/lib/puppet/pops/lookup/invocation.rb +261 -0
- data/lib/puppet/pops/lookup/location_resolver.rb +99 -0
- data/lib/puppet/pops/lookup/lookup_adapter.rb +471 -0
- data/lib/puppet/pops/lookup/lookup_key.rb +99 -0
- data/lib/puppet/pops/lookup/lookup_key_function_provider.rb +92 -0
- data/lib/puppet/pops/lookup/module_data_provider.rb +89 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +92 -0
- data/lib/puppet/pops/lookup.rb +49 -49
- data/lib/puppet/pops/merge_strategy.rb +197 -46
- data/lib/puppet/pops/migration/migration_checker.rb +4 -0
- data/lib/puppet/pops/model/ast.pp +692 -0
- data/lib/puppet/pops/model/ast.rb +4833 -0
- data/lib/puppet/pops/model/ast_transformer.rb +15 -9
- data/lib/puppet/pops/model/factory.rb +547 -528
- data/lib/puppet/pops/model/model_label_provider.rb +31 -8
- data/lib/puppet/pops/model/model_tree_dumper.rb +52 -7
- data/lib/puppet/pops/parser/code_merger.rb +13 -1
- data/lib/puppet/pops/parser/egrammar.ra +185 -61
- data/lib/puppet/pops/parser/eparser.rb +1819 -1348
- data/lib/puppet/pops/parser/epp_support.rb +15 -9
- data/lib/puppet/pops/parser/evaluating_parser.rb +25 -17
- data/lib/puppet/pops/parser/heredoc_support.rb +16 -13
- data/lib/puppet/pops/parser/interpolation_support.rb +11 -4
- data/lib/puppet/pops/parser/lexer2.rb +459 -399
- data/lib/puppet/pops/parser/lexer_support.rb +85 -7
- data/lib/puppet/pops/parser/locator.rb +86 -9
- data/lib/puppet/pops/parser/parser_support.rb +50 -42
- data/lib/puppet/pops/parser/slurp_support.rb +23 -14
- data/lib/puppet/pops/patterns.rb +16 -1
- data/lib/puppet/pops/pcore.rb +103 -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/semantic_error.rb +12 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +176 -0
- data/lib/puppet/pops/serialization/abstract_writer.rb +215 -0
- data/lib/puppet/pops/serialization/deserializer.rb +80 -0
- data/lib/puppet/pops/serialization/extension.rb +157 -0
- data/lib/puppet/pops/serialization/from_data_converter.rb +181 -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/json_path.rb +126 -0
- data/lib/puppet/pops/serialization/object.rb +71 -0
- data/lib/puppet/pops/serialization/serializer.rb +139 -0
- data/lib/puppet/pops/serialization/time_factory.rb +67 -0
- data/lib/puppet/pops/serialization/to_data_converter.rb +292 -0
- data/lib/puppet/pops/serialization.rb +41 -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/annotation.rb +71 -0
- data/lib/puppet/pops/types/class_loader.rb +29 -29
- 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 +226 -0
- data/lib/puppet/pops/types/p_meta_type.rb +87 -0
- data/lib/puppet/pops/types/p_object_type.rb +925 -0
- data/lib/puppet/pops/types/p_runtime_type.rb +115 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +191 -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 +192 -0
- data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
- data/lib/puppet/pops/types/p_type_set_type.rb +360 -0
- data/lib/puppet/pops/types/puppet_object.rb +26 -0
- data/lib/puppet/pops/types/recursion_guard.rb +136 -0
- data/lib/puppet/pops/types/ruby_generator.rb +439 -0
- data/lib/puppet/pops/types/ruby_method.rb +31 -0
- data/lib/puppet/pops/types/string_converter.rb +1099 -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 +251 -1332
- data/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/lib/puppet/pops/types/type_factory.rb +252 -171
- data/lib/puppet/pops/types/type_formatter.rb +734 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1106 -0
- data/lib/puppet/pops/types/type_parser.rb +374 -276
- data/lib/puppet/pops/types/type_set_reference.rb +59 -0
- data/lib/puppet/pops/types/types.rb +3286 -307
- data/lib/puppet/pops/utils.rb +7 -30
- data/lib/puppet/pops/validation/checker4_0.rb +305 -109
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +13 -5
- data/lib/puppet/pops/validation.rb +25 -16
- data/lib/puppet/pops/visitor.rb +30 -6
- data/lib/puppet/pops.rb +42 -57
- data/lib/puppet/property/ensure.rb +4 -4
- data/lib/puppet/property/list.rb +1 -10
- data/lib/puppet/property.rb +84 -21
- data/lib/puppet/provider/aixobject.rb +11 -11
- data/lib/puppet/provider/augeas/augeas.rb +89 -34
- data/lib/puppet/provider/command.rb +1 -1
- data/lib/puppet/provider/cron/crontab.rb +3 -3
- data/lib/puppet/provider/exec/posix.rb +4 -4
- data/lib/puppet/provider/exec/windows.rb +4 -4
- data/lib/puppet/provider/exec.rb +14 -7
- data/lib/puppet/provider/file/posix.rb +5 -5
- data/lib/puppet/provider/file/windows.rb +4 -4
- data/lib/puppet/provider/group/aix.rb +6 -6
- data/lib/puppet/provider/group/directoryservice.rb +10 -0
- data/lib/puppet/provider/group/groupadd.rb +2 -2
- data/lib/puppet/provider/group/pw.rb +2 -1
- data/lib/puppet/provider/group/windows_adsi.rb +15 -3
- data/lib/puppet/provider/host/parsed.rb +1 -1
- data/lib/puppet/provider/macauthorization/macauthorization.rb +20 -19
- data/lib/puppet/provider/mailalias/aliases.rb +1 -1
- data/lib/puppet/provider/maillist/mailman.rb +2 -2
- data/lib/puppet/provider/mcx/mcxcontent.rb +6 -5
- data/lib/puppet/provider/mount/parsed.rb +24 -8
- data/lib/puppet/provider/mount.rb +2 -1
- data/lib/puppet/provider/naginator.rb +1 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +65 -72
- data/lib/puppet/provider/nameservice.rb +40 -17
- data/lib/puppet/provider/network_device.rb +2 -1
- data/lib/puppet/provider/package/aix.rb +5 -5
- data/lib/puppet/provider/package/appdmg.rb +7 -6
- data/lib/puppet/provider/package/apple.rb +2 -2
- data/lib/puppet/provider/package/apt.rb +4 -4
- data/lib/puppet/provider/package/aptitude.rb +1 -1
- data/lib/puppet/provider/package/aptrpm.rb +2 -2
- data/lib/puppet/provider/package/blastwave.rb +4 -4
- data/lib/puppet/provider/package/dnf.rb +46 -0
- data/lib/puppet/provider/package/dpkg.rb +3 -3
- data/lib/puppet/provider/package/fink.rb +3 -3
- data/lib/puppet/provider/package/freebsd.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +35 -9
- data/lib/puppet/provider/package/hpux.rb +1 -1
- data/lib/puppet/provider/package/nim.rb +17 -14
- data/lib/puppet/provider/package/openbsd.rb +11 -11
- data/lib/puppet/provider/package/opkg.rb +1 -1
- data/lib/puppet/provider/package/pacman.rb +20 -19
- data/lib/puppet/provider/package/pip.rb +72 -20
- data/lib/puppet/provider/package/pip3.rb +20 -0
- data/lib/puppet/provider/package/pkg.rb +21 -17
- data/lib/puppet/provider/package/pkgdmg.rb +12 -9
- data/lib/puppet/provider/package/pkgin.rb +6 -6
- data/lib/puppet/provider/package/pkgng.rb +16 -7
- data/lib/puppet/provider/package/pkgutil.rb +7 -7
- data/lib/puppet/provider/package/portage.rb +183 -35
- data/lib/puppet/provider/package/ports.rb +3 -3
- data/lib/puppet/provider/package/portupgrade.rb +4 -4
- data/lib/puppet/provider/package/puppet_gem.rb +0 -0
- data/lib/puppet/provider/package/rpm.rb +130 -21
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +4 -3
- data/lib/puppet/provider/package/tdnf.rb +28 -0
- data/lib/puppet/provider/package/up2date.rb +1 -1
- data/lib/puppet/provider/package/urpmi.rb +1 -1
- data/lib/puppet/provider/package/windows/exe_package.rb +10 -8
- data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
- data/lib/puppet/provider/package/windows/package.rb +12 -4
- data/lib/puppet/provider/package/windows.rb +5 -5
- data/lib/puppet/provider/package/yum.rb +73 -94
- data/lib/puppet/provider/package/zypper.rb +20 -1
- data/lib/puppet/provider/package.rb +6 -2
- data/lib/puppet/provider/parsedfile.rb +3 -3
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +7 -0
- data/lib/puppet/provider/selmodule/semodule.rb +20 -16
- data/lib/puppet/provider/service/base.rb +4 -3
- data/lib/puppet/provider/service/bsd.rb +9 -9
- data/lib/puppet/provider/service/daemontools.rb +5 -5
- data/lib/puppet/provider/service/debian.rb +14 -5
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/service/init.rb +20 -3
- data/lib/puppet/provider/service/launchd.rb +57 -19
- data/lib/puppet/provider/service/rcng.rb +51 -0
- data/lib/puppet/provider/service/redhat.rb +2 -1
- data/lib/puppet/provider/service/runit.rb +4 -4
- data/lib/puppet/provider/service/smf.rb +59 -8
- data/lib/puppet/provider/service/src.rb +66 -39
- data/lib/puppet/provider/service/systemd.rb +141 -22
- data/lib/puppet/provider/service/upstart.rb +1 -3
- 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 +12 -6
- data/lib/puppet/provider/user/directoryservice.rb +43 -66
- data/lib/puppet/provider/user/hpux.rb +1 -1
- data/lib/puppet/provider/user/ldap.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +1 -0
- data/lib/puppet/provider/user/user_role_add.rb +19 -2
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/provider/user/windows_adsi.rb +11 -5
- data/lib/puppet/provider/yumrepo/inifile.rb +12 -9
- 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 +11 -7
- data/lib/puppet/reference/configuration.rb +13 -5
- data/lib/puppet/reference/indirection.rb +2 -2
- data/lib/puppet/reference/metaparameter.rb +1 -1
- data/lib/puppet/reference/providers.rb +8 -9
- data/lib/puppet/reference/report.rb +9 -12
- data/lib/puppet/reference/type.rb +3 -3
- data/lib/puppet/relationship.rb +7 -9
- data/lib/puppet/reports/http.rb +6 -2
- data/lib/puppet/reports.rb +5 -1
- data/lib/puppet/resource/capability_finder.rb +128 -0
- data/lib/puppet/resource/catalog.rb +163 -47
- data/lib/puppet/resource/status.rb +34 -20
- data/lib/puppet/resource/type.rb +246 -97
- data/lib/puppet/resource/type_collection.rb +97 -17
- data/lib/puppet/resource.rb +241 -198
- data/lib/puppet/settings/array_setting.rb +1 -1
- data/lib/puppet/settings/autosign_setting.rb +1 -1
- data/lib/puppet/settings/base_setting.rb +9 -3
- data/lib/puppet/settings/boolean_setting.rb +1 -1
- data/lib/puppet/settings/config_file.rb +4 -3
- data/lib/puppet/settings/directory_setting.rb +6 -0
- data/lib/puppet/settings/duration_setting.rb +1 -1
- data/lib/puppet/settings/enum_setting.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +28 -8
- data/lib/puppet/settings/file_or_directory_setting.rb +6 -0
- data/lib/puppet/settings/file_setting.rb +22 -11
- data/lib/puppet/settings/ini_file.rb +2 -2
- data/lib/puppet/settings/priority_setting.rb +1 -1
- data/lib/puppet/settings/server_list_setting.rb +20 -0
- data/lib/puppet/settings/symbolic_enum_setting.rb +17 -0
- data/lib/puppet/settings/terminus_setting.rb +1 -1
- data/lib/puppet/settings/ttl_setting.rb +2 -2
- data/lib/puppet/settings.rb +99 -46
- data/lib/puppet/ssl/base.rb +16 -3
- data/lib/puppet/ssl/certificate.rb +1 -1
- data/lib/puppet/ssl/certificate_authority/interface.rb +172 -32
- data/lib/puppet/ssl/certificate_authority.rb +67 -31
- data/lib/puppet/ssl/certificate_factory.rb +5 -5
- data/lib/puppet/ssl/certificate_request.rb +19 -19
- data/lib/puppet/ssl/certificate_request_attributes.rb +3 -3
- data/lib/puppet/ssl/certificate_revocation_list.rb +3 -3
- data/lib/puppet/ssl/certificate_signer.rb +1 -1
- data/lib/puppet/ssl/configuration.rb +4 -1
- data/lib/puppet/ssl/host.rb +47 -25
- data/lib/puppet/ssl/inventory.rb +11 -4
- data/lib/puppet/ssl/key.rb +8 -4
- data/lib/puppet/ssl/oids.rb +48 -8
- data/lib/puppet/ssl/validator/default_validator.rb +6 -7
- data/lib/puppet/syntax_checkers/base64.rb +41 -0
- data/lib/puppet/syntax_checkers/json.rb +5 -7
- data/lib/puppet/test/test_helper.rb +21 -11
- data/lib/puppet/transaction/additional_resource_generator.rb +105 -11
- data/lib/puppet/transaction/event.rb +45 -7
- data/lib/puppet/transaction/event_manager.rb +7 -7
- data/lib/puppet/transaction/persistence.rb +84 -0
- data/lib/puppet/transaction/report.rb +113 -37
- data/lib/puppet/transaction/resource_harness.rb +99 -37
- data/lib/puppet/transaction.rb +100 -54
- data/lib/puppet/type/augeas.rb +15 -6
- data/lib/puppet/type/component.rb +11 -0
- data/lib/puppet/type/cron.rb +27 -44
- data/lib/puppet/type/exec.rb +82 -52
- 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 +37 -122
- data/lib/puppet/type/file/data_sync.rb +92 -0
- data/lib/puppet/type/file/ensure.rb +21 -18
- data/lib/puppet/type/file/group.rb +3 -3
- data/lib/puppet/type/file/mode.rb +10 -6
- data/lib/puppet/type/file/owner.rb +3 -3
- data/lib/puppet/type/file/selcontext.rb +19 -2
- data/lib/puppet/type/file/source.rb +134 -37
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/file.rb +159 -61
- data/lib/puppet/type/filebucket.rb +3 -8
- data/lib/puppet/type/group.rb +28 -10
- data/lib/puppet/type/host.rb +7 -7
- data/lib/puppet/type/interface.rb +9 -4
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/macauthorization.rb +2 -2
- data/lib/puppet/type/mailalias.rb +2 -18
- data/lib/puppet/type/maillist.rb +1 -1
- data/lib/puppet/type/mount.rb +22 -7
- data/lib/puppet/type/notify.rb +3 -1
- data/lib/puppet/type/package.rb +37 -17
- data/lib/puppet/type/resources.rb +7 -7
- data/lib/puppet/type/schedule.rb +14 -14
- data/lib/puppet/type/scheduled_task.rb +5 -5
- data/lib/puppet/type/service.rb +25 -1
- data/lib/puppet/type/ssh_authorized_key.rb +20 -30
- data/lib/puppet/type/sshkey.rb +9 -7
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/tidy.rb +22 -15
- data/lib/puppet/type/user.rb +80 -53
- data/lib/puppet/type/yumrepo.rb +31 -11
- data/lib/puppet/type/zone.rb +13 -13
- data/lib/puppet/type/zpool.rb +3 -3
- data/lib/puppet/type.rb +175 -47
- data/lib/puppet/util/at_fork/noop.rb +18 -0
- data/lib/puppet/util/at_fork/solaris.rb +158 -0
- data/lib/puppet/util/at_fork.rb +35 -0
- data/lib/puppet/util/autoload.rb +18 -13
- data/lib/puppet/util/backups.rb +6 -6
- data/lib/puppet/util/character_encoding.rb +98 -0
- data/lib/puppet/util/checksums.rb +74 -31
- data/lib/puppet/util/classgen.rb +5 -5
- data/lib/puppet/util/command_line/puppet_option_parser.rb +3 -3
- data/lib/puppet/util/command_line/trollop.rb +32 -32
- data/lib/puppet/util/command_line.rb +14 -6
- data/lib/puppet/util/diff.rb +1 -1
- data/lib/puppet/util/errors.rb +4 -4
- data/lib/puppet/util/execution.rb +42 -23
- data/lib/puppet/util/feature.rb +5 -5
- data/lib/puppet/util/fileparsing.rb +8 -8
- data/lib/puppet/util/filetype.rb +26 -20
- data/lib/puppet/util/http_proxy.rb +132 -0
- data/lib/puppet/util/inifile.rb +5 -5
- data/lib/puppet/util/instance_loader.rb +2 -2
- data/lib/puppet/util/json_lockfile.rb +4 -4
- data/lib/puppet/util/ldap/connection.rb +2 -2
- data/lib/puppet/util/ldap/manager.rb +2 -2
- data/lib/puppet/util/limits.rb +1 -1
- data/lib/puppet/util/log/destinations.rb +10 -16
- data/lib/puppet/util/log.rb +51 -17
- data/lib/puppet/util/logging.rb +53 -7
- data/lib/puppet/util/metric.rb +9 -6
- data/lib/puppet/util/monkey_patches.rb +41 -65
- data/lib/puppet/util/multi_match.rb +51 -0
- data/lib/puppet/util/network_device/cisco/device.rb +29 -11
- data/lib/puppet/util/network_device/cisco/interface.rb +21 -9
- data/lib/puppet/util/network_device/config.rb +7 -7
- data/lib/puppet/util/network_device/transport/ssh.rb +13 -9
- data/lib/puppet/util/network_device/transport/telnet.rb +39 -36
- data/lib/puppet/util/network_device.rb +1 -1
- data/lib/puppet/util/plist.rb +153 -0
- data/lib/puppet/util/posix.rb +5 -5
- data/lib/puppet/util/profiler/aggregate.rb +1 -1
- data/lib/puppet/util/profiler/around_profiler.rb +1 -1
- data/lib/puppet/util/profiler/wall_clock.rb +1 -1
- data/lib/puppet/util/profiler.rb +1 -1
- data/lib/puppet/util/provider_features.rb +1 -1
- data/lib/puppet/util/psych_support.rb +4 -12
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +3 -3
- data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +2 -1
- data/lib/puppet/util/rdoc.rb +6 -6
- data/lib/puppet/util/reference.rb +9 -7
- data/lib/puppet/util/resource_template.rb +2 -2
- data/lib/puppet/util/retry_action.rb +2 -2
- data/lib/puppet/util/rubygems.rb +1 -1
- data/lib/puppet/util/run_mode.rb +2 -2
- data/lib/puppet/util/selinux.rb +54 -12
- data/lib/puppet/util/skip_tags.rb +9 -0
- data/lib/puppet/util/splayer.rb +18 -0
- data/lib/puppet/util/storage.rb +5 -5
- data/lib/puppet/util/suidmanager.rb +4 -4
- data/lib/puppet/util/symbolic_file_mode.rb +9 -9
- data/lib/puppet/util/tag_set.rb +1 -4
- data/lib/puppet/util/tagging.rb +9 -3
- 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 +110 -45
- data/lib/puppet/util/windows/api_types.rb +28 -19
- data/lib/puppet/util/windows/com.rb +7 -7
- data/lib/puppet/util/windows/error.rb +3 -3
- data/lib/puppet/util/windows/eventlog.rb +192 -0
- data/lib/puppet/util/windows/file.rb +115 -22
- data/lib/puppet/util/windows/principal.rb +191 -0
- data/lib/puppet/util/windows/process.rb +90 -13
- data/lib/puppet/util/windows/registry.rb +31 -25
- data/lib/puppet/util/windows/root_certs.rb +6 -6
- data/lib/puppet/util/windows/security.rb +52 -51
- data/lib/puppet/util/windows/security_descriptor.rb +1 -1
- data/lib/puppet/util/windows/sid.rb +89 -20
- data/lib/puppet/util/windows/taskscheduler.rb +154 -98
- data/lib/puppet/util/windows/user.rb +38 -20
- data/lib/puppet/util/windows.rb +7 -0
- data/lib/puppet/util/yaml.rb +15 -3
- data/lib/puppet/util.rb +259 -33
- 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/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/version.rb +203 -0
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +758 -0
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +9 -0
- data/lib/puppet/vendor/semantic_puppet/locales/config.yaml +21 -0
- data/lib/puppet/version.rb +7 -3
- data/lib/puppet.rb +104 -6
- data/lib/puppet_x.rb +7 -1
- data/locales/config.yaml +29 -0
- data/locales/puppet.pot +7995 -0
- data/man/man5/puppet.conf.5 +13 -35
- data/man/man8/puppet-agent.8 +2 -2
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-ca.8 +2 -2
- data/man/man8/puppet-catalog.8 +2 -2
- data/man/man8/puppet-cert.8 +2 -2
- data/man/man8/puppet-certificate.8 +2 -2
- data/man/man8/puppet-certificate_request.8 +2 -2
- data/man/man8/puppet-certificate_revocation_list.8 +2 -2
- data/man/man8/puppet-config.8 +3 -3
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +2 -2
- data/man/man8/puppet-facts.8 +2 -2
- data/man/man8/puppet-filebucket.8 +2 -2
- data/man/man8/puppet-help.8 +2 -2
- data/man/man8/puppet-inspect.8 +2 -2
- data/man/man8/puppet-key.8 +2 -2
- data/man/man8/puppet-man.8 +2 -2
- data/man/man8/puppet-master.8 +2 -2
- data/man/man8/puppet-module.8 +9 -9
- data/man/man8/puppet-node.8 +2 -2
- data/man/man8/puppet-parser.8 +2 -2
- data/man/man8/puppet-plugin.8 +2 -2
- data/man/man8/puppet-report.8 +2 -2
- data/man/man8/puppet-resource.8 +2 -2
- data/man/man8/puppet-status.8 +3 -3
- data/man/man8/puppet.8 +1 -1
- data/spec/fixtures/module.tar.gz +0 -0
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +22 -0
- data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
- data/spec/fixtures/unit/application/environments/production/manifests/site.pp +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/environment.conf +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/functions/environment/data.pp +10 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/{sample → hiera_bad_syntax_json}/environment.conf +1 -1
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/third_utf8.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/utf8.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +22 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +48 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/server1.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/server2.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +20 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/data/common.yaml +6 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/manifests/init.pp +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/manifests/init.pp +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +2 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/manifests/init.pp +2 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/metadata.json +9 -0
- 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_fixture/environments/production/modules/abc/metadata.json +9 -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/bad_data/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup_fixture/environments/production/modules/bca/metadata.json +9 -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/module/trailing-comma.json +1 -1
- data/spec/fixtures/unit/parser/lexer/subclass_name_duplication.pp +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/functions/usee_puppet.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/functions/usee/usee_ruby.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/type/usee_type.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/manifests/init.pp +8 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/types/zero.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee2/lib/puppet/functions/usee2/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet_init.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_ruby.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/caller2.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet_init.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_ruby.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +87 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/metadata.json +2 -1
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseeone.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseezero.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/no_modules/manifests/site.pp +10 -0
- data/spec/fixtures/unit/pops/parser/lexer/subclass_name_duplication.pp +0 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-broken-notices.txt +187 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-obsoletes.txt +195 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
- data/spec/fixtures/unit/provider/service/smf/svcs.out +4 -3
- data/spec/fixtures/unit/provider/sshkey/parsed/sample_with_blank_lines +8 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_not_update_if_content_on_disk_is_up-to-date.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_update_if_content_differs_on_disk.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_mtime_is_older_on_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_no_header_specified.yml +197 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_not_update_if_mtime_is_newer_on_disk.yml +205 -0
- data/spec/integration/agent/logging_spec.rb +15 -14
- data/spec/integration/application/apply_spec.rb +395 -34
- data/spec/integration/application/doc_spec.rb +0 -0
- data/spec/integration/application/lookup_spec.rb +155 -0
- data/spec/integration/configurer_spec.rb +1 -1
- data/spec/integration/data_binding_spec.rb +195 -0
- data/spec/integration/defaults_spec.rb +29 -4
- 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 +2 -2
- data/spec/integration/file_bucket/file_spec.rb +2 -2
- data/spec/integration/file_serving/fileset_spec.rb +0 -0
- data/spec/integration/file_serving/terminus_helper_spec.rb +0 -0
- data/spec/integration/file_system/uniquefile_spec.rb +29 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +0 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +0 -0
- data/spec/integration/indirector/facts/facter_spec.rb +38 -0
- data/spec/integration/indirector/file_content/file_server_spec.rb +1 -0
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -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 +15 -3
- data/spec/integration/parser/class_spec.rb +6 -6
- data/spec/integration/parser/collection_spec.rb +18 -0
- data/spec/integration/parser/compiler_spec.rb +323 -920
- data/spec/integration/parser/dynamic_scoping_spec.rb +66 -0
- data/spec/integration/parser/parameter_defaults_spec.rb +358 -0
- data/spec/integration/parser/pcore_resource_spec.rb +260 -0
- data/spec/integration/parser/resource_expressions_spec.rb +9 -7
- data/spec/integration/parser/scope_spec.rb +73 -6
- 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 -5
- data/spec/integration/resource/type_collection_spec.rb +14 -0
- data/spec/integration/ssl/autosign_spec.rb +18 -3
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -1
- data/spec/integration/ssl/certificate_request_spec.rb +0 -1
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -1
- data/spec/integration/ssl/host_spec.rb +0 -1
- data/spec/integration/ssl/key_spec.rb +104 -0
- data/spec/integration/test/test_helper_spec.rb +32 -0
- data/spec/integration/transaction/report_spec.rb +683 -1
- data/spec/integration/transaction_spec.rb +127 -3
- data/spec/integration/type/exec_spec.rb +0 -0
- data/spec/integration/type/file_spec.rb +266 -12
- data/spec/integration/type/package_spec.rb +79 -2
- data/spec/integration/type/tidy_spec.rb +21 -9
- data/spec/integration/type/user_spec.rb +13 -6
- data/spec/integration/type_spec.rb +0 -0
- data/spec/integration/util/autoload_spec.rb +0 -0
- data/spec/integration/util/execution_spec.rb +30 -0
- data/spec/integration/util/rdoc/parser_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +26 -0
- data/spec/integration/util/windows/adsi_spec.rb +99 -0
- data/spec/integration/util/windows/principal_spec.rb +250 -0
- data/spec/integration/util/windows/process_spec.rb +35 -2
- data/spec/{unit → integration}/util/windows/registry_spec.rb +92 -2
- data/spec/integration/util/windows/security_spec.rb +61 -16
- data/spec/integration/util/windows/user_spec.rb +27 -5
- data/spec/integration/util_spec.rb +49 -27
- data/spec/lib/matchers/include_in_order.rb +2 -3
- data/spec/lib/matchers/json.rb +3 -3
- data/spec/lib/puppet/face/1.0.0/huzzah.rb +1 -1
- data/spec/lib/puppet/face/basetest.rb +1 -1
- data/spec/lib/puppet/face/huzzah.rb +1 -1
- data/spec/lib/puppet/face/version_matching.rb +1 -1
- data/spec/lib/puppet/indirector_testing.rb +4 -0
- data/spec/lib/puppet_spec/character_encoding.rb +12 -0
- data/spec/lib/puppet_spec/compiler.rb +40 -4
- data/spec/lib/puppet_spec/files.rb +16 -2
- data/spec/lib/puppet_spec/fixtures.rb +0 -0
- data/spec/lib/puppet_spec/language.rb +3 -1
- data/spec/lib/puppet_spec/module_tool/shared_functions.rb +2 -2
- data/spec/lib/puppet_spec/module_tool/stub_source.rb +1 -1
- data/spec/lib/puppet_spec/modules.rb +2 -2
- data/spec/lib/puppet_spec/network.rb +22 -14
- 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 +143 -0
- data/spec/shared_examples/rhel_package_provider.rb +356 -0
- data/spec/spec_helper.rb +23 -13
- data/spec/unit/agent/locker_spec.rb +4 -4
- data/spec/unit/agent_spec.rb +23 -46
- data/spec/unit/application/agent_spec.rb +22 -0
- data/spec/unit/application/apply_spec.rb +59 -14
- 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 +19 -0
- data/spec/unit/application/device_spec.rb +41 -2
- data/spec/unit/application/doc_spec.rb +0 -0
- data/spec/unit/application/face_base_spec.rb +22 -6
- 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/lookup_spec.rb +532 -0
- data/spec/unit/application/master_spec.rb +24 -8
- data/spec/unit/application/resource_spec.rb +39 -1
- data/spec/unit/application_spec.rb +3 -9
- data/spec/unit/capability_spec.rb +412 -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 +76 -20
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
- data/spec/unit/configurer_spec.rb +372 -58
- 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/function_data_provider_spec.rb +21 -3
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +361 -0
- data/spec/unit/defaults_spec.rb +34 -17
- data/spec/unit/environments_spec.rb +26 -4
- data/spec/unit/etc_spec.rb +442 -0
- data/spec/unit/external/pson_spec.rb +0 -0
- data/spec/unit/face/ca_spec.rb +10 -0
- data/spec/unit/face/catalog_spec.rb +0 -0
- data/spec/unit/face/certificate_request_spec.rb +10 -0
- data/spec/unit/face/certificate_revocation_list_spec.rb +10 -0
- data/spec/unit/face/certificate_spec.rb +10 -2
- data/spec/unit/face/config_spec.rb +47 -0
- data/spec/unit/face/epp_face_spec.rb +24 -5
- data/spec/unit/face/facts_spec.rb +0 -0
- data/spec/unit/face/generate_spec.rb +230 -0
- data/spec/unit/face/help_spec.rb +70 -0
- data/spec/unit/face/key_spec.rb +10 -0
- data/spec/unit/face/module/list_spec.rb +60 -0
- data/spec/unit/face/module/search_spec.rb +1 -1
- data/spec/unit/face/node_spec.rb +1 -1
- data/spec/unit/face/parser_spec.rb +49 -2
- data/spec/unit/face/plugin_spec.rb +29 -4
- data/spec/unit/face/status_spec.rb +10 -0
- data/spec/unit/face_spec.rb +0 -0
- data/spec/unit/file_bucket/dipper_spec.rb +210 -1
- data/spec/unit/file_bucket/file_spec.rb +3 -3
- 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 +84 -8
- data/spec/unit/file_serving/mount/file_spec.rb +0 -0
- data/spec/unit/file_serving/mount/modules_spec.rb +0 -0
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +0 -0
- data/spec/unit/file_serving/mount/plugins_spec.rb +0 -0
- data/spec/unit/file_serving/mount_spec.rb +0 -0
- data/spec/unit/file_serving/terminus_helper_spec.rb +0 -0
- data/spec/unit/file_serving/terminus_selector_spec.rb +12 -2
- data/spec/unit/file_system/uniquefile_spec.rb +20 -0
- data/spec/unit/file_system_spec.rb +335 -6
- data/spec/unit/forge/forge_spec.rb +112 -0
- data/spec/unit/forge/repository_spec.rb +31 -4
- data/spec/unit/functions/annotate_spec.rb +175 -0
- data/spec/unit/functions/assert_type_spec.rb +48 -8
- data/spec/unit/functions/binary_file_spec.rb +46 -0
- data/spec/unit/functions/break_spec.rb +117 -0
- data/spec/unit/functions/call_spec.rb +77 -0
- data/spec/unit/{parser/functions → functions}/contain_spec.rb +69 -4
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/dig_spec.rb +58 -0
- data/spec/unit/functions/epp_spec.rb +17 -9
- data/spec/unit/functions/filter_spec.rb +18 -0
- data/spec/unit/functions/find_file_spec.rb +69 -0
- data/spec/unit/functions/hiera_spec.rb +447 -47
- data/spec/unit/functions/include_spec.rb +175 -0
- data/spec/unit/functions/inline_epp_spec.rb +4 -4
- data/spec/unit/functions/lest_spec.rb +34 -0
- data/spec/unit/functions/logging_spec.rb +54 -0
- data/spec/unit/functions/lookup_fixture_spec.rb +688 -0
- data/spec/unit/functions/lookup_spec.rb +3108 -264
- data/spec/unit/functions/match_spec.rb +2 -2
- data/spec/unit/functions/new_spec.rb +694 -0
- data/spec/unit/functions/next_spec.rb +93 -0
- data/spec/unit/functions/regsubst_spec.rb +26 -9
- data/spec/unit/functions/require_spec.rb +83 -0
- data/spec/unit/functions/return_spec.rb +105 -0
- data/spec/unit/functions/reverse_each_spec.rb +108 -0
- data/spec/unit/functions/scanf_spec.rb +1 -1
- data/spec/unit/{parser/functions → functions}/shared.rb +15 -12
- data/spec/unit/functions/split_spec.rb +3 -3
- data/spec/unit/functions/step_spec.rb +113 -0
- data/spec/unit/functions/strftime_spec.rb +152 -0
- data/spec/unit/functions/then_spec.rb +40 -0
- data/spec/unit/functions/type_spec.rb +35 -0
- data/spec/unit/functions/unique_spec.rb +111 -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 +265 -115
- 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 +59 -56
- 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 +887 -83
- data/spec/unit/indirector/catalog/json_spec.rb +50 -1
- 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/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 +4 -12
- data/spec/unit/indirector/facts/network_device_spec.rb +0 -0
- data/spec/unit/indirector/facts/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/facts/yaml_spec.rb +0 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +86 -4
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_content/file_server_spec.rb +0 -0
- data/spec/unit/indirector/file_content/file_spec.rb +0 -0
- data/spec/unit/indirector/file_content/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/file_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_server_spec.rb +17 -2
- data/spec/unit/indirector/indirection_spec.rb +14 -38
- data/spec/unit/indirector/json_spec.rb +27 -6
- data/spec/unit/indirector/key/ca_spec.rb +0 -0
- data/spec/unit/indirector/key/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/key/file_spec.rb +1 -1
- data/spec/unit/indirector/ldap_spec.rb +0 -0
- data/spec/unit/indirector/memory_spec.rb +0 -0
- data/spec/unit/indirector/msgpack_spec.rb +11 -1
- data/spec/unit/indirector/node/exec_spec.rb +12 -12
- data/spec/unit/indirector/node/ldap_spec.rb +29 -8
- 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 +16 -6
- 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/write_only_yaml_spec.rb +12 -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 +2 -2
- data/spec/unit/indirector/report/rest_spec.rb +29 -3
- data/spec/unit/indirector/report/yaml_spec.rb +0 -0
- data/spec/unit/indirector/request_spec.rb +32 -12
- 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/rest_spec.rb +158 -18
- data/spec/unit/indirector/ssl_file_spec.rb +4 -4
- data/spec/unit/indirector/status/rest_spec.rb +0 -0
- data/spec/unit/indirector/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/terminus_spec.rb +0 -0
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/indirector_spec.rb +0 -0
- data/spec/unit/info_service_spec.rb +298 -0
- data/spec/unit/interface/action_builder_spec.rb +0 -0
- data/spec/unit/interface/action_manager_spec.rb +0 -0
- data/spec/unit/interface/action_spec.rb +0 -0
- data/spec/unit/interface/documentation_spec.rb +0 -0
- data/spec/unit/interface/face_collection_spec.rb +7 -7
- 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 +126 -74
- data/spec/unit/module_tool/application_spec.rb +1 -1
- data/spec/unit/module_tool/applications/builder_spec.rb +44 -9
- data/spec/unit/module_tool/applications/installer_spec.rb +11 -3
- data/spec/unit/module_tool/applications/unpacker_spec.rb +2 -1
- data/spec/unit/module_tool/applications/upgrader_spec.rb +9 -2
- 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/tar_spec.rb +16 -10
- 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 +11 -11
- data/spec/unit/network/format_spec.rb +9 -0
- data/spec/unit/network/formats_spec.rb +322 -138
- data/spec/unit/network/http/api/indirected_routes_spec.rb +125 -116
- data/spec/unit/network/http/api/master/v3/environment_spec.rb +186 -0
- data/spec/unit/network/http/api/master/v3_spec.rb +23 -5
- data/spec/unit/network/http/api_spec.rb +1 -1
- data/spec/unit/network/http/compression_spec.rb +132 -84
- data/spec/unit/network/http/connection_spec.rb +25 -19
- data/spec/unit/network/http/error_spec.rb +1 -1
- data/spec/unit/network/http/factory_spec.rb +18 -0
- data/spec/unit/network/http/handler_spec.rb +17 -18
- 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 +9 -2
- data/spec/unit/network/http/rack_spec.rb +0 -0
- data/spec/unit/network/http/request_spec.rb +110 -0
- data/spec/unit/network/http/response_spec.rb +108 -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 +13 -13
- data/spec/unit/node_spec.rb +68 -10
- 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 +84 -5
- data/spec/unit/parser/ast/leaf_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +135 -34
- data/spec/unit/parser/environment_compiler_spec.rb +686 -0
- data/spec/unit/parser/files_spec.rb +0 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +132 -10
- data/spec/unit/parser/functions/digest_spec.rb +0 -0
- data/spec/unit/parser/functions/fail_spec.rb +0 -0
- data/spec/unit/parser/functions/file_spec.rb +0 -0
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +6 -2
- data/spec/unit/parser/functions/generate_spec.rb +3 -12
- data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/inline_template_spec.rb +0 -0
- data/spec/unit/parser/functions/lookup_spec.rb +1 -1
- data/spec/unit/parser/functions/realize_spec.rb +0 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
- data/spec/unit/parser/functions/scanf_spec.rb +0 -0
- data/spec/unit/parser/functions/shellquote_spec.rb +0 -0
- data/spec/unit/parser/functions/split_spec.rb +1 -1
- data/spec/unit/parser/functions/sprintf_spec.rb +0 -0
- data/spec/unit/parser/functions/tag_spec.rb +0 -0
- data/spec/unit/parser/functions/template_spec.rb +0 -0
- data/spec/unit/parser/functions/versioncmp_spec.rb +0 -0
- data/spec/unit/parser/functions_spec.rb +0 -0
- data/spec/unit/parser/relationship_spec.rb +0 -0
- data/spec/unit/parser/resource/param_spec.rb +0 -0
- data/spec/unit/parser/resource_spec.rb +115 -54
- data/spec/unit/parser/scope_spec.rb +83 -85
- data/spec/unit/parser/templatewrapper_spec.rb +0 -0
- data/spec/unit/parser/type_loader_spec.rb +0 -0
- data/spec/unit/pops/benchmark_spec.rb +8 -26
- data/spec/unit/pops/containment_spec.rb +0 -26
- data/spec/unit/pops/evaluator/access_ops_spec.rb +198 -102
- data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +223 -0
- data/spec/unit/pops/evaluator/basic_expressions_spec.rb +5 -6
- data/spec/unit/pops/evaluator/comparison_ops_spec.rb +29 -26
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +135 -30
- data/spec/unit/pops/evaluator/evaluator_rspec_helper.rb +29 -25
- data/spec/unit/pops/evaluator/json_strict_literal_evaluator_spec.rb +63 -0
- data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +168 -0
- data/spec/unit/pops/evaluator/string_interpolation_spec.rb +10 -10
- data/spec/unit/pops/evaluator/variables_spec.rb +2 -2
- data/spec/unit/pops/factory_rspec_helper.rb +0 -4
- data/spec/unit/pops/factory_spec.rb +83 -83
- 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 +454 -28
- data/spec/unit/pops/loaders/module_loaders_spec.rb +63 -2
- data/spec/unit/pops/loaders/static_loader_spec.rb +80 -19
- data/spec/unit/pops/lookup/context_spec.rb +334 -0
- data/spec/unit/pops/lookup/interpolation_spec.rb +373 -0
- data/spec/unit/pops/lookup/lookup_spec.rb +294 -0
- data/spec/unit/pops/merge_strategy_spec.rb +18 -0
- data/spec/unit/pops/model/model_spec.rb +10 -10
- data/spec/unit/pops/parser/epp_parser_spec.rb +1 -1
- data/spec/unit/pops/parser/lexer2_spec.rb +239 -10
- data/spec/unit/pops/parser/locator_spec.rb +24 -0
- data/spec/unit/pops/parser/parse_application_spec.rb +32 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +35 -4
- data/spec/unit/pops/parser/parse_calls_spec.rb +25 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +37 -0
- data/spec/unit/pops/parser/parse_containers_spec.rb +17 -19
- data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_site_spec.rb +48 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +6 -0
- data/spec/unit/pops/parser/parser_spec.rb +32 -6
- data/spec/unit/pops/puppet_stack_spec.rb +79 -0
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +109 -0
- data/spec/unit/pops/serialization/packer_spec.rb +154 -0
- data/spec/unit/pops/serialization/serialization_spec.rb +426 -0
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +494 -0
- data/spec/unit/pops/time/timespan_spec.rb +121 -0
- data/spec/unit/pops/time/timestamp_spec.rb +13 -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 +1253 -0
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +322 -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 +445 -0
- data/spec/unit/pops/types/recursion_guard_spec.rb +93 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +662 -0
- data/spec/unit/pops/types/string_converter_spec.rb +1132 -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 +1122 -967
- data/spec/unit/pops/types/type_factory_spec.rb +137 -96
- data/spec/unit/pops/types/type_formatter_spec.rb +409 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +228 -0
- data/spec/unit/pops/types/type_parser_spec.rb +207 -40
- data/spec/unit/pops/types/types_spec.rb +650 -0
- data/spec/unit/pops/validator/validator_spec.rb +395 -21
- data/spec/unit/pops/visitor_spec.rb +1 -1
- 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 +2 -2
- 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 +60 -1
- data/spec/unit/provider/cisco_spec.rb +0 -0
- data/spec/unit/provider/command_spec.rb +0 -0
- data/spec/unit/provider/cron/crontab_spec.rb +0 -0
- data/spec/unit/provider/cron/parsed_spec.rb +1 -0
- data/spec/unit/provider/exec/posix_spec.rb +0 -0
- data/spec/unit/provider/exec/shell_spec.rb +0 -0
- data/spec/unit/provider/exec/windows_spec.rb +0 -0
- data/spec/unit/provider/exec_spec.rb +0 -0
- data/spec/unit/provider/file/posix_spec.rb +0 -0
- data/spec/unit/provider/file/windows_spec.rb +0 -0
- data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
- data/spec/unit/provider/group/groupadd_spec.rb +0 -0
- data/spec/unit/provider/group/ldap_spec.rb +0 -0
- data/spec/unit/provider/group/pw_spec.rb +0 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +31 -9
- data/spec/unit/provider/host/parsed_spec.rb +0 -0
- data/spec/unit/provider/interface/cisco_spec.rb +0 -0
- data/spec/unit/provider/ldap_spec.rb +0 -0
- data/spec/unit/provider/macauthorization_spec.rb +5 -2
- data/spec/unit/provider/mcx/mcxcontent_spec.rb +0 -0
- data/spec/unit/provider/mount/parsed_spec.rb +0 -0
- data/spec/unit/provider/mount_spec.rb +0 -0
- data/spec/unit/provider/naginator_spec.rb +0 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +16 -19
- data/spec/unit/provider/nameservice_spec.rb +167 -15
- data/spec/unit/provider/network_device_spec.rb +0 -0
- data/spec/unit/provider/package/aix_spec.rb +0 -0
- data/spec/unit/provider/package/appdmg_spec.rb +3 -3
- data/spec/unit/provider/package/apt_spec.rb +0 -0
- data/spec/unit/provider/package/aptitude_spec.rb +0 -0
- data/spec/unit/provider/package/aptrpm_spec.rb +3 -3
- data/spec/unit/provider/package/base_spec.rb +18 -0
- data/spec/unit/provider/package/dnf_spec.rb +30 -0
- data/spec/unit/provider/package/dpkg_spec.rb +0 -0
- data/spec/unit/provider/package/freebsd_spec.rb +0 -0
- data/spec/unit/provider/package/gem_spec.rb +77 -0
- data/spec/unit/provider/package/hpux_spec.rb +0 -0
- data/spec/unit/provider/package/macports_spec.rb +0 -0
- data/spec/unit/provider/package/nim_spec.rb +6 -6
- data/spec/unit/provider/package/openbsd_spec.rb +0 -0
- data/spec/unit/provider/package/opkg_spec.rb +0 -0
- data/spec/unit/provider/package/pacman_spec.rb +55 -0
- data/spec/unit/provider/package/pip3_spec.rb +22 -0
- data/spec/unit/provider/package/pip_spec.rb +164 -46
- data/spec/unit/provider/package/pkg_spec.rb +139 -99
- data/spec/unit/provider/package/pkgdmg_spec.rb +32 -8
- data/spec/unit/provider/package/pkgin_spec.rb +23 -13
- data/spec/unit/provider/package/pkgng_spec.rb +16 -2
- data/spec/unit/provider/package/pkgutil_spec.rb +0 -0
- data/spec/unit/provider/package/portage_spec.rb +150 -8
- data/spec/unit/provider/package/puppet_gem_spec.rb +0 -0
- data/spec/unit/provider/package/rpm_spec.rb +183 -12
- data/spec/unit/provider/package/sun_spec.rb +0 -0
- data/spec/unit/provider/package/tdnf_spec.rb +18 -0
- data/spec/unit/provider/package/windows/package_spec.rb +45 -1
- data/spec/unit/provider/package/windows_spec.rb +8 -2
- data/spec/unit/provider/package/yum_spec.rb +29 -466
- data/spec/unit/provider/package/zypper_spec.rb +14 -0
- data/spec/unit/provider/parsedfile_spec.rb +0 -0
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +211 -0
- data/spec/unit/provider/selboolean_spec.rb +0 -0
- data/spec/unit/provider/selmodule_spec.rb +0 -0
- data/spec/unit/provider/service/base_spec.rb +6 -0
- data/spec/unit/provider/service/bsd_spec.rb +130 -0
- data/spec/unit/provider/service/daemontools_spec.rb +0 -0
- data/spec/unit/provider/service/debian_spec.rb +34 -4
- data/spec/unit/provider/service/freebsd_spec.rb +16 -0
- data/spec/unit/provider/service/gentoo_spec.rb +7 -0
- data/spec/unit/provider/service/init_spec.rb +24 -1
- data/spec/unit/provider/service/launchd_spec.rb +124 -25
- data/spec/unit/provider/service/openbsd_spec.rb +0 -0
- data/spec/unit/provider/service/openrc_spec.rb +7 -0
- data/spec/unit/provider/service/openwrt_spec.rb +0 -0
- data/spec/unit/provider/service/rcng_spec.rb +41 -0
- data/spec/unit/provider/service/redhat_spec.rb +8 -1
- data/spec/unit/provider/service/runit_spec.rb +0 -0
- data/spec/unit/provider/service/smf_spec.rb +77 -13
- data/spec/unit/provider/service/src_spec.rb +31 -4
- data/spec/unit/provider/service/systemd_spec.rb +228 -39
- data/spec/unit/provider/service/upstart_spec.rb +64 -0
- data/spec/unit/provider/service/windows_spec.rb +0 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -1
- data/spec/unit/provider/sshkey/parsed_spec.rb +42 -18
- data/spec/unit/provider/user/aix_spec.rb +7 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +171 -90
- 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 +14 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +30 -6
- data/spec/unit/provider/vlan/cisco_spec.rb +0 -0
- data/spec/unit/provider/yumrepo/inifile_spec.rb +16 -0
- data/spec/unit/provider/zfs/zfs_spec.rb +0 -0
- data/spec/unit/provider/zone/solaris_spec.rb +64 -12
- data/spec/unit/provider/zpool/zpool_spec.rb +0 -0
- data/spec/unit/provider_spec.rb +0 -0
- data/spec/unit/puppet_spec.rb +16 -3
- data/spec/unit/relationship_spec.rb +15 -36
- data/spec/unit/reports/http_spec.rb +11 -8
- 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 +294 -41
- data/spec/unit/resource/status_spec.rb +114 -103
- data/spec/unit/resource/type_collection_spec.rb +28 -7
- data/spec/unit/resource/type_spec.rb +172 -82
- data/spec/unit/resource_spec.rb +161 -76
- 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 +109 -5
- data/spec/unit/ssl/base_spec.rb +9 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +180 -13
- data/spec/unit/ssl/certificate_authority_spec.rb +82 -28
- data/spec/unit/ssl/certificate_factory_spec.rb +2 -2
- data/spec/unit/ssl/certificate_request_attributes_spec.rb +6 -0
- data/spec/unit/ssl/certificate_request_spec.rb +4 -5
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +3 -3
- data/spec/unit/ssl/certificate_spec.rb +1 -1
- data/spec/unit/ssl/configuration_spec.rb +11 -2
- data/spec/unit/ssl/host_spec.rb +37 -37
- data/spec/unit/ssl/inventory_spec.rb +27 -3
- data/spec/unit/ssl/key_spec.rb +7 -7
- data/spec/unit/ssl/oids_spec.rb +24 -13
- data/spec/unit/status_spec.rb +7 -7
- 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 +18 -13
- data/spec/unit/transaction/persistence_spec.rb +178 -0
- data/spec/unit/transaction/report_spec.rb +214 -40
- data/spec/unit/transaction/resource_harness_spec.rb +84 -40
- data/spec/unit/transaction_spec.rb +102 -7
- data/spec/unit/type/augeas_spec.rb +0 -0
- data/spec/unit/type/component_spec.rb +0 -0
- data/spec/unit/type/computer_spec.rb +0 -0
- data/spec/unit/type/cron_spec.rb +0 -0
- data/spec/unit/type/exec_spec.rb +57 -12
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/checksum_value_spec.rb +286 -0
- data/spec/unit/type/file/content_spec.rb +59 -208
- data/spec/unit/type/file/ctime_spec.rb +0 -0
- data/spec/unit/type/file/ensure_spec.rb +0 -0
- data/spec/unit/type/file/group_spec.rb +2 -2
- data/spec/unit/type/file/mode_spec.rb +9 -9
- data/spec/unit/type/file/mtime_spec.rb +0 -0
- data/spec/unit/type/file/owner_spec.rb +2 -2
- data/spec/unit/type/file/selinux_spec.rb +2 -0
- data/spec/unit/type/file/source_spec.rb +224 -119
- data/spec/unit/type/file/type_spec.rb +0 -0
- data/spec/unit/type/file_spec.rb +211 -35
- data/spec/unit/type/filebucket_spec.rb +0 -0
- data/spec/unit/type/group_spec.rb +0 -0
- data/spec/unit/type/host_spec.rb +4 -4
- data/spec/unit/type/interface_spec.rb +32 -0
- data/spec/unit/type/k5login_spec.rb +0 -0
- data/spec/unit/type/macauthorization_spec.rb +4 -1
- data/spec/unit/type/mailalias_spec.rb +0 -0
- data/spec/unit/type/maillist_spec.rb +0 -0
- data/spec/unit/type/mcx_spec.rb +0 -0
- data/spec/unit/type/mount_spec.rb +50 -8
- data/spec/unit/type/nagios_spec.rb +0 -0
- data/spec/unit/type/noop_metaparam_spec.rb +0 -0
- data/spec/unit/type/package/package_settings_spec.rb +0 -0
- data/spec/unit/type/package_spec.rb +1 -0
- data/spec/unit/type/resources_spec.rb +0 -0
- data/spec/unit/type/schedule_spec.rb +0 -0
- data/spec/unit/type/selboolean_spec.rb +0 -0
- data/spec/unit/type/selmodule_spec.rb +0 -0
- data/spec/unit/type/service_spec.rb +21 -0
- data/spec/unit/type/ssh_authorized_key_spec.rb +2 -2
- 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 +38 -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/at_fork_spec.rb +150 -0
- data/spec/unit/util/autoload_spec.rb +0 -0
- data/spec/unit/util/backups_spec.rb +0 -0
- data/spec/unit/util/character_encoding_spec.rb +229 -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 +44 -3
- data/spec/unit/util/execution_stub_spec.rb +0 -0
- data/spec/unit/util/feature_spec.rb +1 -1
- data/spec/unit/util/filetype_spec.rb +4 -4
- data/spec/unit/util/http_proxy_spec.rb +91 -0
- data/spec/unit/util/ldap/connection_spec.rb +0 -0
- data/spec/unit/util/ldap/generator_spec.rb +1 -1
- data/spec/unit/util/ldap/manager_spec.rb +0 -0
- data/spec/unit/util/log/destinations_spec.rb +5 -8
- data/spec/unit/util/log_spec.rb +74 -18
- data/spec/unit/util/logging_spec.rb +69 -0
- data/spec/unit/util/metric_spec.rb +9 -2
- data/spec/unit/util/monkey_patches_spec.rb +37 -127
- 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 +44 -13
- 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/tag_set_spec.rb +2 -2
- data/spec/unit/util/tagging_spec.rb +59 -0
- data/spec/unit/util/user_attr_spec.rb +0 -0
- data/spec/unit/util/warnings_spec.rb +0 -0
- data/spec/unit/util/windows/adsi_spec.rb +82 -40
- data/spec/unit/util/windows/api_types_spec.rb +42 -0
- data/spec/unit/util/windows/eventlog_spec.rb +123 -0
- data/spec/unit/util/windows/file_spec.rb +89 -0
- data/spec/unit/util/windows/root_certs_spec.rb +0 -0
- data/spec/unit/util/windows/security_descriptor_spec.rb +3 -3
- data/spec/unit/util/windows/sid_spec.rb +76 -14
- data/spec/unit/util/yaml_spec.rb +13 -1
- data/spec/unit/util_spec.rb +456 -17
- data/spec/unit/version_spec.rb +19 -0
- data/spec/watchr.rb +0 -0
- data/tasks/benchmark.rake +3 -3
- data/tasks/cfpropertylist.rake +15 -0
- data/tasks/generate_ast_model.rake +78 -0
- metadata +3441 -3081
- checksums.yaml +0 -7
- data/bin/extlookup2hiera +0 -56
- data/ext/emacs/puppet-mode-init.el +0 -6
- data/ext/emacs/puppet-mode.el +0 -433
- 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/ext/vim/README +0 -3
- data/ext/vim/ftdetect/puppet.vim +0 -2
- data/ext/vim/ftplugin/puppet.vim +0 -94
- data/ext/vim/indent/puppet.vim +0 -76
- data/ext/vim/syntax/puppet.vim +0 -115
- data/lib/puppet/application/file.rb +0 -4
- data/lib/puppet/application/inspect.rb +0 -179
- data/lib/puppet/application/resource_type.rb +0 -7
- data/lib/puppet/data_providers/data_adapter.rb +0 -91
- data/lib/puppet/data_providers/data_function_support.rb +0 -45
- data/lib/puppet/data_providers/function_env_data_provider.rb +0 -28
- data/lib/puppet/data_providers/function_module_data_provider.rb +0 -39
- data/lib/puppet/data_providers.rb +0 -31
- data/lib/puppet/face/file/download.rb +0 -56
- data/lib/puppet/face/file/store.rb +0 -21
- data/lib/puppet/face/file.rb +0 -47
- data/lib/puppet/face/resource_type.rb +0 -84
- data/lib/puppet/feature/cfacter.rb +0 -14
- data/lib/puppet/feature/external_facts.rb +0 -5
- data/lib/puppet/indirector/catalog/static_compiler.rb +0 -213
- data/lib/puppet/indirector/resource_type/parser.rb +0 -101
- data/lib/puppet/indirector/resource_type/rest.rb +0 -7
- data/lib/puppet/indirector/resource_type.rb +0 -5
- data/lib/puppet/parser/yaml_trimmer.rb +0 -7
- data/lib/puppet/plugins/binding_schemes.rb +0 -140
- data/lib/puppet/plugins/data_providers.rb +0 -90
- data/lib/puppet/pops/binder/binder.rb +0 -394
- data/lib/puppet/pops/binder/binder_issues.rb +0 -122
- data/lib/puppet/pops/binder/bindings_checker.rb +0 -197
- data/lib/puppet/pops/binder/bindings_composer.rb +0 -177
- data/lib/puppet/pops/binder/bindings_factory.rb +0 -809
- data/lib/puppet/pops/binder/bindings_label_provider.rb +0 -43
- data/lib/puppet/pops/binder/bindings_loader.rb +0 -83
- data/lib/puppet/pops/binder/bindings_model.rb +0 -68
- data/lib/puppet/pops/binder/bindings_model_dumper.rb +0 -215
- data/lib/puppet/pops/binder/bindings_model_meta.rb +0 -215
- data/lib/puppet/pops/binder/bindings_validator_factory.rb +0 -28
- data/lib/puppet/pops/binder/config/binder_config.rb +0 -107
- data/lib/puppet/pops/binder/config/binder_config_checker.rb +0 -142
- data/lib/puppet/pops/binder/config/diagnostic_producer.rb +0 -32
- data/lib/puppet/pops/binder/config/issues.rb +0 -90
- data/lib/puppet/pops/binder/injector.rb +0 -766
- data/lib/puppet/pops/binder/injector_entry.rb +0 -57
- data/lib/puppet/pops/binder/key_factory.rb +0 -67
- data/lib/puppet/pops/binder/producers.rb +0 -826
- data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +0 -34
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +0 -84
- data/lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb +0 -53
- data/lib/puppet/pops/binder/system_bindings.rb +0 -60
- data/lib/puppet/pops/containment.rb +0 -104
- data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
- data/lib/puppet/pops/model/model.rb +0 -114
- data/lib/puppet/pops/model/model_meta.rb +0 -586
- data/lib/puppet/pops/types/types_meta.rb +0 -234
- data/lib/puppet/resource/type_collection_helper.rb +0 -7
- data/lib/puppet/vendor/load_plist.rb +0 -1
- data/lib/puppet/vendor/load_rgen.rb +0 -2
- 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/rgen/CHANGELOG +0 -197
- data/lib/puppet/vendor/rgen/MIT-LICENSE +0 -20
- data/lib/puppet/vendor/rgen/PUPPET_README.md +0 -6
- data/lib/puppet/vendor/rgen/README.rdoc +0 -78
- data/lib/puppet/vendor/rgen/Rakefile +0 -41
- data/lib/puppet/vendor/rgen/TODO +0 -41
- data/lib/puppet/vendor/rgen/anounce.txt +0 -61
- data/lib/puppet/vendor/rgen/design_rationale.txt +0 -71
- data/lib/puppet/vendor/rgen/lib/ea_support/ea_support.rb +0 -54
- data/lib/puppet/vendor/rgen/lib/ea_support/id_store.rb +0 -32
- data/lib/puppet/vendor/rgen/lib/ea_support/uml13_ea_metamodel.rb +0 -562
- data/lib/puppet/vendor/rgen/lib/ea_support/uml13_ea_metamodel_ext.rb +0 -45
- data/lib/puppet/vendor/rgen/lib/ea_support/uml13_ea_metamodel_generator.rb +0 -43
- data/lib/puppet/vendor/rgen/lib/ea_support/uml13_ea_to_uml13.rb +0 -103
- data/lib/puppet/vendor/rgen/lib/ea_support/uml13_to_uml13_ea.rb +0 -89
- data/lib/puppet/vendor/rgen/lib/metamodels/uml13_metamodel.rb +0 -559
- data/lib/puppet/vendor/rgen/lib/metamodels/uml13_metamodel_ext.rb +0 -26
- data/lib/puppet/vendor/rgen/lib/mmgen/metamodel_generator.rb +0 -20
- data/lib/puppet/vendor/rgen/lib/mmgen/mm_ext/ecore_mmgen_ext.rb +0 -91
- data/lib/puppet/vendor/rgen/lib/mmgen/mmgen.rb +0 -28
- data/lib/puppet/vendor/rgen/lib/mmgen/templates/annotations.tpl +0 -37
- data/lib/puppet/vendor/rgen/lib/mmgen/templates/metamodel_generator.tpl +0 -172
- data/lib/puppet/vendor/rgen/lib/rgen/array_extensions.rb +0 -45
- data/lib/puppet/vendor/rgen/lib/rgen/ecore/ecore.rb +0 -218
- data/lib/puppet/vendor/rgen/lib/rgen/ecore/ecore_builder_methods.rb +0 -81
- data/lib/puppet/vendor/rgen/lib/rgen/ecore/ecore_ext.rb +0 -69
- data/lib/puppet/vendor/rgen/lib/rgen/ecore/ecore_interface.rb +0 -47
- data/lib/puppet/vendor/rgen/lib/rgen/ecore/ecore_to_ruby.rb +0 -167
- data/lib/puppet/vendor/rgen/lib/rgen/ecore/ruby_to_ecore.rb +0 -91
- data/lib/puppet/vendor/rgen/lib/rgen/environment.rb +0 -129
- data/lib/puppet/vendor/rgen/lib/rgen/fragment/dump_file_cache.rb +0 -63
- data/lib/puppet/vendor/rgen/lib/rgen/fragment/fragmented_model.rb +0 -140
- data/lib/puppet/vendor/rgen/lib/rgen/fragment/model_fragment.rb +0 -289
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/abstract_instantiator.rb +0 -66
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/abstract_xml_instantiator.rb +0 -66
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/default_xml_instantiator.rb +0 -117
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/ecore_xml_instantiator.rb +0 -169
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/json_instantiator.rb +0 -126
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/json_parser.rb +0 -331
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/json_parser.y +0 -94
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/nodebased_xml_instantiator.rb +0 -137
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/qualified_name_resolver.rb +0 -97
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/reference_resolver.rb +0 -128
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/resolution_helper.rb +0 -47
- data/lib/puppet/vendor/rgen/lib/rgen/instantiator/xmi11_instantiator.rb +0 -168
- data/lib/puppet/vendor/rgen/lib/rgen/metamodel_builder/builder_extensions.rb +0 -556
- data/lib/puppet/vendor/rgen/lib/rgen/metamodel_builder/builder_runtime.rb +0 -174
- data/lib/puppet/vendor/rgen/lib/rgen/metamodel_builder/constant_order_helper.rb +0 -89
- data/lib/puppet/vendor/rgen/lib/rgen/metamodel_builder/data_types.rb +0 -77
- data/lib/puppet/vendor/rgen/lib/rgen/metamodel_builder/intermediate/annotation.rb +0 -30
- data/lib/puppet/vendor/rgen/lib/rgen/metamodel_builder/intermediate/feature.rb +0 -168
- data/lib/puppet/vendor/rgen/lib/rgen/metamodel_builder/mm_multiple.rb +0 -23
- data/lib/puppet/vendor/rgen/lib/rgen/metamodel_builder/module_extension.rb +0 -42
- data/lib/puppet/vendor/rgen/lib/rgen/metamodel_builder.rb +0 -224
- data/lib/puppet/vendor/rgen/lib/rgen/model_builder/builder_context.rb +0 -334
- data/lib/puppet/vendor/rgen/lib/rgen/model_builder/model_serializer.rb +0 -225
- data/lib/puppet/vendor/rgen/lib/rgen/model_builder/reference_resolver.rb +0 -156
- data/lib/puppet/vendor/rgen/lib/rgen/model_builder.rb +0 -32
- data/lib/puppet/vendor/rgen/lib/rgen/serializer/json_serializer.rb +0 -121
- data/lib/puppet/vendor/rgen/lib/rgen/serializer/opposite_reference_filter.rb +0 -18
- data/lib/puppet/vendor/rgen/lib/rgen/serializer/qualified_name_provider.rb +0 -47
- data/lib/puppet/vendor/rgen/lib/rgen/serializer/xmi11_serializer.rb +0 -116
- data/lib/puppet/vendor/rgen/lib/rgen/serializer/xmi20_serializer.rb +0 -71
- data/lib/puppet/vendor/rgen/lib/rgen/serializer/xml_serializer.rb +0 -98
- data/lib/puppet/vendor/rgen/lib/rgen/template_language/directory_template_container.rb +0 -83
- data/lib/puppet/vendor/rgen/lib/rgen/template_language/output_handler.rb +0 -87
- data/lib/puppet/vendor/rgen/lib/rgen/template_language/template_container.rb +0 -234
- data/lib/puppet/vendor/rgen/lib/rgen/template_language/template_helper.rb +0 -26
- data/lib/puppet/vendor/rgen/lib/rgen/template_language.rb +0 -297
- data/lib/puppet/vendor/rgen/lib/rgen/transformer.rb +0 -475
- data/lib/puppet/vendor/rgen/lib/rgen/util/auto_class_creator.rb +0 -61
- data/lib/puppet/vendor/rgen/lib/rgen/util/cached_glob.rb +0 -67
- data/lib/puppet/vendor/rgen/lib/rgen/util/file_cache_map.rb +0 -124
- data/lib/puppet/vendor/rgen/lib/rgen/util/file_change_detector.rb +0 -84
- data/lib/puppet/vendor/rgen/lib/rgen/util/method_delegation.rb +0 -114
- data/lib/puppet/vendor/rgen/lib/rgen/util/model_comparator.rb +0 -68
- data/lib/puppet/vendor/rgen/lib/rgen/util/model_comparator_base.rb +0 -142
- data/lib/puppet/vendor/rgen/lib/rgen/util/model_dumper.rb +0 -29
- data/lib/puppet/vendor/rgen/lib/rgen/util/name_helper.rb +0 -42
- data/lib/puppet/vendor/rgen/lib/rgen/util/pattern_matcher.rb +0 -329
- data/lib/puppet/vendor/rgen/lib/transformers/ecore_to_uml13.rb +0 -79
- data/lib/puppet/vendor/rgen/lib/transformers/uml13_to_ecore.rb +0 -127
- data/lib/puppet/vendor/rgen/test/array_extensions_test.rb +0 -64
- data/lib/puppet/vendor/rgen/test/ea_instantiator_test.rb +0 -35
- data/lib/puppet/vendor/rgen/test/ea_serializer_test.rb +0 -23
- data/lib/puppet/vendor/rgen/test/ecore_self_test.rb +0 -54
- data/lib/puppet/vendor/rgen/test/environment_test.rb +0 -90
- data/lib/puppet/vendor/rgen/test/json_test.rb +0 -171
- data/lib/puppet/vendor/rgen/test/metamodel_builder_test.rb +0 -1482
- data/lib/puppet/vendor/rgen/test/metamodel_from_ecore_test.rb +0 -57
- data/lib/puppet/vendor/rgen/test/metamodel_order_test.rb +0 -131
- data/lib/puppet/vendor/rgen/test/metamodel_roundtrip_test/TestModel.rb +0 -70
- data/lib/puppet/vendor/rgen/test/metamodel_roundtrip_test/houseMetamodel.ecore +0 -42
- data/lib/puppet/vendor/rgen/test/metamodel_roundtrip_test/houseMetamodel_from_ecore.rb +0 -44
- data/lib/puppet/vendor/rgen/test/metamodel_roundtrip_test/using_builtin_types.ecore +0 -9
- data/lib/puppet/vendor/rgen/test/metamodel_roundtrip_test.rb +0 -98
- data/lib/puppet/vendor/rgen/test/method_delegation_test.rb +0 -178
- data/lib/puppet/vendor/rgen/test/model_builder/builder_context_test.rb +0 -59
- data/lib/puppet/vendor/rgen/test/model_builder/builder_test.rb +0 -242
- data/lib/puppet/vendor/rgen/test/model_builder/ecore_original.rb +0 -163
- data/lib/puppet/vendor/rgen/test/model_builder/ecore_original_regenerated.rb +0 -163
- data/lib/puppet/vendor/rgen/test/model_builder/reference_resolver_test.rb +0 -156
- data/lib/puppet/vendor/rgen/test/model_builder/serializer_test.rb +0 -94
- data/lib/puppet/vendor/rgen/test/model_builder/statemachine_metamodel.rb +0 -42
- data/lib/puppet/vendor/rgen/test/model_builder/test_model/statemachine1.rb +0 -23
- data/lib/puppet/vendor/rgen/test/model_builder_test.rb +0 -6
- data/lib/puppet/vendor/rgen/test/model_fragment_test.rb +0 -30
- data/lib/puppet/vendor/rgen/test/output_handler_test.rb +0 -58
- data/lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb +0 -48
- data/lib/puppet/vendor/rgen/test/qualified_name_resolver_test.rb +0 -102
- data/lib/puppet/vendor/rgen/test/reference_resolver_test.rb +0 -117
- data/lib/puppet/vendor/rgen/test/rgen_test.rb +0 -26
- data/lib/puppet/vendor/rgen/test/template_language_test/expected_result1.txt +0 -29
- data/lib/puppet/vendor/rgen/test/template_language_test/expected_result2.txt +0 -9
- data/lib/puppet/vendor/rgen/test/template_language_test/expected_result3.txt +0 -4
- data/lib/puppet/vendor/rgen/test/template_language_test/indentStringTestDefaultIndent.out +0 -1
- data/lib/puppet/vendor/rgen/test/template_language_test/indentStringTestTabIndent.out +0 -1
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/callback_indent_test/a.tpl +0 -12
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/callback_indent_test/b.tpl +0 -5
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/code/array.tpl +0 -11
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/content/author.tpl +0 -7
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/content/chapter.tpl +0 -5
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/define_local_test/local.tpl +0 -8
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/define_local_test/test.tpl +0 -8
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/evaluate_test/test.tpl +0 -7
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/indent_string_test.tpl +0 -12
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/index/c/cmod.tpl +0 -1
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/index/chapter.tpl +0 -3
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/no_backslash_r_test.tpl +0 -5
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/no_indent_test/no_indent.tpl +0 -3
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/no_indent_test/sub1/no_indent.tpl +0 -3
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/no_indent_test/test.tpl +0 -24
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/no_indent_test/test2.tpl +0 -13
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/no_indent_test/test3.tpl +0 -10
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/null_context_test.tpl +0 -17
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/root.tpl +0 -31
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/template_resolution_test/sub1/sub1.tpl +0 -3
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/template_resolution_test/sub1.tpl +0 -9
- data/lib/puppet/vendor/rgen/test/template_language_test/templates/template_resolution_test/test.tpl +0 -4
- data/lib/puppet/vendor/rgen/test/template_language_test/testout.txt +0 -29
- data/lib/puppet/vendor/rgen/test/template_language_test.rb +0 -163
- data/lib/puppet/vendor/rgen/test/testmodel/class_model_checker.rb +0 -119
- data/lib/puppet/vendor/rgen/test/testmodel/ea_testmodel.eap +0 -0
- data/lib/puppet/vendor/rgen/test/testmodel/ea_testmodel.xml +0 -1029
- data/lib/puppet/vendor/rgen/test/testmodel/ea_testmodel_partial.xml +0 -317
- data/lib/puppet/vendor/rgen/test/testmodel/ecore_model_checker.rb +0 -101
- data/lib/puppet/vendor/rgen/test/testmodel/manual_testmodel.xml +0 -22
- data/lib/puppet/vendor/rgen/test/testmodel/object_model_checker.rb +0 -67
- data/lib/puppet/vendor/rgen/test/transformer_test.rb +0 -254
- data/lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb +0 -99
- data/lib/puppet/vendor/rgen/test/util/pattern_matcher_test.rb +0 -97
- data/lib/puppet/vendor/rgen/test/util_test.rb +0 -5
- data/lib/puppet/vendor/rgen/test/xml_instantiator_test/simple_ecore_model_checker.rb +0 -94
- data/lib/puppet/vendor/rgen/test/xml_instantiator_test/simple_xmi_ecore_instantiator.rb +0 -53
- data/lib/puppet/vendor/rgen/test/xml_instantiator_test/simple_xmi_metamodel.rb +0 -49
- data/lib/puppet/vendor/rgen/test/xml_instantiator_test/simple_xmi_to_ecore.rb +0 -75
- data/lib/puppet/vendor/rgen/test/xml_instantiator_test.rb +0 -160
- data/lib/puppet/vendor/rgen_patch.rb +0 -132
- 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/lib/semantic/version.rb +0 -168
- data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +0 -424
- 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/lib/semver.rb +0 -123
- data/man/man8/extlookup2hiera.8 +0 -10
- data/man/man8/puppet-file.8 +0 -189
- data/man/man8/puppet-resource_type.8 +0 -188
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/bindings/abc/default.rb +0 -9
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +0 -9
- data/spec/fixtures/unit/data_providers/environments/sample/manifests/site.pp +0 -6
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet/bindings/dataprovider/default.rb +0 -54
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +0 -31
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +0 -32
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/manifests/init.pp +0 -5
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/abc/lib/puppet/bindings/abc/default.rb +0 -9
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/bindings/bad_data/default.rb +0 -9
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/manifests/init.pp +0 -3
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/lib/puppet/bindings/bca/default.rb +0 -9
- 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/application/inspect_spec.rb +0 -287
- data/spec/unit/data_providers/sample_data_provider_spec.rb +0 -52
- data/spec/unit/face/file_spec.rb +0 -10
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +0 -237
- data/spec/unit/indirector/resource_type/parser_spec.rb +0 -254
- data/spec/unit/indirector/resource_type/rest_spec.rb +0 -14
- 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/pops/binder/binder_spec.rb +0 -43
- data/spec/unit/pops/binder/bindings_checker_spec.rb +0 -155
- data/spec/unit/pops/binder/bindings_composer_spec.rb +0 -64
- data/spec/unit/pops/binder/bindings_validator_factory_spec.rb +0 -18
- data/spec/unit/pops/binder/config/binder_config_spec.rb +0 -42
- data/spec/unit/pops/binder/injector_spec.rb +0 -768
- data/spec/unit/pops/parser/rgen_sanitycheck_spec.rb +0 -23
- data/spec/unit/resource/type_collection_helper_spec.rb +0 -24
- data/spec/unit/semver_spec.rb +0 -305
- /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/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/bca/lib/puppet/functions/bca/data.rb +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/manifests/init.pp +0 -0
- /data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/no_provider/manifests/init.pp +0 -0
- /data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{usee → modules/usee}/lib/puppet/functions/usee/callee.rb +0 -0
- /data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/lib/puppet/functions/user/caller.rb +0 -0
|
@@ -1,373 +1,485 @@
|
|
|
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)
|
|
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
|
-
def
|
|
85
|
-
|
|
94
|
+
def any_t
|
|
95
|
+
TypeFactory.any
|
|
86
96
|
end
|
|
87
97
|
|
|
88
98
|
def optional_t(t)
|
|
89
|
-
|
|
99
|
+
TypeFactory.optional(t)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def type_t(t)
|
|
103
|
+
TypeFactory.type_type(t)
|
|
90
104
|
end
|
|
91
105
|
|
|
92
106
|
def not_undef_t(t = nil)
|
|
93
|
-
|
|
107
|
+
TypeFactory.not_undef(t)
|
|
94
108
|
end
|
|
95
109
|
|
|
96
110
|
def undef_t
|
|
97
|
-
|
|
111
|
+
TypeFactory.undef
|
|
98
112
|
end
|
|
99
113
|
|
|
100
114
|
def unit_t
|
|
101
115
|
# Cannot be created via factory, the type is private to the type system
|
|
102
|
-
|
|
116
|
+
PUnitType::DEFAULT
|
|
103
117
|
end
|
|
104
118
|
|
|
105
|
-
def
|
|
106
|
-
|
|
119
|
+
def runtime_t(t, c)
|
|
120
|
+
TypeFactory.runtime(t, c)
|
|
107
121
|
end
|
|
108
122
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Puppet::Pops::Types::PNotUndefType,
|
|
116
|
-
Puppet::Pops::Types::PDataType,
|
|
117
|
-
Puppet::Pops::Types::PScalarType,
|
|
118
|
-
Puppet::Pops::Types::PStringType,
|
|
119
|
-
Puppet::Pops::Types::PNumericType,
|
|
120
|
-
Puppet::Pops::Types::PIntegerType,
|
|
121
|
-
Puppet::Pops::Types::PFloatType,
|
|
122
|
-
Puppet::Pops::Types::PRegexpType,
|
|
123
|
-
Puppet::Pops::Types::PBooleanType,
|
|
124
|
-
Puppet::Pops::Types::PCollectionType,
|
|
125
|
-
Puppet::Pops::Types::PArrayType,
|
|
126
|
-
Puppet::Pops::Types::PHashType,
|
|
127
|
-
Puppet::Pops::Types::PRuntimeType,
|
|
128
|
-
Puppet::Pops::Types::PHostClassType,
|
|
129
|
-
Puppet::Pops::Types::PResourceType,
|
|
130
|
-
Puppet::Pops::Types::PPatternType,
|
|
131
|
-
Puppet::Pops::Types::PEnumType,
|
|
132
|
-
Puppet::Pops::Types::PVariantType,
|
|
133
|
-
Puppet::Pops::Types::PStructType,
|
|
134
|
-
Puppet::Pops::Types::PTupleType,
|
|
135
|
-
Puppet::Pops::Types::PCallableType,
|
|
136
|
-
Puppet::Pops::Types::PType,
|
|
137
|
-
Puppet::Pops::Types::POptionalType,
|
|
138
|
-
Puppet::Pops::Types::PDefaultType,
|
|
139
|
-
]
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def scalar_types
|
|
143
|
-
# PVariantType is also scalar, if its types are all Scalar
|
|
144
|
-
[
|
|
145
|
-
Puppet::Pops::Types::PScalarType,
|
|
146
|
-
Puppet::Pops::Types::PStringType,
|
|
147
|
-
Puppet::Pops::Types::PNumericType,
|
|
148
|
-
Puppet::Pops::Types::PIntegerType,
|
|
149
|
-
Puppet::Pops::Types::PFloatType,
|
|
150
|
-
Puppet::Pops::Types::PRegexpType,
|
|
151
|
-
Puppet::Pops::Types::PBooleanType,
|
|
152
|
-
Puppet::Pops::Types::PPatternType,
|
|
153
|
-
Puppet::Pops::Types::PEnumType,
|
|
154
|
-
]
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def numeric_types
|
|
158
|
-
# PVariantType is also numeric, if its types are all numeric
|
|
159
|
-
[
|
|
160
|
-
Puppet::Pops::Types::PNumericType,
|
|
161
|
-
Puppet::Pops::Types::PIntegerType,
|
|
162
|
-
Puppet::Pops::Types::PFloatType,
|
|
163
|
-
]
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def string_types
|
|
167
|
-
# PVariantType is also string type, if its types are all compatible
|
|
168
|
-
[
|
|
169
|
-
Puppet::Pops::Types::PStringType,
|
|
170
|
-
Puppet::Pops::Types::PPatternType,
|
|
171
|
-
Puppet::Pops::Types::PEnumType,
|
|
172
|
-
]
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def collection_types
|
|
176
|
-
# PVariantType is also string type, if its types are all compatible
|
|
177
|
-
[
|
|
178
|
-
Puppet::Pops::Types::PCollectionType,
|
|
179
|
-
Puppet::Pops::Types::PHashType,
|
|
180
|
-
Puppet::Pops::Types::PArrayType,
|
|
181
|
-
Puppet::Pops::Types::PStructType,
|
|
182
|
-
Puppet::Pops::Types::PTupleType,
|
|
183
|
-
]
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def data_compatible_types
|
|
187
|
-
result = scalar_types
|
|
188
|
-
result << Puppet::Pops::Types::PDataType
|
|
189
|
-
result << array_t(types::PDataType.new)
|
|
190
|
-
result << types::TypeFactory.hash_of_data
|
|
191
|
-
result << Puppet::Pops::Types::PUndefType
|
|
192
|
-
result << not_undef_t(types::PDataType.new)
|
|
193
|
-
tmp = tuple_t(types::PDataType.new)
|
|
194
|
-
result << (tmp)
|
|
195
|
-
tmp.size_type = range_t(0, nil)
|
|
196
|
-
result
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def type_from_class(c)
|
|
200
|
-
c.is_a?(Class) ? c.new : c
|
|
201
|
-
end
|
|
123
|
+
def object_t(hash)
|
|
124
|
+
TypeFactory.object(hash)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def types
|
|
128
|
+
Types
|
|
202
129
|
end
|
|
203
130
|
|
|
204
131
|
context 'when inferring ruby' do
|
|
205
132
|
|
|
206
133
|
it 'fixnum translates to PIntegerType' do
|
|
207
|
-
expect(calculator.infer(1).class).to eq(
|
|
134
|
+
expect(calculator.infer(1).class).to eq(PIntegerType)
|
|
208
135
|
end
|
|
209
136
|
|
|
210
137
|
it 'large fixnum (or bignum depending on architecture) translates to PIntegerType' do
|
|
211
|
-
expect(calculator.infer(2**33).class).to eq(
|
|
138
|
+
expect(calculator.infer(2**33).class).to eq(PIntegerType)
|
|
212
139
|
end
|
|
213
140
|
|
|
214
141
|
it 'float translates to PFloatType' do
|
|
215
|
-
expect(calculator.infer(1.3).class).to eq(
|
|
142
|
+
expect(calculator.infer(1.3).class).to eq(PFloatType)
|
|
216
143
|
end
|
|
217
144
|
|
|
218
145
|
it 'string translates to PStringType' do
|
|
219
|
-
expect(calculator.infer('foo').class).to eq(
|
|
146
|
+
expect(calculator.infer('foo').class).to eq(PStringType)
|
|
220
147
|
end
|
|
221
148
|
|
|
222
149
|
it 'inferred string type knows the string value' do
|
|
223
150
|
t = calculator.infer('foo')
|
|
224
|
-
expect(t.class).to eq(
|
|
225
|
-
expect(t.
|
|
151
|
+
expect(t.class).to eq(PStringType)
|
|
152
|
+
expect(t.value).to eq('foo')
|
|
226
153
|
end
|
|
227
154
|
|
|
228
155
|
it 'boolean true translates to PBooleanType' do
|
|
229
|
-
expect(calculator.infer(true).class).to eq(
|
|
156
|
+
expect(calculator.infer(true).class).to eq(PBooleanType)
|
|
230
157
|
end
|
|
231
158
|
|
|
232
159
|
it 'boolean false translates to PBooleanType' do
|
|
233
|
-
expect(calculator.infer(false).class).to eq(
|
|
160
|
+
expect(calculator.infer(false).class).to eq(PBooleanType)
|
|
234
161
|
end
|
|
235
162
|
|
|
236
163
|
it 'regexp translates to PRegexpType' do
|
|
237
|
-
expect(calculator.infer(/^a regular expression$/).class).to eq(
|
|
164
|
+
expect(calculator.infer(/^a regular expression$/).class).to eq(PRegexpType)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it 'iterable translates to PIteratorType' do
|
|
168
|
+
expect(calculator.infer(Iterable.on(1))).to be_a(PIteratorType)
|
|
238
169
|
end
|
|
239
170
|
|
|
240
171
|
it 'nil translates to PUndefType' do
|
|
241
|
-
expect(calculator.infer(nil).class).to eq(
|
|
172
|
+
expect(calculator.infer(nil).class).to eq(PUndefType)
|
|
242
173
|
end
|
|
243
174
|
|
|
244
|
-
it ':undef translates to
|
|
245
|
-
expect(calculator.infer(:undef).class).to eq(
|
|
175
|
+
it ':undef translates to PUndefType' do
|
|
176
|
+
expect(calculator.infer(:undef).class).to eq(PUndefType)
|
|
246
177
|
end
|
|
247
178
|
|
|
248
179
|
it 'an instance of class Foo translates to PRuntimeType[ruby, Foo]' do
|
|
249
|
-
|
|
180
|
+
::Foo = Class.new
|
|
181
|
+
begin
|
|
182
|
+
t = calculator.infer(::Foo.new)
|
|
183
|
+
expect(t.class).to eq(PRuntimeType)
|
|
184
|
+
expect(t.runtime).to eq(:ruby)
|
|
185
|
+
expect(t.runtime_type_name).to eq('Foo')
|
|
186
|
+
ensure
|
|
187
|
+
Object.send(:remove_const, :Foo)
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it 'Class Foo translates to PType[PRuntimeType[ruby, Foo]]' do
|
|
192
|
+
::Foo = Class.new
|
|
193
|
+
begin
|
|
194
|
+
t = calculator.infer(::Foo)
|
|
195
|
+
expect(t.class).to eq(PType)
|
|
196
|
+
tt = t.type
|
|
197
|
+
expect(tt.class).to eq(PRuntimeType)
|
|
198
|
+
expect(tt.runtime).to eq(:ruby)
|
|
199
|
+
expect(tt.runtime_type_name).to eq('Foo')
|
|
200
|
+
ensure
|
|
201
|
+
Object.send(:remove_const, :Foo)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it 'Module FooModule translates to PType[PRuntimeType[ruby, FooModule]]' do
|
|
206
|
+
::FooModule = Module.new
|
|
207
|
+
begin
|
|
208
|
+
t = calculator.infer(::FooModule)
|
|
209
|
+
expect(t.class).to eq(PType)
|
|
210
|
+
tt = t.type
|
|
211
|
+
expect(tt.class).to eq(PRuntimeType)
|
|
212
|
+
expect(tt.runtime).to eq(:ruby)
|
|
213
|
+
expect(tt.runtime_type_name).to eq('FooModule')
|
|
214
|
+
ensure
|
|
215
|
+
Object.send(:remove_const, :FooModule)
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
context 'sensitive' do
|
|
220
|
+
it 'translates to PSensitiveType' do
|
|
221
|
+
expect(calculator.infer(PSensitiveType::Sensitive.new("hunter2")).class).to eq(PSensitiveType)
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
context 'binary' do
|
|
226
|
+
it 'translates to PBinaryType' do
|
|
227
|
+
expect(calculator.infer(PBinaryType::Binary.from_binary_string("binary")).class).to eq(PBinaryType)
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
context 'version' do
|
|
232
|
+
it 'translates to PVersionType' do
|
|
233
|
+
expect(calculator.infer(SemanticPuppet::Version.new(1,0,0)).class).to eq(PSemVerType)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
it 'range translates to PVersionRangeType' do
|
|
237
|
+
expect(calculator.infer(SemanticPuppet::VersionRange.parse('1.x')).class).to eq(PSemVerRangeType)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
it 'translates to a limited PVersionType by infer_set' do
|
|
241
|
+
v = SemanticPuppet::Version.new(1,0,0)
|
|
242
|
+
t = calculator.infer_set(v)
|
|
243
|
+
expect(t.class).to eq(PSemVerType)
|
|
244
|
+
expect(t.ranges.size).to eq(1)
|
|
245
|
+
expect(t.ranges[0].begin).to eq(v)
|
|
246
|
+
expect(t.ranges[0].end).to eq(v)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
context 'timespan' do
|
|
251
|
+
it 'translates to PTimespanType' do
|
|
252
|
+
expect(calculator.infer(Time::Timespan.from_fields_hash('days' => 2))).to be_a(PTimespanType)
|
|
250
253
|
end
|
|
251
254
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
255
|
+
it 'translates to a limited PTimespanType by infer_set' do
|
|
256
|
+
ts = Time::Timespan.from_fields_hash('days' => 2)
|
|
257
|
+
t = calculator.infer_set(ts)
|
|
258
|
+
expect(t.class).to eq(PTimespanType)
|
|
259
|
+
expect(t.from).to be(ts)
|
|
260
|
+
expect(t.to).to be(ts)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
context 'timestamp' do
|
|
265
|
+
it 'translates to PTimespanType' do
|
|
266
|
+
expect(calculator.infer(Time::Timestamp.now)).to be_a(PTimestampType)
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
it 'translates to a limited PTimespanType by infer_set' do
|
|
270
|
+
ts = Time::Timestamp.now
|
|
271
|
+
t = calculator.infer_set(ts)
|
|
272
|
+
expect(t.class).to eq(PTimestampType)
|
|
273
|
+
expect(t.from).to be(ts)
|
|
274
|
+
expect(t.to).to be(ts)
|
|
275
|
+
end
|
|
256
276
|
end
|
|
257
277
|
|
|
258
278
|
context 'array' do
|
|
279
|
+
let(:derived) do
|
|
280
|
+
Class.new(Array).new([1,2])
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
let(:derived_object) do
|
|
284
|
+
Class.new(Array) do
|
|
285
|
+
include PuppetObject
|
|
286
|
+
|
|
287
|
+
def self._pcore_type
|
|
288
|
+
@type ||= TypeFactory.object('name' => 'DerivedObjectArray')
|
|
289
|
+
end
|
|
290
|
+
end.new([1,2])
|
|
291
|
+
end
|
|
292
|
+
|
|
259
293
|
it 'translates to PArrayType' do
|
|
260
|
-
expect(calculator.infer([1,2]).class).to eq(
|
|
294
|
+
expect(calculator.infer([1,2]).class).to eq(PArrayType)
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
it 'translates derived Array to PRuntimeType' do
|
|
298
|
+
expect(calculator.infer(derived).class).to eq(PRuntimeType)
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
it 'translates derived Puppet Object Array to PObjectType' do
|
|
302
|
+
expect(calculator.infer(derived_object).class).to eq(PObjectType)
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
it 'Instance of derived Array class is not instance of Array type' do
|
|
306
|
+
expect(PArrayType::DEFAULT).not_to be_instance(derived)
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
it 'Instance of derived Array class is instance of Runtime type' do
|
|
310
|
+
expect(runtime_t('ruby', nil)).to be_instance(derived)
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
it 'Instance of derived Puppet Object Array class is not instance of Array type' do
|
|
314
|
+
expect(PArrayType::DEFAULT).not_to be_instance(derived_object)
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
it 'Instance of derived Puppet Object Array class is instance of Object type' do
|
|
318
|
+
expect(object_t('name' => 'DerivedObjectArray')).to be_instance(derived_object)
|
|
261
319
|
end
|
|
262
320
|
|
|
263
321
|
it 'with fixnum values translates to PArrayType[PIntegerType]' do
|
|
264
|
-
expect(calculator.infer([1,2]).element_type.class).to eq(
|
|
322
|
+
expect(calculator.infer([1,2]).element_type.class).to eq(PIntegerType)
|
|
265
323
|
end
|
|
266
324
|
|
|
267
325
|
it 'with 32 and 64 bit integer values translates to PArrayType[PIntegerType]' do
|
|
268
|
-
expect(calculator.infer([1,2**33]).element_type.class).to eq(
|
|
326
|
+
expect(calculator.infer([1,2**33]).element_type.class).to eq(PIntegerType)
|
|
269
327
|
end
|
|
270
328
|
|
|
271
329
|
it 'Range of integer values are computed' do
|
|
272
330
|
t = calculator.infer([-3,0,42]).element_type
|
|
273
|
-
expect(t.class).to eq(
|
|
331
|
+
expect(t.class).to eq(PIntegerType)
|
|
274
332
|
expect(t.from).to eq(-3)
|
|
275
333
|
expect(t.to).to eq(42)
|
|
276
334
|
end
|
|
277
335
|
|
|
278
|
-
it
|
|
336
|
+
it 'Compound string values are converted to enums' do
|
|
279
337
|
t = calculator.infer(['a','b', 'c']).element_type
|
|
280
|
-
expect(t.class).to eq(
|
|
338
|
+
expect(t.class).to eq(PEnumType)
|
|
281
339
|
expect(t.values).to eq(['a', 'b', 'c'])
|
|
282
340
|
end
|
|
283
341
|
|
|
284
|
-
it 'with
|
|
285
|
-
expect(calculator.infer([1,2.0]).element_type.class).to eq(
|
|
342
|
+
it 'with integer and float values translates to PArrayType[PNumericType]' do
|
|
343
|
+
expect(calculator.infer([1,2.0]).element_type.class).to eq(PNumericType)
|
|
286
344
|
end
|
|
287
345
|
|
|
288
|
-
it 'with
|
|
289
|
-
expect(calculator.infer([1,'two']).element_type.class).to eq(
|
|
346
|
+
it 'with integer and string values translates to PArrayType[PScalarDataType]' do
|
|
347
|
+
expect(calculator.infer([1,'two']).element_type.class).to eq(PScalarDataType)
|
|
290
348
|
end
|
|
291
349
|
|
|
292
|
-
it 'with float and string values translates to PArrayType[
|
|
293
|
-
expect(calculator.infer([1.0,'two']).element_type.class).to eq(
|
|
350
|
+
it 'with float and string values translates to PArrayType[PScalarDataType]' do
|
|
351
|
+
expect(calculator.infer([1.0,'two']).element_type.class).to eq(PScalarDataType)
|
|
294
352
|
end
|
|
295
353
|
|
|
296
|
-
it 'with
|
|
297
|
-
expect(calculator.infer([1, 2.0,'two']).element_type.class).to eq(
|
|
354
|
+
it 'with integer, float, and string values translates to PArrayType[PScalarDataType]' do
|
|
355
|
+
expect(calculator.infer([1, 2.0,'two']).element_type.class).to eq(PScalarDataType)
|
|
298
356
|
end
|
|
299
357
|
|
|
300
|
-
it 'with
|
|
301
|
-
expect(calculator.infer([1, /two/]).element_type.class).to eq(
|
|
358
|
+
it 'with integer and regexp values translates to PArrayType[PScalarType]' do
|
|
359
|
+
expect(calculator.infer([1, /two/]).element_type.class).to eq(PScalarType)
|
|
302
360
|
end
|
|
303
361
|
|
|
304
362
|
it 'with string and regexp values translates to PArrayType[PScalarType]' do
|
|
305
|
-
expect(calculator.infer(['one', /two/]).element_type.class).to eq(
|
|
363
|
+
expect(calculator.infer(['one', /two/]).element_type.class).to eq(PScalarType)
|
|
306
364
|
end
|
|
307
365
|
|
|
308
366
|
it 'with string and symbol values translates to PArrayType[PAnyType]' do
|
|
309
|
-
expect(calculator.infer(['one', :two]).element_type.class).to eq(
|
|
367
|
+
expect(calculator.infer(['one', :two]).element_type.class).to eq(PAnyType)
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
it 'with integer and nil values translates to PArrayType[PIntegerType]' do
|
|
371
|
+
expect(calculator.infer([1, nil]).element_type.class).to eq(PIntegerType)
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
it 'with integer value, and array of string values, translates to Array[Data]' do
|
|
375
|
+
expect(calculator.infer([1, ['two']]).element_type.name).to eq('Data')
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
it 'with integer value, and hash of string => string values, translates to Array[Data]' do
|
|
379
|
+
expect(calculator.infer([1, {'two' => 'three'} ]).element_type.name).to eq('Data')
|
|
310
380
|
end
|
|
311
381
|
|
|
312
|
-
it 'with
|
|
313
|
-
expect(calculator.infer([1,
|
|
382
|
+
it 'with integer value, and hash of integer => string values, translates to Array[RichData]' do
|
|
383
|
+
expect(calculator.infer([1, {2 => 'three'} ]).element_type.name).to eq('RichData')
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
it 'with integer, regexp, and binary values translates to Array[RichData]' do
|
|
387
|
+
expect(calculator.infer([1, /two/, PBinaryType::Binary.from_string('three')]).element_type.name).to eq('RichData')
|
|
314
388
|
end
|
|
315
389
|
|
|
316
390
|
it 'with arrays of string values translates to PArrayType[PArrayType[PStringType]]' do
|
|
317
|
-
et = calculator.infer([['first' 'array'], ['second','array']])
|
|
318
|
-
expect(et.class).to eq(
|
|
391
|
+
et = calculator.infer([['first', 'array'], ['second','array']])
|
|
392
|
+
expect(et.class).to eq(PArrayType)
|
|
319
393
|
et = et.element_type
|
|
320
|
-
expect(et.class).to eq(
|
|
394
|
+
expect(et.class).to eq(PArrayType)
|
|
321
395
|
et = et.element_type
|
|
322
|
-
expect(et.class).to eq(
|
|
396
|
+
expect(et.class).to eq(PEnumType)
|
|
323
397
|
end
|
|
324
398
|
|
|
325
|
-
it 'with array of string values and array of fixnums translates to PArrayType[PArrayType[
|
|
326
|
-
et = calculator.infer([['first' 'array'], [1,2]])
|
|
327
|
-
expect(et.class).to eq(
|
|
399
|
+
it 'with array of string values and array of fixnums translates to PArrayType[PArrayType[PScalarDataType]]' do
|
|
400
|
+
et = calculator.infer([['first', 'array'], [1,2]])
|
|
401
|
+
expect(et.class).to eq(PArrayType)
|
|
328
402
|
et = et.element_type
|
|
329
|
-
expect(et.class).to eq(
|
|
403
|
+
expect(et.class).to eq(PArrayType)
|
|
330
404
|
et = et.element_type
|
|
331
|
-
expect(et.class).to eq(
|
|
405
|
+
expect(et.class).to eq(PScalarDataType)
|
|
332
406
|
end
|
|
333
407
|
|
|
334
|
-
it 'with hashes of string values translates to PArrayType[PHashType[
|
|
408
|
+
it 'with hashes of string values translates to PArrayType[PHashType[PEnumType]]' do
|
|
335
409
|
et = calculator.infer([{:first => 'first', :second => 'second' }, {:first => 'first', :second => 'second' }])
|
|
336
|
-
expect(et.class).to eq(
|
|
337
|
-
et = et.element_type
|
|
338
|
-
expect(et.class).to eq(Puppet::Pops::Types::PHashType)
|
|
410
|
+
expect(et.class).to eq(PArrayType)
|
|
339
411
|
et = et.element_type
|
|
340
|
-
expect(et.class).to eq(
|
|
412
|
+
expect(et.class).to eq(PHashType)
|
|
413
|
+
et = et.value_type
|
|
414
|
+
expect(et.class).to eq(PEnumType)
|
|
341
415
|
end
|
|
342
416
|
|
|
343
|
-
it 'with hash of string values and hash of fixnums translates to PArrayType[PHashType[
|
|
417
|
+
it 'with hash of string values and hash of fixnums translates to PArrayType[PHashType[PScalarDataType]]' do
|
|
344
418
|
et = calculator.infer([{:first => 'first', :second => 'second' }, {:first => 1, :second => 2 }])
|
|
345
|
-
expect(et.class).to eq(
|
|
419
|
+
expect(et.class).to eq(PArrayType)
|
|
346
420
|
et = et.element_type
|
|
347
|
-
expect(et.class).to eq(
|
|
348
|
-
et = et.
|
|
349
|
-
expect(et.class).to eq(
|
|
421
|
+
expect(et.class).to eq(PHashType)
|
|
422
|
+
et = et.value_type
|
|
423
|
+
expect(et.class).to eq(PScalarDataType)
|
|
350
424
|
end
|
|
351
425
|
end
|
|
352
426
|
|
|
353
427
|
context 'hash' do
|
|
428
|
+
let(:derived) do
|
|
429
|
+
Class.new(Hash)[:first => 1, :second => 2]
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
let(:derived_object) do
|
|
433
|
+
Class.new(Hash) do
|
|
434
|
+
include PuppetObject
|
|
435
|
+
|
|
436
|
+
def self._pcore_type
|
|
437
|
+
@type ||= TypeFactory.object('name' => 'DerivedObjectHash')
|
|
438
|
+
end
|
|
439
|
+
end[:first => 1, :second => 2]
|
|
440
|
+
end
|
|
441
|
+
|
|
354
442
|
it 'translates to PHashType' do
|
|
355
|
-
expect(calculator.infer({:first => 1, :second => 2}).class).to eq(
|
|
443
|
+
expect(calculator.infer({:first => 1, :second => 2}).class).to eq(PHashType)
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
it 'translates derived Hash to PRuntimeType' do
|
|
447
|
+
expect(calculator.infer(derived).class).to eq(PRuntimeType)
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
it 'translates derived Puppet Object Hash to PObjectType' do
|
|
451
|
+
expect(calculator.infer(derived_object).class).to eq(PObjectType)
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
it 'Instance of derived Hash class is not instance of Hash type' do
|
|
455
|
+
expect(PHashType::DEFAULT).not_to be_instance(derived)
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
it 'Instance of derived Hash class is instance of Runtime type' do
|
|
459
|
+
expect(runtime_t('ruby', nil)).to be_instance(derived)
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
it 'Instance of derived Puppet Object Hash class is not instance of Hash type' do
|
|
463
|
+
expect(PHashType::DEFAULT).not_to be_instance(derived_object)
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
it 'Instance of derived Puppet Object Hash class is instance of Object type' do
|
|
467
|
+
expect(object_t('name' => 'DerivedObjectHash')).to be_instance(derived_object)
|
|
356
468
|
end
|
|
357
469
|
|
|
358
470
|
it 'with symbolic keys translates to PHashType[PRuntimeType[ruby, Symbol], value]' do
|
|
359
471
|
k = calculator.infer({:first => 1, :second => 2}).key_type
|
|
360
|
-
expect(k.class).to eq(
|
|
472
|
+
expect(k.class).to eq(PRuntimeType)
|
|
361
473
|
expect(k.runtime).to eq(:ruby)
|
|
362
474
|
expect(k.runtime_type_name).to eq('Symbol')
|
|
363
475
|
end
|
|
364
476
|
|
|
365
|
-
it 'with string keys translates to PHashType[
|
|
366
|
-
expect(calculator.infer({'first' => 1, 'second' => 2}).key_type.class).to eq(
|
|
477
|
+
it 'with string keys translates to PHashType[PEnumType, value]' do
|
|
478
|
+
expect(calculator.infer({'first' => 1, 'second' => 2}).key_type.class).to eq(PEnumType)
|
|
367
479
|
end
|
|
368
480
|
|
|
369
481
|
it 'with fixnum values translates to PHashType[key, PIntegerType]' do
|
|
370
|
-
expect(calculator.infer({:first => 1, :second => 2}).
|
|
482
|
+
expect(calculator.infer({:first => 1, :second => 2}).value_type.class).to eq(PIntegerType)
|
|
371
483
|
end
|
|
372
484
|
|
|
373
485
|
it 'when empty infers a type that answers true to is_the_empty_hash?' do
|
|
@@ -380,101 +492,89 @@ describe 'The type calculator' do
|
|
|
380
492
|
end
|
|
381
493
|
|
|
382
494
|
it 'when empty is not assignable to a PHashType with from size > 0' do
|
|
383
|
-
expect(calculator.assignable?(
|
|
495
|
+
expect(calculator.assignable?(hash_t(string_t,string_t,range_t(1, 1)), calculator.infer({}))).to eq(false)
|
|
384
496
|
end
|
|
385
497
|
|
|
386
498
|
context 'using infer_set' do
|
|
387
499
|
it "with 'first' and 'second' keys translates to PStructType[{first=>value,second=>value}]" do
|
|
388
500
|
t = calculator.infer_set({'first' => 1, 'second' => 2})
|
|
389
|
-
expect(t.class).to eq(
|
|
501
|
+
expect(t.class).to eq(PStructType)
|
|
390
502
|
expect(t.elements.size).to eq(2)
|
|
391
503
|
expect(t.elements.map { |e| e.name }.sort).to eq(['first', 'second'])
|
|
392
504
|
end
|
|
393
505
|
|
|
394
506
|
it 'with string keys and string and array values translates to PStructType[{key1=>PStringType,key2=>PTupleType}]' do
|
|
395
507
|
t = calculator.infer_set({ 'mode' => 'read', 'path' => ['foo', 'fee' ] })
|
|
396
|
-
expect(t.class).to eq(
|
|
508
|
+
expect(t.class).to eq(PStructType)
|
|
397
509
|
expect(t.elements.size).to eq(2)
|
|
398
510
|
els = t.elements.map { |e| e.value_type }.sort {|a,b| a.to_s <=> b.to_s }
|
|
399
|
-
expect(els[0].class).to eq(
|
|
400
|
-
expect(els[1].class).to eq(
|
|
511
|
+
expect(els[0].class).to eq(PStringType)
|
|
512
|
+
expect(els[1].class).to eq(PTupleType)
|
|
401
513
|
end
|
|
402
514
|
|
|
403
515
|
it 'with mixed string and non-string keys translates to PHashType' do
|
|
404
516
|
t = calculator.infer_set({ 1 => 'first', 'second' => 'second' })
|
|
405
|
-
expect(t.class).to eq(
|
|
517
|
+
expect(t.class).to eq(PHashType)
|
|
406
518
|
end
|
|
407
519
|
|
|
408
520
|
it 'with empty string keys translates to PHashType' do
|
|
409
521
|
t = calculator.infer_set({ '' => 'first', 'second' => 'second' })
|
|
410
|
-
expect(t.class).to eq(
|
|
522
|
+
expect(t.class).to eq(PHashType)
|
|
411
523
|
end
|
|
412
524
|
end
|
|
413
525
|
end
|
|
414
526
|
end
|
|
415
527
|
|
|
416
528
|
context 'patterns' do
|
|
417
|
-
it
|
|
529
|
+
it 'constructs a PPatternType' do
|
|
418
530
|
t = pattern_t('a(b)c')
|
|
419
|
-
expect(t.class).to eq(
|
|
531
|
+
expect(t.class).to eq(PPatternType)
|
|
420
532
|
expect(t.patterns.size).to eq(1)
|
|
421
|
-
expect(t.patterns[0].class).to eq(
|
|
533
|
+
expect(t.patterns[0].class).to eq(PRegexpType)
|
|
422
534
|
expect(t.patterns[0].pattern).to eq('a(b)c')
|
|
423
535
|
expect(t.patterns[0].regexp.match('abc')[1]).to eq('b')
|
|
424
536
|
end
|
|
425
537
|
|
|
426
|
-
it
|
|
427
|
-
t =
|
|
428
|
-
expect(t.values).to eq(['a', 'b', 'c', 'abc'])
|
|
538
|
+
it 'constructs a PEnumType with multiple strings' do
|
|
539
|
+
t = enum_t('a', 'b', 'c', 'abc')
|
|
540
|
+
expect(t.values).to eq(['a', 'b', 'c', 'abc'].sort)
|
|
429
541
|
end
|
|
430
542
|
end
|
|
431
543
|
|
|
432
544
|
# Deal with cases not covered by computing common type
|
|
433
545
|
context 'when computing common type' do
|
|
434
546
|
it 'computes given resource type commonality' do
|
|
435
|
-
r1 =
|
|
436
|
-
|
|
437
|
-
r2
|
|
438
|
-
|
|
439
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("File")
|
|
547
|
+
r1 = PResourceType.new('File', nil)
|
|
548
|
+
r2 = PResourceType.new('File', nil)
|
|
549
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('File')
|
|
550
|
+
|
|
440
551
|
|
|
441
|
-
r2 =
|
|
442
|
-
r2.
|
|
443
|
-
r2.title = '/tmp/foo'
|
|
444
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("File")
|
|
552
|
+
r2 = PResourceType.new('File', '/tmp/foo')
|
|
553
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('File')
|
|
445
554
|
|
|
446
|
-
r1 =
|
|
447
|
-
r1.
|
|
448
|
-
r1.title = '/tmp/foo'
|
|
449
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("File['/tmp/foo']")
|
|
555
|
+
r1 = PResourceType.new('File', '/tmp/foo')
|
|
556
|
+
expect(calculator.common_type(r1, r2).to_s).to eq("File['/tmp/foo']")
|
|
450
557
|
|
|
451
|
-
r1 =
|
|
452
|
-
r1.
|
|
453
|
-
r1.title = '/tmp/bar'
|
|
454
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("File")
|
|
558
|
+
r1 = PResourceType.new('File', '/tmp/bar')
|
|
559
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('File')
|
|
455
560
|
|
|
456
|
-
r2 =
|
|
457
|
-
r2.
|
|
458
|
-
r2.title = 'apache'
|
|
459
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("Resource")
|
|
561
|
+
r2 = PResourceType.new('Package', 'apache')
|
|
562
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Resource')
|
|
460
563
|
end
|
|
461
564
|
|
|
462
565
|
it 'computes given hostclass type commonality' do
|
|
463
|
-
r1 =
|
|
464
|
-
|
|
465
|
-
r2
|
|
466
|
-
r2.class_name = 'foo'
|
|
467
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("Class[foo]")
|
|
566
|
+
r1 = PHostClassType.new('foo')
|
|
567
|
+
r2 = PHostClassType.new('foo')
|
|
568
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class[foo]')
|
|
468
569
|
|
|
469
|
-
r2 =
|
|
470
|
-
r2.
|
|
471
|
-
expect(calculator.string(calculator.common_type(r1, r2))).to eq("Class")
|
|
570
|
+
r2 = PHostClassType.new('bar')
|
|
571
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class')
|
|
472
572
|
|
|
473
|
-
r2 =
|
|
474
|
-
expect(calculator.
|
|
573
|
+
r2 = PHostClassType.new(nil)
|
|
574
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class')
|
|
475
575
|
|
|
476
|
-
r1 =
|
|
477
|
-
expect(calculator.
|
|
576
|
+
r1 = PHostClassType.new(nil)
|
|
577
|
+
expect(calculator.common_type(r1, r2).to_s).to eq('Class')
|
|
478
578
|
end
|
|
479
579
|
|
|
480
580
|
context 'of strings' do
|
|
@@ -482,37 +582,32 @@ describe 'The type calculator' do
|
|
|
482
582
|
t1 = string_t('abc')
|
|
483
583
|
t2 = string_t('xyz')
|
|
484
584
|
common_t = calculator.common_type(t1,t2)
|
|
485
|
-
expect(common_t.class).to eq(
|
|
585
|
+
expect(common_t.class).to eq(PEnumType)
|
|
486
586
|
expect(common_t.values).to eq(['abc', 'xyz'])
|
|
487
587
|
end
|
|
488
588
|
|
|
489
589
|
it 'computes common size_type' do
|
|
490
|
-
t1 =
|
|
491
|
-
|
|
492
|
-
t2 = string_t
|
|
493
|
-
t2.size_type = range_t(2,4)
|
|
590
|
+
t1 = constrained_string_t(range_t(3,6))
|
|
591
|
+
t2 = constrained_string_t(range_t(2,4))
|
|
494
592
|
common_t = calculator.common_type(t1,t2)
|
|
495
|
-
expect(common_t.class).to eq(
|
|
593
|
+
expect(common_t.class).to eq(PStringType)
|
|
496
594
|
expect(common_t.size_type).to eq(range_t(2,6))
|
|
497
595
|
end
|
|
498
596
|
|
|
499
597
|
it 'computes common size_type to be undef when one of the types has no size_type' do
|
|
500
598
|
t1 = string_t
|
|
501
|
-
t2 =
|
|
502
|
-
t2.size_type = range_t(2,4)
|
|
599
|
+
t2 = constrained_string_t(range_t(2,4))
|
|
503
600
|
common_t = calculator.common_type(t1,t2)
|
|
504
|
-
expect(common_t.class).to eq(
|
|
601
|
+
expect(common_t.class).to eq(PStringType)
|
|
505
602
|
expect(common_t.size_type).to be_nil
|
|
506
603
|
end
|
|
507
604
|
|
|
508
605
|
it 'computes values to be empty if the one has empty values' do
|
|
509
606
|
t1 = string_t('apa')
|
|
510
|
-
|
|
511
|
-
t2 = string_t
|
|
512
|
-
t2.size_type = range_t(2,4)
|
|
607
|
+
t2 = constrained_string_t(range_t(2,4))
|
|
513
608
|
common_t = calculator.common_type(t1,t2)
|
|
514
|
-
expect(common_t.class).to eq(
|
|
515
|
-
expect(common_t.
|
|
609
|
+
expect(common_t.class).to eq(PStringType)
|
|
610
|
+
expect(common_t.value).to be_nil
|
|
516
611
|
end
|
|
517
612
|
end
|
|
518
613
|
|
|
@@ -520,9 +615,9 @@ describe 'The type calculator' do
|
|
|
520
615
|
t1 = pattern_t('abc')
|
|
521
616
|
t2 = pattern_t('xyz')
|
|
522
617
|
common_t = calculator.common_type(t1,t2)
|
|
523
|
-
expect(common_t.class).to eq(
|
|
618
|
+
expect(common_t.class).to eq(PPatternType)
|
|
524
619
|
expect(common_t.patterns.map { |pr| pr.pattern }).to eq(['abc', 'xyz'])
|
|
525
|
-
expect(
|
|
620
|
+
expect(common_t.to_s).to eq('Pattern[/abc/, /xyz/]')
|
|
526
621
|
end
|
|
527
622
|
|
|
528
623
|
it 'computes enum commonality to value set sum' do
|
|
@@ -533,116 +628,172 @@ describe 'The type calculator' do
|
|
|
533
628
|
end
|
|
534
629
|
|
|
535
630
|
it 'computed variant commonality to type union where added types are not sub-types' do
|
|
536
|
-
a_t1 = integer_t
|
|
631
|
+
a_t1 = integer_t
|
|
537
632
|
a_t2 = enum_t('b')
|
|
538
633
|
v_a = variant_t(a_t1, a_t2)
|
|
539
|
-
b_t1 =
|
|
540
|
-
|
|
634
|
+
b_t1 = integer_t
|
|
635
|
+
b_t2 = enum_t('a')
|
|
636
|
+
v_b = variant_t(b_t1, b_t2)
|
|
541
637
|
common_t = calculator.common_type(v_a, v_b)
|
|
542
|
-
expect(common_t.class).to eq(
|
|
543
|
-
expect(Set.new(common_t.types)).to eq(Set.new([a_t1, a_t2, b_t1]))
|
|
638
|
+
expect(common_t.class).to eq(PVariantType)
|
|
639
|
+
expect(Set.new(common_t.types)).to eq(Set.new([a_t1, a_t2, b_t1, b_t2]))
|
|
544
640
|
end
|
|
545
641
|
|
|
546
642
|
it 'computed variant commonality to type union where added types are sub-types' do
|
|
547
|
-
a_t1 = integer_t
|
|
548
|
-
a_t2 = string_t
|
|
643
|
+
a_t1 = integer_t
|
|
644
|
+
a_t2 = string_t
|
|
549
645
|
v_a = variant_t(a_t1, a_t2)
|
|
550
|
-
b_t1 =
|
|
551
|
-
|
|
646
|
+
b_t1 = integer_t
|
|
647
|
+
b_t2 = enum_t('a')
|
|
648
|
+
v_b = variant_t(b_t1, b_t2)
|
|
552
649
|
common_t = calculator.common_type(v_a, v_b)
|
|
553
|
-
expect(common_t.class).to eq(
|
|
650
|
+
expect(common_t.class).to eq(PVariantType)
|
|
554
651
|
expect(Set.new(common_t.types)).to eq(Set.new([a_t1, a_t2]))
|
|
555
652
|
end
|
|
556
653
|
|
|
557
|
-
context
|
|
654
|
+
context 'commonality of scalar data types' do
|
|
655
|
+
it 'Numeric and String == ScalarData' do
|
|
656
|
+
expect(calculator.common_type(PNumericType::DEFAULT, PStringType::DEFAULT).class).to eq(PScalarDataType)
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
it 'Numeric and Boolean == ScalarData' do
|
|
660
|
+
expect(calculator.common_type(PNumericType::DEFAULT, PBooleanType::DEFAULT).class).to eq(PScalarDataType)
|
|
661
|
+
end
|
|
662
|
+
|
|
663
|
+
it 'String and Boolean == ScalarData' do
|
|
664
|
+
expect(calculator.common_type(PStringType::DEFAULT, PBooleanType::DEFAULT).class).to eq(PScalarDataType)
|
|
665
|
+
end
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
context 'commonality of scalar types' do
|
|
669
|
+
it 'Regexp and Integer == Scalar' do
|
|
670
|
+
expect(calculator.common_type(PRegexpType::DEFAULT, PScalarDataType::DEFAULT).class).to eq(PScalarType)
|
|
671
|
+
end
|
|
672
|
+
|
|
673
|
+
it 'Regexp and SemVer == ScalarData' do
|
|
674
|
+
expect(calculator.common_type(PRegexpType::DEFAULT, PSemVerType::DEFAULT).class).to eq(PScalarType)
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
it 'Timestamp and Timespan == ScalarData' do
|
|
678
|
+
expect(calculator.common_type(PTimestampType::DEFAULT, PTimespanType::DEFAULT).class).to eq(PScalarType)
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
it 'Timestamp and Boolean == ScalarData' do
|
|
682
|
+
expect(calculator.common_type(PTimestampType::DEFAULT, PBooleanType::DEFAULT).class).to eq(PScalarType)
|
|
683
|
+
end
|
|
684
|
+
end
|
|
685
|
+
|
|
686
|
+
context 'of callables' do
|
|
558
687
|
it 'incompatible instances => generic callable' do
|
|
559
688
|
t1 = callable_t(String)
|
|
560
689
|
t2 = callable_t(Integer)
|
|
561
690
|
common_t = calculator.common_type(t1, t2)
|
|
562
|
-
expect(common_t.class).to be(
|
|
691
|
+
expect(common_t.class).to be(PCallableType)
|
|
563
692
|
expect(common_t.param_types).to be_nil
|
|
564
693
|
expect(common_t.block_type).to be_nil
|
|
565
694
|
end
|
|
566
695
|
|
|
567
696
|
it 'compatible instances => the most specific' do
|
|
568
697
|
t1 = callable_t(String)
|
|
569
|
-
scalar_t =
|
|
698
|
+
scalar_t = PScalarType.new
|
|
570
699
|
t2 = callable_t(scalar_t)
|
|
571
700
|
common_t = calculator.common_type(t1, t2)
|
|
572
|
-
expect(common_t.class).to be(
|
|
573
|
-
expect(common_t.param_types.class).to be(
|
|
701
|
+
expect(common_t.class).to be(PCallableType)
|
|
702
|
+
expect(common_t.param_types.class).to be(PTupleType)
|
|
574
703
|
expect(common_t.param_types.types).to eql([string_t])
|
|
575
704
|
expect(common_t.block_type).to be_nil
|
|
576
705
|
end
|
|
577
706
|
|
|
578
707
|
it 'block_type is included in the check (incompatible block)' do
|
|
579
|
-
|
|
580
|
-
|
|
708
|
+
b1 = callable_t(String)
|
|
709
|
+
b2 = callable_t(Integer)
|
|
710
|
+
t1 = callable_t(String, b1)
|
|
711
|
+
t2 = callable_t(String, b2)
|
|
581
712
|
common_t = calculator.common_type(t1, t2)
|
|
582
|
-
expect(common_t.class).to be(
|
|
713
|
+
expect(common_t.class).to be(PCallableType)
|
|
583
714
|
expect(common_t.param_types).to be_nil
|
|
584
715
|
expect(common_t.block_type).to be_nil
|
|
585
716
|
end
|
|
586
717
|
|
|
587
718
|
it 'block_type is included in the check (compatible block)' do
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
719
|
+
b1 = callable_t(String)
|
|
720
|
+
t1 = callable_t(String, b1)
|
|
721
|
+
scalar_t = PScalarType::DEFAULT
|
|
722
|
+
b2 = callable_t(scalar_t)
|
|
723
|
+
t2 = callable_t(String, b2)
|
|
591
724
|
common_t = calculator.common_type(t1, t2)
|
|
592
|
-
expect(common_t.param_types.class).to be(
|
|
725
|
+
expect(common_t.param_types.class).to be(PTupleType)
|
|
593
726
|
expect(common_t.block_type).to eql(callable_t(scalar_t))
|
|
594
727
|
end
|
|
728
|
+
|
|
729
|
+
it 'return_type is included in the check (incompatible return_type)' do
|
|
730
|
+
t1 = callable_t([String], String)
|
|
731
|
+
t2 = callable_t([String], Integer)
|
|
732
|
+
common_t = calculator.common_type(t1, t2)
|
|
733
|
+
expect(common_t.class).to be(PCallableType)
|
|
734
|
+
expect(common_t.param_types).to be_nil
|
|
735
|
+
expect(common_t.return_type).to be_nil
|
|
736
|
+
end
|
|
737
|
+
|
|
738
|
+
it 'return_type is included in the check (compatible return_type)' do
|
|
739
|
+
t1 = callable_t([String], Numeric)
|
|
740
|
+
t2 = callable_t([String], Integer)
|
|
741
|
+
common_t = calculator.common_type(t1, t2)
|
|
742
|
+
expect(common_t.class).to be(PCallableType)
|
|
743
|
+
expect(common_t.param_types).to be_a(PTupleType)
|
|
744
|
+
expect(common_t.return_type).to eql(PNumericType::DEFAULT)
|
|
745
|
+
end
|
|
595
746
|
end
|
|
596
747
|
end
|
|
597
748
|
|
|
598
749
|
context 'computes assignability' do
|
|
599
|
-
include_context
|
|
750
|
+
include_context 'types_setup'
|
|
600
751
|
|
|
601
752
|
it 'such that all types are assignable to themselves' do
|
|
602
753
|
all_types.each do |tc|
|
|
603
|
-
t = tc
|
|
754
|
+
t = tc::DEFAULT
|
|
604
755
|
expect(t).to be_assignable_to(t)
|
|
605
756
|
end
|
|
606
757
|
end
|
|
607
758
|
|
|
608
759
|
context 'for Unit, such that' do
|
|
609
760
|
it 'all types are assignable to Unit' do
|
|
610
|
-
t =
|
|
611
|
-
all_types.each { |t2| expect(t2
|
|
761
|
+
t = PUnitType::DEFAULT
|
|
762
|
+
all_types.each { |t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
612
763
|
end
|
|
613
764
|
|
|
614
765
|
it 'Unit is assignable to all other types' do
|
|
615
|
-
t =
|
|
616
|
-
all_types.each { |t2| expect(t).to be_assignable_to(t2
|
|
766
|
+
t = PUnitType::DEFAULT
|
|
767
|
+
all_types.each { |t2| expect(t).to be_assignable_to(t2::DEFAULT) }
|
|
617
768
|
end
|
|
618
769
|
|
|
619
770
|
it 'Unit is assignable to Unit' do
|
|
620
|
-
t =
|
|
621
|
-
t2 =
|
|
771
|
+
t = PUnitType::DEFAULT
|
|
772
|
+
t2 = PUnitType::DEFAULT
|
|
622
773
|
expect(t).to be_assignable_to(t2)
|
|
623
774
|
end
|
|
624
775
|
end
|
|
625
776
|
|
|
626
|
-
context
|
|
777
|
+
context 'for Any, such that' do
|
|
627
778
|
it 'all types are assignable to Any' do
|
|
628
|
-
t =
|
|
629
|
-
all_types.each { |t2| expect(t2
|
|
779
|
+
t = PAnyType::DEFAULT
|
|
780
|
+
all_types.each { |t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
630
781
|
end
|
|
631
782
|
|
|
632
783
|
it 'Any is not assignable to anything but Any and Optional (implied Optional[Any])' do
|
|
633
|
-
tested_types = all_types() - [
|
|
634
|
-
t =
|
|
635
|
-
tested_types.each { |t2| expect(t).not_to be_assignable_to(t2
|
|
784
|
+
tested_types = all_types() - [PAnyType, POptionalType]
|
|
785
|
+
t = PAnyType::DEFAULT
|
|
786
|
+
tested_types.each { |t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
636
787
|
end
|
|
637
788
|
end
|
|
638
789
|
|
|
639
790
|
context "for NotUndef, such that" do
|
|
640
791
|
it 'all types except types assignable from Undef are assignable to NotUndef' do
|
|
641
792
|
t = not_undef_t
|
|
642
|
-
tc =
|
|
643
|
-
undef_t =
|
|
644
|
-
all_types
|
|
645
|
-
t2 = c
|
|
793
|
+
tc = TypeCalculator.singleton
|
|
794
|
+
undef_t = PUndefType::DEFAULT
|
|
795
|
+
all_types.each do |c|
|
|
796
|
+
t2 = c::DEFAULT
|
|
646
797
|
if tc.assignable?(t2, undef_t)
|
|
647
798
|
expect(t2).not_to be_assignable_to(t)
|
|
648
799
|
else
|
|
@@ -652,10 +803,10 @@ describe 'The type calculator' do
|
|
|
652
803
|
end
|
|
653
804
|
|
|
654
805
|
it 'type NotUndef[T] is assignable from T unless T is assignable from Undef ' do
|
|
655
|
-
tc =
|
|
656
|
-
undef_t =
|
|
806
|
+
tc = TypeCalculator.singleton
|
|
807
|
+
undef_t = PUndefType::DEFAULT
|
|
657
808
|
all_types().select do |c|
|
|
658
|
-
t2 = c
|
|
809
|
+
t2 = c::DEFAULT
|
|
659
810
|
not_undef_t = not_undef_t(t2)
|
|
660
811
|
if tc.assignable?(t2, undef_t)
|
|
661
812
|
expect(t2).not_to be_assignable_to(not_undef_t)
|
|
@@ -666,10 +817,10 @@ describe 'The type calculator' do
|
|
|
666
817
|
end
|
|
667
818
|
|
|
668
819
|
it 'type T is assignable from NotUndef[T] unless T is assignable from Undef' do
|
|
669
|
-
tc =
|
|
670
|
-
undef_t =
|
|
820
|
+
tc = TypeCalculator.singleton
|
|
821
|
+
undef_t = PUndefType::DEFAULT
|
|
671
822
|
all_types().select do |c|
|
|
672
|
-
t2 = c
|
|
823
|
+
t2 = c::DEFAULT
|
|
673
824
|
not_undef_t = not_undef_t(t2)
|
|
674
825
|
unless tc.assignable?(t2, undef_t)
|
|
675
826
|
expect(not_undef_t).to be_assignable_to(t2)
|
|
@@ -678,35 +829,52 @@ describe 'The type calculator' do
|
|
|
678
829
|
end
|
|
679
830
|
end
|
|
680
831
|
|
|
681
|
-
context "for
|
|
682
|
-
it '
|
|
683
|
-
t =
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
832
|
+
context "for TypeReference, such that" do
|
|
833
|
+
it 'no other type is assignable' do
|
|
834
|
+
t = PTypeReferenceType::DEFAULT
|
|
835
|
+
all_instances = (all_types - [
|
|
836
|
+
PTypeReferenceType, # Avoid comparison with t
|
|
837
|
+
PVariantType, # DEFAULT contains no variants, so assignability is never tested and always true
|
|
838
|
+
PTypeAliasType # DEFAULT resolves to PTypeReferenceType::DEFAULT, i.e. t
|
|
839
|
+
]).map {|c| c::DEFAULT }
|
|
840
|
+
|
|
841
|
+
# Add a non-empty variant
|
|
842
|
+
all_instances << variant_t(PAnyType::DEFAULT, PUnitType::DEFAULT)
|
|
843
|
+
# Add a type alias that doesn't resolve to 't'
|
|
844
|
+
all_instances << type_alias_t('MyInt', 'Integer').resolve(TypeParser.singleton, nil)
|
|
845
|
+
|
|
846
|
+
all_instances.each { |i| expect(i).not_to be_assignable_to(t) }
|
|
687
847
|
end
|
|
688
848
|
|
|
689
|
-
it 'a
|
|
690
|
-
|
|
691
|
-
data_compatible_types.each { |t2| expect(variant_t(type_from_class(t2))).to be_assignable_to(t) }
|
|
849
|
+
it 'a TypeReference to the exact same type is assignable' do
|
|
850
|
+
expect(type_reference_t('Integer[0,10]')).to be_assignable_to(type_reference_t('Integer[0,10]'))
|
|
692
851
|
end
|
|
693
852
|
|
|
694
|
-
it '
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
853
|
+
it 'a TypeReference to the different type is not assignable' do
|
|
854
|
+
expect(type_reference_t('String')).not_to be_assignable_to(type_reference_t('Integer'))
|
|
855
|
+
end
|
|
856
|
+
|
|
857
|
+
it 'a TypeReference to the different type is not assignable even if the referenced type is' do
|
|
858
|
+
expect(type_reference_t('Integer[1,2]')).not_to be_assignable_to(type_reference_t('Integer[0,3]'))
|
|
859
|
+
end
|
|
860
|
+
end
|
|
861
|
+
|
|
862
|
+
context 'for Data, such that' do
|
|
863
|
+
let(:data) { TypeFactory.data }
|
|
864
|
+
data_compatible_types.map { |t2| type_from_class(t2) }.each do |tc|
|
|
865
|
+
it "#{tc.name} is assignable to Data" do
|
|
866
|
+
expect(tc).to be_assignable_to(data)
|
|
867
|
+
end
|
|
698
868
|
end
|
|
699
869
|
|
|
700
|
-
it 'Data is not assignable to
|
|
701
|
-
|
|
702
|
-
types_to_test
|
|
703
|
-
types_to_test.each { |t2| expect(t).not_to be_assignable_to(variant_t(type_from_class(t2))) }
|
|
870
|
+
it 'Data is not assignable to any of its subtypes' do
|
|
871
|
+
types_to_test = data_compatible_types
|
|
872
|
+
types_to_test.each {|t2| expect(data).not_to be_assignable_to(type_from_class(t2)) }
|
|
704
873
|
end
|
|
705
874
|
|
|
706
875
|
it 'Data is not assignable to any disjunct type' do
|
|
707
|
-
tested_types = all_types - [
|
|
708
|
-
|
|
709
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2.new) }
|
|
876
|
+
tested_types = all_types - [PAnyType, POptionalType] - scalar_types
|
|
877
|
+
tested_types.each {|t2| expect(data).not_to be_assignable_to(t2::DEFAULT) }
|
|
710
878
|
end
|
|
711
879
|
end
|
|
712
880
|
|
|
@@ -728,109 +896,130 @@ describe 'The type calculator' do
|
|
|
728
896
|
end
|
|
729
897
|
end
|
|
730
898
|
|
|
731
|
-
context
|
|
732
|
-
it
|
|
733
|
-
t =
|
|
734
|
-
scalar_types.each {|t2| expect(t2
|
|
899
|
+
context 'for Scalar, such that' do
|
|
900
|
+
it 'all scalars are assignable to Scalar' do
|
|
901
|
+
t = PScalarType::DEFAULT
|
|
902
|
+
scalar_types.each {|t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
735
903
|
end
|
|
736
904
|
|
|
737
905
|
it 'Scalar is not assignable to any of its subtypes' do
|
|
738
|
-
t =
|
|
739
|
-
types_to_test = scalar_types - [
|
|
740
|
-
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
906
|
+
t = PScalarType::DEFAULT
|
|
907
|
+
types_to_test = scalar_types - [PScalarType]
|
|
908
|
+
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
741
909
|
end
|
|
742
910
|
|
|
743
911
|
it 'Scalar is not assignable to any disjunct type' do
|
|
744
|
-
tested_types = all_types - [
|
|
745
|
-
t =
|
|
746
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
912
|
+
tested_types = all_types - [PAnyType, POptionalType, PNotUndefType] - scalar_types
|
|
913
|
+
t = PScalarType::DEFAULT
|
|
914
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
747
915
|
end
|
|
748
916
|
end
|
|
749
917
|
|
|
750
|
-
context
|
|
751
|
-
it
|
|
752
|
-
t =
|
|
753
|
-
numeric_types.each {|t2| expect(t2
|
|
918
|
+
context 'for Numeric, such that' do
|
|
919
|
+
it 'all numerics are assignable to Numeric' do
|
|
920
|
+
t = PNumericType::DEFAULT
|
|
921
|
+
numeric_types.each {|t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
754
922
|
end
|
|
755
923
|
|
|
756
924
|
it 'Numeric is not assignable to any of its subtypes' do
|
|
757
|
-
t =
|
|
758
|
-
types_to_test = numeric_types - [
|
|
759
|
-
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
925
|
+
t = PNumericType::DEFAULT
|
|
926
|
+
types_to_test = numeric_types - [PNumericType]
|
|
927
|
+
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
760
928
|
end
|
|
761
929
|
|
|
762
930
|
it 'Numeric is not assignable to any disjunct type' do
|
|
763
931
|
tested_types = all_types - [
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
932
|
+
PAnyType,
|
|
933
|
+
POptionalType,
|
|
934
|
+
PNotUndefType,
|
|
935
|
+
PScalarType,
|
|
936
|
+
PScalarDataType,
|
|
769
937
|
] - numeric_types
|
|
770
|
-
t =
|
|
771
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
938
|
+
t = PNumericType::DEFAULT
|
|
939
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
772
940
|
end
|
|
773
941
|
end
|
|
774
942
|
|
|
775
|
-
context
|
|
776
|
-
it
|
|
777
|
-
t =
|
|
778
|
-
collection_types.each {|t2| expect(t2
|
|
943
|
+
context 'for Collection, such that' do
|
|
944
|
+
it 'all collections are assignable to Collection' do
|
|
945
|
+
t = PCollectionType::DEFAULT
|
|
946
|
+
collection_types.each {|t2| expect(t2::DEFAULT).to be_assignable_to(t) }
|
|
779
947
|
end
|
|
780
948
|
|
|
781
949
|
it 'Collection is not assignable to any of its subtypes' do
|
|
782
|
-
t =
|
|
783
|
-
types_to_test = collection_types - [
|
|
784
|
-
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
950
|
+
t = PCollectionType::DEFAULT
|
|
951
|
+
types_to_test = collection_types - [PCollectionType]
|
|
952
|
+
types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
785
953
|
end
|
|
786
954
|
|
|
787
955
|
it 'Collection is not assignable to any disjunct type' do
|
|
788
|
-
tested_types = all_types - [
|
|
789
|
-
|
|
790
|
-
|
|
956
|
+
tested_types = all_types - [
|
|
957
|
+
PAnyType,
|
|
958
|
+
POptionalType,
|
|
959
|
+
PNotUndefType,
|
|
960
|
+
PIterableType] - collection_types
|
|
961
|
+
t = PCollectionType::DEFAULT
|
|
962
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
791
963
|
end
|
|
792
964
|
end
|
|
793
965
|
|
|
794
|
-
context
|
|
795
|
-
it
|
|
796
|
-
t =
|
|
966
|
+
context 'for Array, such that' do
|
|
967
|
+
it 'Array is not assignable to non Array based Collection type' do
|
|
968
|
+
t = PArrayType::DEFAULT
|
|
797
969
|
tested_types = collection_types - [
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
970
|
+
PCollectionType,
|
|
971
|
+
PNotUndefType,
|
|
972
|
+
PArrayType,
|
|
973
|
+
PTupleType]
|
|
974
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
803
975
|
end
|
|
804
976
|
|
|
805
977
|
it 'Array is not assignable to any disjunct type' do
|
|
806
978
|
tested_types = all_types - [
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
t =
|
|
812
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
979
|
+
PAnyType,
|
|
980
|
+
POptionalType,
|
|
981
|
+
PNotUndefType,
|
|
982
|
+
PIterableType] - collection_types
|
|
983
|
+
t = PArrayType::DEFAULT
|
|
984
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
985
|
+
end
|
|
986
|
+
|
|
987
|
+
it 'Empty Array is assignable to an array that accepts 0 entries' do
|
|
988
|
+
expect(empty_array_t).to be_assignable_to(array_t(string_t))
|
|
989
|
+
expect(empty_array_t).to be_assignable_to(array_t(integer_t))
|
|
990
|
+
end
|
|
991
|
+
|
|
992
|
+
it 'A Tuple is assignable to an array' do
|
|
993
|
+
expect(tuple_t(String)).to be_assignable_to(array_t(String))
|
|
994
|
+
end
|
|
995
|
+
|
|
996
|
+
it 'A Tuple with <n> elements is assignable to an array with min size <n>' do
|
|
997
|
+
expect(tuple_t(String,String)).to be_assignable_to(array_t(String, range_t(2, :default)))
|
|
998
|
+
end
|
|
999
|
+
|
|
1000
|
+
it 'A Tuple with <n> elements where the last 2 are optional is assignable to an array with size <n> - 2' do
|
|
1001
|
+
expect(constrained_tuple_t(range_t(2, :default), String,String,String,String)).to be_assignable_to(array_t(String, range_t(2, :default)))
|
|
813
1002
|
end
|
|
814
1003
|
end
|
|
815
1004
|
|
|
816
|
-
context
|
|
817
|
-
it
|
|
818
|
-
t =
|
|
1005
|
+
context 'for Hash, such that' do
|
|
1006
|
+
it 'Hash is not assignable to any other Collection type' do
|
|
1007
|
+
t = PHashType::DEFAULT
|
|
819
1008
|
tested_types = collection_types - [
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
1009
|
+
PCollectionType,
|
|
1010
|
+
PStructType,
|
|
1011
|
+
PHashType]
|
|
1012
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
824
1013
|
end
|
|
825
1014
|
|
|
826
1015
|
it 'Hash is not assignable to any disjunct type' do
|
|
827
1016
|
tested_types = all_types - [
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
t =
|
|
833
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
1017
|
+
PAnyType,
|
|
1018
|
+
POptionalType,
|
|
1019
|
+
PNotUndefType,
|
|
1020
|
+
PIterableType] - collection_types
|
|
1021
|
+
t = PHashType::DEFAULT
|
|
1022
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
834
1023
|
end
|
|
835
1024
|
|
|
836
1025
|
it 'Struct is assignable to Hash with Pattern that matches all keys' do
|
|
@@ -850,51 +1039,85 @@ describe 'The type calculator' do
|
|
|
850
1039
|
end
|
|
851
1040
|
end
|
|
852
1041
|
|
|
853
|
-
context
|
|
854
|
-
it
|
|
855
|
-
|
|
1042
|
+
context 'for Timespan such that' do
|
|
1043
|
+
it 'Timespan is assignable to less constrained Timespan' do
|
|
1044
|
+
t1 = PTimespanType.new('00:00:10', '00:00:20')
|
|
1045
|
+
t2 = PTimespanType.new('00:00:11', '00:00:19')
|
|
1046
|
+
expect(t2).to be_assignable_to(t1)
|
|
1047
|
+
end
|
|
1048
|
+
|
|
1049
|
+
it 'Timespan is not assignable to more constrained Timespan' do
|
|
1050
|
+
t1 = PTimespanType.new('00:00:10', '00:00:20')
|
|
1051
|
+
t2 = PTimespanType.new('00:00:11', '00:00:19')
|
|
1052
|
+
expect(t1).not_to be_assignable_to(t2)
|
|
1053
|
+
end
|
|
1054
|
+
end
|
|
1055
|
+
|
|
1056
|
+
context 'for Timestamp such that' do
|
|
1057
|
+
it 'Timestamp is assignable to less constrained Timestamp' do
|
|
1058
|
+
t1 = PTimestampType.new('2016-01-01', '2016-12-31')
|
|
1059
|
+
t2 = PTimestampType.new('2016-02-01', '2016-11-30')
|
|
1060
|
+
expect(t2).to be_assignable_to(t1)
|
|
1061
|
+
end
|
|
1062
|
+
|
|
1063
|
+
it 'Timestamp is not assignable to more constrained Timestamp' do
|
|
1064
|
+
t1 = PTimestampType.new('2016-01-01', '2016-12-31')
|
|
1065
|
+
t2 = PTimestampType.new('2016-02-01', '2016-11-30')
|
|
1066
|
+
expect(t1).not_to be_assignable_to(t2)
|
|
1067
|
+
end
|
|
1068
|
+
end
|
|
1069
|
+
|
|
1070
|
+
context 'for Tuple, such that' do
|
|
1071
|
+
it 'Tuple is not assignable to any other non Array based Collection type' do
|
|
1072
|
+
t = PTupleType::DEFAULT
|
|
856
1073
|
tested_types = collection_types - [
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
1074
|
+
PCollectionType,
|
|
1075
|
+
PTupleType,
|
|
1076
|
+
PArrayType]
|
|
1077
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
1078
|
+
end
|
|
1079
|
+
|
|
1080
|
+
it 'A tuple with parameters is assignable to the default Tuple' do
|
|
1081
|
+
t = PTupleType::DEFAULT
|
|
1082
|
+
t2 = PTupleType.new([PStringType::DEFAULT])
|
|
1083
|
+
expect(t2).to be_assignable_to(t)
|
|
861
1084
|
end
|
|
862
1085
|
|
|
863
1086
|
it 'Tuple is not assignable to any disjunct type' do
|
|
864
1087
|
tested_types = all_types - [
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
t =
|
|
870
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
1088
|
+
PAnyType,
|
|
1089
|
+
POptionalType,
|
|
1090
|
+
PNotUndefType,
|
|
1091
|
+
PIterableType] - collection_types
|
|
1092
|
+
t = PTupleType::DEFAULT
|
|
1093
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
871
1094
|
end
|
|
872
1095
|
end
|
|
873
1096
|
|
|
874
|
-
context
|
|
875
|
-
it
|
|
876
|
-
t =
|
|
1097
|
+
context 'for Struct, such that' do
|
|
1098
|
+
it 'Struct is not assignable to any other non Hashed based Collection type' do
|
|
1099
|
+
t = PStructType::DEFAULT
|
|
877
1100
|
tested_types = collection_types - [
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
1101
|
+
PCollectionType,
|
|
1102
|
+
PStructType,
|
|
1103
|
+
PHashType]
|
|
1104
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
882
1105
|
end
|
|
883
1106
|
|
|
884
1107
|
it 'Struct is not assignable to any disjunct type' do
|
|
885
1108
|
tested_types = all_types - [
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
t =
|
|
891
|
-
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2
|
|
1109
|
+
PAnyType,
|
|
1110
|
+
POptionalType,
|
|
1111
|
+
PNotUndefType,
|
|
1112
|
+
PIterableType] - collection_types
|
|
1113
|
+
t = PStructType::DEFAULT
|
|
1114
|
+
tested_types.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
|
|
892
1115
|
end
|
|
893
1116
|
|
|
894
1117
|
it 'Default key optionality is controlled by value assignability to undef' do
|
|
895
1118
|
t1 = struct_t({'member' => string_t})
|
|
896
1119
|
expect(t1.elements[0].key_type).to eq(string_t('member'))
|
|
897
|
-
t1 = struct_t({'member' =>
|
|
1120
|
+
t1 = struct_t({'member' => any_t})
|
|
898
1121
|
expect(t1.elements[0].key_type).to eq(optional_t(string_t('member')))
|
|
899
1122
|
end
|
|
900
1123
|
|
|
@@ -915,38 +1138,86 @@ describe 'The type calculator' do
|
|
|
915
1138
|
end
|
|
916
1139
|
|
|
917
1140
|
it 'Required members not optional even when value is' do
|
|
918
|
-
t1 = struct_t({not_undef_t('required_member') =>
|
|
1141
|
+
t1 = struct_t({not_undef_t('required_member') => any_t, not_undef_t('other_member') => string_t})
|
|
919
1142
|
t2 = struct_t({not_undef_t('other_member') => string_t})
|
|
920
1143
|
expect(t2).not_to be_assignable_to(t1)
|
|
921
1144
|
end
|
|
1145
|
+
|
|
1146
|
+
it 'A hash of string is not assignable to struct with integer value' do
|
|
1147
|
+
t1 = struct_t({'foo' => integer_t, 'bar' => string_t})
|
|
1148
|
+
t2 = hash_t(string_t, string_t, range_t(2, 2))
|
|
1149
|
+
expect(t1.assignable?(t2)).to eql(false)
|
|
1150
|
+
end
|
|
1151
|
+
|
|
1152
|
+
it 'A hash of with integer key is not assignable to struct with string key' do
|
|
1153
|
+
t1 = struct_t({'foo' => string_t, 'bar' => string_t})
|
|
1154
|
+
t2 = hash_t(integer_t, string_t, range_t(2, 2))
|
|
1155
|
+
expect(t1.assignable?(t2)).to eql(false)
|
|
1156
|
+
end
|
|
922
1157
|
end
|
|
923
1158
|
|
|
924
|
-
context
|
|
925
|
-
it
|
|
926
|
-
t =
|
|
1159
|
+
context 'for Callable, such that' do
|
|
1160
|
+
it 'Callable is not assignable to any disjunct type' do
|
|
1161
|
+
t = PCallableType::DEFAULT
|
|
927
1162
|
tested_types = all_types - [
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
tested_types.each {|t2| expect(t).to_not be_assignable_to(t2
|
|
1163
|
+
PCallableType,
|
|
1164
|
+
PAnyType,
|
|
1165
|
+
POptionalType,
|
|
1166
|
+
PNotUndefType]
|
|
1167
|
+
tested_types.each {|t2| expect(t).to_not be_assignable_to(t2::DEFAULT) }
|
|
1168
|
+
end
|
|
1169
|
+
|
|
1170
|
+
it 'a callable with parameter is assignable to the default callable' do
|
|
1171
|
+
expect(callable_t(string_t)).to be_assignable_to(PCallableType::DEFAULT)
|
|
1172
|
+
end
|
|
1173
|
+
|
|
1174
|
+
it 'the default callable is not assignable to a callable with parameter' do
|
|
1175
|
+
expect(PCallableType::DEFAULT).not_to be_assignable_to(callable_t(string_t))
|
|
1176
|
+
end
|
|
1177
|
+
|
|
1178
|
+
it 'a callable with a return type is assignable to the default callable' do
|
|
1179
|
+
expect(callable_t([], string_t)).to be_assignable_to(PCallableType::DEFAULT)
|
|
1180
|
+
end
|
|
1181
|
+
|
|
1182
|
+
it 'the default callable is not assignable to a callable with a return type' do
|
|
1183
|
+
expect(PCallableType::DEFAULT).not_to be_assignable_to(callable_t([],string_t))
|
|
1184
|
+
end
|
|
1185
|
+
|
|
1186
|
+
it 'a callable with a return type Any is assignable to the default callable' do
|
|
1187
|
+
expect(callable_t([], any_t)).to be_assignable_to(PCallableType::DEFAULT)
|
|
1188
|
+
end
|
|
1189
|
+
|
|
1190
|
+
it 'a callable with a return type Any is equal to a callable with the same parameters and no return type' do
|
|
1191
|
+
expect(callable_t([string_t], any_t)).to eql(callable_t(string_t))
|
|
1192
|
+
end
|
|
1193
|
+
|
|
1194
|
+
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
|
|
1195
|
+
expect(callable_t([string_t], string_t)).not_to eql(callable_t(string_t))
|
|
1196
|
+
end
|
|
1197
|
+
|
|
1198
|
+
it 'a callable with a return type is assignable from another callable with an assignable return type' do
|
|
1199
|
+
expect(callable_t([], string_t)).to be_assignable_to(callable_t([], PScalarType::DEFAULT))
|
|
1200
|
+
end
|
|
1201
|
+
|
|
1202
|
+
it 'a callable with a return type is not assignable from another callable unless the return type is assignable' do
|
|
1203
|
+
expect(callable_t([], string_t)).not_to be_assignable_to(callable_t([], integer_t))
|
|
933
1204
|
end
|
|
934
1205
|
end
|
|
935
1206
|
|
|
936
1207
|
it 'should recognize mapped ruby types' do
|
|
937
|
-
{ Integer =>
|
|
938
|
-
Fixnum =>
|
|
939
|
-
Bignum =>
|
|
940
|
-
Float =>
|
|
941
|
-
Numeric =>
|
|
942
|
-
NilClass =>
|
|
943
|
-
TrueClass =>
|
|
944
|
-
FalseClass =>
|
|
945
|
-
String =>
|
|
946
|
-
Regexp =>
|
|
947
|
-
Regexp =>
|
|
948
|
-
Array =>
|
|
949
|
-
Hash =>
|
|
1208
|
+
{ Integer => PIntegerType::DEFAULT,
|
|
1209
|
+
Fixnum => PIntegerType::DEFAULT,
|
|
1210
|
+
Bignum => PIntegerType::DEFAULT,
|
|
1211
|
+
Float => PFloatType::DEFAULT,
|
|
1212
|
+
Numeric => PNumericType::DEFAULT,
|
|
1213
|
+
NilClass => PUndefType::DEFAULT,
|
|
1214
|
+
TrueClass => PBooleanType::DEFAULT,
|
|
1215
|
+
FalseClass => PBooleanType::DEFAULT,
|
|
1216
|
+
String => PStringType::DEFAULT,
|
|
1217
|
+
Regexp => PRegexpType::DEFAULT,
|
|
1218
|
+
Regexp => PRegexpType::DEFAULT,
|
|
1219
|
+
Array => TypeFactory.array_of_any,
|
|
1220
|
+
Hash => TypeFactory.hash_of_any
|
|
950
1221
|
}.each do |ruby_type, puppet_type |
|
|
951
1222
|
expect(ruby_type).to be_assignable_to(puppet_type)
|
|
952
1223
|
end
|
|
@@ -957,35 +1228,18 @@ describe 'The type calculator' do
|
|
|
957
1228
|
expect(calculator.assignable?(range_t(2,5), range_t(2,5))).to eq(true)
|
|
958
1229
|
end
|
|
959
1230
|
|
|
960
|
-
it 'should accept an equal reverse range' do
|
|
961
|
-
expect(calculator.assignable?(range_t(2,5), range_t(5,2))).to eq(true)
|
|
962
|
-
end
|
|
963
|
-
|
|
964
1231
|
it 'should accept a narrower range' do
|
|
965
1232
|
expect(calculator.assignable?(range_t(2,10), range_t(3,5))).to eq(true)
|
|
966
1233
|
end
|
|
967
1234
|
|
|
968
|
-
it 'should accept a narrower reverse range' do
|
|
969
|
-
expect(calculator.assignable?(range_t(2,10), range_t(5,3))).to eq(true)
|
|
970
|
-
end
|
|
971
|
-
|
|
972
1235
|
it 'should reject a wider range' do
|
|
973
1236
|
expect(calculator.assignable?(range_t(3,5), range_t(2,10))).to eq(false)
|
|
974
1237
|
end
|
|
975
1238
|
|
|
976
|
-
it 'should reject a wider reverse range' do
|
|
977
|
-
expect(calculator.assignable?(range_t(3,5), range_t(10,2))).to eq(false)
|
|
978
|
-
end
|
|
979
|
-
|
|
980
1239
|
it 'should reject a partially overlapping range' do
|
|
981
1240
|
expect(calculator.assignable?(range_t(3,5), range_t(2,4))).to eq(false)
|
|
982
1241
|
expect(calculator.assignable?(range_t(3,5), range_t(4,6))).to eq(false)
|
|
983
1242
|
end
|
|
984
|
-
|
|
985
|
-
it 'should reject a partially overlapping reverse range' do
|
|
986
|
-
expect(calculator.assignable?(range_t(3,5), range_t(4,2))).to eq(false)
|
|
987
|
-
expect(calculator.assignable?(range_t(3,5), range_t(6,4))).to eq(false)
|
|
988
|
-
end
|
|
989
1243
|
end
|
|
990
1244
|
|
|
991
1245
|
context 'when dealing with patterns' do
|
|
@@ -1021,7 +1275,7 @@ describe 'The type calculator' do
|
|
|
1021
1275
|
|
|
1022
1276
|
it 'should accept multiple strings if they all match any patterns' do
|
|
1023
1277
|
p_t = pattern_t('X', 'Y', 'abc')
|
|
1024
|
-
p_s =
|
|
1278
|
+
p_s = enum_t('Xa', 'aY', 'abc')
|
|
1025
1279
|
expect(calculator.assignable?(p_t, p_s)).to eq(true)
|
|
1026
1280
|
end
|
|
1027
1281
|
|
|
@@ -1033,7 +1287,7 @@ describe 'The type calculator' do
|
|
|
1033
1287
|
|
|
1034
1288
|
it 'should reject multiple strings if not all match any patterns' do
|
|
1035
1289
|
p_t = pattern_t('abc', 'ab', 'c', 'q')
|
|
1036
|
-
p_s =
|
|
1290
|
+
p_s = enum_t('X', 'Y', 'Z')
|
|
1037
1291
|
expect(calculator.assignable?(p_t, p_s)).to eq(false)
|
|
1038
1292
|
end
|
|
1039
1293
|
|
|
@@ -1049,18 +1303,18 @@ describe 'The type calculator' do
|
|
|
1049
1303
|
end
|
|
1050
1304
|
|
|
1051
1305
|
it 'pattern representing all patterns should accept any pattern' do
|
|
1052
|
-
expect(calculator.assignable?(pattern_t
|
|
1053
|
-
expect(calculator.assignable?(pattern_t
|
|
1306
|
+
expect(calculator.assignable?(pattern_t, pattern_t('a'))).to eq(true)
|
|
1307
|
+
expect(calculator.assignable?(pattern_t, pattern_t)).to eq(true)
|
|
1054
1308
|
end
|
|
1055
1309
|
|
|
1056
1310
|
it 'pattern representing all patterns should accept any enum' do
|
|
1057
|
-
expect(calculator.assignable?(pattern_t
|
|
1058
|
-
expect(calculator.assignable?(pattern_t
|
|
1311
|
+
expect(calculator.assignable?(pattern_t, enum_t('a'))).to eq(true)
|
|
1312
|
+
expect(calculator.assignable?(pattern_t, enum_t)).to eq(true)
|
|
1059
1313
|
end
|
|
1060
1314
|
|
|
1061
1315
|
it 'pattern representing all patterns should accept any string' do
|
|
1062
|
-
expect(calculator.assignable?(pattern_t
|
|
1063
|
-
expect(calculator.assignable?(pattern_t
|
|
1316
|
+
expect(calculator.assignable?(pattern_t, string_t('a'))).to eq(true)
|
|
1317
|
+
expect(calculator.assignable?(pattern_t, string_t)).to eq(true)
|
|
1064
1318
|
end
|
|
1065
1319
|
|
|
1066
1320
|
end
|
|
@@ -1079,8 +1333,8 @@ describe 'The type calculator' do
|
|
|
1079
1333
|
end
|
|
1080
1334
|
|
|
1081
1335
|
it 'non parameterized enum accepts any other enum but not the reverse' do
|
|
1082
|
-
expect(calculator.assignable?(enum_t
|
|
1083
|
-
expect(calculator.assignable?(enum_t('a'), enum_t
|
|
1336
|
+
expect(calculator.assignable?(enum_t, enum_t('a'))).to eq(true)
|
|
1337
|
+
expect(calculator.assignable?(enum_t('a'), enum_t)).to eq(false)
|
|
1084
1338
|
end
|
|
1085
1339
|
|
|
1086
1340
|
it 'enum should accept a variant where all variants are acceptable' do
|
|
@@ -1091,54 +1345,53 @@ describe 'The type calculator' do
|
|
|
1091
1345
|
|
|
1092
1346
|
context 'when dealing with string and enum combinations' do
|
|
1093
1347
|
it 'should accept assigning any enum to unrestricted string' do
|
|
1094
|
-
expect(calculator.assignable?(string_t
|
|
1095
|
-
expect(calculator.assignable?(string_t
|
|
1348
|
+
expect(calculator.assignable?(string_t, enum_t('blue'))).to eq(true)
|
|
1349
|
+
expect(calculator.assignable?(string_t, enum_t('blue', 'red'))).to eq(true)
|
|
1096
1350
|
end
|
|
1097
1351
|
|
|
1098
1352
|
it 'should not accept assigning longer enum value to size restricted string' do
|
|
1099
|
-
expect(calculator.assignable?(
|
|
1353
|
+
expect(calculator.assignable?(constrained_string_t(range_t(2,2)), enum_t('a','blue'))).to eq(false)
|
|
1100
1354
|
end
|
|
1101
1355
|
|
|
1102
1356
|
it 'should accept assigning any string to empty enum' do
|
|
1103
|
-
expect(calculator.assignable?(enum_t
|
|
1357
|
+
expect(calculator.assignable?(enum_t, string_t)).to eq(true)
|
|
1104
1358
|
end
|
|
1105
1359
|
|
|
1106
1360
|
it 'should accept assigning empty enum to any string' do
|
|
1107
|
-
expect(calculator.assignable?(string_t
|
|
1361
|
+
expect(calculator.assignable?(string_t, enum_t)).to eq(true)
|
|
1108
1362
|
end
|
|
1109
1363
|
|
|
1110
1364
|
it 'should not accept assigning empty enum to size constrained string' do
|
|
1111
|
-
expect(calculator.assignable?(
|
|
1365
|
+
expect(calculator.assignable?(constrained_string_t(range_t(2,2)), enum_t)).to eq(false)
|
|
1112
1366
|
end
|
|
1113
1367
|
end
|
|
1114
1368
|
|
|
1115
1369
|
context 'when dealing with string/pattern/enum combinations' do
|
|
1116
1370
|
it 'any string is equal to any enum is equal to any pattern' do
|
|
1117
|
-
expect(calculator.assignable?(string_t
|
|
1118
|
-
expect(calculator.assignable?(string_t
|
|
1119
|
-
expect(calculator.assignable?(enum_t
|
|
1120
|
-
expect(calculator.assignable?(enum_t
|
|
1121
|
-
expect(calculator.assignable?(pattern_t
|
|
1122
|
-
expect(calculator.assignable?(pattern_t
|
|
1371
|
+
expect(calculator.assignable?(string_t, enum_t)).to eq(true)
|
|
1372
|
+
expect(calculator.assignable?(string_t, pattern_t)).to eq(true)
|
|
1373
|
+
expect(calculator.assignable?(enum_t, string_t)).to eq(true)
|
|
1374
|
+
expect(calculator.assignable?(enum_t, pattern_t)).to eq(true)
|
|
1375
|
+
expect(calculator.assignable?(pattern_t, string_t)).to eq(true)
|
|
1376
|
+
expect(calculator.assignable?(pattern_t, enum_t)).to eq(true)
|
|
1123
1377
|
end
|
|
1124
1378
|
end
|
|
1125
1379
|
|
|
1126
1380
|
context 'when dealing with tuples' do
|
|
1127
1381
|
it 'matches empty tuples' do
|
|
1128
|
-
tuple1 = tuple_t
|
|
1129
|
-
tuple2 = tuple_t
|
|
1382
|
+
tuple1 = tuple_t
|
|
1383
|
+
tuple2 = tuple_t
|
|
1130
1384
|
|
|
1131
1385
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1132
1386
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1133
1387
|
end
|
|
1134
1388
|
|
|
1135
1389
|
it 'accepts an empty tuple as assignable to a tuple with a min size of 0' do
|
|
1136
|
-
tuple1 =
|
|
1137
|
-
factory.constrain_size(tuple1, 0, :default)
|
|
1390
|
+
tuple1 = constrained_tuple_t(range_t(0, :default))
|
|
1138
1391
|
tuple2 = tuple_t()
|
|
1139
1392
|
|
|
1140
1393
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1141
|
-
expect(calculator.assignable?(tuple2, tuple1)).to eq(
|
|
1394
|
+
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1142
1395
|
end
|
|
1143
1396
|
|
|
1144
1397
|
it 'should accept matching tuples' do
|
|
@@ -1156,62 +1409,51 @@ describe 'The type calculator' do
|
|
|
1156
1409
|
end
|
|
1157
1410
|
|
|
1158
1411
|
it 'should accept ranged tuples' do
|
|
1159
|
-
tuple1 =
|
|
1160
|
-
factory.constrain_size(tuple1, 5, 5)
|
|
1412
|
+
tuple1 = constrained_tuple_t(range_t(5,5), 1)
|
|
1161
1413
|
tuple2 = tuple_t(Integer,Integer, Integer, Integer, Integer)
|
|
1162
1414
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1163
1415
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1164
1416
|
end
|
|
1165
1417
|
|
|
1166
1418
|
it 'should reject ranged tuples when ranges does not match' do
|
|
1167
|
-
tuple1 =
|
|
1168
|
-
factory.constrain_size(tuple1, 4, 5)
|
|
1419
|
+
tuple1 = constrained_tuple_t(range_t(4, 5), 1)
|
|
1169
1420
|
tuple2 = tuple_t(Integer,Integer, Integer, Integer, Integer)
|
|
1170
1421
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1171
1422
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(false)
|
|
1172
1423
|
end
|
|
1173
1424
|
|
|
1174
1425
|
it 'should reject ranged tuples when ranges does not match (using infinite upper bound)' do
|
|
1175
|
-
tuple1 =
|
|
1176
|
-
factory.constrain_size(tuple1, 4, :default)
|
|
1426
|
+
tuple1 = constrained_tuple_t(range_t(4, :default), 1)
|
|
1177
1427
|
tuple2 = tuple_t(Integer,Integer, Integer, Integer, Integer)
|
|
1178
1428
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(true)
|
|
1179
1429
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(false)
|
|
1180
1430
|
end
|
|
1181
1431
|
|
|
1182
1432
|
it 'should accept matching tuples with optional entries by repeating last' do
|
|
1183
|
-
tuple1 =
|
|
1184
|
-
|
|
1185
|
-
tuple2 = tuple_t(Numeric,Numeric)
|
|
1186
|
-
factory.constrain_size(tuple2, 0, :default)
|
|
1433
|
+
tuple1 = constrained_tuple_t(range_t(0, :default), 1,2)
|
|
1434
|
+
tuple2 = constrained_tuple_t(range_t(0, :default), Numeric,Numeric)
|
|
1187
1435
|
expect(calculator.assignable?(tuple1, tuple2)).to eq(false)
|
|
1188
1436
|
expect(calculator.assignable?(tuple2, tuple1)).to eq(true)
|
|
1189
1437
|
end
|
|
1190
1438
|
|
|
1191
1439
|
it 'should accept matching tuples with optional entries' do
|
|
1192
|
-
tuple1 =
|
|
1193
|
-
|
|
1194
|
-
array2 = factory.constrain_size(array_t(Integer),2,2)
|
|
1440
|
+
tuple1 = constrained_tuple_t(range_t(1, 3), Integer, Integer, String)
|
|
1441
|
+
array2 = array_t(Integer, range_t(2,2))
|
|
1195
1442
|
expect(calculator.assignable?(tuple1, array2)).to eq(true)
|
|
1196
|
-
|
|
1443
|
+
tuple1 = constrained_tuple_t(range_t(3, 3), tuple1.types)
|
|
1197
1444
|
expect(calculator.assignable?(tuple1, array2)).to eq(false)
|
|
1198
1445
|
end
|
|
1199
1446
|
|
|
1200
1447
|
it 'should accept matching array' do
|
|
1201
1448
|
tuple1 = tuple_t(1,2)
|
|
1202
|
-
array = array_t(Integer)
|
|
1203
|
-
factory.constrain_size(array, 2, 2)
|
|
1449
|
+
array = array_t(Integer, range_t(2, 2))
|
|
1204
1450
|
expect(calculator.assignable?(tuple1, array)).to eq(true)
|
|
1205
1451
|
expect(calculator.assignable?(array, tuple1)).to eq(true)
|
|
1206
1452
|
end
|
|
1207
1453
|
|
|
1208
1454
|
it 'should accept empty array when tuple allows min of 0' do
|
|
1209
|
-
tuple1 =
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
array = array_t(Integer)
|
|
1213
|
-
factory.constrain_size(array, 0, 0)
|
|
1214
|
-
|
|
1455
|
+
tuple1 = constrained_tuple_t(range_t(0, 1), Integer)
|
|
1456
|
+
array = array_t(unit_t, range_t(0, 0))
|
|
1215
1457
|
expect(calculator.assignable?(tuple1, array)).to eq(true)
|
|
1216
1458
|
expect(calculator.assignable?(array, tuple1)).to eq(false)
|
|
1217
1459
|
end
|
|
@@ -1258,18 +1500,15 @@ describe 'The type calculator' do
|
|
|
1258
1500
|
|
|
1259
1501
|
it 'should accept matching hash' do
|
|
1260
1502
|
struct1 = struct_t({'a'=>Integer, 'b'=>Integer})
|
|
1261
|
-
non_empty_string =
|
|
1262
|
-
|
|
1263
|
-
hsh = hash_t(non_empty_string, Integer)
|
|
1264
|
-
factory.constrain_size(hsh, 2, 2)
|
|
1503
|
+
non_empty_string = constrained_string_t(range_t(1, nil))
|
|
1504
|
+
hsh = hash_t(non_empty_string, Integer, range_t(2,2))
|
|
1265
1505
|
expect(calculator.assignable?(struct1, hsh)).to eq(true)
|
|
1266
1506
|
expect(calculator.assignable?(hsh, struct1)).to eq(true)
|
|
1267
1507
|
end
|
|
1268
1508
|
|
|
1269
|
-
it 'should accept empty hash with key_type
|
|
1509
|
+
it 'should accept empty hash with key_type unit' do
|
|
1270
1510
|
struct1 = struct_t({'a'=>optional_t(Integer)})
|
|
1271
|
-
hsh = hash_t(
|
|
1272
|
-
factory.constrain_size(hsh, 0, 0)
|
|
1511
|
+
hsh = hash_t(unit_t, unit_t, range_t(0, 0))
|
|
1273
1512
|
expect(calculator.assignable?(struct1, hsh)).to eq(true)
|
|
1274
1513
|
end
|
|
1275
1514
|
end
|
|
@@ -1294,112 +1533,228 @@ describe 'The type calculator' do
|
|
|
1294
1533
|
expect(calculator.assignable?(Bar, fooType)).to eq(false)
|
|
1295
1534
|
end
|
|
1296
1535
|
|
|
1297
|
-
it
|
|
1298
|
-
hc1 =
|
|
1299
|
-
hc2 =
|
|
1536
|
+
it 'should allow host class with same name' do
|
|
1537
|
+
hc1 = TypeFactory.host_class('the_name')
|
|
1538
|
+
hc2 = TypeFactory.host_class('the_name')
|
|
1300
1539
|
expect(calculator.assignable?(hc1, hc2)).to eq(true)
|
|
1301
1540
|
end
|
|
1302
1541
|
|
|
1303
|
-
it
|
|
1304
|
-
hc1 =
|
|
1305
|
-
hc2 =
|
|
1542
|
+
it 'should allow host class with name assigned to hostclass without name' do
|
|
1543
|
+
hc1 = TypeFactory.host_class
|
|
1544
|
+
hc2 = TypeFactory.host_class('the_name')
|
|
1306
1545
|
expect(calculator.assignable?(hc1, hc2)).to eq(true)
|
|
1307
1546
|
end
|
|
1308
1547
|
|
|
1309
|
-
it
|
|
1310
|
-
hc1 =
|
|
1311
|
-
hc2 =
|
|
1548
|
+
it 'should reject host classes with different names' do
|
|
1549
|
+
hc1 = TypeFactory.host_class('the_name')
|
|
1550
|
+
hc2 = TypeFactory.host_class('another_name')
|
|
1312
1551
|
expect(calculator.assignable?(hc1, hc2)).to eq(false)
|
|
1313
1552
|
end
|
|
1314
1553
|
|
|
1315
|
-
it
|
|
1316
|
-
hc1 =
|
|
1317
|
-
hc2 =
|
|
1554
|
+
it 'should reject host classes without name assigned to host class with name' do
|
|
1555
|
+
hc1 = TypeFactory.host_class('the_name')
|
|
1556
|
+
hc2 = TypeFactory.host_class
|
|
1318
1557
|
expect(calculator.assignable?(hc1, hc2)).to eq(false)
|
|
1319
1558
|
end
|
|
1320
1559
|
|
|
1321
|
-
it
|
|
1322
|
-
r1 =
|
|
1323
|
-
r2 =
|
|
1560
|
+
it 'should allow resource with same type_name and title' do
|
|
1561
|
+
r1 = TypeFactory.resource('file', 'foo')
|
|
1562
|
+
r2 = TypeFactory.resource('file', 'foo')
|
|
1324
1563
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1325
1564
|
end
|
|
1326
1565
|
|
|
1327
|
-
it
|
|
1328
|
-
r1 =
|
|
1329
|
-
r2 =
|
|
1566
|
+
it 'should allow more specific resource assignment' do
|
|
1567
|
+
r1 = TypeFactory.resource
|
|
1568
|
+
r2 = TypeFactory.resource('file')
|
|
1330
1569
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1331
|
-
r2 =
|
|
1570
|
+
r2 = TypeFactory.resource('file', '/tmp/foo')
|
|
1332
1571
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1333
|
-
r1 =
|
|
1572
|
+
r1 = TypeFactory.resource('file')
|
|
1334
1573
|
expect(calculator.assignable?(r1, r2)).to eq(true)
|
|
1335
1574
|
end
|
|
1336
1575
|
|
|
1337
|
-
it
|
|
1338
|
-
r1 =
|
|
1339
|
-
r2 =
|
|
1576
|
+
it 'should reject less specific resource assignment' do
|
|
1577
|
+
r1 = TypeFactory.resource('file', '/tmp/foo')
|
|
1578
|
+
r2 = TypeFactory.resource('file')
|
|
1340
1579
|
expect(calculator.assignable?(r1, r2)).to eq(false)
|
|
1341
|
-
r2 =
|
|
1580
|
+
r2 = TypeFactory.resource
|
|
1342
1581
|
expect(calculator.assignable?(r1, r2)).to eq(false)
|
|
1343
1582
|
end
|
|
1344
1583
|
|
|
1584
|
+
context 'for TypeAlias, such that' do
|
|
1585
|
+
let!(:parser) { TypeParser.singleton }
|
|
1586
|
+
|
|
1587
|
+
it 'it is assignable to the type that it is an alias for' do
|
|
1588
|
+
t = type_alias_t('Alias', 'Integer').resolve(parser, nil)
|
|
1589
|
+
expect(calculator.assignable?(integer_t, t)).to be_truthy
|
|
1590
|
+
end
|
|
1591
|
+
|
|
1592
|
+
it 'the type that it is an alias for is assignable to it' do
|
|
1593
|
+
t = type_alias_t('Alias', 'Integer').resolve(parser, nil)
|
|
1594
|
+
expect(calculator.assignable?(t, integer_t)).to be_truthy
|
|
1595
|
+
end
|
|
1596
|
+
|
|
1597
|
+
it 'a recursive alias can be assignable from a conformant type with any depth' do
|
|
1598
|
+
scope = Object.new
|
|
1599
|
+
|
|
1600
|
+
t = type_alias_t('Tree', 'Hash[String,Variant[String,Tree]]')
|
|
1601
|
+
loader = Object.new
|
|
1602
|
+
loader.expects(:load).with(:type, 'tree').returns t
|
|
1603
|
+
|
|
1604
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1605
|
+
|
|
1606
|
+
t.resolve(parser, scope)
|
|
1607
|
+
expect(calculator.assignable?(t, parser.parse('Hash[String,Variant[String,Hash[String,Variant[String,String]]]]'))).to be_truthy
|
|
1608
|
+
end
|
|
1609
|
+
|
|
1610
|
+
|
|
1611
|
+
it 'similar recursive aliases are assignable' do
|
|
1612
|
+
scope = Object.new
|
|
1613
|
+
|
|
1614
|
+
t1 = type_alias_t('Tree1', 'Hash[String,Variant[String,Tree1]]')
|
|
1615
|
+
t2 = type_alias_t('Tree2', 'Hash[String,Variant[String,Tree2]]')
|
|
1616
|
+
loader = Object.new
|
|
1617
|
+
loader.expects(:load).with(:type, 'tree1').returns t1
|
|
1618
|
+
loader.expects(:load).with(:type, 'tree2').returns t2
|
|
1619
|
+
|
|
1620
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1621
|
+
|
|
1622
|
+
t1.resolve(parser, scope)
|
|
1623
|
+
t2.resolve(parser, scope)
|
|
1624
|
+
expect(calculator.assignable?(t1, t2)).to be_truthy
|
|
1625
|
+
end
|
|
1626
|
+
|
|
1627
|
+
it 'crossing recursive aliases are assignable' do
|
|
1628
|
+
t1 = type_alias_t('Tree1', 'Hash[String,Variant[String,Tree2]]')
|
|
1629
|
+
t2 = type_alias_t('Tree2', 'Hash[String,Variant[String,Tree1]]')
|
|
1630
|
+
loader = Object.new
|
|
1631
|
+
loader.expects(:load).with(:type, 'tree1').returns t1
|
|
1632
|
+
loader.expects(:load).with(:type, 'tree2').returns t2
|
|
1633
|
+
|
|
1634
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1635
|
+
|
|
1636
|
+
t1.resolve(parser, loader)
|
|
1637
|
+
t2.resolve(parser, loader)
|
|
1638
|
+
expect(calculator.assignable?(t1, t2)).to be_truthy
|
|
1639
|
+
end
|
|
1640
|
+
|
|
1641
|
+
it 'Type[T] is assignable to Type[AT] when AT is an alias for T' do
|
|
1642
|
+
scope = Object.new
|
|
1643
|
+
|
|
1644
|
+
ta = type_alias_t('PositiveInteger', 'Integer[0,default]')
|
|
1645
|
+
loader = Object.new
|
|
1646
|
+
loader.expects(:load).with(:type, 'positiveinteger').returns ta
|
|
1647
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1648
|
+
|
|
1649
|
+
t1 = type_t(range_t(0, :default))
|
|
1650
|
+
t2 = parser.parse('Type[PositiveInteger]', scope)
|
|
1651
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1652
|
+
end
|
|
1653
|
+
|
|
1654
|
+
it 'Type[T] is assignable to AT when AT is an alias for Type[T]' do
|
|
1655
|
+
scope = Object.new
|
|
1656
|
+
|
|
1657
|
+
ta = type_alias_t('PositiveIntegerType', 'Type[Integer[0,default]]')
|
|
1658
|
+
loader = Object.new
|
|
1659
|
+
loader.expects(:load).with(:type, 'positiveintegertype').returns ta
|
|
1660
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1661
|
+
|
|
1662
|
+
t1 = type_t(range_t(0, :default))
|
|
1663
|
+
t2 = parser.parse('PositiveIntegerType', scope)
|
|
1664
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1665
|
+
end
|
|
1666
|
+
|
|
1667
|
+
it 'Type[Type[T]] is assignable to Type[Type[AT]] when AT is an alias for T' do
|
|
1668
|
+
scope = Object.new
|
|
1669
|
+
|
|
1670
|
+
ta = type_alias_t('PositiveInteger', 'Integer[0,default]')
|
|
1671
|
+
loader = Object.new
|
|
1672
|
+
loader.expects(:load).with(:type, 'positiveinteger').returns ta
|
|
1673
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1674
|
+
|
|
1675
|
+
t1 = type_t(type_t(range_t(0, :default)))
|
|
1676
|
+
t2 = parser.parse('Type[Type[PositiveInteger]]', scope)
|
|
1677
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1678
|
+
end
|
|
1679
|
+
|
|
1680
|
+
it 'Type[Type[T]] is assignable to Type[AT] when AT is an alias for Type[T]' do
|
|
1681
|
+
scope = Object.new
|
|
1682
|
+
|
|
1683
|
+
ta = type_alias_t('PositiveIntegerType', 'Type[Integer[0,default]]')
|
|
1684
|
+
loader = Object.new
|
|
1685
|
+
loader.expects(:load).with(:type, 'positiveintegertype').returns ta
|
|
1686
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1687
|
+
|
|
1688
|
+
t1 = type_t(type_t(range_t(0, :default)))
|
|
1689
|
+
t2 = parser.parse('Type[PositiveIntegerType]', scope)
|
|
1690
|
+
expect(calculator.assignable?(t2, t1)).to be_truthy
|
|
1691
|
+
end
|
|
1692
|
+
end
|
|
1345
1693
|
end
|
|
1346
1694
|
|
|
1347
1695
|
context 'when testing if x is instance of type t' do
|
|
1348
|
-
include_context
|
|
1696
|
+
include_context 'types_setup'
|
|
1349
1697
|
|
|
1350
1698
|
it 'should consider undef to be instance of Any, NilType, and optional' do
|
|
1351
|
-
expect(calculator.instance?(
|
|
1352
|
-
expect(calculator.instance?(
|
|
1353
|
-
expect(calculator.instance?(
|
|
1699
|
+
expect(calculator.instance?(PUndefType::DEFAULT, nil)).to eq(true)
|
|
1700
|
+
expect(calculator.instance?(PAnyType::DEFAULT, nil)).to eq(true)
|
|
1701
|
+
expect(calculator.instance?(POptionalType::DEFAULT, nil)).to eq(true)
|
|
1354
1702
|
end
|
|
1355
1703
|
|
|
1356
1704
|
it 'all types should be (ruby) instance of PAnyType' do
|
|
1357
1705
|
all_types.each do |t|
|
|
1358
|
-
expect(t.
|
|
1706
|
+
expect(t::DEFAULT.is_a?(PAnyType)).to eq(true)
|
|
1359
1707
|
end
|
|
1360
1708
|
end
|
|
1361
1709
|
|
|
1362
|
-
it "should
|
|
1363
|
-
expect(calculator.
|
|
1710
|
+
it "should infer :undef to be Undef" do
|
|
1711
|
+
expect(calculator.infer(:undef)).to be_assignable_to(undef_t)
|
|
1712
|
+
end
|
|
1713
|
+
|
|
1714
|
+
it "should not consider :default to be instance of Runtime['ruby', 'Symbol]" do
|
|
1715
|
+
expect(calculator.instance?(PRuntimeType.new(:ruby, 'Symbol'), :default)).to eq(false)
|
|
1716
|
+
end
|
|
1717
|
+
|
|
1718
|
+
it "should not consider :undef to be instance of Runtime['ruby', 'Symbol]" do
|
|
1719
|
+
expect(calculator.instance?(PRuntimeType.new(:ruby, 'Symbol'), :undef)).to eq(false)
|
|
1364
1720
|
end
|
|
1365
1721
|
|
|
1366
|
-
it
|
|
1367
|
-
expect(calculator.instance?(
|
|
1722
|
+
it 'should consider :undef to be instance of an Optional type' do
|
|
1723
|
+
expect(calculator.instance?(POptionalType::DEFAULT, :undef)).to eq(true)
|
|
1368
1724
|
end
|
|
1369
1725
|
|
|
1370
1726
|
it 'should not consider undef to be an instance of any other type than Any, UndefType and Data' do
|
|
1371
1727
|
types_to_test = all_types - [
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
Puppet::Pops::Types::POptionalType,
|
|
1728
|
+
PAnyType,
|
|
1729
|
+
PUndefType,
|
|
1730
|
+
POptionalType,
|
|
1376
1731
|
]
|
|
1377
1732
|
|
|
1378
|
-
types_to_test.each {|t| expect(calculator.instance?(t
|
|
1379
|
-
types_to_test.each {|t| expect(calculator.instance?(t
|
|
1733
|
+
types_to_test.each {|t| expect(calculator.instance?(t::DEFAULT, nil)).to eq(false) }
|
|
1734
|
+
types_to_test.each {|t| expect(calculator.instance?(t::DEFAULT, :undef)).to eq(false) }
|
|
1380
1735
|
end
|
|
1381
1736
|
|
|
1382
1737
|
it 'should consider default to be instance of Default and Any' do
|
|
1383
|
-
expect(calculator.instance?(
|
|
1384
|
-
expect(calculator.instance?(
|
|
1738
|
+
expect(calculator.instance?(PDefaultType::DEFAULT, :default)).to eq(true)
|
|
1739
|
+
expect(calculator.instance?(PAnyType::DEFAULT, :default)).to eq(true)
|
|
1385
1740
|
end
|
|
1386
1741
|
|
|
1387
1742
|
it 'should not consider "default" to be an instance of anything but Default, NotUndef, and Any' do
|
|
1388
1743
|
types_to_test = all_types - [
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1744
|
+
PAnyType,
|
|
1745
|
+
PNotUndefType,
|
|
1746
|
+
PDefaultType,
|
|
1392
1747
|
]
|
|
1393
1748
|
|
|
1394
|
-
types_to_test.each {|t| expect(calculator.instance?(t
|
|
1749
|
+
types_to_test.each {|t| expect(calculator.instance?(t::DEFAULT, :default)).to eq(false) }
|
|
1395
1750
|
end
|
|
1396
1751
|
|
|
1397
|
-
it 'should consider
|
|
1398
|
-
expect(calculator.instance?(
|
|
1752
|
+
it 'should consider integer instanceof PIntegerType' do
|
|
1753
|
+
expect(calculator.instance?(PIntegerType::DEFAULT, 1)).to eq(true)
|
|
1399
1754
|
end
|
|
1400
1755
|
|
|
1401
|
-
it 'should consider
|
|
1402
|
-
expect(calculator.instance?(
|
|
1756
|
+
it 'should consider integer instanceof Integer' do
|
|
1757
|
+
expect(calculator.instance?(Integer, 1)).to eq(true)
|
|
1403
1758
|
end
|
|
1404
1759
|
|
|
1405
1760
|
it 'should consider integer in range' do
|
|
@@ -1411,7 +1766,7 @@ describe 'The type calculator' do
|
|
|
1411
1766
|
end
|
|
1412
1767
|
|
|
1413
1768
|
it 'should consider string in length range' do
|
|
1414
|
-
range =
|
|
1769
|
+
range = constrained_string_t(range_t(1,3))
|
|
1415
1770
|
expect(calculator.instance?(range, 'a')).to eq(true)
|
|
1416
1771
|
expect(calculator.instance?(range, 'abc')).to eq(true)
|
|
1417
1772
|
expect(calculator.instance?(range, '')).to eq(false)
|
|
@@ -1419,14 +1774,13 @@ describe 'The type calculator' do
|
|
|
1419
1774
|
end
|
|
1420
1775
|
|
|
1421
1776
|
it 'should consider string values' do
|
|
1422
|
-
string = string_t('a'
|
|
1777
|
+
string = string_t('a')
|
|
1423
1778
|
expect(calculator.instance?(string, 'a')).to eq(true)
|
|
1424
|
-
expect(calculator.instance?(string, 'b')).to eq(true)
|
|
1425
1779
|
expect(calculator.instance?(string, 'c')).to eq(false)
|
|
1426
1780
|
end
|
|
1427
1781
|
|
|
1428
1782
|
it 'should consider array in length range' do
|
|
1429
|
-
range =
|
|
1783
|
+
range = array_t(integer_t, range_t(1,3))
|
|
1430
1784
|
expect(calculator.instance?(range, [1])).to eq(true)
|
|
1431
1785
|
expect(calculator.instance?(range, [1,2,3])).to eq(true)
|
|
1432
1786
|
expect(calculator.instance?(range, [])).to eq(false)
|
|
@@ -1434,7 +1788,7 @@ describe 'The type calculator' do
|
|
|
1434
1788
|
end
|
|
1435
1789
|
|
|
1436
1790
|
it 'should consider hash in length range' do
|
|
1437
|
-
range =
|
|
1791
|
+
range = hash_t(integer_t, integer_t, range_t(1,2))
|
|
1438
1792
|
expect(calculator.instance?(range, {1=>1})).to eq(true)
|
|
1439
1793
|
expect(calculator.instance?(range, {1=>1, 2=>2})).to eq(true)
|
|
1440
1794
|
expect(calculator.instance?(range, {})).to eq(false)
|
|
@@ -1442,7 +1796,7 @@ describe 'The type calculator' do
|
|
|
1442
1796
|
end
|
|
1443
1797
|
|
|
1444
1798
|
it 'should consider collection in length range for array ' do
|
|
1445
|
-
range =
|
|
1799
|
+
range = collection_t(range_t(1,3))
|
|
1446
1800
|
expect(calculator.instance?(range, [1])).to eq(true)
|
|
1447
1801
|
expect(calculator.instance?(range, [1,2,3])).to eq(true)
|
|
1448
1802
|
expect(calculator.instance?(range, [])).to eq(false)
|
|
@@ -1450,7 +1804,7 @@ describe 'The type calculator' do
|
|
|
1450
1804
|
end
|
|
1451
1805
|
|
|
1452
1806
|
it 'should consider collection in length range for hash' do
|
|
1453
|
-
range =
|
|
1807
|
+
range = collection_t(range_t(1,2))
|
|
1454
1808
|
expect(calculator.instance?(range, {1=>1})).to eq(true)
|
|
1455
1809
|
expect(calculator.instance?(range, {1=>1, 2=>2})).to eq(true)
|
|
1456
1810
|
expect(calculator.instance?(range, {})).to eq(false)
|
|
@@ -1526,7 +1880,7 @@ describe 'The type calculator' do
|
|
|
1526
1880
|
end
|
|
1527
1881
|
|
|
1528
1882
|
it 'should consider nil to be a valid element value' do
|
|
1529
|
-
struct = struct_t({not_undef_t('a') =>
|
|
1883
|
+
struct = struct_t({not_undef_t('a') => any_t, 'b'=>String})
|
|
1530
1884
|
expect(calculator.instance?(struct, {'a'=>nil , 'b'=>'a'})).to eq(true)
|
|
1531
1885
|
end
|
|
1532
1886
|
|
|
@@ -1581,16 +1935,16 @@ describe 'The type calculator' do
|
|
|
1581
1935
|
end
|
|
1582
1936
|
end
|
|
1583
1937
|
|
|
1584
|
-
context
|
|
1938
|
+
context 'and t is something Callable' do
|
|
1585
1939
|
|
|
1586
1940
|
it 'a Closure should be considered a Callable' do
|
|
1587
|
-
factory =
|
|
1941
|
+
factory = Model::Factory
|
|
1588
1942
|
params = [factory.PARAM('a')]
|
|
1589
|
-
the_block = factory.LAMBDA(params,factory.literal(42))
|
|
1590
|
-
the_closure =
|
|
1943
|
+
the_block = factory.LAMBDA(params,factory.literal(42), nil).model
|
|
1944
|
+
the_closure = Evaluator::Closure::Dynamic.new(:fake_evaluator, the_block, :fake_scope)
|
|
1591
1945
|
expect(calculator.instance?(all_callables_t, the_closure)).to be_truthy
|
|
1592
|
-
expect(calculator.instance?(callable_t(
|
|
1593
|
-
expect(calculator.instance?(callable_t(
|
|
1946
|
+
expect(calculator.instance?(callable_t(any_t), the_closure)).to be_truthy
|
|
1947
|
+
expect(calculator.instance?(callable_t(any_t, any_t), the_closure)).to be_falsey
|
|
1594
1948
|
end
|
|
1595
1949
|
|
|
1596
1950
|
it 'a Function instance should be considered a Callable' do
|
|
@@ -1610,485 +1964,288 @@ describe 'The type calculator' do
|
|
|
1610
1964
|
expect(calculator.instance?(callable_t(String), f)).to be_truthy
|
|
1611
1965
|
end
|
|
1612
1966
|
end
|
|
1613
|
-
end
|
|
1614
1967
|
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
[Integer,Fixnum,Bignum].each do |c|
|
|
1618
|
-
expect(calculator.type(c).class).to eq(Puppet::Pops::Types::PIntegerType)
|
|
1619
|
-
end
|
|
1620
|
-
end
|
|
1968
|
+
context 'and t is a TypeAlias' do
|
|
1969
|
+
let!(:parser) { TypeParser.singleton }
|
|
1621
1970
|
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
it 'should yield \'PBooleanType\' for FalseClass and TrueClass' do
|
|
1627
|
-
[FalseClass,TrueClass].each do |c|
|
|
1628
|
-
expect(calculator.type(c).class).to eq(Puppet::Pops::Types::PBooleanType)
|
|
1971
|
+
it 'should consider x an instance of the aliased simple type' do
|
|
1972
|
+
t = type_alias_t('Alias', 'Integer').resolve(parser, nil)
|
|
1973
|
+
expect(calculator.instance?(t, 15)).to be_truthy
|
|
1629
1974
|
end
|
|
1630
|
-
end
|
|
1631
1975
|
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
it 'should yield \'PStringType\' for String' do
|
|
1637
|
-
expect(calculator.type(String).class).to eq(Puppet::Pops::Types::PStringType)
|
|
1638
|
-
end
|
|
1639
|
-
|
|
1640
|
-
it 'should yield \'PRegexpType\' for Regexp' do
|
|
1641
|
-
expect(calculator.type(Regexp).class).to eq(Puppet::Pops::Types::PRegexpType)
|
|
1642
|
-
end
|
|
1643
|
-
|
|
1644
|
-
it 'should yield \'PArrayType[PDataType]\' for Array' do
|
|
1645
|
-
t = calculator.type(Array)
|
|
1646
|
-
expect(t.class).to eq(Puppet::Pops::Types::PArrayType)
|
|
1647
|
-
expect(t.element_type.class).to eq(Puppet::Pops::Types::PDataType)
|
|
1648
|
-
end
|
|
1649
|
-
|
|
1650
|
-
it 'should yield \'PHashType[PScalarType,PDataType]\' for Hash' do
|
|
1651
|
-
t = calculator.type(Hash)
|
|
1652
|
-
expect(t.class).to eq(Puppet::Pops::Types::PHashType)
|
|
1653
|
-
expect(t.key_type.class).to eq(Puppet::Pops::Types::PScalarType)
|
|
1654
|
-
expect(t.element_type.class).to eq(Puppet::Pops::Types::PDataType)
|
|
1655
|
-
end
|
|
1656
|
-
end
|
|
1657
|
-
|
|
1658
|
-
context 'when representing the type as string' do
|
|
1659
|
-
it 'should yield \'Type\' for PType' do
|
|
1660
|
-
expect(calculator.string(Puppet::Pops::Types::PType.new())).to eq('Type')
|
|
1661
|
-
end
|
|
1662
|
-
|
|
1663
|
-
it 'should yield \'Object\' for PAnyType' do
|
|
1664
|
-
expect(calculator.string(Puppet::Pops::Types::PAnyType.new())).to eq('Any')
|
|
1665
|
-
end
|
|
1666
|
-
|
|
1667
|
-
it 'should yield \'Scalar\' for PScalarType' do
|
|
1668
|
-
expect(calculator.string(Puppet::Pops::Types::PScalarType.new())).to eq('Scalar')
|
|
1669
|
-
end
|
|
1670
|
-
|
|
1671
|
-
it 'should yield \'Boolean\' for PBooleanType' do
|
|
1672
|
-
expect(calculator.string(Puppet::Pops::Types::PBooleanType.new())).to eq('Boolean')
|
|
1673
|
-
end
|
|
1674
|
-
|
|
1675
|
-
it 'should yield \'Data\' for PDataType' do
|
|
1676
|
-
expect(calculator.string(Puppet::Pops::Types::PDataType.new())).to eq('Data')
|
|
1677
|
-
end
|
|
1678
|
-
|
|
1679
|
-
it 'should yield \'Numeric\' for PNumericType' do
|
|
1680
|
-
expect(calculator.string(Puppet::Pops::Types::PNumericType.new())).to eq('Numeric')
|
|
1681
|
-
end
|
|
1682
|
-
|
|
1683
|
-
it 'should yield \'Integer\' and from/to for PIntegerType' do
|
|
1684
|
-
int_T = Puppet::Pops::Types::PIntegerType
|
|
1685
|
-
expect(calculator.string(int_T.new())).to eq('Integer')
|
|
1686
|
-
int = int_T.new()
|
|
1687
|
-
int.from = 1
|
|
1688
|
-
int.to = 1
|
|
1689
|
-
expect(calculator.string(int)).to eq('Integer[1, 1]')
|
|
1690
|
-
int = int_T.new()
|
|
1691
|
-
int.from = 1
|
|
1692
|
-
int.to = 2
|
|
1693
|
-
expect(calculator.string(int)).to eq('Integer[1, 2]')
|
|
1694
|
-
int = int_T.new()
|
|
1695
|
-
int.from = nil
|
|
1696
|
-
int.to = 2
|
|
1697
|
-
expect(calculator.string(int)).to eq('Integer[default, 2]')
|
|
1698
|
-
int = int_T.new()
|
|
1699
|
-
int.from = 2
|
|
1700
|
-
int.to = nil
|
|
1701
|
-
expect(calculator.string(int)).to eq('Integer[2, default]')
|
|
1702
|
-
end
|
|
1703
|
-
|
|
1704
|
-
it 'should yield \'Float\' for PFloatType' do
|
|
1705
|
-
expect(calculator.string(Puppet::Pops::Types::PFloatType.new())).to eq('Float')
|
|
1706
|
-
end
|
|
1707
|
-
|
|
1708
|
-
it 'should yield \'Regexp\' for PRegexpType' do
|
|
1709
|
-
expect(calculator.string(Puppet::Pops::Types::PRegexpType.new())).to eq('Regexp')
|
|
1710
|
-
end
|
|
1711
|
-
|
|
1712
|
-
it 'should yield \'Regexp[/pat/]\' for parameterized PRegexpType' do
|
|
1713
|
-
t = Puppet::Pops::Types::PRegexpType.new()
|
|
1714
|
-
t.pattern = ('a/b')
|
|
1715
|
-
expect(calculator.string(Puppet::Pops::Types::PRegexpType.new())).to eq('Regexp')
|
|
1716
|
-
end
|
|
1717
|
-
|
|
1718
|
-
it 'should yield \'String\' for PStringType' do
|
|
1719
|
-
expect(calculator.string(Puppet::Pops::Types::PStringType.new())).to eq('String')
|
|
1720
|
-
end
|
|
1721
|
-
|
|
1722
|
-
it 'should yield \'String\' for PStringType with multiple values' do
|
|
1723
|
-
expect(calculator.string(string_t('a', 'b', 'c'))).to eq('String')
|
|
1724
|
-
end
|
|
1725
|
-
|
|
1726
|
-
it 'should yield \'String\' and from/to for PStringType' do
|
|
1727
|
-
string_T = Puppet::Pops::Types::PStringType
|
|
1728
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), 1,1))).to eq('String[1, 1]')
|
|
1729
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), 1,2))).to eq('String[1, 2]')
|
|
1730
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), :default, 2))).to eq('String[default, 2]')
|
|
1731
|
-
expect(calculator.string(factory.constrain_size(string_T.new(), 2, :default))).to eq('String[2, default]')
|
|
1732
|
-
end
|
|
1733
|
-
|
|
1734
|
-
it 'should yield \'Array[Integer]\' for PArrayType[PIntegerType]' do
|
|
1735
|
-
t = Puppet::Pops::Types::PArrayType.new()
|
|
1736
|
-
t.element_type = Puppet::Pops::Types::PIntegerType.new()
|
|
1737
|
-
expect(calculator.string(t)).to eq('Array[Integer]')
|
|
1738
|
-
end
|
|
1739
|
-
|
|
1740
|
-
it 'should yield \'Collection\' and from/to for PCollectionType' do
|
|
1741
|
-
col = collection_t()
|
|
1742
|
-
expect(calculator.string(factory.constrain_size(col.copy, 1,1))).to eq('Collection[1, 1]')
|
|
1743
|
-
expect(calculator.string(factory.constrain_size(col.copy, 1,2))).to eq('Collection[1, 2]')
|
|
1744
|
-
expect(calculator.string(factory.constrain_size(col.copy, :default, 2))).to eq('Collection[default, 2]')
|
|
1745
|
-
expect(calculator.string(factory.constrain_size(col.copy, 2, :default))).to eq('Collection[2, default]')
|
|
1746
|
-
end
|
|
1747
|
-
|
|
1748
|
-
it 'should yield \'Array\' and from/to for PArrayType' do
|
|
1749
|
-
arr = array_t(string_t)
|
|
1750
|
-
expect(calculator.string(factory.constrain_size(arr.copy, 1,1))).to eq('Array[String, 1, 1]')
|
|
1751
|
-
expect(calculator.string(factory.constrain_size(arr.copy, 1,2))).to eq('Array[String, 1, 2]')
|
|
1752
|
-
expect(calculator.string(factory.constrain_size(arr.copy, :default, 2))).to eq('Array[String, default, 2]')
|
|
1753
|
-
expect(calculator.string(factory.constrain_size(arr.copy, 2, :default))).to eq('Array[String, 2, default]')
|
|
1754
|
-
end
|
|
1755
|
-
|
|
1756
|
-
it 'should yield \'Tuple[Integer]\' for PTupleType[PIntegerType]' do
|
|
1757
|
-
t = Puppet::Pops::Types::PTupleType.new()
|
|
1758
|
-
t.addTypes(Puppet::Pops::Types::PIntegerType.new())
|
|
1759
|
-
expect(calculator.string(t)).to eq('Tuple[Integer]')
|
|
1760
|
-
end
|
|
1761
|
-
|
|
1762
|
-
it 'should yield \'Tuple[T, T,..]\' for PTupleType[T, T, ...]' do
|
|
1763
|
-
t = Puppet::Pops::Types::PTupleType.new()
|
|
1764
|
-
t.addTypes(Puppet::Pops::Types::PIntegerType.new())
|
|
1765
|
-
t.addTypes(Puppet::Pops::Types::PIntegerType.new())
|
|
1766
|
-
t.addTypes(Puppet::Pops::Types::PStringType.new())
|
|
1767
|
-
expect(calculator.string(t)).to eq('Tuple[Integer, Integer, String]')
|
|
1768
|
-
end
|
|
1769
|
-
|
|
1770
|
-
it 'should yield \'Tuple\' and from/to for PTupleType' do
|
|
1771
|
-
tuple_t = tuple_t(string_t)
|
|
1772
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, 1,1))).to eq('Tuple[String, 1, 1]')
|
|
1773
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, 1,2))).to eq('Tuple[String, 1, 2]')
|
|
1774
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, :default, 2))).to eq('Tuple[String, default, 2]')
|
|
1775
|
-
expect(calculator.string(factory.constrain_size(tuple_t.copy, 2, :default))).to eq('Tuple[String, 2, default]')
|
|
1776
|
-
end
|
|
1777
|
-
|
|
1778
|
-
it 'should yield \'Struct\' and details for PStructType' do
|
|
1779
|
-
struct_t = struct_t({'a'=>Integer, 'b'=>String})
|
|
1780
|
-
expect(calculator.string(struct_t)).to eq("Struct[{'a'=>Integer, 'b'=>String}]")
|
|
1781
|
-
struct_t = struct_t({})
|
|
1782
|
-
expect(calculator.string(struct_t)).to eq("Struct")
|
|
1783
|
-
end
|
|
1784
|
-
|
|
1785
|
-
it 'should yield \'Hash[String, Integer]\' for PHashType[PStringType, PIntegerType]' do
|
|
1786
|
-
t = Puppet::Pops::Types::PHashType.new()
|
|
1787
|
-
t.key_type = Puppet::Pops::Types::PStringType.new()
|
|
1788
|
-
t.element_type = Puppet::Pops::Types::PIntegerType.new()
|
|
1789
|
-
expect(calculator.string(t)).to eq('Hash[String, Integer]')
|
|
1790
|
-
end
|
|
1791
|
-
|
|
1792
|
-
it 'should yield \'Hash\' and from/to for PHashType' do
|
|
1793
|
-
hsh = hash_t(string_t, string_t)
|
|
1794
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, 1,1))).to eq('Hash[String, String, 1, 1]')
|
|
1795
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, 1,2))).to eq('Hash[String, String, 1, 2]')
|
|
1796
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, :default, 2))).to eq('Hash[String, String, default, 2]')
|
|
1797
|
-
expect(calculator.string(factory.constrain_size(hsh.copy, 2, :default))).to eq('Hash[String, String, 2, default]')
|
|
1798
|
-
end
|
|
1799
|
-
|
|
1800
|
-
it "should yield 'Class' for a PHostClassType" do
|
|
1801
|
-
t = Puppet::Pops::Types::PHostClassType.new()
|
|
1802
|
-
expect(calculator.string(t)).to eq('Class')
|
|
1803
|
-
end
|
|
1804
|
-
|
|
1805
|
-
it "should yield 'Class[x]' for a PHostClassType[x]" do
|
|
1806
|
-
t = Puppet::Pops::Types::PHostClassType.new()
|
|
1807
|
-
t.class_name = 'x'
|
|
1808
|
-
expect(calculator.string(t)).to eq('Class[x]')
|
|
1809
|
-
end
|
|
1810
|
-
|
|
1811
|
-
it "should yield 'Resource' for a PResourceType" do
|
|
1812
|
-
t = Puppet::Pops::Types::PResourceType.new()
|
|
1813
|
-
expect(calculator.string(t)).to eq('Resource')
|
|
1814
|
-
end
|
|
1815
|
-
|
|
1816
|
-
it 'should yield \'File\' for a PResourceType[\'File\']' do
|
|
1817
|
-
t = Puppet::Pops::Types::PResourceType.new()
|
|
1818
|
-
t.type_name = 'File'
|
|
1819
|
-
expect(calculator.string(t)).to eq('File')
|
|
1820
|
-
end
|
|
1976
|
+
it 'should consider x an instance of the aliased parameterized type' do
|
|
1977
|
+
t = type_alias_t('Alias', 'Integer[0,20]').resolve(parser, nil)
|
|
1978
|
+
expect(calculator.instance?(t, 15)).to be_truthy
|
|
1979
|
+
end
|
|
1821
1980
|
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
expect(calculator.string(t)).to eq("File['/tmp/foo']")
|
|
1827
|
-
end
|
|
1981
|
+
it 'should consider x an instance of the aliased type that uses self recursion' do
|
|
1982
|
+
t = type_alias_t('Tree', 'Hash[String,Variant[String,Tree]]')
|
|
1983
|
+
loader = Object.new
|
|
1984
|
+
loader.expects(:load).with(:type, 'tree').returns t
|
|
1828
1985
|
|
|
1829
|
-
|
|
1830
|
-
t = enum_t('a', 'b', 'c')
|
|
1831
|
-
expect(calculator.string(t)).to eq("Enum['a', 'b', 'c']")
|
|
1832
|
-
end
|
|
1986
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1833
1987
|
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
expect(calculator.string(t)).to eq("Pattern[/a/]")
|
|
1838
|
-
expect(calculator.string(t2)).to eq("Pattern[/a/, /b/, /c/]")
|
|
1839
|
-
end
|
|
1988
|
+
t.resolve(parser, loader)
|
|
1989
|
+
expect(calculator.instance?(t, {'a'=>{'aa'=>{'aaa'=>'aaaa'}}, 'b'=>'bb'})).to be_truthy
|
|
1990
|
+
end
|
|
1840
1991
|
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1992
|
+
it 'should consider x an instance of the aliased type that uses contains an alias that causes self recursion' do
|
|
1993
|
+
t1 = type_alias_t('Tree', 'Hash[String,Variant[String,OtherTree]]')
|
|
1994
|
+
t2 = type_alias_t('OtherTree', 'Hash[String,Tree]')
|
|
1995
|
+
loader = Object.new
|
|
1996
|
+
loader.expects(:load).with(:type, 'tree').returns t1
|
|
1997
|
+
loader.expects(:load).with(:type, 'othertree').returns t2
|
|
1845
1998
|
|
|
1846
|
-
|
|
1847
|
-
t1 = string_t()
|
|
1848
|
-
t2 = integer_t()
|
|
1849
|
-
t3 = pattern_t('a')
|
|
1850
|
-
t = variant_t(t1, t2, t3)
|
|
1851
|
-
expect(calculator.string(t)).to eq("Variant[String, Integer, Pattern[/a/]]")
|
|
1852
|
-
end
|
|
1999
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
|
1853
2000
|
|
|
1854
|
-
|
|
1855
|
-
|
|
2001
|
+
t1.resolve(parser, loader)
|
|
2002
|
+
expect(calculator.instance?(t1, {'a'=>{'aa'=>{'aaa'=>'aaaa'}}, 'b'=>'bb'})).to be_truthy
|
|
2003
|
+
end
|
|
1856
2004
|
end
|
|
2005
|
+
end
|
|
1857
2006
|
|
|
1858
|
-
|
|
1859
|
-
|
|
2007
|
+
context 'when converting a ruby class' do
|
|
2008
|
+
it 'should yield \'PIntegerType\' for Fixnum' do
|
|
2009
|
+
expect(calculator.type(Fixnum).class).to eq(PIntegerType)
|
|
1860
2010
|
end
|
|
1861
2011
|
|
|
1862
|
-
it
|
|
1863
|
-
expect(calculator.
|
|
2012
|
+
it 'should yield \'PIntegerType\' for Bignum' do
|
|
2013
|
+
expect(calculator.type(Bignum).class).to eq(PIntegerType)
|
|
1864
2014
|
end
|
|
1865
2015
|
|
|
1866
|
-
it
|
|
1867
|
-
expect(calculator.
|
|
2016
|
+
it 'should yield \'PIntegerType\' for Integer' do
|
|
2017
|
+
expect(calculator.type(Integer).class).to eq(PIntegerType)
|
|
1868
2018
|
end
|
|
1869
2019
|
|
|
1870
|
-
it
|
|
1871
|
-
expect(calculator.
|
|
2020
|
+
it 'should yield \'PFloatType\' for Float' do
|
|
2021
|
+
expect(calculator.type(Float).class).to eq(PFloatType)
|
|
1872
2022
|
end
|
|
1873
2023
|
|
|
1874
|
-
it
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
2024
|
+
it 'should yield \'PBooleanType\' for FalseClass and TrueClass' do
|
|
2025
|
+
[FalseClass,TrueClass].each do |c|
|
|
2026
|
+
expect(calculator.type(c).class).to eq(PBooleanType)
|
|
2027
|
+
end
|
|
1878
2028
|
end
|
|
1879
2029
|
|
|
1880
|
-
it
|
|
1881
|
-
expect(calculator.
|
|
1882
|
-
expect(calculator.string(callable_t(string_t, all_callables_t))).to eql("Callable[String, Callable]")
|
|
1883
|
-
expect(calculator.string(callable_t(string_t, 1,1, all_callables_t))).to eql("Callable[String, 1, 1, Callable]")
|
|
2030
|
+
it 'should yield \'PUndefType\' for NilClass' do
|
|
2031
|
+
expect(calculator.type(NilClass).class).to eq(PUndefType)
|
|
1884
2032
|
end
|
|
1885
2033
|
|
|
1886
|
-
it
|
|
1887
|
-
expect(calculator.
|
|
2034
|
+
it 'should yield \'PStringType\' for String' do
|
|
2035
|
+
expect(calculator.type(String).class).to eq(PStringType)
|
|
1888
2036
|
end
|
|
1889
2037
|
|
|
1890
|
-
it
|
|
1891
|
-
|
|
1892
|
-
expect(calculator.string(t)).to eq('NotUndef')
|
|
2038
|
+
it 'should yield \'PRegexpType\' for Regexp' do
|
|
2039
|
+
expect(calculator.type(Regexp).class).to eq(PRegexpType)
|
|
1893
2040
|
end
|
|
1894
2041
|
|
|
1895
|
-
it
|
|
1896
|
-
t =
|
|
1897
|
-
expect(
|
|
2042
|
+
it 'should yield \'PArrayType[PAnyType]\' for Array' do
|
|
2043
|
+
t = calculator.type(Array)
|
|
2044
|
+
expect(t.class).to eq(PArrayType)
|
|
2045
|
+
expect(t.element_type.class).to eq(PAnyType)
|
|
1898
2046
|
end
|
|
1899
2047
|
|
|
1900
|
-
it
|
|
1901
|
-
t =
|
|
1902
|
-
expect(
|
|
2048
|
+
it 'should yield \'PHashType[PAnyType,PAnyType]\' for Hash' do
|
|
2049
|
+
t = calculator.type(Hash)
|
|
2050
|
+
expect(t.class).to eq(PHashType)
|
|
2051
|
+
expect(t.key_type.class).to eq(PAnyType)
|
|
2052
|
+
expect(t.value_type.class).to eq(PAnyType)
|
|
1903
2053
|
end
|
|
1904
2054
|
end
|
|
1905
2055
|
|
|
1906
2056
|
context 'when processing meta type' do
|
|
1907
2057
|
it 'should infer PType as the type of all other types' do
|
|
1908
|
-
ptype =
|
|
1909
|
-
expect(calculator.infer(
|
|
1910
|
-
expect(calculator.infer(
|
|
1911
|
-
expect(calculator.infer(
|
|
1912
|
-
expect(calculator.infer(
|
|
1913
|
-
expect(calculator.infer(
|
|
1914
|
-
expect(calculator.infer(
|
|
1915
|
-
expect(calculator.infer(
|
|
1916
|
-
expect(calculator.infer(
|
|
1917
|
-
expect(calculator.infer(
|
|
1918
|
-
expect(calculator.infer(
|
|
1919
|
-
expect(calculator.infer(
|
|
1920
|
-
expect(calculator.infer(
|
|
1921
|
-
expect(calculator.infer(
|
|
1922
|
-
expect(calculator.infer(
|
|
1923
|
-
expect(calculator.infer(
|
|
1924
|
-
expect(calculator.infer(
|
|
1925
|
-
expect(calculator.infer(
|
|
1926
|
-
expect(calculator.infer(
|
|
1927
|
-
expect(calculator.infer(
|
|
1928
|
-
expect(calculator.infer(
|
|
1929
|
-
expect(calculator.infer(
|
|
2058
|
+
ptype = PType
|
|
2059
|
+
expect(calculator.infer(PUndefType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2060
|
+
expect(calculator.infer(PScalarType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2061
|
+
expect(calculator.infer(PScalarDataType::DEFAULT).is_a?(ptype)).to eq(true)
|
|
2062
|
+
expect(calculator.infer(PStringType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2063
|
+
expect(calculator.infer(PNumericType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2064
|
+
expect(calculator.infer(PIntegerType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2065
|
+
expect(calculator.infer(PFloatType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2066
|
+
expect(calculator.infer(PRegexpType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2067
|
+
expect(calculator.infer(PBooleanType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2068
|
+
expect(calculator.infer(PCollectionType::DEFAULT).is_a?(ptype)).to eq(true)
|
|
2069
|
+
expect(calculator.infer(PArrayType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2070
|
+
expect(calculator.infer(PHashType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2071
|
+
expect(calculator.infer(PIterableType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2072
|
+
expect(calculator.infer(PRuntimeType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2073
|
+
expect(calculator.infer(PHostClassType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2074
|
+
expect(calculator.infer(PResourceType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2075
|
+
expect(calculator.infer(PEnumType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2076
|
+
expect(calculator.infer(PPatternType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2077
|
+
expect(calculator.infer(PVariantType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2078
|
+
expect(calculator.infer(PTupleType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2079
|
+
expect(calculator.infer(POptionalType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
2080
|
+
expect(calculator.infer(PCallableType::DEFAULT ).is_a?(ptype)).to eq(true)
|
|
1930
2081
|
end
|
|
1931
2082
|
|
|
1932
2083
|
it 'should infer PType as the type of all other types' do
|
|
1933
|
-
|
|
1934
|
-
expect(calculator.
|
|
1935
|
-
expect(calculator.
|
|
1936
|
-
expect(calculator.
|
|
1937
|
-
expect(calculator.
|
|
1938
|
-
expect(calculator.
|
|
1939
|
-
expect(calculator.
|
|
1940
|
-
expect(calculator.
|
|
1941
|
-
expect(calculator.
|
|
1942
|
-
expect(calculator.
|
|
1943
|
-
expect(calculator.
|
|
1944
|
-
expect(calculator.
|
|
1945
|
-
expect(calculator.
|
|
1946
|
-
expect(calculator.
|
|
1947
|
-
expect(calculator.
|
|
1948
|
-
expect(calculator.
|
|
1949
|
-
expect(calculator.
|
|
1950
|
-
expect(calculator.
|
|
1951
|
-
expect(calculator.
|
|
1952
|
-
expect(calculator.
|
|
1953
|
-
expect(calculator.
|
|
1954
|
-
expect(calculator.
|
|
1955
|
-
|
|
1956
|
-
expect(calculator.infer(
|
|
1957
|
-
expect(calculator.
|
|
1958
|
-
expect(calculator.infer(
|
|
2084
|
+
expect(calculator.infer(PUndefType::DEFAULT ).to_s).to eq('Type[Undef]')
|
|
2085
|
+
expect(calculator.infer(PScalarType::DEFAULT ).to_s).to eq('Type[Scalar]')
|
|
2086
|
+
expect(calculator.infer(PScalarDataType::DEFAULT).to_s).to eq('Type[ScalarData]')
|
|
2087
|
+
expect(calculator.infer(PStringType::DEFAULT ).to_s).to eq('Type[String]')
|
|
2088
|
+
expect(calculator.infer(PNumericType::DEFAULT ).to_s).to eq('Type[Numeric]')
|
|
2089
|
+
expect(calculator.infer(PIntegerType::DEFAULT ).to_s).to eq('Type[Integer]')
|
|
2090
|
+
expect(calculator.infer(PFloatType::DEFAULT ).to_s).to eq('Type[Float]')
|
|
2091
|
+
expect(calculator.infer(PRegexpType::DEFAULT ).to_s).to eq('Type[Regexp]')
|
|
2092
|
+
expect(calculator.infer(PBooleanType::DEFAULT ).to_s).to eq('Type[Boolean]')
|
|
2093
|
+
expect(calculator.infer(PCollectionType::DEFAULT).to_s).to eq('Type[Collection]')
|
|
2094
|
+
expect(calculator.infer(PArrayType::DEFAULT ).to_s).to eq('Type[Array]')
|
|
2095
|
+
expect(calculator.infer(PHashType::DEFAULT ).to_s).to eq('Type[Hash]')
|
|
2096
|
+
expect(calculator.infer(PIterableType::DEFAULT ).to_s).to eq('Type[Iterable]')
|
|
2097
|
+
expect(calculator.infer(PRuntimeType::DEFAULT ).to_s).to eq('Type[Runtime[?, ?]]')
|
|
2098
|
+
expect(calculator.infer(PHostClassType::DEFAULT ).to_s).to eq('Type[Class]')
|
|
2099
|
+
expect(calculator.infer(PResourceType::DEFAULT ).to_s).to eq('Type[Resource]')
|
|
2100
|
+
expect(calculator.infer(PEnumType::DEFAULT ).to_s).to eq('Type[Enum]')
|
|
2101
|
+
expect(calculator.infer(PVariantType::DEFAULT ).to_s).to eq('Type[Variant]')
|
|
2102
|
+
expect(calculator.infer(PPatternType::DEFAULT ).to_s).to eq('Type[Pattern]')
|
|
2103
|
+
expect(calculator.infer(PTupleType::DEFAULT ).to_s).to eq('Type[Tuple]')
|
|
2104
|
+
expect(calculator.infer(POptionalType::DEFAULT ).to_s).to eq('Type[Optional]')
|
|
2105
|
+
expect(calculator.infer(PCallableType::DEFAULT ).to_s).to eq('Type[Callable]')
|
|
2106
|
+
|
|
2107
|
+
expect(calculator.infer(PResourceType.new('foo::fee::fum')).to_s).to eq('Type[Foo::Fee::Fum]')
|
|
2108
|
+
expect(calculator.infer(PResourceType.new('foo::fee::fum')).to_s).to eq('Type[Foo::Fee::Fum]')
|
|
2109
|
+
expect(calculator.infer(PResourceType.new('Foo::Fee::Fum')).to_s).to eq('Type[Foo::Fee::Fum]')
|
|
1959
2110
|
end
|
|
1960
2111
|
|
|
1961
2112
|
it "computes the common type of PType's type parameter" do
|
|
1962
|
-
int_t =
|
|
1963
|
-
string_t =
|
|
1964
|
-
expect(calculator.
|
|
1965
|
-
expect(calculator.
|
|
2113
|
+
int_t = PIntegerType::DEFAULT
|
|
2114
|
+
string_t = PStringType::DEFAULT
|
|
2115
|
+
expect(calculator.infer([int_t]).to_s).to eq('Array[Type[Integer], 1, 1]')
|
|
2116
|
+
expect(calculator.infer([int_t, string_t]).to_s).to eq('Array[Type[ScalarData], 2, 2]')
|
|
1966
2117
|
end
|
|
1967
2118
|
|
|
1968
2119
|
it 'should infer PType as the type of ruby classes' do
|
|
1969
2120
|
class Foo
|
|
1970
2121
|
end
|
|
1971
2122
|
[Object, Numeric, Integer, Fixnum, Bignum, Float, String, Regexp, Array, Hash, Foo].each do |c|
|
|
1972
|
-
expect(calculator.infer(c).is_a?(
|
|
2123
|
+
expect(calculator.infer(c).is_a?(PType)).to eq(true)
|
|
1973
2124
|
end
|
|
1974
2125
|
end
|
|
1975
2126
|
|
|
1976
2127
|
it 'should infer PType as the type of PType (meta regression short-circuit)' do
|
|
1977
|
-
expect(calculator.infer(
|
|
2128
|
+
expect(calculator.infer(PType::DEFAULT).is_a?(PType)).to eq(true)
|
|
1978
2129
|
end
|
|
1979
2130
|
|
|
1980
2131
|
it 'computes instance? to be true if parameterized and type match' do
|
|
1981
|
-
int_t =
|
|
1982
|
-
type_t =
|
|
1983
|
-
type_type_t =
|
|
2132
|
+
int_t = PIntegerType::DEFAULT
|
|
2133
|
+
type_t = TypeFactory.type_type(int_t)
|
|
2134
|
+
type_type_t = TypeFactory.type_type(type_t)
|
|
1984
2135
|
expect(calculator.instance?(type_type_t, type_t)).to eq(true)
|
|
1985
2136
|
end
|
|
1986
2137
|
|
|
1987
2138
|
it 'computes instance? to be false if parameterized and type do not match' do
|
|
1988
|
-
int_t =
|
|
1989
|
-
string_t =
|
|
1990
|
-
type_t =
|
|
1991
|
-
type_t2 =
|
|
1992
|
-
type_type_t =
|
|
2139
|
+
int_t = PIntegerType::DEFAULT
|
|
2140
|
+
string_t = PStringType::DEFAULT
|
|
2141
|
+
type_t = TypeFactory.type_type(int_t)
|
|
2142
|
+
type_t2 = TypeFactory.type_type(string_t)
|
|
2143
|
+
type_type_t = TypeFactory.type_type(type_t)
|
|
1993
2144
|
# i.e. Type[Integer] =~ Type[Type[Integer]] # false
|
|
1994
2145
|
expect(calculator.instance?(type_type_t, type_t2)).to eq(false)
|
|
1995
2146
|
end
|
|
1996
2147
|
|
|
1997
2148
|
it 'computes instance? to be true if unparameterized and matched against a type[?]' do
|
|
1998
|
-
int_t =
|
|
1999
|
-
type_t =
|
|
2000
|
-
expect(calculator.instance?(
|
|
2149
|
+
int_t = PIntegerType::DEFAULT
|
|
2150
|
+
type_t = TypeFactory.type_type(int_t)
|
|
2151
|
+
expect(calculator.instance?(PType::DEFAULT, type_t)).to eq(true)
|
|
2001
2152
|
end
|
|
2002
2153
|
end
|
|
2003
2154
|
|
|
2004
|
-
context
|
|
2005
|
-
it
|
|
2006
|
-
t =
|
|
2007
|
-
t.
|
|
2008
|
-
t.to = 10
|
|
2009
|
-
expect(calculator.enumerable(t).respond_to?(:each)).to eq(true)
|
|
2155
|
+
context 'when asking for an iterable ' do
|
|
2156
|
+
it 'should produce an iterable for an Integer range that is finite' do
|
|
2157
|
+
t = PIntegerType.new(1, 10)
|
|
2158
|
+
expect(calculator.iterable(t).respond_to?(:each)).to eq(true)
|
|
2010
2159
|
end
|
|
2011
2160
|
|
|
2012
|
-
it
|
|
2013
|
-
t =
|
|
2014
|
-
t.
|
|
2015
|
-
t.to = 10
|
|
2016
|
-
expect(calculator.enumerable(t)).to eq(nil)
|
|
2161
|
+
it 'should not produce an iterable for an Integer range that has an infinite side' do
|
|
2162
|
+
t = PIntegerType.new(nil, 10)
|
|
2163
|
+
expect(calculator.iterable(t)).to eq(nil)
|
|
2017
2164
|
|
|
2018
|
-
t =
|
|
2019
|
-
t.
|
|
2020
|
-
t.to = nil
|
|
2021
|
-
expect(calculator.enumerable(t)).to eq(nil)
|
|
2165
|
+
t = PIntegerType.new(1, nil)
|
|
2166
|
+
expect(calculator.iterable(t)).to eq(nil)
|
|
2022
2167
|
end
|
|
2023
2168
|
|
|
2024
|
-
it
|
|
2169
|
+
it 'all but Integer range are not iterable' do
|
|
2025
2170
|
[Object, Numeric, Float, String, Regexp, Array, Hash].each do |t|
|
|
2026
|
-
expect(calculator.
|
|
2171
|
+
expect(calculator.iterable(calculator.type(t))).to eq(nil)
|
|
2027
2172
|
end
|
|
2028
2173
|
end
|
|
2029
2174
|
end
|
|
2030
2175
|
|
|
2031
|
-
context
|
|
2032
|
-
it
|
|
2176
|
+
context 'when dealing with different types of inference' do
|
|
2177
|
+
it 'an instance specific inference is produced by infer' do
|
|
2033
2178
|
expect(calculator.infer(['a','b']).element_type.values).to eq(['a', 'b'])
|
|
2034
2179
|
end
|
|
2035
2180
|
|
|
2036
|
-
it
|
|
2037
|
-
expect(calculator.infer_generic(['a','b']).element_type
|
|
2181
|
+
it 'a generic inference is produced using infer_generic' do
|
|
2182
|
+
expect(calculator.infer_generic(['a','b']).element_type).to eql(string_t(range_t(1,1)))
|
|
2038
2183
|
end
|
|
2039
2184
|
|
|
2040
|
-
it
|
|
2185
|
+
it 'a generic result is created by generalize given an instance specific result for an Array' do
|
|
2041
2186
|
generic = calculator.infer(['a','b'])
|
|
2042
|
-
expect(generic.element_type.values).to eq(['a',
|
|
2043
|
-
|
|
2044
|
-
expect(generic.element_type
|
|
2187
|
+
expect(generic.element_type.values).to eq(['a','b'])
|
|
2188
|
+
generic = generic.generalize
|
|
2189
|
+
expect(generic.element_type).to eql(string_t(range_t(1,1)))
|
|
2045
2190
|
end
|
|
2046
2191
|
|
|
2047
|
-
it 'a generic result is created by generalize
|
|
2048
|
-
generic = calculator.infer({'a' =>1,'
|
|
2049
|
-
expect(generic.key_type.values.sort).to eq(['a', '
|
|
2050
|
-
expect(generic.
|
|
2051
|
-
expect(generic.
|
|
2052
|
-
|
|
2053
|
-
expect(generic.key_type.
|
|
2054
|
-
expect(generic.
|
|
2055
|
-
expect(generic.
|
|
2192
|
+
it 'a generic result is created by generalize given an instance specific result for a Hash' do
|
|
2193
|
+
generic = calculator.infer({'a' =>1,'bcd' => 2})
|
|
2194
|
+
expect(generic.key_type.values.sort).to eq(['a', 'bcd'])
|
|
2195
|
+
expect(generic.value_type.from).to eq(1)
|
|
2196
|
+
expect(generic.value_type.to).to eq(2)
|
|
2197
|
+
generic = generic.generalize
|
|
2198
|
+
expect(generic.key_type.size_type).to eq(range_t(1,3))
|
|
2199
|
+
expect(generic.value_type.from).to eq(nil)
|
|
2200
|
+
expect(generic.value_type.to).to eq(nil)
|
|
2056
2201
|
end
|
|
2057
2202
|
|
|
2058
2203
|
it 'ensures that Struct key types are not generalized' do
|
|
2059
|
-
generic =
|
|
2060
|
-
expect(
|
|
2061
|
-
generic =
|
|
2062
|
-
expect(
|
|
2063
|
-
generic =
|
|
2064
|
-
expect(
|
|
2204
|
+
generic = struct_t({'a' => any_t}).generalize
|
|
2205
|
+
expect(generic.to_s).to eq("Struct[{'a' => Any}]")
|
|
2206
|
+
generic = struct_t({not_undef_t('a') => any_t}).generalize
|
|
2207
|
+
expect(generic.to_s).to eq("Struct[{NotUndef['a'] => Any}]")
|
|
2208
|
+
generic = struct_t({optional_t('a') => string_t}).generalize
|
|
2209
|
+
expect(generic.to_s).to eq("Struct[{Optional['a'] => String}]")
|
|
2065
2210
|
end
|
|
2066
2211
|
|
|
2067
2212
|
it 'ensures that Struct value types are generalized' do
|
|
2068
|
-
generic =
|
|
2069
|
-
expect(
|
|
2213
|
+
generic = struct_t({'a' => range_t(1, 3)}).generalize
|
|
2214
|
+
expect(generic.to_s).to eq("Struct[{'a' => Integer}]")
|
|
2070
2215
|
end
|
|
2071
2216
|
|
|
2072
2217
|
it "does not reduce by combining types when using infer_set" do
|
|
2073
2218
|
element_type = calculator.infer(['a','b',1,2]).element_type
|
|
2074
|
-
expect(element_type.class).to eq(
|
|
2219
|
+
expect(element_type.class).to eq(PScalarDataType)
|
|
2075
2220
|
inferred_type = calculator.infer_set(['a','b',1,2])
|
|
2076
|
-
expect(inferred_type.class).to eq(
|
|
2221
|
+
expect(inferred_type.class).to eq(PTupleType)
|
|
2077
2222
|
element_types = inferred_type.types
|
|
2078
|
-
expect(element_types[0].class).to eq(
|
|
2079
|
-
expect(element_types[1].class).to eq(
|
|
2080
|
-
expect(element_types[2].class).to eq(
|
|
2081
|
-
expect(element_types[3].class).to eq(
|
|
2223
|
+
expect(element_types[0].class).to eq(PStringType)
|
|
2224
|
+
expect(element_types[1].class).to eq(PStringType)
|
|
2225
|
+
expect(element_types[2].class).to eq(PIntegerType)
|
|
2226
|
+
expect(element_types[3].class).to eq(PIntegerType)
|
|
2082
2227
|
end
|
|
2083
2228
|
|
|
2084
|
-
it
|
|
2229
|
+
it 'does not reduce by combining types when using infer_set and values are undef' do
|
|
2085
2230
|
element_type = calculator.infer(['a',nil]).element_type
|
|
2086
|
-
expect(element_type.class).to eq(
|
|
2231
|
+
expect(element_type.class).to eq(PStringType)
|
|
2087
2232
|
inferred_type = calculator.infer_set(['a',nil])
|
|
2088
|
-
expect(inferred_type.class).to eq(
|
|
2233
|
+
expect(inferred_type.class).to eq(PTupleType)
|
|
2089
2234
|
element_types = inferred_type.types
|
|
2090
|
-
expect(element_types[0].class).to eq(
|
|
2091
|
-
expect(element_types[1].class).to eq(
|
|
2235
|
+
expect(element_types[0].class).to eq(PStringType)
|
|
2236
|
+
expect(element_types[1].class).to eq(PUndefType)
|
|
2237
|
+
end
|
|
2238
|
+
|
|
2239
|
+
it 'infers on an empty Array produces Array[Unit,0,0]' do
|
|
2240
|
+
inferred_type = calculator.infer([])
|
|
2241
|
+
expect(inferred_type.element_type.class).to eq(PUnitType)
|
|
2242
|
+
expect(inferred_type.size_range).to eq([0, 0])
|
|
2243
|
+
end
|
|
2244
|
+
|
|
2245
|
+
it 'infer_set on an empty Array produces Array[Unit,0,0]' do
|
|
2246
|
+
inferred_type = calculator.infer_set([])
|
|
2247
|
+
expect(inferred_type.element_type.class).to eq(PUnitType)
|
|
2248
|
+
expect(inferred_type.size_range).to eq([0, 0])
|
|
2092
2249
|
end
|
|
2093
2250
|
end
|
|
2094
2251
|
|
|
@@ -2114,8 +2271,7 @@ describe 'The type calculator' do
|
|
|
2114
2271
|
|
|
2115
2272
|
it 'with args array' do
|
|
2116
2273
|
required = callable_t(string_t)
|
|
2117
|
-
given = array_t(string_t)
|
|
2118
|
-
factory.constrain_size(given, 1, 1)
|
|
2274
|
+
given = array_t(string_t, range_t(1, 1))
|
|
2119
2275
|
expect(calculator.callable?(required, given)).to eq(true)
|
|
2120
2276
|
end
|
|
2121
2277
|
end
|
|
@@ -2123,50 +2279,50 @@ describe 'The type calculator' do
|
|
|
2123
2279
|
context 'and given is more generic' do
|
|
2124
2280
|
it 'with callable' do
|
|
2125
2281
|
required = callable_t(string_t)
|
|
2126
|
-
given = callable_t(
|
|
2282
|
+
given = callable_t(any_t)
|
|
2127
2283
|
expect(calculator.callable?(required, given)).to eq(true)
|
|
2128
2284
|
end
|
|
2129
2285
|
|
|
2130
2286
|
it 'with args tuple' do
|
|
2131
2287
|
required = callable_t(string_t)
|
|
2132
|
-
given = tuple_t(
|
|
2288
|
+
given = tuple_t(any_t)
|
|
2133
2289
|
expect(calculator.callable?(required, given)).to eq(false)
|
|
2134
2290
|
end
|
|
2135
2291
|
|
|
2136
2292
|
it 'with args tuple having a block' do
|
|
2137
2293
|
required = callable_t(string_t, callable_t(string_t))
|
|
2138
|
-
given = tuple_t(string_t, callable_t(
|
|
2294
|
+
given = tuple_t(string_t, callable_t(any_t))
|
|
2139
2295
|
expect(calculator.callable?(required, given)).to eq(true)
|
|
2140
2296
|
end
|
|
2141
2297
|
|
|
2142
2298
|
it 'with args tuple having a block with captures rest' do
|
|
2143
2299
|
required = callable_t(string_t, callable_t(string_t))
|
|
2144
|
-
given = tuple_t(string_t, callable_t(
|
|
2300
|
+
given = tuple_t(string_t, callable_t(any_t, 0, :default))
|
|
2145
2301
|
expect(calculator.callable?(required, given)).to eq(true)
|
|
2146
2302
|
end
|
|
2147
2303
|
end
|
|
2148
2304
|
|
|
2149
2305
|
context 'and given is more specific' do
|
|
2150
2306
|
it 'with callable' do
|
|
2151
|
-
required = callable_t(
|
|
2307
|
+
required = callable_t(any_t)
|
|
2152
2308
|
given = callable_t(string_t)
|
|
2153
2309
|
expect(calculator.callable?(required, given)).to eq(false)
|
|
2154
2310
|
end
|
|
2155
2311
|
|
|
2156
2312
|
it 'with args tuple' do
|
|
2157
|
-
required = callable_t(
|
|
2313
|
+
required = callable_t(any_t)
|
|
2158
2314
|
given = tuple_t(string_t)
|
|
2159
2315
|
expect(calculator.callable?(required, given)).to eq(true)
|
|
2160
2316
|
end
|
|
2161
2317
|
|
|
2162
2318
|
it 'with args tuple having a block' do
|
|
2163
|
-
required = callable_t(string_t, callable_t(
|
|
2319
|
+
required = callable_t(string_t, callable_t(any_t))
|
|
2164
2320
|
given = tuple_t(string_t, callable_t(string_t))
|
|
2165
2321
|
expect(calculator.callable?(required, given)).to eq(false)
|
|
2166
2322
|
end
|
|
2167
2323
|
|
|
2168
2324
|
it 'with args tuple having a block with captures rest' do
|
|
2169
|
-
required = callable_t(string_t, callable_t(
|
|
2325
|
+
required = callable_t(string_t, callable_t(any_t))
|
|
2170
2326
|
given = tuple_t(string_t, callable_t(string_t, 0, :default))
|
|
2171
2327
|
expect(calculator.callable?(required, given)).to eq(false)
|
|
2172
2328
|
end
|
|
@@ -2174,19 +2330,18 @@ describe 'The type calculator' do
|
|
|
2174
2330
|
end
|
|
2175
2331
|
|
|
2176
2332
|
matcher :be_assignable_to do |type|
|
|
2177
|
-
calc = Puppet::Pops::Types::TypeCalculator.singleton
|
|
2178
|
-
|
|
2179
2333
|
match do |actual|
|
|
2180
|
-
|
|
2334
|
+
type.is_a?(PAnyType) && type.assignable?(actual)
|
|
2181
2335
|
end
|
|
2182
2336
|
|
|
2183
2337
|
failure_message do |actual|
|
|
2184
|
-
"#{
|
|
2338
|
+
"#{TypeFormatter.string(actual)} should be assignable to #{TypeFormatter.string(type)}"
|
|
2185
2339
|
end
|
|
2186
2340
|
|
|
2187
2341
|
failure_message_when_negated do |actual|
|
|
2188
|
-
"#{
|
|
2342
|
+
"#{TypeFormatter.string(actual)} is assignable to #{TypeFormatter.string(type)} when it should not"
|
|
2189
2343
|
end
|
|
2190
2344
|
end
|
|
2191
|
-
|
|
2345
|
+
end
|
|
2346
|
+
end
|
|
2192
2347
|
end
|