puppet 4.4.1-x86-mingw32 → 4.4.2-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/lib/puppet/application/ca.rb +1 -0
- data/lib/puppet/application/lookup.rb +4 -16
- data/lib/puppet/application/resource.rb +0 -4
- data/lib/puppet/data_providers/hiera_interpolate.rb +8 -2
- data/lib/puppet/data_providers/json_data_provider_factory.rb +1 -1
- data/lib/puppet/defaults.rb +32 -16
- data/lib/puppet/file_system/uniquefile.rb +2 -2
- data/lib/puppet/file_system/windows.rb +1 -15
- data/lib/puppet/functions/assert_type.rb +1 -1
- data/lib/puppet/functions/lookup.rb +0 -3
- data/lib/puppet/indirector/catalog/compiler.rb +2 -1
- data/lib/puppet/indirector/msgpack.rb +1 -1
- data/lib/puppet/indirector/terminus.rb +4 -4
- data/lib/puppet/module.rb +3 -3
- data/lib/puppet/module_tool/applications/builder.rb +2 -2
- data/lib/puppet/network/auth_config_parser.rb +1 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +0 -2
- data/lib/puppet/network/http/rack/rest.rb +10 -1
- data/lib/puppet/parser/functions/lookup.rb +0 -3
- data/lib/puppet/pops/evaluator/access_operator.rb +25 -1
- data/lib/puppet/pops/evaluator/closure.rb +10 -5
- data/lib/puppet/pops/merge_strategy.rb +0 -10
- data/lib/puppet/pops/types/recursion_guard.rb +10 -0
- data/lib/puppet/pops/types/type_asserter.rb +2 -2
- data/lib/puppet/pops/types/type_calculator.rb +1 -1
- data/lib/puppet/pops/types/type_formatter.rb +14 -2
- data/lib/puppet/pops/types/type_mismatch_describer.rb +22 -10
- data/lib/puppet/pops/types/types.rb +240 -98
- data/lib/puppet/provider/package/puppet_gem.rb +0 -0
- data/lib/puppet/provider/user/user_role_add.rb +3 -1
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/ssl/oids.rb +24 -2
- data/lib/puppet/util/monkey_patches.rb +10 -5
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/file.rb +40 -10
- data/lib/puppet/version.rb +1 -1
- 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/hiera.yaml +5 -1
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +2 -2
- data/spec/fixtures/unit/parser/lexer/subclass_name_duplication.pp +0 -0
- data/spec/fixtures/unit/pops/parser/lexer/subclass_name_duplication.pp +0 -0
- data/spec/integration/agent/logging_spec.rb +0 -0
- data/spec/integration/application/apply_spec.rb +0 -0
- data/spec/integration/application/doc_spec.rb +0 -0
- data/spec/integration/configurer_spec.rb +0 -0
- data/spec/integration/data_binding_spec.rb +0 -0
- data/spec/integration/defaults_spec.rb +0 -0
- data/spec/integration/faces/ca_spec.rb +0 -0
- data/spec/integration/faces/documentation_spec.rb +0 -0
- data/spec/integration/file_serving/fileset_spec.rb +0 -0
- data/spec/integration/file_serving/terminus_helper_spec.rb +0 -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/file_content/file_server_spec.rb +0 -0
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +0 -0
- data/spec/integration/indirector/node/ldap_spec.rb +0 -0
- data/spec/integration/network/formats_spec.rb +0 -0
- data/spec/integration/node/environment_spec.rb +0 -0
- data/spec/integration/node/facts_spec.rb +0 -0
- data/spec/integration/node_spec.rb +0 -0
- data/spec/integration/parser/collection_spec.rb +0 -0
- data/spec/integration/parser/compiler_spec.rb +0 -0
- data/spec/integration/parser/functions/require_spec.rb +0 -0
- data/spec/integration/parser/parameter_defaults_spec.rb +19 -1
- data/spec/integration/provider/mailalias/aliases_spec.rb +0 -0
- data/spec/integration/provider/mount_spec.rb +0 -0
- data/spec/integration/provider/package_spec.rb +0 -0
- data/spec/integration/provider/service/init_spec.rb +0 -0
- data/spec/integration/provider/ssh_authorized_key_spec.rb +0 -0
- data/spec/integration/reference/providers_spec.rb +0 -0
- data/spec/integration/reports_spec.rb +0 -0
- data/spec/integration/resource/catalog_spec.rb +0 -0
- data/spec/integration/resource/type_collection_spec.rb +0 -0
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -0
- data/spec/integration/ssl/certificate_request_spec.rb +0 -0
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -0
- data/spec/integration/ssl/host_spec.rb +0 -0
- data/spec/integration/transaction/report_spec.rb +0 -0
- data/spec/integration/transaction_spec.rb +0 -0
- data/spec/integration/type/exec_spec.rb +0 -0
- data/spec/integration/type/file_spec.rb +0 -0
- data/spec/integration/type/package_spec.rb +0 -0
- data/spec/integration/type/tidy_spec.rb +0 -0
- data/spec/integration/type_spec.rb +0 -0
- data/spec/integration/util/autoload_spec.rb +0 -0
- data/spec/integration/util/rdoc/parser_spec.rb +0 -0
- data/spec/integration/util/settings_spec.rb +26 -0
- data/spec/integration/util/windows/registry_spec.rb +0 -0
- data/spec/integration/util/windows/security_spec.rb +0 -0
- data/spec/integration/util/windows/user_spec.rb +0 -0
- data/spec/integration/util_spec.rb +0 -0
- data/spec/lib/puppet/face/1.0.0/huzzah.rb +0 -0
- data/spec/lib/puppet/face/basetest.rb +0 -0
- data/spec/lib/puppet/face/huzzah.rb +0 -0
- data/spec/lib/puppet_spec/files.rb +0 -0
- data/spec/lib/puppet_spec/fixtures.rb +0 -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/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/spec_helper.rb +0 -0
- data/spec/unit/agent/locker_spec.rb +0 -0
- data/spec/unit/agent_spec.rb +0 -0
- data/spec/unit/application/agent_spec.rb +0 -0
- data/spec/unit/application/apply_spec.rb +0 -0
- data/spec/unit/application/cert_spec.rb +0 -0
- data/spec/unit/application/certificate_spec.rb +0 -0
- data/spec/unit/application/config_spec.rb +0 -0
- data/spec/unit/application/describe_spec.rb +0 -0
- data/spec/unit/application/device_spec.rb +0 -0
- data/spec/unit/application/doc_spec.rb +0 -0
- data/spec/unit/application/face_base_spec.rb +0 -0
- data/spec/unit/application/facts_spec.rb +0 -0
- data/spec/unit/application/filebucket_spec.rb +0 -0
- data/spec/unit/application/indirection_base_spec.rb +0 -0
- data/spec/unit/application/inspect_spec.rb +0 -0
- data/spec/unit/application/lookup_spec.rb +1 -1
- data/spec/unit/application/master_spec.rb +0 -0
- data/spec/unit/application/resource_spec.rb +0 -0
- data/spec/unit/application_spec.rb +0 -0
- data/spec/unit/configurer/downloader_factory_spec.rb +0 -0
- data/spec/unit/configurer/downloader_spec.rb +0 -0
- data/spec/unit/configurer/fact_handler_spec.rb +0 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +0 -0
- data/spec/unit/configurer_spec.rb +0 -0
- 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/daemon_spec.rb +0 -0
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +1 -1
- data/spec/unit/data_providers/hiera_interpolation_spec.rb +6 -0
- data/spec/unit/external/pson_spec.rb +0 -0
- data/spec/unit/face/catalog_spec.rb +0 -0
- data/spec/unit/face/certificate_spec.rb +0 -0
- data/spec/unit/face/config_spec.rb +0 -0
- data/spec/unit/face/facts_spec.rb +0 -0
- data/spec/unit/face/file_spec.rb +0 -0
- data/spec/unit/face/help_spec.rb +0 -0
- data/spec/unit/face/node_spec.rb +0 -0
- data/spec/unit/face/plugin_spec.rb +0 -0
- data/spec/unit/face_spec.rb +0 -0
- data/spec/unit/file_bucket/dipper_spec.rb +0 -0
- data/spec/unit/file_bucket/file_spec.rb +0 -0
- data/spec/unit/file_serving/base_spec.rb +0 -0
- data/spec/unit/file_serving/configuration/parser_spec.rb +0 -0
- data/spec/unit/file_serving/configuration_spec.rb +0 -0
- 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/metadata_spec.rb +0 -0
- data/spec/unit/file_serving/mount/file_spec.rb +0 -0
- data/spec/unit/file_serving/mount/modules_spec.rb +0 -0
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +0 -0
- data/spec/unit/file_serving/mount/plugins_spec.rb +0 -0
- data/spec/unit/file_serving/mount_spec.rb +0 -0
- data/spec/unit/file_serving/terminus_helper_spec.rb +0 -0
- data/spec/unit/file_serving/terminus_selector_spec.rb +0 -0
- data/spec/unit/file_system/uniquefile_spec.rb +20 -0
- data/spec/unit/file_system_spec.rb +61 -0
- data/spec/unit/functions/assert_type_spec.rb +8 -0
- data/spec/unit/functions/defined_spec.rb +0 -0
- data/spec/unit/functions/hiera_spec.rb +0 -0
- data/spec/unit/functions/lookup_spec.rb +3 -3
- data/spec/unit/functions/regsubst_spec.rb +0 -0
- data/spec/unit/functions/split_spec.rb +0 -0
- data/spec/unit/functions/versioncmp_spec.rb +0 -0
- data/spec/unit/graph/relationship_graph_spec.rb +0 -0
- data/spec/unit/graph/simple_graph_spec.rb +0 -0
- data/spec/unit/indirector/catalog/compiler_spec.rb +7 -0
- data/spec/unit/indirector/catalog/json_spec.rb +0 -0
- data/spec/unit/indirector/catalog/msgpack_spec.rb +0 -0
- data/spec/unit/indirector/catalog/rest_spec.rb +0 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +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/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 +0 -0
- data/spec/unit/indirector/facts/facter_spec.rb +0 -0
- 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 +0 -0
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_content/file_server_spec.rb +0 -0
- data/spec/unit/indirector/file_content/file_spec.rb +0 -0
- data/spec/unit/indirector/file_content/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/file_spec.rb +0 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +0 -0
- data/spec/unit/indirector/file_server_spec.rb +0 -0
- data/spec/unit/indirector/indirection_spec.rb +0 -0
- data/spec/unit/indirector/json_spec.rb +0 -0
- data/spec/unit/indirector/key/ca_spec.rb +0 -0
- data/spec/unit/indirector/key/disabled_ca_spec.rb +0 -0
- data/spec/unit/indirector/key/file_spec.rb +0 -0
- data/spec/unit/indirector/ldap_spec.rb +0 -0
- data/spec/unit/indirector/memory_spec.rb +0 -0
- data/spec/unit/indirector/msgpack_spec.rb +11 -1
- data/spec/unit/indirector/node/exec_spec.rb +0 -0
- data/spec/unit/indirector/node/ldap_spec.rb +0 -0
- data/spec/unit/indirector/node/memory_spec.rb +0 -0
- data/spec/unit/indirector/node/msgpack_spec.rb +0 -0
- data/spec/unit/indirector/node/plain_spec.rb +0 -0
- data/spec/unit/indirector/node/rest_spec.rb +0 -0
- data/spec/unit/indirector/node/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/node/yaml_spec.rb +0 -0
- data/spec/unit/indirector/plain_spec.rb +0 -0
- data/spec/unit/indirector/report/msgpack_spec.rb +0 -0
- data/spec/unit/indirector/report/processor_spec.rb +0 -0
- data/spec/unit/indirector/report/rest_spec.rb +0 -0
- data/spec/unit/indirector/report/yaml_spec.rb +0 -0
- data/spec/unit/indirector/request_spec.rb +0 -0
- data/spec/unit/indirector/resource/ral_spec.rb +0 -0
- data/spec/unit/indirector/resource/store_configs_spec.rb +0 -0
- data/spec/unit/indirector/resource_type/parser_spec.rb +0 -0
- data/spec/unit/indirector/resource_type/rest_spec.rb +0 -0
- data/spec/unit/indirector/rest_spec.rb +0 -0
- data/spec/unit/indirector/ssl_file_spec.rb +0 -0
- 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 +0 -0
- data/spec/unit/indirector_spec.rb +0 -0
- data/spec/unit/interface/action_builder_spec.rb +0 -0
- data/spec/unit/interface/action_manager_spec.rb +0 -0
- data/spec/unit/interface/action_spec.rb +0 -0
- data/spec/unit/interface/documentation_spec.rb +0 -0
- data/spec/unit/interface/face_collection_spec.rb +0 -0
- data/spec/unit/interface/option_builder_spec.rb +0 -0
- data/spec/unit/interface/option_spec.rb +0 -0
- data/spec/unit/interface_spec.rb +0 -0
- data/spec/unit/man_spec.rb +0 -0
- data/spec/unit/module_spec.rb +30 -6
- data/spec/unit/module_tool/applications/builder_spec.rb +23 -3
- data/spec/unit/module_tool_spec.rb +0 -0
- data/spec/unit/network/auth_config_parser_spec.rb +16 -0
- data/spec/unit/network/authconfig_spec.rb +0 -0
- data/spec/unit/network/authstore_spec.rb +0 -0
- data/spec/unit/network/format_handler_spec.rb +0 -0
- data/spec/unit/network/format_spec.rb +0 -0
- data/spec/unit/network/formats_spec.rb +0 -0
- data/spec/unit/network/http/api/indirected_routes_spec.rb +21 -13
- data/spec/unit/network/http/api/master/v3_spec.rb +0 -0
- data/spec/unit/network/http/compression_spec.rb +0 -0
- data/spec/unit/network/http/connection_spec.rb +0 -0
- data/spec/unit/network/http/factory_spec.rb +0 -0
- data/spec/unit/network/http/handler_spec.rb +0 -0
- data/spec/unit/network/http/nocache_pool_spec.rb +0 -0
- data/spec/unit/network/http/pool_spec.rb +0 -0
- data/spec/unit/network/http/rack/rest_spec.rb +7 -0
- data/spec/unit/network/http/rack_spec.rb +0 -0
- data/spec/unit/network/http/session_spec.rb +0 -0
- data/spec/unit/network/http/site_spec.rb +0 -0
- data/spec/unit/network/http/webrick/rest_spec.rb +0 -0
- data/spec/unit/network/http/webrick_spec.rb +0 -0
- 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 +0 -0
- data/spec/unit/network/server_spec.rb +0 -0
- data/spec/unit/node/environment_spec.rb +0 -0
- data/spec/unit/node/facts_spec.rb +0 -0
- data/spec/unit/node_spec.rb +0 -0
- data/spec/unit/other/selinux_spec.rb +0 -0
- data/spec/unit/parameter/path_spec.rb +0 -0
- data/spec/unit/parameter/value_collection_spec.rb +0 -0
- data/spec/unit/parameter/value_spec.rb +0 -0
- data/spec/unit/parameter_spec.rb +0 -0
- data/spec/unit/parser/ast/leaf_spec.rb +0 -0
- data/spec/unit/parser/compiler_spec.rb +0 -0
- data/spec/unit/parser/files_spec.rb +0 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +0 -0
- data/spec/unit/parser/functions/defined_spec.rb +0 -0
- 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 +0 -0
- data/spec/unit/parser/functions/generate_spec.rb +0 -0
- data/spec/unit/parser/functions/hiera_spec.rb +0 -0
- data/spec/unit/parser/functions/include_spec.rb +0 -0
- data/spec/unit/parser/functions/inline_template_spec.rb +0 -0
- data/spec/unit/parser/functions/realize_spec.rb +0 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +0 -0
- data/spec/unit/parser/functions/require_spec.rb +0 -0
- 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 +0 -0
- 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 +0 -0
- data/spec/unit/parser/scope_spec.rb +0 -0
- data/spec/unit/parser/templatewrapper_spec.rb +0 -0
- data/spec/unit/parser/type_loader_spec.rb +0 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +8 -8
- data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
- data/spec/unit/pops/types/type_calculator_spec.rb +32 -6
- data/spec/unit/pops/types/type_factory_spec.rb +26 -0
- data/spec/unit/pops/types/type_formatter_spec.rb +7 -2
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +25 -0
- data/spec/unit/pops/types/type_parser_spec.rb +1 -1
- data/spec/unit/pops/types/types_spec.rb +215 -0
- data/spec/unit/property/ensure_spec.rb +0 -0
- data/spec/unit/property/keyvalue_spec.rb +0 -0
- data/spec/unit/property/list_spec.rb +0 -0
- data/spec/unit/property/ordered_list_spec.rb +0 -0
- data/spec/unit/property_spec.rb +0 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +0 -0
- data/spec/unit/provider/cisco_spec.rb +0 -0
- data/spec/unit/provider/command_spec.rb +0 -0
- data/spec/unit/provider/cron/crontab_spec.rb +0 -0
- data/spec/unit/provider/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/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 +0 -0
- 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 +0 -0
- 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 +0 -0
- data/spec/unit/provider/nameservice_spec.rb +0 -0
- data/spec/unit/provider/network_device_spec.rb +0 -0
- data/spec/unit/provider/package/aix_spec.rb +0 -0
- data/spec/unit/provider/package/appdmg_spec.rb +0 -0
- 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 +0 -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 +0 -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 +0 -0
- 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 +0 -0
- data/spec/unit/provider/package/pip3_spec.rb +0 -0
- data/spec/unit/provider/package/pip_spec.rb +0 -0
- data/spec/unit/provider/package/pkg_spec.rb +0 -0
- data/spec/unit/provider/package/pkgutil_spec.rb +0 -0
- data/spec/unit/provider/package/puppet_gem_spec.rb +0 -0
- data/spec/unit/provider/package/rpm_spec.rb +0 -0
- data/spec/unit/provider/package/sun_spec.rb +0 -0
- data/spec/unit/provider/package/windows/package_spec.rb +0 -0
- data/spec/unit/provider/package/windows_spec.rb +0 -0
- data/spec/unit/provider/package/yum_spec.rb +0 -0
- data/spec/unit/provider/package/zypper_spec.rb +0 -0
- data/spec/unit/provider/parsedfile_spec.rb +0 -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 +0 -0
- data/spec/unit/provider/service/bsd_spec.rb +0 -0
- data/spec/unit/provider/service/daemontools_spec.rb +0 -0
- data/spec/unit/provider/service/debian_spec.rb +0 -0
- data/spec/unit/provider/service/freebsd_spec.rb +0 -0
- data/spec/unit/provider/service/gentoo_spec.rb +0 -0
- data/spec/unit/provider/service/init_spec.rb +0 -0
- data/spec/unit/provider/service/launchd_spec.rb +0 -0
- data/spec/unit/provider/service/openbsd_spec.rb +0 -0
- data/spec/unit/provider/service/openrc_spec.rb +0 -0
- data/spec/unit/provider/service/openwrt_spec.rb +0 -0
- data/spec/unit/provider/service/rcng_spec.rb +0 -0
- data/spec/unit/provider/service/redhat_spec.rb +0 -0
- data/spec/unit/provider/service/runit_spec.rb +0 -0
- data/spec/unit/provider/service/smf_spec.rb +0 -0
- data/spec/unit/provider/service/src_spec.rb +0 -0
- data/spec/unit/provider/service/systemd_spec.rb +0 -0
- data/spec/unit/provider/service/upstart_spec.rb +0 -0
- data/spec/unit/provider/service/windows_spec.rb +0 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +0 -0
- data/spec/unit/provider/sshkey/parsed_spec.rb +0 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +0 -0
- 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 +0 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +0 -0
- data/spec/unit/provider/vlan/cisco_spec.rb +0 -0
- data/spec/unit/provider/zfs/zfs_spec.rb +0 -0
- data/spec/unit/provider/zone/solaris_spec.rb +0 -0
- data/spec/unit/provider/zpool/zpool_spec.rb +0 -0
- data/spec/unit/provider_spec.rb +0 -0
- data/spec/unit/puppet_spec.rb +0 -0
- data/spec/unit/relationship_spec.rb +0 -0
- data/spec/unit/reports/http_spec.rb +0 -0
- data/spec/unit/reports/store_spec.rb +0 -0
- data/spec/unit/reports_spec.rb +0 -0
- data/spec/unit/resource/catalog_spec.rb +0 -0
- data/spec/unit/resource/status_spec.rb +0 -0
- data/spec/unit/resource/type_collection_helper_spec.rb +0 -0
- data/spec/unit/resource/type_collection_spec.rb +0 -0
- data/spec/unit/resource/type_spec.rb +0 -0
- data/spec/unit/resource_spec.rb +0 -0
- data/spec/unit/settings/directory_setting_spec.rb +0 -0
- data/spec/unit/settings/duration_setting_spec.rb +0 -0
- data/spec/unit/settings/file_setting_spec.rb +0 -0
- 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 +1 -1
- data/spec/unit/ssl/base_spec.rb +0 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +0 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +0 -0
- data/spec/unit/ssl/certificate_factory_spec.rb +0 -0
- data/spec/unit/ssl/certificate_request_spec.rb +0 -0
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +0 -0
- data/spec/unit/ssl/certificate_spec.rb +0 -0
- data/spec/unit/ssl/configuration_spec.rb +0 -0
- data/spec/unit/ssl/host_spec.rb +0 -0
- data/spec/unit/ssl/inventory_spec.rb +0 -0
- data/spec/unit/ssl/key_spec.rb +0 -0
- data/spec/unit/status_spec.rb +0 -0
- data/spec/unit/transaction/event_manager_spec.rb +0 -0
- data/spec/unit/transaction/event_spec.rb +0 -0
- data/spec/unit/transaction/report_spec.rb +0 -0
- data/spec/unit/transaction/resource_harness_spec.rb +0 -0
- data/spec/unit/transaction_spec.rb +0 -0
- data/spec/unit/type/augeas_spec.rb +0 -0
- data/spec/unit/type/component_spec.rb +0 -0
- data/spec/unit/type/computer_spec.rb +0 -0
- data/spec/unit/type/cron_spec.rb +0 -0
- data/spec/unit/type/exec_spec.rb +0 -0
- data/spec/unit/type/file/checksum_spec.rb +0 -0
- data/spec/unit/type/file/checksum_value_spec.rb +0 -0
- data/spec/unit/type/file/content_spec.rb +0 -0
- data/spec/unit/type/file/ctime_spec.rb +0 -0
- data/spec/unit/type/file/ensure_spec.rb +0 -0
- data/spec/unit/type/file/group_spec.rb +0 -0
- data/spec/unit/type/file/mode_spec.rb +0 -0
- data/spec/unit/type/file/mtime_spec.rb +0 -0
- data/spec/unit/type/file/owner_spec.rb +0 -0
- data/spec/unit/type/file/selinux_spec.rb +0 -0
- data/spec/unit/type/file/source_spec.rb +0 -0
- data/spec/unit/type/file/type_spec.rb +0 -0
- data/spec/unit/type/file_spec.rb +0 -0
- 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 +0 -0
- data/spec/unit/type/interface_spec.rb +0 -0
- data/spec/unit/type/k5login_spec.rb +0 -0
- data/spec/unit/type/macauthorization_spec.rb +0 -0
- 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 +0 -0
- 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 +0 -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 +0 -0
- data/spec/unit/type/ssh_authorized_key_spec.rb +0 -0
- data/spec/unit/type/sshkey_spec.rb +0 -0
- data/spec/unit/type/stage_spec.rb +0 -0
- data/spec/unit/type/tidy_spec.rb +0 -0
- data/spec/unit/type/user_spec.rb +0 -0
- data/spec/unit/type/vlan_spec.rb +0 -0
- data/spec/unit/type/whit_spec.rb +0 -0
- data/spec/unit/type/yumrepo_spec.rb +0 -0
- 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 +0 -0
- data/spec/unit/util/autoload_spec.rb +0 -0
- data/spec/unit/util/backups_spec.rb +0 -0
- data/spec/unit/util/checksums_spec.rb +0 -0
- data/spec/unit/util/colors_spec.rb +0 -0
- data/spec/unit/util/command_line_spec.rb +0 -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 +0 -0
- data/spec/unit/util/execution_stub_spec.rb +0 -0
- data/spec/unit/util/feature_spec.rb +0 -0
- data/spec/unit/util/filetype_spec.rb +0 -0
- data/spec/unit/util/ldap/connection_spec.rb +0 -0
- data/spec/unit/util/ldap/generator_spec.rb +0 -0
- data/spec/unit/util/ldap/manager_spec.rb +0 -0
- data/spec/unit/util/log/destinations_spec.rb +0 -0
- data/spec/unit/util/log_spec.rb +0 -0
- data/spec/unit/util/logging_spec.rb +0 -0
- data/spec/unit/util/metric_spec.rb +0 -0
- data/spec/unit/util/monkey_patches_spec.rb +19 -3
- data/spec/unit/util/nagios_maker_spec.rb +0 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +0 -0
- 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 +0 -0
- data/spec/unit/util/network_device/transport/telnet_spec.rb +0 -0
- data/spec/unit/util/package_spec.rb +0 -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 +0 -0
- data/spec/unit/util/retry_action_spec.rb +0 -0
- data/spec/unit/util/run_mode_spec.rb +0 -0
- data/spec/unit/util/selinux_spec.rb +0 -0
- data/spec/unit/util/storage_spec.rb +0 -0
- data/spec/unit/util/suidmanager_spec.rb +0 -0
- data/spec/unit/util/symbolic_file_mode_spec.rb +0 -0
- data/spec/unit/util/tagging_spec.rb +0 -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 +0 -0
- data/spec/unit/util/windows/file_spec.rb +34 -0
- data/spec/unit/util/windows/root_certs_spec.rb +0 -0
- data/spec/unit/util/windows/sid_spec.rb +0 -0
- data/spec/unit/util_spec.rb +0 -0
- data/spec/watchr.rb +0 -0
- metadata +3386 -3358
- checksums.yaml +0 -7
@@ -54,6 +54,16 @@ class RecursionGuard
|
|
54
54
|
@state
|
55
55
|
end
|
56
56
|
|
57
|
+
# @return the number of objects added to the `this` map
|
58
|
+
def this_count
|
59
|
+
this_map.size
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return the number of objects added to the `that` map
|
63
|
+
def that_count
|
64
|
+
that_map.size
|
65
|
+
end
|
66
|
+
|
57
67
|
private
|
58
68
|
|
59
69
|
def map_put(map, o)
|
@@ -30,7 +30,7 @@ module TypeAsserter
|
|
30
30
|
# @api public
|
31
31
|
def self.assert_instance_of(subject, expected_type, value, nil_ok = false, &block)
|
32
32
|
unless value.nil? && nil_ok
|
33
|
-
report_type_mismatch(subject, expected_type, TypeCalculator.singleton.infer_set(value)
|
33
|
+
report_type_mismatch(subject, expected_type, TypeCalculator.singleton.infer_set(value), &block) unless expected_type.instance?(value)
|
34
34
|
end
|
35
35
|
value
|
36
36
|
end
|
@@ -39,7 +39,7 @@ module TypeAsserter
|
|
39
39
|
subject = yield(subject) if block_given?
|
40
40
|
subject = subject[0] % subject[1..-1] if subject.is_a?(Array)
|
41
41
|
raise TypeAssertionError.new(
|
42
|
-
TypeMismatchDescriber.singleton.describe_mismatch("#{subject}
|
42
|
+
TypeMismatchDescriber.singleton.describe_mismatch("#{subject} had wrong type,", expected_type, actual_type), expected_type, actual_type)
|
43
43
|
end
|
44
44
|
private_class_method :report_type_mismatch
|
45
45
|
end
|
@@ -697,7 +697,7 @@ class TypeCalculator
|
|
697
697
|
if o.empty?
|
698
698
|
PHashType::EMPTY
|
699
699
|
elsif o.keys.all? {|k| PStringType::NON_EMPTY.instance?(k) }
|
700
|
-
PStructType.new(o.each_pair.map { |k,v| PStructElement.new(PStringType.new(
|
700
|
+
PStructType.new(o.each_pair.map { |k,v| PStructElement.new(PStringType.new(size_as_type(k), [k]), infer_set(v)) })
|
701
701
|
else
|
702
702
|
ktype = PVariantType.new(o.keys.map {|k| infer_set(k) })
|
703
703
|
etype = PVariantType.new(o.values.map {|e| infer_set(e) })
|
@@ -206,14 +206,26 @@ class TypeFormatter
|
|
206
206
|
append_array('Runtime', [string(t.runtime), string(t.runtime_type_name)])
|
207
207
|
end
|
208
208
|
|
209
|
+
def is_empty_range?(from, to)
|
210
|
+
from == 0 && to == 0
|
211
|
+
end
|
212
|
+
|
209
213
|
# @api private
|
210
214
|
def string_PArrayType(t)
|
211
|
-
|
215
|
+
if t.has_empty_range?
|
216
|
+
append_array('Array', ['0', '0'])
|
217
|
+
else
|
218
|
+
append_array('Array', t == PArrayType::DATA ? EMPTY_ARRAY : [string(t.element_type)] + range_array_part(t.size_type))
|
219
|
+
end
|
212
220
|
end
|
213
221
|
|
214
222
|
# @api private
|
215
223
|
def string_PHashType(t)
|
216
|
-
|
224
|
+
if t.has_empty_range?
|
225
|
+
append_array('Hash', ['0', '0'])
|
226
|
+
else
|
227
|
+
append_array('Hash', t == PHashType::DATA ? EMPTY_ARRAY : [string(t.key_type), string(t.element_type)] + range_array_part(t.size_type))
|
228
|
+
end
|
217
229
|
end
|
218
230
|
|
219
231
|
# @api private
|
@@ -28,13 +28,13 @@ module Types
|
|
28
28
|
|
29
29
|
class MemberPathElement < TypePathElement
|
30
30
|
def to_s
|
31
|
-
"struct member #{key}"
|
31
|
+
"struct member '#{key}'"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
class MemberKeyPathElement < TypePathElement
|
36
36
|
def to_s
|
37
|
-
"struct member key #{key}"
|
37
|
+
"struct member key '#{key}'"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -301,6 +301,22 @@ module Types
|
|
301
301
|
|
302
302
|
private
|
303
303
|
|
304
|
+
# Answers the question if `e` is a specialized type of `a`
|
305
|
+
# @param e [PAnyType] the expected type
|
306
|
+
# @param a [PAnyType] the actual type
|
307
|
+
# @return [Boolean] `true` when the _e_ is a specialization of _a_
|
308
|
+
#
|
309
|
+
def specialization(e, a)
|
310
|
+
case e
|
311
|
+
when PStructType
|
312
|
+
a.is_a?(PHashType)
|
313
|
+
when PTupleType
|
314
|
+
a.is_a?(PArrayType)
|
315
|
+
else
|
316
|
+
false
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
304
320
|
# Decides whether or not the report must be fully detailed, or if generalization can be permitted
|
305
321
|
# in the mismatch report. All comparisons are made using resolved aliases rather than the alias
|
306
322
|
# itself.
|
@@ -313,7 +329,7 @@ module Types
|
|
313
329
|
if e.is_a?(Array)
|
314
330
|
e.any? { |t| always_fully_detailed?(t, a) }
|
315
331
|
else
|
316
|
-
e.class == a.class || e.is_a?(PTypeAliasType) || a.is_a?(PTypeAliasType)
|
332
|
+
e.class == a.class || e.is_a?(PTypeAliasType) || a.is_a?(PTypeAliasType) || specialization(e, a)
|
317
333
|
end
|
318
334
|
end
|
319
335
|
|
@@ -713,15 +729,11 @@ module Types
|
|
713
729
|
h2.each_key { |key| descriptions << ExtraneousKey.new(path, key) }
|
714
730
|
elsif actual.is_a?(PHashType)
|
715
731
|
actual_size = actual.size_type || PCollectionType::DEFAULT_SIZE
|
716
|
-
expected_size = PIntegerType.new(elements.count { |e| !e.
|
732
|
+
expected_size = PIntegerType.new(elements.count { |e| !e.key_type.assignable?(PUndefType::DEFAULT) }, elements.size)
|
717
733
|
if expected_size.assignable?(actual_size)
|
718
|
-
|
719
|
-
descriptions.concat(describe(e.type, actual.element_type, path + [MemberPathElement.new(e.key)]))
|
720
|
-
else
|
721
|
-
descriptions << TypeMismatch(path, @non_empty_string_, actual.key_type)
|
722
|
-
end
|
734
|
+
descriptions << TypeMismatch.new(path, expected, actual)
|
723
735
|
else
|
724
|
-
descriptions << SizeMismatch(path, expected_size, actual_size)
|
736
|
+
descriptions << SizeMismatch.new(path, expected_size, actual_size)
|
725
737
|
end
|
726
738
|
else
|
727
739
|
descriptions << TypeMismatch.new(path, expected, actual)
|
@@ -64,7 +64,7 @@ class PAnyType < TypedModelObject
|
|
64
64
|
# @api public
|
65
65
|
def assignable?(o, guard = nil)
|
66
66
|
case o
|
67
|
-
|
67
|
+
when Class
|
68
68
|
# Safe to call _assignable directly since a Class never is a Unit or Variant
|
69
69
|
_assignable?(TypeCalculator.singleton.type(o), guard)
|
70
70
|
when PUnitType
|
@@ -177,11 +177,22 @@ class PAnyType < TypedModelObject
|
|
177
177
|
end
|
178
178
|
|
179
179
|
# Returns true if the given argument _o_ is an instance of this type
|
180
|
+
# @param guard [RecursionGuard] guard against recursion. Only used by internal calls
|
180
181
|
# @return [Boolean]
|
181
|
-
|
182
|
+
# @api public
|
183
|
+
def instance?(o, guard = nil)
|
182
184
|
true
|
183
185
|
end
|
184
186
|
|
187
|
+
# An object is considered to really be an instance of a type when something other than a
|
188
|
+
# TypeAlias or a Variant responds true to a call to {#instance?}.
|
189
|
+
#
|
190
|
+
# @return [Integer] -1 = is not instance, 0 = recursion detected, 1 = is instance
|
191
|
+
# @api private
|
192
|
+
def really_instance?(o, guard = nil)
|
193
|
+
instance?(o, guard) ? 1 : -1
|
194
|
+
end
|
195
|
+
|
185
196
|
def eql?(o)
|
186
197
|
self.class == o.class
|
187
198
|
end
|
@@ -238,7 +249,7 @@ class PAnyType < TypedModelObject
|
|
238
249
|
#
|
239
250
|
# @api private
|
240
251
|
#
|
241
|
-
def tuple_entry_at(tuple_t,
|
252
|
+
def tuple_entry_at(tuple_t, to, index)
|
242
253
|
regular = (tuple_t.types.size - 1)
|
243
254
|
if index < regular
|
244
255
|
tuple_t.types[index]
|
@@ -336,11 +347,11 @@ end
|
|
336
347
|
# @api public
|
337
348
|
#
|
338
349
|
class PType < PTypeWithContainedType
|
339
|
-
def instance?(o)
|
350
|
+
def instance?(o, guard = nil)
|
340
351
|
if o.is_a?(PAnyType)
|
341
|
-
type.nil? || type.assignable?(o)
|
352
|
+
type.nil? || type.assignable?(o, guard)
|
342
353
|
else
|
343
|
-
assignable?(TypeCalculator.infer(o))
|
354
|
+
assignable?(TypeCalculator.infer(o), guard)
|
344
355
|
end
|
345
356
|
end
|
346
357
|
|
@@ -398,8 +409,8 @@ class PNotUndefType < PTypeWithContainedType
|
|
398
409
|
super(type.class == PAnyType ? nil : type)
|
399
410
|
end
|
400
411
|
|
401
|
-
def instance?(o)
|
402
|
-
!(o.nil? || o == :undef) && (@type.nil? || @type.instance?(o))
|
412
|
+
def instance?(o, guard = nil)
|
413
|
+
!(o.nil? || o == :undef) && (@type.nil? || @type.instance?(o, guard))
|
403
414
|
end
|
404
415
|
|
405
416
|
def normalize(guard = nil)
|
@@ -409,7 +420,7 @@ class PNotUndefType < PTypeWithContainedType
|
|
409
420
|
else
|
410
421
|
if n.type.is_a?(POptionalType)
|
411
422
|
# No point in having an optional in a NotUndef
|
412
|
-
|
423
|
+
PNotUndefType.new(n.type.type).normalize
|
413
424
|
elsif !n.type.assignable?(PUndefType::DEFAULT)
|
414
425
|
# THe type is NotUndef anyway, so it can be stripped of
|
415
426
|
n.type
|
@@ -432,7 +443,7 @@ end
|
|
432
443
|
# @api public
|
433
444
|
#
|
434
445
|
class PUndefType < PAnyType
|
435
|
-
def instance?(o)
|
446
|
+
def instance?(o, guard = nil)
|
436
447
|
o.nil? || o == :undef
|
437
448
|
end
|
438
449
|
|
@@ -455,7 +466,7 @@ end
|
|
455
466
|
# @api private
|
456
467
|
#
|
457
468
|
class PUnitType < PAnyType
|
458
|
-
def instance?(o)
|
469
|
+
def instance?(o, guard = nil)
|
459
470
|
true
|
460
471
|
end
|
461
472
|
|
@@ -471,7 +482,7 @@ end
|
|
471
482
|
# @api public
|
472
483
|
#
|
473
484
|
class PDefaultType < PAnyType
|
474
|
-
def instance?(o)
|
485
|
+
def instance?(o, guard = nil)
|
475
486
|
o == :default
|
476
487
|
end
|
477
488
|
|
@@ -493,8 +504,8 @@ class PDataType < PAnyType
|
|
493
504
|
self.class == o.class || o == PVariantType::DATA
|
494
505
|
end
|
495
506
|
|
496
|
-
def instance?(o)
|
497
|
-
PVariantType::DATA.instance?(o)
|
507
|
+
def instance?(o, guard = nil)
|
508
|
+
PVariantType::DATA.instance?(o, guard)
|
498
509
|
end
|
499
510
|
|
500
511
|
DEFAULT = PDataType.new
|
@@ -521,8 +532,8 @@ end
|
|
521
532
|
#
|
522
533
|
class PScalarType < PAnyType
|
523
534
|
|
524
|
-
def instance?(o)
|
525
|
-
assignable?(TypeCalculator.infer(o))
|
535
|
+
def instance?(o, guard = nil)
|
536
|
+
assignable?(TypeCalculator.infer(o), guard)
|
526
537
|
end
|
527
538
|
|
528
539
|
DEFAULT = PScalarType.new
|
@@ -609,7 +620,7 @@ class PNumericType < PScalarType
|
|
609
620
|
# @return [Boolean] `true` if this range intersects with the other range
|
610
621
|
# @api public
|
611
622
|
def intersect?(o)
|
612
|
-
self.class == o.class && !(@to < o.
|
623
|
+
self.class == o.class && !(@to < o.numeric_from || o.numeric_to < @from)
|
613
624
|
end
|
614
625
|
|
615
626
|
# Returns the lower bound of the numeric range or `nil` if no lower bound is set.
|
@@ -644,7 +655,7 @@ class PNumericType < PScalarType
|
|
644
655
|
self.class == o.class && @from == o.numeric_from && @to == o.numeric_to
|
645
656
|
end
|
646
657
|
|
647
|
-
def instance?(o)
|
658
|
+
def instance?(o, guard = nil)
|
648
659
|
o.is_a?(Numeric) && o >= @from && o <= @to
|
649
660
|
end
|
650
661
|
|
@@ -678,7 +689,7 @@ class PIntegerType < PNumericType
|
|
678
689
|
DEFAULT
|
679
690
|
end
|
680
691
|
|
681
|
-
def instance?(o)
|
692
|
+
def instance?(o, guard = nil)
|
682
693
|
o.is_a?(Integer) && o >= numeric_from && o <= numeric_to
|
683
694
|
end
|
684
695
|
|
@@ -699,8 +710,8 @@ class PIntegerType < PNumericType
|
|
699
710
|
# @api public
|
700
711
|
def merge(o)
|
701
712
|
if intersect?(o) || adjacent?(o)
|
702
|
-
min = @from <= o.
|
703
|
-
max = @to >= o.
|
713
|
+
min = @from <= o.numeric_from ? @from : o.numeric_from
|
714
|
+
max = @to >= o.numeric_to ? @to : o.numeric_to
|
704
715
|
PIntegerType.new(min, max)
|
705
716
|
else
|
706
717
|
nil
|
@@ -752,7 +763,7 @@ class PFloatType < PNumericType
|
|
752
763
|
DEFAULT
|
753
764
|
end
|
754
765
|
|
755
|
-
def instance?(o)
|
766
|
+
def instance?(o, guard = nil)
|
756
767
|
o.is_a?(Float) && o >= numeric_from && o <= numeric_to
|
757
768
|
end
|
758
769
|
|
@@ -783,6 +794,9 @@ class PCollectionType < PAnyType
|
|
783
794
|
def initialize(element_type, size_type = nil)
|
784
795
|
@element_type = element_type
|
785
796
|
@size_type = size_type
|
797
|
+
if has_empty_range? && !@element_type.is_a?(PUnitType)
|
798
|
+
raise ArgumentError, 'An empty collection may not specify an element type'
|
799
|
+
end
|
786
800
|
end
|
787
801
|
|
788
802
|
def accept(visitor, guard)
|
@@ -809,8 +823,8 @@ class PCollectionType < PAnyType
|
|
809
823
|
end
|
810
824
|
end
|
811
825
|
|
812
|
-
def instance?(o)
|
813
|
-
assignable?(TypeCalculator.infer(o))
|
826
|
+
def instance?(o, guard = nil)
|
827
|
+
assignable?(TypeCalculator.infer(o), guard)
|
814
828
|
end
|
815
829
|
|
816
830
|
# Returns an array with from (min) size to (max) size
|
@@ -818,6 +832,11 @@ class PCollectionType < PAnyType
|
|
818
832
|
(@size_type || DEFAULT_SIZE).range
|
819
833
|
end
|
820
834
|
|
835
|
+
def has_empty_range?
|
836
|
+
from, to = size_range
|
837
|
+
from == 0 && to == 0
|
838
|
+
end
|
839
|
+
|
821
840
|
def hash
|
822
841
|
@element_type.hash ^ @size_type.hash
|
823
842
|
end
|
@@ -867,8 +886,8 @@ class PIterableType < PTypeWithContainedType
|
|
867
886
|
@type
|
868
887
|
end
|
869
888
|
|
870
|
-
def instance?(o)
|
871
|
-
if @type.nil? || @type.assignable?(PAnyType::DEFAULT)
|
889
|
+
def instance?(o, guard = nil)
|
890
|
+
if @type.nil? || @type.assignable?(PAnyType::DEFAULT, guard)
|
872
891
|
# Any element_type will do
|
873
892
|
case o
|
874
893
|
when Iterable, String, Hash, Array, Range, PEnumType
|
@@ -881,7 +900,7 @@ class PIterableType < PTypeWithContainedType
|
|
881
900
|
false
|
882
901
|
end
|
883
902
|
else
|
884
|
-
assignable?(TypeCalculator.infer(o))
|
903
|
+
assignable?(TypeCalculator.infer(o), guard)
|
885
904
|
end
|
886
905
|
end
|
887
906
|
|
@@ -916,8 +935,8 @@ class PIteratorType < PTypeWithContainedType
|
|
916
935
|
@type
|
917
936
|
end
|
918
937
|
|
919
|
-
def instance?(o)
|
920
|
-
o.is_a?(Iterable) && (@
|
938
|
+
def instance?(o, guard = nil)
|
939
|
+
o.is_a?(Iterable) && (@type.nil? || @type.assignable?(o.element_type, guard))
|
921
940
|
end
|
922
941
|
|
923
942
|
def iterable?(guard = nil)
|
@@ -925,7 +944,7 @@ class PIteratorType < PTypeWithContainedType
|
|
925
944
|
end
|
926
945
|
|
927
946
|
def iterable_type(guard = nil)
|
928
|
-
@type.nil? ?
|
947
|
+
@type.nil? ? PIterableType::DEFAULT : PIterableType.new(@type)
|
929
948
|
end
|
930
949
|
|
931
950
|
DEFAULT = PIteratorType.new(nil)
|
@@ -934,7 +953,7 @@ class PIteratorType < PTypeWithContainedType
|
|
934
953
|
|
935
954
|
# @api private
|
936
955
|
def _assignable?(o, guard)
|
937
|
-
o.is_a?(PIteratorType) && (@
|
956
|
+
o.is_a?(PIteratorType) && (@type.nil? || @type.assignable?(o.element_type, guard))
|
938
957
|
end
|
939
958
|
end
|
940
959
|
|
@@ -973,9 +992,9 @@ class PStringType < PScalarType
|
|
973
992
|
self.class == o.class && @size_type == o.size_type && @values == o.values
|
974
993
|
end
|
975
994
|
|
976
|
-
def instance?(o)
|
995
|
+
def instance?(o, guard = nil)
|
977
996
|
# true if size compliant
|
978
|
-
if o.is_a?(String) && (@size_type.nil? || @size_type.instance?(o.size))
|
997
|
+
if o.is_a?(String) && (@size_type.nil? || @size_type.instance?(o.size, guard))
|
979
998
|
@values.empty? || @values.include?(o)
|
980
999
|
else
|
981
1000
|
false
|
@@ -1123,7 +1142,7 @@ end
|
|
1123
1142
|
#
|
1124
1143
|
class PBooleanType < PScalarType
|
1125
1144
|
|
1126
|
-
def instance?(o)
|
1145
|
+
def instance?(o, guard = nil)
|
1127
1146
|
o == true || o == false
|
1128
1147
|
end
|
1129
1148
|
|
@@ -1180,7 +1199,11 @@ class PStructElement < TypedModelObject
|
|
1180
1199
|
end
|
1181
1200
|
|
1182
1201
|
def eql?(o)
|
1183
|
-
|
1202
|
+
self == o
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
def ==(o)
|
1206
|
+
self.class == o.class && value_type == o.value_type && key_type == o.key_type
|
1184
1207
|
end
|
1185
1208
|
end
|
1186
1209
|
|
@@ -1255,7 +1278,7 @@ class PStructType < PAnyType
|
|
1255
1278
|
@elements
|
1256
1279
|
end
|
1257
1280
|
|
1258
|
-
def instance?(o)
|
1281
|
+
def instance?(o, guard = nil)
|
1259
1282
|
return false unless o.is_a?(Hash)
|
1260
1283
|
matched = 0
|
1261
1284
|
@elements.all? do |e|
|
@@ -1263,10 +1286,10 @@ class PStructType < PAnyType
|
|
1263
1286
|
v = o[key]
|
1264
1287
|
if v.nil? && !o.include?(key)
|
1265
1288
|
# Entry is missing. Only OK when key is optional
|
1266
|
-
e.key_type.assignable?(PUndefType::DEFAULT)
|
1289
|
+
e.key_type.assignable?(PUndefType::DEFAULT, guard)
|
1267
1290
|
else
|
1268
1291
|
matched += 1
|
1269
|
-
e.value_type.instance?(v)
|
1292
|
+
e.value_type.instance?(v, guard)
|
1270
1293
|
end
|
1271
1294
|
end && matched == o.size
|
1272
1295
|
end
|
@@ -1292,16 +1315,26 @@ class PStructType < PAnyType
|
|
1292
1315
|
elsif o.is_a?(Types::PHashType)
|
1293
1316
|
required = 0
|
1294
1317
|
required_elements_assignable = elements.all? do |e|
|
1295
|
-
|
1318
|
+
key_type = e.key_type
|
1319
|
+
if key_type.assignable?(PUndefType::DEFAULT)
|
1320
|
+
# Element is optional so Hash does not need to provide it
|
1296
1321
|
true
|
1297
1322
|
else
|
1298
1323
|
required += 1
|
1299
|
-
e.value_type.assignable?(o.element_type, guard)
|
1324
|
+
if e.value_type.assignable?(o.element_type, guard)
|
1325
|
+
# Hash must have something that is assignable. We don't care about the name or size of the key though
|
1326
|
+
# because we have no instance of a hash to compare against.
|
1327
|
+
key_type.generalize.assignable?(o.key_type)
|
1328
|
+
else
|
1329
|
+
false
|
1330
|
+
end
|
1300
1331
|
end
|
1301
1332
|
end
|
1302
1333
|
if required_elements_assignable
|
1303
|
-
size_o = o.size_type ||
|
1334
|
+
size_o = o.size_type || PCollectionType::DEFAULT_SIZE
|
1304
1335
|
PIntegerType.new(required, elements.size).assignable?(size_o, guard)
|
1336
|
+
else
|
1337
|
+
false
|
1305
1338
|
end
|
1306
1339
|
else
|
1307
1340
|
false
|
@@ -1391,14 +1424,14 @@ class PTupleType < PAnyType
|
|
1391
1424
|
end
|
1392
1425
|
end
|
1393
1426
|
|
1394
|
-
def instance?(o)
|
1427
|
+
def instance?(o, guard = nil)
|
1395
1428
|
return false unless o.is_a?(Array)
|
1396
1429
|
# compute the tuple's min/max size, and check if that size matches
|
1397
1430
|
size_t = size_type || PIntegerType.new(*size_range)
|
1398
1431
|
|
1399
|
-
return false unless size_t.instance?(o.size)
|
1432
|
+
return false unless size_t.instance?(o.size, guard)
|
1400
1433
|
o.each_with_index do |element, index|
|
1401
|
-
return false unless (types[index] || types[-1]).instance?(element)
|
1434
|
+
return false unless (types[index] || types[-1]).instance?(element, guard)
|
1402
1435
|
end
|
1403
1436
|
true
|
1404
1437
|
end
|
@@ -1415,7 +1448,7 @@ class PTupleType < PAnyType
|
|
1415
1448
|
def size_range
|
1416
1449
|
if @size_type.nil?
|
1417
1450
|
types_size = @types.size
|
1418
|
-
[types_size, types_size]
|
1451
|
+
types_size == 0 ? [0, Float::INFINITY] : [types_size, types_size]
|
1419
1452
|
else
|
1420
1453
|
@size_type.range
|
1421
1454
|
end
|
@@ -1452,36 +1485,33 @@ class PTupleType < PAnyType
|
|
1452
1485
|
# @api private
|
1453
1486
|
def _assignable?(o, guard)
|
1454
1487
|
return true if self == o
|
1488
|
+
return false unless o.is_a?(PTupleType) || o.is_a?(PArrayType)
|
1455
1489
|
s_types = types
|
1456
|
-
return true if s_types.empty? && (o.is_a?(PArrayType))
|
1457
1490
|
size_s = size_type || PIntegerType.new(*size_range)
|
1458
1491
|
|
1459
1492
|
if o.is_a?(PTupleType)
|
1460
1493
|
size_o = o.size_type || PIntegerType.new(*o.size_range)
|
1461
|
-
|
1462
|
-
|
1463
|
-
if size_s.assignable?(size_o, guard)
|
1494
|
+
return false unless size_s.assignable?(size_o, guard)
|
1495
|
+
unless s_types.empty?
|
1464
1496
|
o_types = o.types
|
1497
|
+
return false if o_types.empty?
|
1465
1498
|
o_types.size.times do |index|
|
1466
1499
|
return false unless (s_types[index] || s_types[-1]).assignable?(o_types[index], guard)
|
1467
1500
|
end
|
1468
|
-
return true
|
1469
|
-
else
|
1470
|
-
return false
|
1471
1501
|
end
|
1472
|
-
|
1473
|
-
o_entry = o.element_type
|
1474
|
-
# Array of anything can not be assigned (unless tuple is tuple of anything) - this case
|
1475
|
-
# was handled at the top of this method.
|
1476
|
-
#
|
1477
|
-
return false if o_entry.nil?
|
1502
|
+
else
|
1478
1503
|
size_o = o.size_type || PCollectionType::DEFAULT_SIZE
|
1479
1504
|
return false unless size_s.assignable?(size_o, guard)
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1505
|
+
unless s_types.empty?
|
1506
|
+
o_entry = o.element_type
|
1507
|
+
# Array of anything can not be assigned (unless tuple is tuple of anything) - this case
|
1508
|
+
# was handled at the top of this method.
|
1509
|
+
#
|
1510
|
+
return false if o_entry.nil?
|
1511
|
+
[s_types.size, size_o.range[1]].min.times { |index| return false unless (s_types[index] || s_types[-1]).assignable?(o_entry, guard) }
|
1512
|
+
end
|
1484
1513
|
end
|
1514
|
+
true
|
1485
1515
|
end
|
1486
1516
|
end
|
1487
1517
|
|
@@ -1531,8 +1561,8 @@ class PCallableType < PAnyType
|
|
1531
1561
|
end
|
1532
1562
|
end
|
1533
1563
|
|
1534
|
-
def instance?(o)
|
1535
|
-
assignable?(TypeCalculator.infer(o))
|
1564
|
+
def instance?(o, guard = nil)
|
1565
|
+
assignable?(TypeCalculator.infer(o), guard)
|
1536
1566
|
end
|
1537
1567
|
|
1538
1568
|
# @api private
|
@@ -1589,7 +1619,9 @@ class PCallableType < PAnyType
|
|
1589
1619
|
|
1590
1620
|
# NOTE: these tests are made in reverse as it is calling the callable that is constrained
|
1591
1621
|
# (it's lower bound), not its upper bound
|
1592
|
-
|
1622
|
+
other_param_types = o.param_types
|
1623
|
+
|
1624
|
+
return false if other_param_types.nil? || !other_param_types.assignable?(@param_types, guard)
|
1593
1625
|
# names are ignored, they are just information
|
1594
1626
|
# Blocks must be compatible
|
1595
1627
|
this_block_t = @block_type || PUndefType::DEFAULT
|
@@ -1626,12 +1658,12 @@ class PArrayType < PCollectionType
|
|
1626
1658
|
end
|
1627
1659
|
end
|
1628
1660
|
|
1629
|
-
def instance?(o)
|
1661
|
+
def instance?(o, guard = nil)
|
1630
1662
|
return false unless o.is_a?(Array)
|
1631
1663
|
element_t = element_type
|
1632
|
-
return false unless element_t.nil? || o.all? {|element| element_t.instance?(element) }
|
1664
|
+
return false unless element_t.nil? || o.all? {|element| element_t.instance?(element, guard) }
|
1633
1665
|
size_t = size_type
|
1634
|
-
size_t.nil? || size_t.instance?(o.size)
|
1666
|
+
size_t.nil? || size_t.instance?(o.size, guard)
|
1635
1667
|
end
|
1636
1668
|
|
1637
1669
|
DATA = PArrayType.new(PDataType::DEFAULT, DEFAULT_SIZE)
|
@@ -1664,7 +1696,7 @@ class PArrayType < PCollectionType
|
|
1664
1696
|
return false if o_regular.size + o_to > max
|
1665
1697
|
# each tuple type must be assignable to the element type
|
1666
1698
|
o_required.times do |index|
|
1667
|
-
o_entry = tuple_entry_at(o,
|
1699
|
+
o_entry = tuple_entry_at(o, o_to, index)
|
1668
1700
|
return false unless s_entry.assignable?(o_entry, guard)
|
1669
1701
|
end
|
1670
1702
|
# ... and so must the last, possibly optional (ranged) type
|
@@ -1685,6 +1717,9 @@ class PHashType < PCollectionType
|
|
1685
1717
|
def initialize(key_type, value_type, size_type = nil)
|
1686
1718
|
super(value_type, size_type)
|
1687
1719
|
@key_type = key_type
|
1720
|
+
if has_empty_range? && !@key_type.is_a?(PUnitType)
|
1721
|
+
raise ArgumentError, 'An empty hash may not specify a key type'
|
1722
|
+
end
|
1688
1723
|
end
|
1689
1724
|
|
1690
1725
|
def accept(visitor, guard)
|
@@ -1720,14 +1755,14 @@ class PHashType < PCollectionType
|
|
1720
1755
|
super ^ @key_type.hash
|
1721
1756
|
end
|
1722
1757
|
|
1723
|
-
def instance?(o)
|
1758
|
+
def instance?(o, guard = nil)
|
1724
1759
|
return false unless o.is_a?(Hash)
|
1725
1760
|
key_t = key_type
|
1726
1761
|
element_t = element_type
|
1727
|
-
if (key_t.nil? || o.keys.all? {|key| key_t.instance?(key) }) &&
|
1728
|
-
(element_t.nil? || o.values.all? {|value| element_t.instance?(value) })
|
1762
|
+
if (key_t.nil? || o.keys.all? {|key| key_t.instance?(key, guard) }) &&
|
1763
|
+
(element_t.nil? || o.values.all? {|value| element_t.instance?(value, guard) })
|
1729
1764
|
size_t = size_type
|
1730
|
-
size_t.nil? || size_t.instance?(o.size)
|
1765
|
+
size_t.nil? || size_t.instance?(o.size, guard)
|
1731
1766
|
else
|
1732
1767
|
false
|
1733
1768
|
end
|
@@ -1775,8 +1810,8 @@ class PHashType < PCollectionType
|
|
1775
1810
|
# hash must accept all value types
|
1776
1811
|
# hash must accept the size of the struct
|
1777
1812
|
o_elements = o.elements
|
1778
|
-
(size_type || DEFAULT_SIZE).instance?(o_elements.size) &&
|
1779
|
-
o_elements.all? {|e| (key_type.nil? || key_type.instance?(e.name)) && (element_type.nil? || element_type.assignable?(e.value_type, guard)) }
|
1813
|
+
(size_type || DEFAULT_SIZE).instance?(o_elements.size, guard) &&
|
1814
|
+
o_elements.all? {|e| (key_type.nil? || key_type.instance?(e.name, guard)) && (element_type.nil? || element_type.assignable?(e.value_type, guard)) }
|
1780
1815
|
else
|
1781
1816
|
false
|
1782
1817
|
end
|
@@ -1813,7 +1848,7 @@ class PVariantType < PAnyType
|
|
1813
1848
|
if self == DEFAULT || self == DATA
|
1814
1849
|
self
|
1815
1850
|
else
|
1816
|
-
alter_type_array(@types, :generalize) { |altered| PVariantType.new(
|
1851
|
+
alter_type_array(@types, :generalize) { |altered| PVariantType.new(altered) }
|
1817
1852
|
end
|
1818
1853
|
end
|
1819
1854
|
|
@@ -1868,9 +1903,17 @@ class PVariantType < PAnyType
|
|
1868
1903
|
@types.hash
|
1869
1904
|
end
|
1870
1905
|
|
1871
|
-
def instance?(o)
|
1906
|
+
def instance?(o, guard = nil)
|
1872
1907
|
# instance of variant if o is instance? of any of variant's types
|
1873
|
-
@types.any? { |type| type.instance?(o) }
|
1908
|
+
@types.any? { |type| type.instance?(o, guard) }
|
1909
|
+
end
|
1910
|
+
|
1911
|
+
def really_instance?(o, guard = nil)
|
1912
|
+
@types.inject(-1) do |memo, type|
|
1913
|
+
ri = type.really_instance?(o, guard)
|
1914
|
+
memo = ri if ri > memo
|
1915
|
+
memo
|
1916
|
+
end
|
1874
1917
|
end
|
1875
1918
|
|
1876
1919
|
def kind_of_callable?(optional = true, guard = nil)
|
@@ -1993,7 +2036,7 @@ class PVariantType < PAnyType
|
|
1993
2036
|
# @api private
|
1994
2037
|
def merge_ranges(ranges)
|
1995
2038
|
result = []
|
1996
|
-
|
2039
|
+
until ranges.empty?
|
1997
2040
|
unmerged = []
|
1998
2041
|
x = ranges.pop
|
1999
2042
|
result << ranges.inject(x) do |memo, y|
|
@@ -2029,8 +2072,8 @@ class PRuntimeType < PAnyType
|
|
2029
2072
|
self.class == o.class && @runtime == o.runtime && @runtime_type_name == o.runtime_type_name
|
2030
2073
|
end
|
2031
2074
|
|
2032
|
-
def instance?(o)
|
2033
|
-
assignable?(TypeCalculator.infer(o))
|
2075
|
+
def instance?(o, guard = nil)
|
2076
|
+
assignable?(TypeCalculator.infer(o), guard)
|
2034
2077
|
end
|
2035
2078
|
|
2036
2079
|
def iterable?(guard = nil)
|
@@ -2070,8 +2113,8 @@ class PCatalogEntryType < PAnyType
|
|
2070
2113
|
|
2071
2114
|
DEFAULT = PCatalogEntryType.new
|
2072
2115
|
|
2073
|
-
def instance?(o)
|
2074
|
-
assignable?(TypeCalculator.infer(o))
|
2116
|
+
def instance?(o, guard = nil)
|
2117
|
+
assignable?(TypeCalculator.infer(o), guard)
|
2075
2118
|
end
|
2076
2119
|
|
2077
2120
|
protected
|
@@ -2158,8 +2201,8 @@ class POptionalType < PTypeWithContainedType
|
|
2158
2201
|
optional && !@type.nil? && @type.kind_of_callable?(optional, guard)
|
2159
2202
|
end
|
2160
2203
|
|
2161
|
-
def instance?(o)
|
2162
|
-
PUndefType::DEFAULT.instance?(o) || (!@type.nil? && @type.instance?(o))
|
2204
|
+
def instance?(o, guard = nil)
|
2205
|
+
PUndefType::DEFAULT.instance?(o, guard) || (!@type.nil? && @type.instance?(o, guard))
|
2163
2206
|
end
|
2164
2207
|
|
2165
2208
|
def normalize(guard = nil)
|
@@ -2207,7 +2250,7 @@ class PTypeReferenceType < PAnyType
|
|
2207
2250
|
false
|
2208
2251
|
end
|
2209
2252
|
|
2210
|
-
def instance?(o)
|
2253
|
+
def instance?(o, guard = nil)
|
2211
2254
|
false
|
2212
2255
|
end
|
2213
2256
|
|
@@ -2248,6 +2291,14 @@ class PTypeAliasType < PAnyType
|
|
2248
2291
|
@self_recursion = false
|
2249
2292
|
end
|
2250
2293
|
|
2294
|
+
def assignable?(o, guard = nil)
|
2295
|
+
if @self_recursion
|
2296
|
+
guard ||= RecursionGuard.new
|
2297
|
+
return true if guard.add_this(self) == RecursionGuard::SELF_RECURSION_IN_BOTH
|
2298
|
+
end
|
2299
|
+
super(o, guard)
|
2300
|
+
end
|
2301
|
+
|
2251
2302
|
# Returns the resolved type. The type must have been resolved by a call prior to calls to this
|
2252
2303
|
# method or an error will be raised.
|
2253
2304
|
#
|
@@ -2266,9 +2317,8 @@ class PTypeAliasType < PAnyType
|
|
2266
2317
|
guarded_recursion(guard, false) { |g| resolved_type.kind_of_callable?(optional, g) }
|
2267
2318
|
end
|
2268
2319
|
|
2269
|
-
def instance?(o)
|
2270
|
-
|
2271
|
-
resolved_type.instance?(o)
|
2320
|
+
def instance?(o, guard = nil)
|
2321
|
+
really_instance?(o, guard) == 1
|
2272
2322
|
end
|
2273
2323
|
|
2274
2324
|
def iterable?(guard = nil)
|
@@ -2283,6 +2333,44 @@ class PTypeAliasType < PAnyType
|
|
2283
2333
|
@name.hash
|
2284
2334
|
end
|
2285
2335
|
|
2336
|
+
# Acceptor used when checking for self recursion and that a type contains
|
2337
|
+
# something other than aliases or type references
|
2338
|
+
#
|
2339
|
+
# @api private
|
2340
|
+
class AssertOtherTypeAcceptor
|
2341
|
+
def initialize
|
2342
|
+
@other_type_detected = false
|
2343
|
+
end
|
2344
|
+
|
2345
|
+
def visit(type, _)
|
2346
|
+
unless type.is_a?(PTypeAliasType) || type.is_a?(PVariantType) || type.is_a?(PTypeReferenceType)
|
2347
|
+
@other_type_detected = true
|
2348
|
+
end
|
2349
|
+
end
|
2350
|
+
|
2351
|
+
def other_type_detected?
|
2352
|
+
@other_type_detected
|
2353
|
+
end
|
2354
|
+
end
|
2355
|
+
|
2356
|
+
# Acceptor used when re-checking for self recursion after a self recursion has been detected
|
2357
|
+
#
|
2358
|
+
# @api private
|
2359
|
+
class AssertSelfRecursionStatusAcceptor
|
2360
|
+
def visit(type, _)
|
2361
|
+
type.set_self_recursion_status if type.is_a?(PTypeAliasType)
|
2362
|
+
end
|
2363
|
+
end
|
2364
|
+
|
2365
|
+
def set_self_recursion_status
|
2366
|
+
return if @self_recursion || @resolved_type.is_a?(PTypeReferenceType)
|
2367
|
+
@self_recursion = true
|
2368
|
+
guard = RecursionGuard.new
|
2369
|
+
accept(NoopTypeAcceptor::INSTANCE, guard)
|
2370
|
+
@self_recursion = guard.recursive_this?(self)
|
2371
|
+
when_self_recursion_detected if @self_recursion # no difference
|
2372
|
+
end
|
2373
|
+
|
2286
2374
|
# Called from the TypeParser once it has found a type using the Loader. The TypeParser will
|
2287
2375
|
# interpret the contained expression and the resolved type is remembered. This method also
|
2288
2376
|
# checks and remembers if the resolve type contains self recursion.
|
@@ -2303,8 +2391,17 @@ class PTypeAliasType < PAnyType
|
|
2303
2391
|
# on several methods and this knowledge is used to avoid that for non-recursive
|
2304
2392
|
# types.
|
2305
2393
|
guard = RecursionGuard.new
|
2306
|
-
|
2394
|
+
real_type_asserter = AssertOtherTypeAcceptor.new
|
2395
|
+
accept(real_type_asserter, guard)
|
2396
|
+
unless real_type_asserter.other_type_detected?
|
2397
|
+
raise ArgumentError, "Type alias '#{name}' cannot be resolved to a real type"
|
2398
|
+
end
|
2307
2399
|
@self_recursion = guard.recursive_this?(self)
|
2400
|
+
# All aliases involved must re-check status since this alias is now resolved
|
2401
|
+
if @self_recursion
|
2402
|
+
accept(AssertSelfRecursionStatusAcceptor.new, RecursionGuard.new)
|
2403
|
+
when_self_recursion_detected
|
2404
|
+
end
|
2308
2405
|
rescue
|
2309
2406
|
@resolved_type = nil
|
2310
2407
|
raise
|
@@ -2328,17 +2425,38 @@ class PTypeAliasType < PAnyType
|
|
2328
2425
|
@self_recursion
|
2329
2426
|
end
|
2330
2427
|
|
2428
|
+
# Returns the expanded string the form of the alias, e.g. <alias name> = <resolved type>
|
2429
|
+
#
|
2430
|
+
# @return [String] the expanded form of this alias
|
2431
|
+
# @api public
|
2432
|
+
def to_s
|
2433
|
+
TypeFormatter.singleton.alias_expanded_string(self)
|
2434
|
+
end
|
2435
|
+
|
2436
|
+
# Delegates to resolved type
|
2437
|
+
def respond_to_missing?(name, include_private)
|
2438
|
+
resolved_type.respond_to?(name, include_private)
|
2439
|
+
end
|
2440
|
+
|
2441
|
+
# Delegates to resolved type
|
2442
|
+
def method_missing(name, *arguments, &block)
|
2443
|
+
resolved_type.send(name, *arguments, &block)
|
2444
|
+
end
|
2445
|
+
|
2446
|
+
# @api private
|
2447
|
+
def really_instance?(o, guard = nil)
|
2448
|
+
if @self_recursion
|
2449
|
+
guard ||= RecursionGuard.new
|
2450
|
+
guard.add_that(o)
|
2451
|
+
return 0 if guard.add_this(self) == RecursionGuard::SELF_RECURSION_IN_BOTH
|
2452
|
+
end
|
2453
|
+
resolved_type.really_instance?(o, guard)
|
2454
|
+
end
|
2455
|
+
|
2331
2456
|
protected
|
2332
2457
|
|
2333
2458
|
def _assignable?(o, guard)
|
2334
|
-
guard
|
2335
|
-
if guard.add_this(self) == RecursionGuard::SELF_RECURSION_IN_BOTH
|
2336
|
-
# Recursion detected both in self and other. This means that other is assignable
|
2337
|
-
# to self. This point would not have been reached otherwise
|
2338
|
-
true
|
2339
|
-
else
|
2340
|
-
resolved_type.assignable?(o, guard)
|
2341
|
-
end
|
2459
|
+
resolved_type.assignable?(o, guard)
|
2342
2460
|
end
|
2343
2461
|
|
2344
2462
|
private
|
@@ -2352,6 +2470,30 @@ class PTypeAliasType < PAnyType
|
|
2352
2470
|
end
|
2353
2471
|
end
|
2354
2472
|
|
2473
|
+
def when_self_recursion_detected
|
2474
|
+
if @resolved_type.is_a?(PVariantType)
|
2475
|
+
# Drop variants that are not real types
|
2476
|
+
resolved_types = @resolved_type.types
|
2477
|
+
real_types = resolved_types.select do |type|
|
2478
|
+
next false if type == self
|
2479
|
+
real_type_asserter = AssertOtherTypeAcceptor.new
|
2480
|
+
accept(real_type_asserter, RecursionGuard.new)
|
2481
|
+
real_type_asserter.other_type_detected?
|
2482
|
+
end
|
2483
|
+
if real_types.size != resolved_types.size
|
2484
|
+
if real_types.size == 1
|
2485
|
+
@resolved_type = real_types[0]
|
2486
|
+
else
|
2487
|
+
@resolved_type = PVariantType.new(real_types)
|
2488
|
+
end
|
2489
|
+
# Drop self recursion status in case it's not self recursive anymore
|
2490
|
+
guard = RecursionGuard.new
|
2491
|
+
accept(NoopTypeAcceptor::INSTANCE, guard)
|
2492
|
+
@self_recursion = guard.recursive_this?(self)
|
2493
|
+
end
|
2494
|
+
end
|
2495
|
+
end
|
2496
|
+
|
2355
2497
|
DEFAULT = PTypeAliasType.new('UnresolvedAlias', nil, PTypeReferenceType::DEFAULT)
|
2356
2498
|
end
|
2357
2499
|
end
|