puppet 3.5.1-x86-mingw32 → 3.6.0.rc1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CONTRIBUTING.md +5 -0
- data/Gemfile +17 -9
- data/README.md +1 -0
- data/conf/fileserver.conf +4 -3
- data/ext/README.environment +8 -0
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/control +2 -2
- data/ext/debian/puppet-common.dirs +4 -0
- data/ext/debian/rules +4 -0
- data/ext/emacs/puppet-mode-init.el +1 -1
- data/ext/emacs/puppet-mode.el +36 -17
- data/ext/redhat/client.init +3 -3
- data/ext/redhat/puppet.spec.erb +9 -0
- data/ext/systemd/puppet.service +3 -4
- data/ext/systemd/puppetmaster.service +1 -3
- data/install.rb +1 -1
- data/lib/puppet.rb +2 -1
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application.rb +17 -17
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/configurer.rb +4 -1
- data/lib/puppet/configurer/downloader.rb +13 -12
- data/lib/puppet/configurer/plugin_handler.rb +3 -3
- data/lib/puppet/context.rb +6 -1
- data/lib/puppet/defaults.rb +82 -12
- data/lib/puppet/environments.rb +169 -13
- data/lib/puppet/external/nagios/grammar.ry +2 -0
- data/lib/puppet/external/nagios/parser.rb +28 -19
- data/lib/puppet/face/config.rb +19 -6
- data/lib/puppet/face/module/generate.rb +209 -7
- data/lib/puppet/face/module/install.rb +17 -16
- data/lib/puppet/face/module/list.rb +83 -82
- data/lib/puppet/face/module/search.rb +1 -1
- data/lib/puppet/face/module/upgrade.rb +10 -9
- data/lib/puppet/face/parser.rb +3 -2
- data/lib/puppet/face/plugin.rb +8 -4
- data/lib/puppet/file_bucket/dipper.rb +6 -3
- data/lib/puppet/file_bucket/file.rb +4 -2
- data/lib/puppet/file_serving/metadata.rb +1 -1
- data/lib/puppet/file_system/memory_file.rb +27 -1
- data/lib/puppet/file_system/memory_impl.rb +15 -1
- data/lib/puppet/forge.rb +148 -52
- data/lib/puppet/forge/cache.rb +5 -1
- data/lib/puppet/forge/errors.rb +10 -0
- data/lib/puppet/forge/repository.rb +61 -26
- data/lib/puppet/functions.rb +548 -0
- data/lib/puppet/functions/assert_type.rb +42 -0
- data/lib/puppet/functions/import.rb +7 -0
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
- data/lib/puppet/indirector/rest.rb +18 -0
- data/lib/puppet/loaders.rb +20 -0
- data/lib/puppet/module.rb +2 -2
- data/lib/puppet/module_tool.rb +40 -14
- data/lib/puppet/module_tool/applications.rb +0 -1
- data/lib/puppet/module_tool/applications/application.rb +35 -26
- data/lib/puppet/module_tool/applications/builder.rb +16 -6
- data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
- data/lib/puppet/module_tool/applications/installer.rb +196 -35
- data/lib/puppet/module_tool/applications/searcher.rb +1 -0
- data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
- data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
- data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
- data/lib/puppet/module_tool/checksums.rb +5 -8
- data/lib/puppet/module_tool/errors/installer.rb +12 -44
- data/lib/puppet/module_tool/errors/shared.rb +84 -11
- data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
- data/lib/puppet/module_tool/install_directory.rb +7 -6
- data/lib/puppet/module_tool/installed_modules.rb +92 -0
- data/lib/puppet/module_tool/local_tarball.rb +91 -0
- data/lib/puppet/module_tool/metadata.rb +119 -115
- data/lib/puppet/module_tool/modulefile.rb +9 -9
- data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
- data/lib/puppet/module_tool/tar.rb +3 -7
- data/lib/puppet/module_tool/tar/gnu.rb +21 -9
- data/lib/puppet/module_tool/tar/mini.rb +2 -8
- data/lib/puppet/network/http/api/v1.rb +1 -1
- data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
- data/lib/puppet/network/http/issues.rb +1 -0
- data/lib/puppet/network/http_pool.rb +15 -6
- data/lib/puppet/node/environment.rb +91 -20
- data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
- data/lib/puppet/parser/collector.rb +1 -1
- data/lib/puppet/parser/compiler.rb +50 -7
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/pops.rb +22 -1
- data/lib/puppet/pops/adapters.rb +8 -1
- data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
- data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
- data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
- data/lib/puppet/pops/binder/producers.rb +2 -2
- data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
- data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
- data/lib/puppet/pops/evaluator/closure.rb +57 -2
- data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
- data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
- data/lib/puppet/pops/functions/dispatch.rb +71 -0
- data/lib/puppet/pops/functions/dispatcher.rb +237 -0
- data/lib/puppet/pops/functions/function.rb +77 -0
- data/lib/puppet/pops/issues.rb +12 -0
- data/lib/puppet/pops/loader/base_loader.rb +102 -0
- data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
- data/lib/puppet/pops/loader/gem_support.rb +49 -0
- data/lib/puppet/pops/loader/loader.rb +180 -0
- data/lib/puppet/pops/loader/loader_paths.rb +137 -0
- data/lib/puppet/pops/loader/module_loaders.rb +242 -0
- data/lib/puppet/pops/loader/null_loader.rb +44 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
- data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
- data/lib/puppet/pops/loader/static_loader.rb +69 -0
- data/lib/puppet/pops/loader/uri_helper.rb +22 -0
- data/lib/puppet/pops/loaders.rb +240 -0
- data/lib/puppet/pops/model/factory.rb +13 -5
- data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
- data/lib/puppet/pops/parser/egrammar.ra +31 -18
- data/lib/puppet/pops/parser/eparser.rb +1137 -1106
- data/lib/puppet/pops/parser/lexer2.rb +17 -16
- data/lib/puppet/pops/semantic_error.rb +17 -0
- data/lib/puppet/pops/types/type_calculator.rb +150 -15
- data/lib/puppet/pops/types/type_factory.rb +69 -0
- data/lib/puppet/pops/types/type_parser.rb +9 -0
- data/lib/puppet/pops/types/types.rb +65 -4
- data/lib/puppet/pops/validation/checker4_0.rb +1 -1
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
- data/lib/puppet/property/list.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +2 -2
- data/lib/puppet/provider/cron/crontab.rb +13 -2
- data/lib/puppet/provider/package.rb +24 -0
- data/lib/puppet/provider/package/apt.rb +6 -1
- data/lib/puppet/provider/package/gem.rb +8 -2
- data/lib/puppet/provider/package/msi.rb +0 -15
- data/lib/puppet/provider/package/openbsd.rb +0 -24
- data/lib/puppet/provider/package/rpm.rb +3 -29
- data/lib/puppet/provider/package/windows.rb +0 -15
- data/lib/puppet/provider/package/yum.rb +101 -24
- data/lib/puppet/provider/package/yumhelper.py +31 -1
- data/lib/puppet/provider/package/zypper.rb +10 -28
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +3 -0
- data/lib/puppet/provider/service/openbsd.rb +318 -0
- data/lib/puppet/provider/service/redhat.rb +6 -3
- data/lib/puppet/provider/service/systemd.rb +2 -2
- data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
- data/lib/puppet/resource.rb +13 -9
- data/lib/puppet/resource/catalog.rb +12 -6
- data/lib/puppet/resource/type_collection.rb +3 -3
- data/lib/puppet/settings.rb +57 -36
- data/lib/puppet/settings/config_file.rb +5 -0
- data/lib/puppet/settings/environment_conf.rb +147 -0
- data/lib/puppet/settings/ttl_setting.rb +48 -0
- data/lib/puppet/ssl/certificate_authority.rb +2 -3
- data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +4 -4
- data/lib/puppet/ssl/validator/default_validator.rb +2 -2
- data/lib/puppet/status.rb +1 -1
- data/lib/puppet/test/test_helper.rb +1 -0
- data/lib/puppet/type/augeas.rb +13 -1
- data/lib/puppet/type/cron.rb +32 -18
- data/lib/puppet/type/file.rb +4 -2
- data/lib/puppet/type/file/checksum.rb +15 -5
- data/lib/puppet/type/file/content.rb +3 -1
- data/lib/puppet/type/file/source.rb +5 -5
- data/lib/puppet/type/package.rb +12 -17
- data/lib/puppet/type/resources.rb +3 -1
- data/lib/puppet/type/scheduled_task.rb +4 -5
- data/lib/puppet/type/service.rb +12 -2
- data/lib/puppet/type/user.rb +106 -0
- data/lib/puppet/type/yumrepo.rb +9 -1
- data/lib/puppet/util/checksums.rb +60 -1
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/execution.rb +20 -16
- data/lib/puppet/util/feature.rb +3 -0
- data/lib/puppet/util/logging.rb +19 -12
- data/lib/puppet/util/rubygems.rb +10 -0
- data/lib/puppet/util/watched_file.rb +1 -1
- data/lib/puppet/util/windows/security.rb +5 -3
- data/lib/puppet/vendor/load_semantic.rb +1 -0
- data/lib/puppet/vendor/require_vendored.rb +2 -0
- data/lib/puppet/vendor/semantic/Gemfile +20 -0
- data/lib/puppet/vendor/semantic/Rakefile +69 -0
- data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
- data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/java.tgz +0 -0
- data/spec/fixtures/stdlib.tgz +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
- data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
- data/spec/fixtures/unit/type/user/authorized_keys +5 -0
- data/spec/integration/application/apply_spec.rb +1 -2
- data/spec/integration/configurer_spec.rb +2 -2
- data/spec/integration/faces/plugin_spec.rb +62 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
- data/spec/integration/node/environment_spec.rb +2 -2
- data/spec/integration/parser/future_compiler_spec.rb +96 -142
- data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
- data/spec/integration/provider/cron/crontab_spec.rb +35 -0
- data/spec/integration/type/file_spec.rb +74 -72
- data/spec/integration/util/windows/security_spec.rb +17 -0
- data/spec/lib/matchers/resource.rb +45 -13
- data/spec/lib/puppet_spec/files.rb +18 -0
- data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
- data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
- data/spec/shared_contexts/checksums.rb +55 -0
- data/spec/unit/application/apply_spec.rb +10 -7
- data/spec/unit/application/doc_spec.rb +17 -10
- data/spec/unit/application/indirection_base_spec.rb +18 -10
- data/spec/unit/application/inspect_spec.rb +22 -20
- data/spec/unit/configurer/downloader_spec.rb +7 -6
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/context_spec.rb +23 -0
- data/spec/unit/environments_spec.rb +274 -16
- data/spec/unit/face/config_spec.rb +111 -11
- data/spec/unit/face/module/install_spec.rb +14 -85
- data/spec/unit/face/module/list_spec.rb +108 -62
- data/spec/unit/face/module/search_spec.rb +1 -1
- data/spec/unit/face/module/uninstall_spec.rb +21 -42
- data/spec/unit/face/parser_spec.rb +5 -2
- data/spec/unit/file_bucket/dipper_spec.rb +92 -86
- data/spec/unit/file_bucket/file_spec.rb +23 -75
- data/spec/unit/file_serving/metadata_spec.rb +74 -74
- data/spec/unit/forge/module_release_spec.rb +131 -0
- data/spec/unit/forge/repository_spec.rb +21 -20
- data/spec/unit/forge_spec.rb +99 -23
- data/spec/unit/functions/assert_type_spec.rb +59 -0
- data/spec/unit/functions4_spec.rb +671 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
- data/spec/unit/indirector/facts/facter_spec.rb +9 -3
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
- data/spec/unit/indirector/rest_spec.rb +8 -0
- data/spec/unit/interface/face_collection_spec.rb +35 -23
- data/spec/unit/module_spec.rb +20 -8
- data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
- data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
- data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
- data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
- data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
- data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
- data/spec/unit/module_tool/metadata_spec.rb +223 -14
- data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
- data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
- data/spec/unit/module_tool/tar_spec.rb +4 -18
- data/spec/unit/module_tool_spec.rb +123 -27
- data/spec/unit/network/formats_spec.rb +2 -2
- data/spec/unit/network/http_pool_spec.rb +21 -0
- data/spec/unit/network/rights_spec.rb +10 -8
- data/spec/unit/node/environment_spec.rb +27 -2
- data/spec/unit/parser/collector_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +1 -1
- data/spec/unit/parser/functions/generate_spec.rb +4 -0
- data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
- data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
- data/spec/unit/pops/types/type_factory_spec.rb +101 -0
- data/spec/unit/pops/types/type_parser_spec.rb +22 -0
- data/spec/unit/property/list_spec.rb +9 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
- data/spec/unit/provider/cron/crontab_spec.rb +1 -0
- data/spec/unit/provider/cron/parsed_spec.rb +15 -0
- data/spec/unit/provider/naginator_spec.rb +14 -0
- data/spec/unit/provider/package/apt_spec.rb +78 -64
- data/spec/unit/provider/package/gem_spec.rb +15 -0
- data/spec/unit/provider/package/rpm_spec.rb +6 -6
- data/spec/unit/provider/package/windows_spec.rb +1 -1
- data/spec/unit/provider/package/yum_spec.rb +199 -104
- data/spec/unit/provider/package/zypper_spec.rb +41 -15
- data/spec/unit/provider/service/openbsd_spec.rb +129 -22
- data/spec/unit/provider/service/redhat_spec.rb +18 -4
- data/spec/unit/provider/service/systemd_spec.rb +5 -9
- data/spec/unit/provider/service/upstart_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
- data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
- data/spec/unit/resource/catalog_spec.rb +20 -104
- data/spec/unit/resource/type_collection_spec.rb +10 -9
- data/spec/unit/settings/config_file_spec.rb +29 -6
- data/spec/unit/settings/environment_conf_spec.rb +51 -0
- data/spec/unit/settings_spec.rb +97 -12
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
- data/spec/unit/type/augeas_spec.rb +1 -1
- data/spec/unit/type/cron_spec.rb +6 -7
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/content_spec.rb +277 -207
- data/spec/unit/type/file_spec.rb +9 -7
- data/spec/unit/type/user_spec.rb +106 -18
- data/spec/unit/type/yumrepo_spec.rb +8 -0
- data/spec/unit/util/checksums_spec.rb +12 -5
- data/spec/unit/util/diff_spec.rb +8 -0
- data/spec/unit/util/execution_spec.rb +4 -4
- data/spec/unit/util/feature_spec.rb +2 -0
- data/spec/unit/util/logging_spec.rb +14 -4
- data/spec/unit/util/rdoc/parser_spec.rb +5 -4
- data/spec/unit/util/rubygems_spec.rb +14 -0
- data/tasks/parallel.rake +2 -2
- metadata +154 -21
- checksums.yaml +0 -7
- data/lib/puppet/module_tool/applications/generator.rb +0 -142
- data/lib/puppet/module_tool/skeleton.rb +0 -37
- data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
- data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
- data/lib/puppet/module_tool/tar/solaris.rb +0 -5
- data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
- data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet_spec/files'
|
3
|
+
|
4
|
+
require 'puppet/pops'
|
5
|
+
require 'puppet/loaders'
|
6
|
+
|
7
|
+
describe 'loaders' do
|
8
|
+
include PuppetSpec::Files
|
9
|
+
|
10
|
+
let(:module_without_metadata) { File.join(config_dir('wo_metadata_module'), 'modules') }
|
11
|
+
let(:module_with_metadata) { File.join(config_dir('single_module'), 'modules') }
|
12
|
+
let(:dependent_modules_with_metadata) { config_dir('dependent_modules_with_metadata') }
|
13
|
+
let(:empty_test_env) { environment_for() }
|
14
|
+
|
15
|
+
# Loaders caches the puppet_system_loader, must reset between tests
|
16
|
+
before(:each) { Puppet::Pops::Loaders.clear() }
|
17
|
+
|
18
|
+
it 'creates a puppet_system loader' do
|
19
|
+
loaders = Puppet::Pops::Loaders.new(empty_test_env)
|
20
|
+
expect(loaders.puppet_system_loader()).to be_a(Puppet::Pops::Loader::ModuleLoaders::FileBased)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'creates an environment loader' do
|
24
|
+
loaders = Puppet::Pops::Loaders.new(empty_test_env)
|
25
|
+
|
26
|
+
expect(loaders.public_environment_loader()).to be_a(Puppet::Pops::Loader::SimpleEnvironmentLoader)
|
27
|
+
expect(loaders.public_environment_loader().to_s).to eql("(SimpleEnvironmentLoader 'environment:*test*')")
|
28
|
+
expect(loaders.private_environment_loader()).to be_a(Puppet::Pops::Loader::DependencyLoader)
|
29
|
+
expect(loaders.private_environment_loader().to_s).to eql("(DependencyLoader 'environment' [])")
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'can load 3x system functions' do
|
33
|
+
Puppet[:biff] = true
|
34
|
+
loaders = Puppet::Pops::Loaders.new(empty_test_env)
|
35
|
+
puppet_loader = loaders.puppet_system_loader()
|
36
|
+
|
37
|
+
function = puppet_loader.load_typed(typed_name(:function, 'sprintf')).value
|
38
|
+
|
39
|
+
expect(function.class.name).to eq('sprintf')
|
40
|
+
expect(function).to be_a(Puppet::Functions::Function)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'can load a function using a qualified or unqualified name from a module with metadata' do
|
44
|
+
loaders = Puppet::Pops::Loaders.new(environment_for(module_with_metadata))
|
45
|
+
modulea_loader = loaders.public_loader_for_module('modulea')
|
46
|
+
|
47
|
+
unqualified_function = modulea_loader.load_typed(typed_name(:function, 'rb_func_a')).value
|
48
|
+
qualified_function = modulea_loader.load_typed(typed_name(:function, 'modulea::rb_func_a')).value
|
49
|
+
|
50
|
+
expect(unqualified_function).to be_a(Puppet::Functions::Function)
|
51
|
+
expect(qualified_function).to be_a(Puppet::Functions::Function)
|
52
|
+
expect(unqualified_function.class.name).to eq('rb_func_a')
|
53
|
+
expect(qualified_function.class.name).to eq('modulea::rb_func_a')
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'can load a function with a qualified name from module without metadata' do
|
57
|
+
loaders = Puppet::Pops::Loaders.new(environment_for(module_without_metadata))
|
58
|
+
|
59
|
+
moduleb_loader = loaders.public_loader_for_module('moduleb')
|
60
|
+
function = moduleb_loader.load_typed(typed_name(:function, 'moduleb::rb_func_b')).value
|
61
|
+
|
62
|
+
expect(function).to be_a(Puppet::Functions::Function)
|
63
|
+
expect(function.class.name).to eq('moduleb::rb_func_b')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'cannot load an unqualified function from a module without metadata' do
|
67
|
+
loaders = Puppet::Pops::Loaders.new(environment_for(module_without_metadata))
|
68
|
+
|
69
|
+
moduleb_loader = loaders.public_loader_for_module('moduleb')
|
70
|
+
|
71
|
+
expect(moduleb_loader.load_typed(typed_name(:function, 'rb_func_b'))).to be_nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'makes all other modules visible to a module without metadata' do
|
75
|
+
env = environment_for(module_with_metadata, module_without_metadata)
|
76
|
+
loaders = Puppet::Pops::Loaders.new(env)
|
77
|
+
|
78
|
+
moduleb_loader = loaders.private_loader_for_module('moduleb')
|
79
|
+
function = moduleb_loader.load_typed(typed_name(:function, 'moduleb::rb_func_b')).value
|
80
|
+
|
81
|
+
expect(function.call({})).to eql("I am modulea::rb_func_a() + I am moduleb::rb_func_b()")
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'makes dependent modules visible to a module with metadata' do
|
85
|
+
env = environment_for(dependent_modules_with_metadata)
|
86
|
+
loaders = Puppet::Pops::Loaders.new(env)
|
87
|
+
|
88
|
+
moduleb_loader = loaders.private_loader_for_module('user')
|
89
|
+
function = moduleb_loader.load_typed(typed_name(:function, 'user::caller')).value
|
90
|
+
|
91
|
+
expect(function.call({})).to eql("usee::callee() was told 'passed value' + I am user::caller()")
|
92
|
+
end
|
93
|
+
|
94
|
+
def environment_for(*module_paths)
|
95
|
+
Puppet::Node::Environment.create(:'*test*', module_paths, '')
|
96
|
+
end
|
97
|
+
|
98
|
+
def typed_name(type, name)
|
99
|
+
Puppet::Pops::Loader::Loader::TypedName.new(type, name)
|
100
|
+
end
|
101
|
+
|
102
|
+
def config_dir(config_name)
|
103
|
+
my_fixture(config_name)
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet_spec/files'
|
3
|
+
require 'puppet/pops'
|
4
|
+
require 'puppet/loaders'
|
5
|
+
|
6
|
+
describe 'FileBased module loader' do
|
7
|
+
include PuppetSpec::Files
|
8
|
+
|
9
|
+
let(:static_loader) { Puppet::Pops::Loader::StaticLoader.new() }
|
10
|
+
let(:loaders) { Puppet::Pops::Loaders.new(Puppet::Node::Environment.create(:testing, [])) }
|
11
|
+
|
12
|
+
it 'can load a 4x function API ruby function in global name space' do
|
13
|
+
module_dir = dir_containing('testmodule', {
|
14
|
+
'lib' => {
|
15
|
+
'puppet' => {
|
16
|
+
'functions' => {
|
17
|
+
'foo4x.rb' => <<-CODE
|
18
|
+
Puppet::Functions.create_function(:foo4x) do
|
19
|
+
def foo4x()
|
20
|
+
'yay'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
CODE
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
})
|
28
|
+
|
29
|
+
module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
|
30
|
+
function = module_loader.load_typed(typed_name(:function, 'foo4x')).value
|
31
|
+
|
32
|
+
expect(function.class.name).to eq('foo4x')
|
33
|
+
expect(function.is_a?(Puppet::Functions::Function)).to eq(true)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'can load a 4x function API ruby function in qualified name space' do
|
37
|
+
module_dir = dir_containing('testmodule', {
|
38
|
+
'lib' => {
|
39
|
+
'puppet' => {
|
40
|
+
'functions' => {
|
41
|
+
'testmodule' => {
|
42
|
+
'foo4x.rb' => <<-CODE
|
43
|
+
Puppet::Functions.create_function('testmodule::foo4x') do
|
44
|
+
def foo4x()
|
45
|
+
'yay'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
CODE
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}})
|
53
|
+
|
54
|
+
module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
|
55
|
+
function = module_loader.load_typed(typed_name(:function, 'testmodule::foo4x')).value
|
56
|
+
expect(function.class.name).to eq('testmodule::foo4x')
|
57
|
+
expect(function.is_a?(Puppet::Functions::Function)).to eq(true)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'makes parent loader win over entries in child' do
|
61
|
+
module_dir = dir_containing('testmodule', {
|
62
|
+
'lib' => { 'puppet' => { 'functions' => { 'testmodule' => {
|
63
|
+
'foo.rb' => <<-CODE
|
64
|
+
Puppet::Functions.create_function('testmodule::foo') do
|
65
|
+
def foo()
|
66
|
+
'yay'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
CODE
|
70
|
+
}}}}})
|
71
|
+
module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
|
72
|
+
|
73
|
+
module_dir2 = dir_containing('testmodule2', {
|
74
|
+
'lib' => { 'puppet' => { 'functions' => { 'testmodule2' => {
|
75
|
+
'foo.rb' => <<-CODE
|
76
|
+
raise "should not get here"
|
77
|
+
CODE
|
78
|
+
}}}}})
|
79
|
+
module_loader2 = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(module_loader, loaders, 'testmodule2', module_dir2, 'test2')
|
80
|
+
|
81
|
+
function = module_loader2.load_typed(typed_name(:function, 'testmodule::foo')).value
|
82
|
+
|
83
|
+
expect(function.class.name).to eq('testmodule::foo')
|
84
|
+
expect(function.is_a?(Puppet::Functions::Function)).to eq(true)
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when delegating 3x to 4x' do
|
88
|
+
before(:each) { Puppet[:biff] = true }
|
89
|
+
|
90
|
+
it 'can load a 3x function API ruby function in global name space' do
|
91
|
+
module_dir = dir_containing('testmodule', {
|
92
|
+
'lib' => {
|
93
|
+
'puppet' => {
|
94
|
+
'parser' => {
|
95
|
+
'functions' => {
|
96
|
+
'foo3x.rb' => <<-CODE
|
97
|
+
Puppet::Parser::Functions::newfunction(
|
98
|
+
:foo3x, :type => :rvalue,
|
99
|
+
:arity => 1
|
100
|
+
) do |args|
|
101
|
+
args[0]
|
102
|
+
end
|
103
|
+
CODE
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}})
|
108
|
+
|
109
|
+
module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
|
110
|
+
function = module_loader.load_typed(typed_name(:function, 'foo3x')).value
|
111
|
+
expect(function.class.name).to eq('foo3x')
|
112
|
+
expect(function.is_a?(Puppet::Functions::Function)).to eq(true)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def typed_name(type, name)
|
117
|
+
Puppet::Pops::Loader::Loader::TypedName.new(type, name)
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/pops'
|
3
|
+
require 'puppet/loaders'
|
4
|
+
|
5
|
+
describe 'the static loader' do
|
6
|
+
it 'has no parent' do
|
7
|
+
expect(Puppet::Pops::Loader::StaticLoader.new.parent).to be(nil)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'identifies itself in string form' do
|
11
|
+
expect(Puppet::Pops::Loader::StaticLoader.new.to_s).to be_eql('(StaticLoader)')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'support the Loader API' do
|
15
|
+
# it may produce things later, this is just to test that calls work as they should - now all lookups are nil.
|
16
|
+
loader = Puppet::Pops::Loader::StaticLoader.new()
|
17
|
+
a_typed_name = typed_name(:function, 'foo')
|
18
|
+
expect(loader[a_typed_name]).to be(nil)
|
19
|
+
expect(loader.load_typed(a_typed_name)).to be(nil)
|
20
|
+
expect(loader.find(a_typed_name)).to be(nil)
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'provides access to logging functions' do
|
24
|
+
let(:loader) { loader = Puppet::Pops::Loader::StaticLoader.new() }
|
25
|
+
# Ensure all logging functions produce output
|
26
|
+
before(:each) { Puppet::Util::Log.level = :debug }
|
27
|
+
|
28
|
+
Puppet::Util::Log.levels.each do |level|
|
29
|
+
it "defines the function #{level.to_s}" do
|
30
|
+
expect(loader.load(:function, level).class.name).to eql(level.to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'and #{level.to_s} can be called' do
|
34
|
+
expect(loader.load(:function, level).call({}, 'yay').to_s).to eql('yay')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "uses the evaluator to format output" do
|
38
|
+
expect(loader.load(:function, level).call({}, ['yay', 'surprise']).to_s).to eql('[yay, surprise]')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def typed_name(type, name)
|
44
|
+
Puppet::Pops::Loader::Loader::TypedName.new(type, name)
|
45
|
+
end
|
46
|
+
end
|
@@ -23,6 +23,21 @@ describe 'The type calculator' do
|
|
23
23
|
Puppet::Pops::Types::TypeFactory.string(*strings)
|
24
24
|
end
|
25
25
|
|
26
|
+
def callable_t(*params)
|
27
|
+
Puppet::Pops::Types::TypeFactory.callable(*params)
|
28
|
+
end
|
29
|
+
def all_callables_t(*params)
|
30
|
+
Puppet::Pops::Types::TypeFactory.all_callables()
|
31
|
+
end
|
32
|
+
|
33
|
+
def with_block_t(callable_t, *params)
|
34
|
+
Puppet::Pops::Types::TypeFactory.with_block(callable_t, *params)
|
35
|
+
end
|
36
|
+
|
37
|
+
def with_optional_block_t(callable_t, *params)
|
38
|
+
Puppet::Pops::Types::TypeFactory.with_optional_block(callable_t, *params)
|
39
|
+
end
|
40
|
+
|
26
41
|
def enum_t(*strings)
|
27
42
|
Puppet::Pops::Types::TypeFactory.enum(*strings)
|
28
43
|
end
|
@@ -63,6 +78,10 @@ describe 'The type calculator' do
|
|
63
78
|
Puppet::Pops::Types::TypeFactory.struct(type_hash)
|
64
79
|
end
|
65
80
|
|
81
|
+
def optional_object_t
|
82
|
+
Puppet::Pops::Types::TypeFactory.optional_object()
|
83
|
+
end
|
84
|
+
|
66
85
|
def types
|
67
86
|
Puppet::Pops::Types
|
68
87
|
end
|
@@ -91,6 +110,7 @@ describe 'The type calculator' do
|
|
91
110
|
Puppet::Pops::Types::PVariantType,
|
92
111
|
Puppet::Pops::Types::PStructType,
|
93
112
|
Puppet::Pops::Types::PTupleType,
|
113
|
+
Puppet::Pops::Types::PCallableType,
|
94
114
|
]
|
95
115
|
end
|
96
116
|
|
@@ -426,6 +446,46 @@ describe 'The type calculator' do
|
|
426
446
|
common_t.class.should == Puppet::Pops::Types::PVariantType
|
427
447
|
Set.new(common_t.types).should == Set.new([a_t1, a_t2])
|
428
448
|
end
|
449
|
+
|
450
|
+
context "of callables" do
|
451
|
+
it 'incompatible instances => generic callable' do
|
452
|
+
t1 = callable_t(String)
|
453
|
+
t2 = callable_t(Integer)
|
454
|
+
common_t = calculator.common_type(t1, t2)
|
455
|
+
expect(common_t.class).to be(Puppet::Pops::Types::PCallableType)
|
456
|
+
expect(common_t.param_types).to be_nil
|
457
|
+
expect(common_t.block_type).to be_nil
|
458
|
+
end
|
459
|
+
|
460
|
+
it 'compatible instances => the least specific' do
|
461
|
+
t1 = callable_t(String)
|
462
|
+
scalar_t = Puppet::Pops::Types::PScalarType.new
|
463
|
+
t2 = callable_t(scalar_t)
|
464
|
+
common_t = calculator.common_type(t1, t2)
|
465
|
+
expect(common_t.class).to be(Puppet::Pops::Types::PCallableType)
|
466
|
+
expect(common_t.param_types.class).to be(Puppet::Pops::Types::PTupleType)
|
467
|
+
expect(common_t.param_types.types).to eql([scalar_t])
|
468
|
+
expect(common_t.block_type).to be_nil
|
469
|
+
end
|
470
|
+
|
471
|
+
it 'block_type is included in the check (incompatible block)' do
|
472
|
+
t1 = with_block_t(callable_t(String), String)
|
473
|
+
t2 = with_block_t(callable_t(String), Integer)
|
474
|
+
common_t = calculator.common_type(t1, t2)
|
475
|
+
expect(common_t.class).to be(Puppet::Pops::Types::PCallableType)
|
476
|
+
expect(common_t.param_types).to be_nil
|
477
|
+
expect(common_t.block_type).to be_nil
|
478
|
+
end
|
479
|
+
|
480
|
+
it 'block_type is included in the check (compatible block)' do
|
481
|
+
t1 = with_block_t(callable_t(String), String)
|
482
|
+
scalar_t = Puppet::Pops::Types::PScalarType.new
|
483
|
+
t2 = with_block_t(callable_t(String), scalar_t)
|
484
|
+
common_t = calculator.common_type(t1, t2)
|
485
|
+
expect(common_t.param_types.class).to be(Puppet::Pops::Types::PTupleType)
|
486
|
+
expect(common_t.block_type).to eql(callable_t(scalar_t))
|
487
|
+
end
|
488
|
+
end
|
429
489
|
end
|
430
490
|
|
431
491
|
context 'computes assignability' do
|
@@ -613,6 +673,16 @@ describe 'The type calculator' do
|
|
613
673
|
end
|
614
674
|
end
|
615
675
|
|
676
|
+
context "for Callable, such that" do
|
677
|
+
it "Callable is not assignable to any disjunct type" do
|
678
|
+
t = Puppet::Pops::Types::PCallableType.new()
|
679
|
+
tested_types = all_types - [
|
680
|
+
Puppet::Pops::Types::PCallableType,
|
681
|
+
Puppet::Pops::Types::PObjectType]
|
682
|
+
tested_types.each {|t2| t.should_not be_assignable_to(t2.new) }
|
683
|
+
end
|
684
|
+
end
|
685
|
+
|
616
686
|
it 'should recognize mapped ruby types' do
|
617
687
|
{ Integer => Puppet::Pops::Types::PIntegerType.new,
|
618
688
|
Fixnum => Puppet::Pops::Types::PIntegerType.new,
|
@@ -1040,6 +1110,38 @@ describe 'The type calculator' do
|
|
1040
1110
|
calculator.instance?(data_t, [1, nil, 'a']).should == true
|
1041
1111
|
end
|
1042
1112
|
end
|
1113
|
+
|
1114
|
+
context "and t is something Callable" do
|
1115
|
+
|
1116
|
+
it 'a Closure should be considered a Callable' do
|
1117
|
+
factory = Puppet::Pops::Model::Factory
|
1118
|
+
params = [factory.PARAM('a')]
|
1119
|
+
the_block = factory.LAMBDA(params,factory.literal(42))
|
1120
|
+
the_closure = Puppet::Pops::Evaluator::Closure.new(:fake_evaluator, the_block, :fake_scope)
|
1121
|
+
expect(calculator.instance?(all_callables_t, the_closure)).to be_true
|
1122
|
+
# TODO: lambdas are currently unttypes, anything can be given if arg count is correct
|
1123
|
+
expect(calculator.instance?(callable_t(optional_object_t), the_closure)).to be_true
|
1124
|
+
# Arg count is wrong
|
1125
|
+
expect(calculator.instance?(callable_t(optional_object_t, optional_object_t), the_closure)).to be_false
|
1126
|
+
end
|
1127
|
+
|
1128
|
+
it 'a Function instance should be considered a Callable' do
|
1129
|
+
fc = Puppet::Functions.create_function(:foo) do
|
1130
|
+
dispatch :foo do
|
1131
|
+
param 'String', 'a'
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
def foo(a)
|
1135
|
+
a
|
1136
|
+
end
|
1137
|
+
end
|
1138
|
+
f = fc.new(:closure_scope, :loader)
|
1139
|
+
# Any callable
|
1140
|
+
expect(calculator.instance?(all_callables_t, f)).to be_true
|
1141
|
+
# Callable[String]
|
1142
|
+
expect(calculator.instance?(callable_t(String), f)).to be_true
|
1143
|
+
end
|
1144
|
+
end
|
1043
1145
|
end
|
1044
1146
|
|
1045
1147
|
context 'when converting a ruby class' do
|
@@ -1282,6 +1384,33 @@ describe 'The type calculator' do
|
|
1282
1384
|
t = variant_t(t1, t2, t3)
|
1283
1385
|
calculator.string(t).should == "Variant[String, Integer, Pattern[/a/]]"
|
1284
1386
|
end
|
1387
|
+
|
1388
|
+
it "should yield 'Callable' for generic callable" do
|
1389
|
+
expect(calculator.string(all_callables_t)).to eql("Callable")
|
1390
|
+
end
|
1391
|
+
|
1392
|
+
it "should yield 'Callable[0,0]' for callable without params" do
|
1393
|
+
expect(calculator.string(callable_t)).to eql("Callable[0, 0]")
|
1394
|
+
end
|
1395
|
+
|
1396
|
+
it "should yield 'Callable[t,t]' for callable with typed parameters" do
|
1397
|
+
expect(calculator.string(callable_t(String, Integer))).to eql("Callable[String, Integer]")
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
it "should yield 'Callable[t,min.max]' for callable with size constraint (infinite max)" do
|
1401
|
+
expect(calculator.string(callable_t(String, 0))).to eql("Callable[String, 0, default]")
|
1402
|
+
end
|
1403
|
+
|
1404
|
+
it "should yield 'Callable[t,min.max]' for callable with size constraint (capped max)" do
|
1405
|
+
expect(calculator.string(callable_t(String, 0, 3))).to eql("Callable[String, 0, 3]")
|
1406
|
+
end
|
1407
|
+
|
1408
|
+
it "should yield 'Callable[Callable]' for callable with block" do
|
1409
|
+
expect(calculator.string(callable_t(all_callables_t))).to eql("Callable[0, 0, Callable]")
|
1410
|
+
expect(calculator.string(callable_t(string_t, all_callables_t))).to eql("Callable[String, Callable]")
|
1411
|
+
expect(calculator.string(callable_t(string_t, 1,1, all_callables_t))).to eql("Callable[String, 1, 1, Callable]")
|
1412
|
+
end
|
1413
|
+
|
1285
1414
|
end
|
1286
1415
|
|
1287
1416
|
context 'when processing meta type' do
|
@@ -1306,6 +1435,8 @@ describe 'The type calculator' do
|
|
1306
1435
|
calculator.infer(Puppet::Pops::Types::PPatternType.new() ).is_a?(ptype).should() == true
|
1307
1436
|
calculator.infer(Puppet::Pops::Types::PVariantType.new() ).is_a?(ptype).should() == true
|
1308
1437
|
calculator.infer(Puppet::Pops::Types::PTupleType.new() ).is_a?(ptype).should() == true
|
1438
|
+
calculator.infer(Puppet::Pops::Types::POptionalType.new() ).is_a?(ptype).should() == true
|
1439
|
+
calculator.infer(Puppet::Pops::Types::PCallableType.new() ).is_a?(ptype).should() == true
|
1309
1440
|
end
|
1310
1441
|
|
1311
1442
|
it 'should infer PType as the type of all other types' do
|
@@ -1329,6 +1460,8 @@ describe 'The type calculator' do
|
|
1329
1460
|
calculator.string(calculator.infer(Puppet::Pops::Types::PVariantType.new() )).should == "Type[Variant]"
|
1330
1461
|
calculator.string(calculator.infer(Puppet::Pops::Types::PPatternType.new() )).should == "Type[Pattern]"
|
1331
1462
|
calculator.string(calculator.infer(Puppet::Pops::Types::PTupleType.new() )).should == "Type[Tuple]"
|
1463
|
+
calculator.string(calculator.infer(Puppet::Pops::Types::POptionalType.new() )).should == "Type[Optional]"
|
1464
|
+
calculator.string(calculator.infer(Puppet::Pops::Types::PCallableType.new() )).should == "Type[Callable]"
|
1332
1465
|
end
|
1333
1466
|
|
1334
1467
|
it "computes the common type of PType's type parameter" do
|
@@ -1431,21 +1564,23 @@ describe 'The type calculator' do
|
|
1431
1564
|
it "does not reduce by combining types when using infer_set" do
|
1432
1565
|
element_type = calculator.infer(['a','b',1,2]).element_type
|
1433
1566
|
element_type.class.should == Puppet::Pops::Types::PScalarType
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1567
|
+
inferred_type = calculator.infer_set(['a','b',1,2])
|
1568
|
+
inferred_type.class.should == Puppet::Pops::Types::PTupleType
|
1569
|
+
element_types = inferred_type.types
|
1570
|
+
element_types[0].class.should == Puppet::Pops::Types::PStringType
|
1571
|
+
element_types[1].class.should == Puppet::Pops::Types::PStringType
|
1572
|
+
element_types[2].class.should == Puppet::Pops::Types::PIntegerType
|
1573
|
+
element_types[3].class.should == Puppet::Pops::Types::PIntegerType
|
1440
1574
|
end
|
1441
1575
|
|
1442
1576
|
it "does not reduce by combining types when using infer_set and values are undef" do
|
1443
1577
|
element_type = calculator.infer(['a',nil]).element_type
|
1444
1578
|
element_type.class.should == Puppet::Pops::Types::PStringType
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1579
|
+
inferred_type = calculator.infer_set(['a',nil])
|
1580
|
+
inferred_type.class.should == Puppet::Pops::Types::PTupleType
|
1581
|
+
element_types = inferred_type.types
|
1582
|
+
element_types[0].class.should == Puppet::Pops::Types::PStringType
|
1583
|
+
element_types[1].class.should == Puppet::Pops::Types::PNilType
|
1449
1584
|
end
|
1450
1585
|
end
|
1451
1586
|
|