puppet 4.1.0 → 4.10.0

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