puppet 4.7.1-x64-mingw32 → 4.8.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (276) hide show
  1. data/Gemfile +0 -3
  2. data/MAINTAINERS +76 -0
  3. data/README.md +0 -6
  4. data/Rakefile +2 -2
  5. data/lib/puppet/agent.rb +3 -3
  6. data/lib/puppet/application/apply.rb +1 -1
  7. data/lib/puppet/configurer.rb +2 -2
  8. data/lib/puppet/data_providers.rb +1 -0
  9. data/lib/puppet/data_providers/data_adapter.rb +1 -0
  10. data/lib/puppet/data_providers/data_function_support.rb +1 -0
  11. data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
  12. data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
  13. data/lib/puppet/data_providers/hiera_config.rb +1 -0
  14. data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
  15. data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
  16. data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
  17. data/lib/puppet/data_providers/hiera_support.rb +1 -2
  18. data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
  19. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
  20. data/lib/puppet/defaults.rb +20 -1
  21. data/lib/puppet/environments.rb +5 -2
  22. data/lib/puppet/face/catalog.rb +1 -1
  23. data/lib/puppet/face/epp.rb +57 -11
  24. data/lib/puppet/face/module/install.rb +6 -6
  25. data/lib/puppet/functions.rb +23 -24
  26. data/lib/puppet/functions/alert.rb +14 -0
  27. data/lib/puppet/functions/binary_file.rb +25 -0
  28. data/lib/puppet/functions/break.rb +22 -0
  29. data/lib/puppet/functions/contain.rb +33 -0
  30. data/lib/puppet/functions/crit.rb +14 -0
  31. data/lib/puppet/functions/debug.rb +14 -0
  32. data/lib/puppet/functions/emerg.rb +14 -0
  33. data/lib/puppet/functions/epp.rb +1 -1
  34. data/lib/puppet/functions/err.rb +14 -0
  35. data/lib/puppet/functions/find_file.rb +31 -0
  36. data/lib/puppet/functions/include.rb +21 -0
  37. data/lib/puppet/functions/info.rb +14 -0
  38. data/lib/puppet/functions/new.rb +1 -1
  39. data/lib/puppet/functions/next.rb +23 -0
  40. data/lib/puppet/functions/notice.rb +14 -0
  41. data/lib/puppet/functions/regsubst.rb +12 -16
  42. data/lib/puppet/functions/require.rb +37 -0
  43. data/lib/puppet/functions/return.rb +22 -0
  44. data/lib/puppet/functions/strftime.rb +35 -0
  45. data/lib/puppet/functions/warning.rb +14 -0
  46. data/lib/puppet/generate/models/type/type.rb +4 -0
  47. data/lib/puppet/generate/templates/type/pcore.erb +2 -1
  48. data/lib/puppet/indirector/face.rb +6 -1
  49. data/lib/puppet/network/http/error.rb +2 -2
  50. data/lib/puppet/network/http/handler.rb +2 -2
  51. data/lib/puppet/node/environment.rb +11 -0
  52. data/lib/puppet/parser/ast.rb +5 -0
  53. data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
  54. data/lib/puppet/parser/compiler.rb +29 -1
  55. data/lib/puppet/parser/functions.rb +6 -0
  56. data/lib/puppet/parser/functions/assert_type.rb +1 -1
  57. data/lib/puppet/parser/functions/binary_file.rb +24 -0
  58. data/lib/puppet/parser/functions/break.rb +39 -0
  59. data/lib/puppet/parser/functions/contain.rb +7 -15
  60. data/lib/puppet/parser/functions/defined.rb +2 -2
  61. data/lib/puppet/parser/functions/dig.rb +1 -1
  62. data/lib/puppet/parser/functions/each.rb +1 -1
  63. data/lib/puppet/parser/functions/epp.rb +2 -2
  64. data/lib/puppet/parser/functions/filter.rb +1 -1
  65. data/lib/puppet/parser/functions/find_file.rb +28 -0
  66. data/lib/puppet/parser/functions/hiera.rb +4 -4
  67. data/lib/puppet/parser/functions/hiera_array.rb +1 -1
  68. data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
  69. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  70. data/lib/puppet/parser/functions/include.rb +4 -8
  71. data/lib/puppet/parser/functions/inline_epp.rb +1 -1
  72. data/lib/puppet/parser/functions/lest.rb +1 -1
  73. data/lib/puppet/parser/functions/lookup.rb +4 -2
  74. data/lib/puppet/parser/functions/map.rb +1 -1
  75. data/lib/puppet/parser/functions/match.rb +1 -1
  76. data/lib/puppet/parser/functions/new.rb +414 -18
  77. data/lib/puppet/parser/functions/next.rb +38 -0
  78. data/lib/puppet/parser/functions/reduce.rb +1 -1
  79. data/lib/puppet/parser/functions/regsubst.rb +4 -2
  80. data/lib/puppet/parser/functions/require.rb +4 -27
  81. data/lib/puppet/parser/functions/return.rb +71 -0
  82. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  83. data/lib/puppet/parser/functions/scanf.rb +13 -8
  84. data/lib/puppet/parser/functions/slice.rb +1 -1
  85. data/lib/puppet/parser/functions/split.rb +1 -1
  86. data/lib/puppet/parser/functions/step.rb +1 -1
  87. data/lib/puppet/parser/functions/strftime.rb +185 -0
  88. data/lib/puppet/parser/functions/then.rb +1 -1
  89. data/lib/puppet/parser/functions/type.rb +1 -1
  90. data/lib/puppet/parser/functions/with.rb +3 -3
  91. data/lib/puppet/parser/resource.rb +8 -5
  92. data/lib/puppet/parser/scope.rb +1 -1
  93. data/lib/puppet/plugins/configuration.rb +8 -0
  94. data/lib/puppet/plugins/data_providers.rb +1 -0
  95. data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
  96. data/lib/puppet/plugins/data_providers/registry.rb +1 -0
  97. data/lib/puppet/pops.rb +4 -0
  98. data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
  99. data/lib/puppet/pops/evaluator/closure.rb +81 -12
  100. data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
  101. data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
  102. data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
  103. data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
  104. data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
  105. data/lib/puppet/pops/functions/dispatch.rb +9 -2
  106. data/lib/puppet/pops/functions/dispatcher.rb +3 -1
  107. data/lib/puppet/pops/functions/function.rb +19 -2
  108. data/lib/puppet/pops/issues.rb +9 -0
  109. data/lib/puppet/pops/label_provider.rb +2 -2
  110. data/lib/puppet/pops/loader/loader.rb +17 -0
  111. data/lib/puppet/pops/loader/static_loader.rb +0 -41
  112. data/lib/puppet/pops/lookup.rb +12 -0
  113. data/lib/puppet/pops/lookup/context.rb +86 -0
  114. data/lib/puppet/pops/lookup/explainer.rb +46 -6
  115. data/lib/puppet/pops/lookup/invocation.rb +19 -0
  116. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  117. data/lib/puppet/pops/model/factory.rb +20 -8
  118. data/lib/puppet/pops/model/model_label_provider.rb +3 -0
  119. data/lib/puppet/pops/model/model_meta.rb +2 -0
  120. data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
  121. data/lib/puppet/pops/parser/egrammar.ra +11 -6
  122. data/lib/puppet/pops/parser/eparser.rb +1112 -1086
  123. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  124. data/lib/puppet/pops/pcore.rb +1 -0
  125. data/lib/puppet/pops/puppet_stack.rb +3 -3
  126. data/lib/puppet/pops/resource/param.rb +5 -1
  127. data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
  128. data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
  129. data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
  130. data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
  131. data/lib/puppet/pops/serialization/deserializer.rb +5 -1
  132. data/lib/puppet/pops/serialization/extension.rb +2 -0
  133. data/lib/puppet/pops/serialization/json.rb +76 -26
  134. data/lib/puppet/pops/serialization/serializer.rb +5 -1
  135. data/lib/puppet/pops/serialization/time_factory.rb +2 -1
  136. data/lib/puppet/pops/time/timespan.rb +718 -0
  137. data/lib/puppet/pops/time/timestamp.rb +148 -0
  138. data/lib/puppet/pops/types/p_binary_type.rb +220 -0
  139. data/lib/puppet/pops/types/p_object_type.rb +12 -6
  140. data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
  141. data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
  142. data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
  143. data/lib/puppet/pops/types/string_converter.rb +62 -0
  144. data/lib/puppet/pops/types/type_asserter.rb +1 -1
  145. data/lib/puppet/pops/types/type_calculator.rb +17 -3
  146. data/lib/puppet/pops/types/type_factory.rb +35 -1
  147. data/lib/puppet/pops/types/type_formatter.rb +64 -11
  148. data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
  149. data/lib/puppet/pops/types/type_parser.rb +18 -4
  150. data/lib/puppet/pops/types/types.rb +98 -63
  151. data/lib/puppet/pops/validation.rb +9 -1
  152. data/lib/puppet/pops/validation/checker4_0.rb +7 -0
  153. data/lib/puppet/property.rb +1 -1
  154. data/lib/puppet/provider.rb +3 -6
  155. data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
  156. data/lib/puppet/provider/mount/parsed.rb +18 -4
  157. data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
  158. data/lib/puppet/provider/package/gem.rb +6 -1
  159. data/lib/puppet/provider/package/pip.rb +0 -1
  160. data/lib/puppet/provider/package/pkg.rb +5 -1
  161. data/lib/puppet/provider/package/pkgng.rb +1 -1
  162. data/lib/puppet/provider/package/yum.rb +10 -0
  163. data/lib/puppet/provider/service/launchd.rb +1 -0
  164. data/lib/puppet/provider/user/directoryservice.rb +6 -6
  165. data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
  166. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  167. data/lib/puppet/resource.rb +54 -12
  168. data/lib/puppet/resource/capability_finder.rb +15 -9
  169. data/lib/puppet/resource/catalog.rb +25 -6
  170. data/lib/puppet/resource/type.rb +3 -1
  171. data/lib/puppet/settings.rb +1 -1
  172. data/lib/puppet/settings/environment_conf.rb +12 -4
  173. data/lib/puppet/syntax_checkers/base64.rb +41 -0
  174. data/lib/puppet/syntax_checkers/json.rb +0 -2
  175. data/lib/puppet/transaction.rb +6 -0
  176. data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
  177. data/lib/puppet/transaction/report.rb +7 -2
  178. data/lib/puppet/type.rb +2 -1
  179. data/lib/puppet/type/file/checksum.rb +1 -0
  180. data/lib/puppet/type/file/content.rb +4 -4
  181. data/lib/puppet/type/mount.rb +44 -0
  182. data/lib/puppet/type/ssh_authorized_key.rb +1 -1
  183. data/lib/puppet/type/tidy.rb +3 -0
  184. data/lib/puppet/type/user.rb +12 -6
  185. data/lib/puppet/util/log.rb +25 -0
  186. data/lib/puppet/util/plist.rb +8 -3
  187. data/lib/puppet/version.rb +1 -1
  188. data/lib/puppet_x.rb +7 -1
  189. data/spec/integration/application/apply_spec.rb +118 -0
  190. data/spec/integration/parser/compiler_spec.rb +28 -0
  191. data/spec/integration/parser/pcore_resource_spec.rb +40 -3
  192. data/spec/integration/provider/mount_spec.rb +2 -1
  193. data/spec/integration/util/windows/principal_spec.rb +2 -2
  194. data/spec/integration/util/windows/registry_spec.rb +4 -4
  195. data/spec/lib/puppet_spec/compiler.rb +5 -1
  196. data/spec/lib/puppet_spec/unindent.rb +5 -0
  197. data/spec/shared_contexts/types_setup.rb +6 -0
  198. data/spec/shared_examples/rhel_package_provider.rb +16 -0
  199. data/spec/spec_helper.rb +1 -0
  200. data/spec/unit/agent_spec.rb +11 -0
  201. data/spec/unit/application/lookup_spec.rb +94 -3
  202. data/spec/unit/capability_spec.rb +22 -0
  203. data/spec/unit/configurer_spec.rb +8 -0
  204. data/spec/unit/face/epp_face_spec.rb +22 -3
  205. data/spec/unit/functions/assert_type_spec.rb +3 -3
  206. data/spec/unit/functions/binary_file_spec.rb +46 -0
  207. data/spec/unit/functions/break_spec.rb +89 -0
  208. data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
  209. data/spec/unit/functions/find_file_spec.rb +69 -0
  210. data/spec/unit/functions/include_spec.rb +175 -0
  211. data/spec/unit/functions/logging_spec.rb +54 -0
  212. data/spec/unit/functions/lookup_spec.rb +3 -3
  213. data/spec/unit/functions/new_spec.rb +105 -5
  214. data/spec/unit/functions/next_spec.rb +93 -0
  215. data/spec/unit/functions/require_spec.rb +83 -0
  216. data/spec/unit/functions/return_spec.rb +105 -0
  217. data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
  218. data/spec/unit/functions/strftime_spec.rb +152 -0
  219. data/spec/unit/functions4_spec.rb +22 -0
  220. data/spec/unit/indirector/face_spec.rb +10 -2
  221. data/spec/unit/network/http/error_spec.rb +1 -2
  222. data/spec/unit/network/http/handler_spec.rb +6 -5
  223. data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
  224. data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
  225. data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
  226. data/spec/unit/parser/functions/hiera_spec.rb +1 -1
  227. data/spec/unit/parser/functions/lookup_spec.rb +1 -1
  228. data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
  229. data/spec/unit/parser/functions/split_spec.rb +1 -1
  230. data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
  231. data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
  232. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
  233. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
  234. data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
  235. data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
  236. data/spec/unit/pops/lookup/context_spec.rb +149 -0
  237. data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
  238. data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
  239. data/spec/unit/pops/puppet_stack_spec.rb +1 -1
  240. data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
  241. data/spec/unit/pops/serialization/packer_spec.rb +34 -14
  242. data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
  243. data/spec/unit/pops/time/timespan_spec.rb +121 -0
  244. data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
  245. data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
  246. data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
  247. data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
  248. data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
  249. data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
  250. data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
  251. data/spec/unit/pops/types/string_converter_spec.rb +89 -0
  252. data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
  253. data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
  254. data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
  255. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
  256. data/spec/unit/pops/types/type_parser_spec.rb +87 -4
  257. data/spec/unit/pops/types/types_spec.rb +1 -1
  258. data/spec/unit/pops/validator/validator_spec.rb +23 -0
  259. data/spec/unit/provider/mount/parsed_spec.rb +47 -29
  260. data/spec/unit/provider/package/pkg_spec.rb +109 -99
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
  262. data/spec/unit/provider/user/aix_spec.rb +1 -1
  263. data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
  264. data/spec/unit/resource/capability_finder_spec.rb +29 -7
  265. data/spec/unit/resource/catalog_spec.rb +127 -0
  266. data/spec/unit/ssl/certificate_request_spec.rb +1 -1
  267. data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
  268. data/spec/unit/transaction/persistence_spec.rb +1 -6
  269. data/spec/unit/transaction/report_spec.rb +23 -0
  270. data/spec/unit/transaction_spec.rb +38 -0
  271. data/spec/unit/type/mount_spec.rb +5 -0
  272. data/spec/unit/util/plist_spec.rb +14 -2
  273. metadata +71 -12
  274. data/spec/integration/parser/functions/require_spec.rb +0 -43
  275. data/spec/unit/parser/functions/include_spec.rb +0 -55
  276. data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -31,7 +31,7 @@ describe 'The Object Type' do
31
31
  }
32
32
  OBJECT
33
33
  expect { parse_object('MyObject', obj) }.to raise_error(TypeAssertionError,
34
- /attribute MyObject\[a\] had wrong type, expected a Type value, got Integer/)
34
+ /attribute MyObject\[a\] has wrong type, expects a Type value, got Integer/)
35
35
  end
36
36
 
37
37
  it 'raises an error if the type is missing' do
@@ -41,7 +41,7 @@ describe 'The Object Type' do
41
41
  }
42
42
  OBJECT
43
43
  expect { parse_object('MyObject', obj) }.to raise_error(TypeAssertionError,
44
- /expected a value for key 'type'/)
44
+ /expects a value for key 'type'/)
45
45
  end
46
46
 
47
47
  it 'raises an error when value is of incompatible type' do
@@ -51,7 +51,7 @@ describe 'The Object Type' do
51
51
  }
52
52
  OBJECT
53
53
  expect { parse_object('MyObject', obj) }.to raise_error(TypeAssertionError,
54
- /attribute MyObject\[a\] value had wrong type, expected an Integer value, got String/)
54
+ /attribute MyObject\[a\] value has wrong type, expects an Integer value, got String/)
55
55
  end
56
56
 
57
57
  it 'raises an error if the kind is invalid' do
@@ -61,7 +61,7 @@ describe 'The Object Type' do
61
61
  }
62
62
  OBJECT
63
63
  expect { parse_object('MyObject', obj) }.to raise_error(TypeAssertionError,
64
- /expected a match for Enum\['constant', 'derived', 'given_or_derived'\], got 'derivd'/)
64
+ /expects a match for Enum\['constant', 'derived', 'given_or_derived'\], got 'derivd'/)
65
65
  end
66
66
 
67
67
  it 'stores value in attribute' do
@@ -155,7 +155,7 @@ describe 'The Object Type' do
155
155
  }
156
156
  OBJECT
157
157
  expect { parse_object('MyObject', obj) }.to raise_error(TypeAssertionError,
158
- /function MyObject\[a\] had wrong type, expected a Type\[Callable\] value, got Type\[String\]/)
158
+ /function MyObject\[a\] has wrong type, expects a Type\[Callable\] value, got Type\[String\]/)
159
159
  end
160
160
 
161
161
  it 'raises an error when a function has the same name as an attribute' do
@@ -494,7 +494,7 @@ describe 'The Object Type' do
494
494
  a => Integer
495
495
  }
496
496
  OBJECT
497
- expect { parse_object('MyObject', obj) }.to raise_error(TypeAssertionError, /object initializer had wrong type, unrecognized key 'attribrutes'/)
497
+ expect { parse_object('MyObject', obj) }.to raise_error(TypeAssertionError, /object initializer has wrong type, unrecognized key 'attribrutes'/)
498
498
  end
499
499
 
500
500
  it 'raises an error when attribute contains invalid keys' do
@@ -503,7 +503,7 @@ describe 'The Object Type' do
503
503
  a => { type => Integer, knid => constant }
504
504
  }
505
505
  OBJECT
506
- expect { parse_object('MyObject', obj) }.to raise_error(TypeAssertionError, /initializer for attribute MyObject\[a\] had wrong type, unrecognized key 'knid'/)
506
+ expect { parse_object('MyObject', obj) }.to raise_error(TypeAssertionError, /initializer for attribute MyObject\[a\] has wrong type, unrecognized key 'knid'/)
507
507
  end
508
508
 
509
509
  context 'when inheriting from a another Object type' do
@@ -96,7 +96,7 @@ describe 'Sensitive Type' do
96
96
  CODE
97
97
  expect {
98
98
  eval_and_collect_notices(code)
99
- }.to raise_error(Puppet::Error, /expected a Sensitive\[String\[10, 20\]\] value, got Sensitive\[String\[7, 7\]\]/)
99
+ }.to raise_error(Puppet::Error, /expects a Sensitive\[String\[10, 20\]\] value, got Sensitive\[String\[7, 7\]\]/)
100
100
  end
101
101
 
102
102
  it 'does not match an inappropriate parameterized type' do
@@ -0,0 +1,273 @@
1
+ require 'spec_helper'
2
+ require 'puppet/pops'
3
+ require 'puppet_spec/compiler'
4
+
5
+ module Puppet::Pops
6
+ module Types
7
+ describe 'Timespan type' do
8
+ it 'is normalized in a Variant' do
9
+ t = TypeFactory.variant(TypeFactory.timespan('10:00:00', '15:00:00'), TypeFactory.timespan('14:00:00', '17:00:00')).normalize
10
+ expect(t).to be_a(PTimespanType)
11
+ expect(t).to eql(TypeFactory.timespan('10:00:00', '17:00:00'))
12
+ end
13
+
14
+ context 'when used in Puppet expressions' do
15
+ include PuppetSpec::Compiler
16
+ it 'is equal to itself only' do
17
+ code = <<-CODE
18
+ $t = Timespan
19
+ notice(Timespan =~ Type[Timespan])
20
+ notice(Timespan == Timespan)
21
+ notice(Timespan < Timespan)
22
+ notice(Timespan > Timespan)
23
+ CODE
24
+ expect(eval_and_collect_notices(code)).to eq(%w(true true false false))
25
+ end
26
+
27
+ context "when parameterized" do
28
+ it 'is equal other types with the same parameterization' do
29
+ code = <<-CODE
30
+ notice(Timespan['01:00:00', '13:00:00'] == Timespan['01:00:00', '13:00:00'])
31
+ notice(Timespan['01:00:00', '13:00:00'] != Timespan['01:12:20', '13:00:00'])
32
+ CODE
33
+ expect(eval_and_collect_notices(code)).to eq(%w(true true))
34
+ end
35
+
36
+ it 'using just one parameter is the same as using that parameter twice' do
37
+ code = <<-CODE
38
+ notice(Timespan['01:00:00'] == Timespan['01:00:00', '01:00:00'])
39
+ CODE
40
+ expect(eval_and_collect_notices(code)).to eq(%w(true))
41
+ end
42
+
43
+ it 'orders parameterized types based on range inclusion' do
44
+ code = <<-CODE
45
+ notice(Timespan['01:00:00', '13:00:00'] < Timespan['00:00:00', '14:00:00'])
46
+ notice(Timespan['01:00:00', '13:00:00'] > Timespan['00:00:00', '14:00:00'])
47
+ CODE
48
+ expect(eval_and_collect_notices(code)).to eq(%w(true false))
49
+ end
50
+ end
51
+
52
+ context 'a Timespan instance' do
53
+ it 'can be created from a string' do
54
+ code = <<-CODE
55
+ $o = Timespan('3-11:00')
56
+ notice($o)
57
+ notice(type($o))
58
+ CODE
59
+ expect(eval_and_collect_notices(code)).to eq(%w(3-11:00:00.0 Timespan['3-11:00:00.0']))
60
+ end
61
+
62
+ it 'can be created from a string and format' do
63
+ code = <<-CODE
64
+ $o = Timespan('1d11h23m', '%Dd%Hh%Mm')
65
+ notice($o)
66
+ CODE
67
+ expect(eval_and_collect_notices(code)).to eq(%w(1-11:23:00.0))
68
+ end
69
+
70
+ it 'can be created from a hash with string and format' do
71
+ code = <<-CODE
72
+ $o = Timespan({string => '1d11h23m', format => '%Dd%Hh%Mm'})
73
+ notice($o)
74
+ CODE
75
+ expect(eval_and_collect_notices(code)).to eq(%w(1-11:23:00.0))
76
+ end
77
+
78
+ it 'can be created from a string and array of formats' do
79
+ code = <<-CODE
80
+ $fmts = ['%Dd%Hh%Mm%Ss', '%Hh%Mm%Ss', '%Dd%Hh%Mm', '%Dd%Hh', '%Hh%Mm', '%Mm%Ss', '%Dd', '%Hh', '%Mm', '%Ss' ]
81
+ notice(Timespan('1d11h23m13s', $fmts))
82
+ notice(Timespan('11h23m13s', $fmts))
83
+ notice(Timespan('1d11h23m', $fmts))
84
+ notice(Timespan('1d11h', $fmts))
85
+ notice(Timespan('11h23m', $fmts))
86
+ notice(Timespan('23m13s', $fmts))
87
+ notice(Timespan('1d', $fmts))
88
+ notice(Timespan('11h', $fmts))
89
+ notice(Timespan('23m', $fmts))
90
+ notice(Timespan('13s', $fmts))
91
+ CODE
92
+ expect(eval_and_collect_notices(code)).to eq(
93
+ %w(1-11:23:13.0 0-11:23:13.0 1-11:23:00.0 1-11:00:00.0 0-11:23:00.0 0-00:23:13.0 1-00:00:00.0 0-11:00:00.0 0-00:23:00.0 0-00:00:13.0))
94
+ end
95
+
96
+ it 'can be created from a integer that represents seconds since epoch' do
97
+ code = <<-CODE
98
+ $o = Timespan(6800)
99
+ notice(Integer($o) == 6800)
100
+ notice($o == Timespan('01:53:20'))
101
+ CODE
102
+ expect(eval_and_collect_notices(code)).to eq(%w(true true))
103
+ end
104
+
105
+ it 'can be created from a float that represents seconds with fraction since epoch' do
106
+ code = <<-CODE
107
+ $o = Timespan(6800.123456789)
108
+ notice(Float($o) == 6800.123456789)
109
+ notice($o == Timespan('01:53:20.123456789', '%H:%M:%S.%N'))
110
+ CODE
111
+ expect(eval_and_collect_notices(code)).to eq(%w(true true))
112
+ end
113
+
114
+ it 'matches the appropriate parameterized type' do
115
+ code = <<-CODE
116
+ $o = Timespan('3-11:12:13')
117
+ notice(assert_type(Timespan['3-00:00:00', '4-00:00:00'], $o))
118
+ CODE
119
+ expect(eval_and_collect_notices(code)).to eq(['3-11:12:13.0'])
120
+ end
121
+
122
+ it 'does not match an inappropriate parameterized type' do
123
+ code = <<-CODE
124
+ $o = Timespan('1-03:04:05')
125
+ notice(assert_type(Timespan['2-00:00:00', '3-00:00:00'], $o) |$e, $a| { 'nope' })
126
+ CODE
127
+ expect(eval_and_collect_notices(code)).to eq(['nope'])
128
+ end
129
+
130
+ it 'can be compared to other instances' do
131
+ code = <<-CODE
132
+ $o1 = Timespan('00:00:01')
133
+ $o2 = Timespan('00:00:02')
134
+ $o3 = Timespan('00:00:02')
135
+ notice($o1 > $o3)
136
+ notice($o1 >= $o3)
137
+ notice($o1 < $o3)
138
+ notice($o1 <= $o3)
139
+ notice($o1 == $o3)
140
+ notice($o1 != $o3)
141
+ notice($o2 > $o3)
142
+ notice($o2 < $o3)
143
+ notice($o2 >= $o3)
144
+ notice($o2 <= $o3)
145
+ notice($o2 == $o3)
146
+ notice($o2 != $o3)
147
+ CODE
148
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false true false false true true true false))
149
+ end
150
+
151
+ it 'can be compared to integer that represents seconds' do
152
+ code = <<-CODE
153
+ $o1 = Timespan('00:00:01')
154
+ $o2 = Timespan('00:00:02')
155
+ $o3 = 2
156
+ notice($o1 > $o3)
157
+ notice($o1 >= $o3)
158
+ notice($o1 < $o3)
159
+ notice($o1 <= $o3)
160
+ notice($o2 > $o3)
161
+ notice($o2 < $o3)
162
+ notice($o2 >= $o3)
163
+ notice($o2 <= $o3)
164
+ CODE
165
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
166
+ end
167
+
168
+ it 'integer that represents seconds can be compared to it' do
169
+ code = <<-CODE
170
+ $o1 = 1
171
+ $o2 = 2
172
+ $o3 = Timespan('00:00:02')
173
+ notice($o1 > $o3)
174
+ notice($o1 >= $o3)
175
+ notice($o1 < $o3)
176
+ notice($o1 <= $o3)
177
+ notice($o2 > $o3)
178
+ notice($o2 < $o3)
179
+ notice($o2 >= $o3)
180
+ notice($o2 <= $o3)
181
+ CODE
182
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
183
+ end
184
+
185
+ it 'is equal to integer that represents seconds' do
186
+ code = <<-CODE
187
+ $o1 = Timespan('02', '%S')
188
+ $o2 = 2
189
+ notice($o1 == $o2)
190
+ notice($o1 != $o2)
191
+ notice(Integer($o1) == $o2)
192
+ CODE
193
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
194
+ end
195
+
196
+ it 'integer that represents seconds is equal to it' do
197
+ code = <<-CODE
198
+ $o1 = 2
199
+ $o2 = Timespan('02', '%S')
200
+ notice($o1 == $o2)
201
+ notice($o1 != $o2)
202
+ notice($o1 == Integer($o2))
203
+ CODE
204
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
205
+ end
206
+
207
+ it 'can be compared to float that represents seconds with fraction' do
208
+ code = <<-CODE
209
+ $o1 = Timespan('01.123456789', '%S.%N')
210
+ $o2 = Timespan('02.123456789', '%S.%N')
211
+ $o3 = 2.123456789
212
+ notice($o1 > $o3)
213
+ notice($o1 >= $o3)
214
+ notice($o1 < $o3)
215
+ notice($o1 <= $o3)
216
+ notice($o2 > $o3)
217
+ notice($o2 < $o3)
218
+ notice($o2 >= $o3)
219
+ notice($o2 <= $o3)
220
+ CODE
221
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
222
+ end
223
+
224
+ it 'float that represents seconds with fraction can be compared to it' do
225
+ code = <<-CODE
226
+ $o1 = 1.123456789
227
+ $o2 = 2.123456789
228
+ $o3 = Timespan('02.123456789', '%S.%N')
229
+ notice($o1 > $o3)
230
+ notice($o1 >= $o3)
231
+ notice($o1 < $o3)
232
+ notice($o1 <= $o3)
233
+ notice($o2 > $o3)
234
+ notice($o2 < $o3)
235
+ notice($o2 >= $o3)
236
+ notice($o2 <= $o3)
237
+ CODE
238
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
239
+ end
240
+
241
+ it 'is equal to float that represents seconds with fraction' do
242
+ code = <<-CODE
243
+ $o1 = Timespan('02.123456789', '%S.%N')
244
+ $o2 = 2.123456789
245
+ notice($o1 == $o2)
246
+ notice($o1 != $o2)
247
+ notice(Float($o1) == $o2)
248
+ CODE
249
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
250
+ end
251
+
252
+ it 'float that represents seconds with fraction is equal to it' do
253
+ code = <<-CODE
254
+ $o1 = 2.123456789
255
+ $o2 = Timespan('02.123456789', '%S.%N')
256
+ notice($o1 == $o2)
257
+ notice($o1 != $o2)
258
+ notice($o1 == Float($o2))
259
+ CODE
260
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
261
+ end
262
+
263
+ it 'it cannot be compared to a Timestamp' do
264
+ code = <<-CODE
265
+ notice(Timespan(3) < Timestamp())
266
+ CODE
267
+ expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /Timespans are only comparable to Timespans, Integers, and Floats/)
268
+ end
269
+ end
270
+ end
271
+ end
272
+ end
273
+ end
@@ -0,0 +1,311 @@
1
+ require 'spec_helper'
2
+ require 'puppet/pops'
3
+ require 'puppet_spec/compiler'
4
+
5
+ module Puppet::Pops
6
+ module Types
7
+ describe 'Timestamp type' do
8
+
9
+ it 'is normalized in a Variant' do
10
+ t = TypeFactory.variant(TypeFactory.timestamp('2015-03-01', '2016-01-01'), TypeFactory.timestamp('2015-11-03', '2016-12-24')).normalize
11
+ expect(t).to be_a(PTimestampType)
12
+ expect(t).to eql(TypeFactory.timestamp('2015-03-01', '2016-12-24'))
13
+ end
14
+
15
+ context 'when used in Puppet expressions' do
16
+ include PuppetSpec::Compiler
17
+ it 'is equal to itself only' do
18
+ code = <<-CODE
19
+ $t = Timestamp
20
+ notice(Timestamp =~ Type[Timestamp])
21
+ notice(Timestamp == Timestamp)
22
+ notice(Timestamp < Timestamp)
23
+ notice(Timestamp > Timestamp)
24
+ CODE
25
+ expect(eval_and_collect_notices(code)).to eq(%w(true true false false))
26
+ end
27
+
28
+ context "when parameterized" do
29
+ it 'is equal other types with the same parameterization' do
30
+ code = <<-CODE
31
+ notice(Timestamp['2015-03-01', '2016-01-01'] == Timestamp['2015-03-01', '2016-01-01'])
32
+ notice(Timestamp['2015-03-01', '2016-01-01'] != Timestamp['2015-11-03', '2016-12-24'])
33
+ CODE
34
+ expect(eval_and_collect_notices(code)).to eq(%w(true true))
35
+ end
36
+
37
+ it 'using just one parameter is the same as using that parameter twice' do
38
+ code = <<-CODE
39
+ notice(Timestamp['2015-03-01'] == Timestamp['2015-03-01', '2015-03-01'])
40
+ CODE
41
+ expect(eval_and_collect_notices(code)).to eq(%w(true))
42
+ end
43
+
44
+ it 'orders parameterized types based on range inclusion' do
45
+ code = <<-CODE
46
+ notice(Timestamp['2015-03-01', '2015-09-30'] < Timestamp['2015-02-01', '2015-10-30'])
47
+ notice(Timestamp['2015-03-01', '2015-09-30'] > Timestamp['2015-02-01', '2015-10-30'])
48
+ CODE
49
+ expect(eval_and_collect_notices(code)).to eq(%w(true false))
50
+ end
51
+ end
52
+
53
+ context 'a Timestamp instance' do
54
+ it 'can be created from a string' do
55
+ code = <<-CODE
56
+ $o = Timestamp('2015-03-01')
57
+ notice($o)
58
+ notice(type($o))
59
+ CODE
60
+ expect(eval_and_collect_notices(code)).to eq(['2015-03-01T00:00:00.000 UTC', "Timestamp['2015-03-01T00:00:00.000 UTC']"])
61
+ end
62
+
63
+ it 'can be created from a string and format' do
64
+ code = <<-CODE
65
+ $o = Timestamp('Sunday, 28 August, 2016', '%A, %d %B, %Y')
66
+ notice($o)
67
+ CODE
68
+ expect(eval_and_collect_notices(code)).to eq(['2016-08-28T00:00:00.000 UTC'])
69
+ end
70
+
71
+ it 'can be created from a string, format, and a timezone' do
72
+ code = <<-CODE
73
+ $o = Timestamp('Sunday, 28 August, 2016', '%A, %d %B, %Y', 'EST')
74
+ notice($o)
75
+ CODE
76
+ expect(eval_and_collect_notices(code)).to eq(['2016-08-28T05:00:00.000 UTC'])
77
+ end
78
+
79
+ it 'can be not be created from a string, format with timezone designator, and a timezone' do
80
+ code = <<-CODE
81
+ $o = Timestamp('Sunday, 28 August, 2016 UTC', '%A, %d %B, %Y %z', 'EST')
82
+ notice($o)
83
+ CODE
84
+ expect { eval_and_collect_notices(code) }.to raise_error(
85
+ /Using a Timezone designator in format specification is mutually exclusive to providing an explicit timezone argument/)
86
+ end
87
+
88
+ it 'can be created from a hash with string and format' do
89
+ code = <<-CODE
90
+ $o = Timestamp({ string => 'Sunday, 28 August, 2016', format => '%A, %d %B, %Y' })
91
+ notice($o)
92
+ CODE
93
+ expect(eval_and_collect_notices(code)).to eq(['2016-08-28T00:00:00.000 UTC'])
94
+ end
95
+
96
+ it 'can be created from a hash with string, format, and a timezone' do
97
+ code = <<-CODE
98
+ $o = Timestamp({ string => 'Sunday, 28 August, 2016', format => '%A, %d %B, %Y', timezone => 'EST' })
99
+ notice($o)
100
+ CODE
101
+ expect(eval_and_collect_notices(code)).to eq(['2016-08-28T05:00:00.000 UTC'])
102
+ end
103
+
104
+ it 'can be created from a string and array of formats' do
105
+ code = <<-CODE
106
+ $fmts = [
107
+ '%A, %d %B, %Y at %r',
108
+ '%b %d, %Y, %l:%M %P',
109
+ '%y-%m-%d %H:%M:%S %z'
110
+ ]
111
+ notice(Timestamp('Sunday, 28 August, 2016 at 12:15:00 PM', $fmts))
112
+ notice(Timestamp('Jul 24, 2016, 1:20 am', $fmts))
113
+ notice(Timestamp('16-06-21 18:23:15 UTC', $fmts))
114
+ CODE
115
+ expect(eval_and_collect_notices(code)).to eq(
116
+ ['2016-08-28T12:15:00.000 UTC', '2016-07-24T01:20:00.000 UTC', '2016-06-21T18:23:15.000 UTC'])
117
+ end
118
+
119
+ it 'can be created from a string, array of formats, and a timezone' do
120
+ code = <<-CODE
121
+ $fmts = [
122
+ '%A, %d %B, %Y at %r',
123
+ '%b %d, %Y, %l:%M %P',
124
+ '%y-%m-%d %H:%M:%S'
125
+ ]
126
+ notice(Timestamp('Sunday, 28 August, 2016 at 12:15:00 PM', $fmts, 'CET'))
127
+ notice(Timestamp('Jul 24, 2016, 1:20 am', $fmts, 'CET'))
128
+ notice(Timestamp('16-06-21 18:23:15', $fmts, 'CET'))
129
+ CODE
130
+ expect(eval_and_collect_notices(code)).to eq(
131
+ ['2016-08-28T11:15:00.000 UTC', '2016-07-24T00:20:00.000 UTC', '2016-06-21T17:23:15.000 UTC'])
132
+ end
133
+
134
+ it 'can be created from a integer that represents seconds since epoch' do
135
+ code = <<-CODE
136
+ $o = Timestamp(1433116800)
137
+ notice(Integer($o) == 1433116800)
138
+ notice($o == Timestamp('2015-06-01T00:00:00 UTC'))
139
+ CODE
140
+ expect(eval_and_collect_notices(code)).to eq(%w(true true))
141
+ end
142
+
143
+ it 'can be created from a float that represents seconds with fraction since epoch' do
144
+ code = <<-CODE
145
+ $o = Timestamp(1433116800.123456)
146
+ notice(Float($o) == 1433116800.123456)
147
+ notice($o == Timestamp('2015-06-01T00:00:00.123456 UTC'))
148
+ CODE
149
+ expect(eval_and_collect_notices(code)).to eq(%w(true true))
150
+ end
151
+
152
+ it 'matches the appropriate parameterized type' do
153
+ code = <<-CODE
154
+ $o = Timestamp('2015-05-01')
155
+ notice(assert_type(Timestamp['2015-03-01', '2015-09-30'], $o))
156
+ CODE
157
+ expect(eval_and_collect_notices(code)).to eq(['2015-05-01T00:00:00.000 UTC'])
158
+ end
159
+
160
+ it 'does not match an inappropriate parameterized type' do
161
+ code = <<-CODE
162
+ $o = Timestamp('2015-05-01')
163
+ notice(assert_type(Timestamp['2016-03-01', '2016-09-30'], $o) |$e, $a| { 'nope' })
164
+ CODE
165
+ expect(eval_and_collect_notices(code)).to eq(['nope'])
166
+ end
167
+
168
+ it 'can be compared to other instances' do
169
+ code = <<-CODE
170
+ $o1 = Timestamp('2015-05-01')
171
+ $o2 = Timestamp('2015-06-01')
172
+ $o3 = Timestamp('2015-06-01')
173
+ notice($o1 > $o3)
174
+ notice($o1 >= $o3)
175
+ notice($o1 < $o3)
176
+ notice($o1 <= $o3)
177
+ notice($o1 == $o3)
178
+ notice($o1 != $o3)
179
+ notice($o2 > $o3)
180
+ notice($o2 < $o3)
181
+ notice($o2 >= $o3)
182
+ notice($o2 <= $o3)
183
+ notice($o2 == $o3)
184
+ notice($o2 != $o3)
185
+ CODE
186
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false true false false true true true false))
187
+ end
188
+
189
+ it 'can be compared to integer that represents seconds since epoch' do
190
+ code = <<-CODE
191
+ $o1 = Timestamp('2015-05-01')
192
+ $o2 = Timestamp('2015-06-01')
193
+ $o3 = 1433116800
194
+ notice($o1 > $o3)
195
+ notice($o1 >= $o3)
196
+ notice($o1 < $o3)
197
+ notice($o1 <= $o3)
198
+ notice($o2 > $o3)
199
+ notice($o2 < $o3)
200
+ notice($o2 >= $o3)
201
+ notice($o2 <= $o3)
202
+ CODE
203
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
204
+ end
205
+
206
+ it 'integer that represents seconds since epoch can be compared to it' do
207
+ code = <<-CODE
208
+ $o1 = 1430438400
209
+ $o2 = 1433116800
210
+ $o3 = Timestamp('2015-06-01')
211
+ notice($o1 > $o3)
212
+ notice($o1 >= $o3)
213
+ notice($o1 < $o3)
214
+ notice($o1 <= $o3)
215
+ notice($o2 > $o3)
216
+ notice($o2 < $o3)
217
+ notice($o2 >= $o3)
218
+ notice($o2 <= $o3)
219
+ CODE
220
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
221
+ end
222
+
223
+ it 'is equal to integer that represents seconds since epoch' do
224
+ code = <<-CODE
225
+ $o1 = Timestamp('2015-06-01T00:00:00 UTC')
226
+ $o2 = 1433116800
227
+ notice($o1 == $o2)
228
+ notice($o1 != $o2)
229
+ notice(Integer($o1) == $o2)
230
+ CODE
231
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
232
+ end
233
+
234
+ it 'integer that represents seconds is equal to it' do
235
+ code = <<-CODE
236
+ $o1 = 1433116800
237
+ $o2 = Timestamp('2015-06-01T00:00:00 UTC')
238
+ notice($o1 == $o2)
239
+ notice($o1 != $o2)
240
+ notice($o1 == Integer($o2))
241
+ CODE
242
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
243
+ end
244
+
245
+ it 'can be compared to float that represents seconds with fraction since epoch' do
246
+ code = <<-CODE
247
+ $o1 = Timestamp('2015-05-01T00:00:00.123456789 UTC')
248
+ $o2 = Timestamp('2015-06-01T00:00:00.123456789 UTC')
249
+ $o3 = 1433116800.123456789
250
+ notice($o1 > $o3)
251
+ notice($o1 >= $o3)
252
+ notice($o1 < $o3)
253
+ notice($o1 <= $o3)
254
+ notice($o2 > $o3)
255
+ notice($o2 < $o3)
256
+ notice($o2 >= $o3)
257
+ notice($o2 <= $o3)
258
+ CODE
259
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
260
+ end
261
+
262
+ it 'float that represents seconds with fraction since epoch can be compared to it' do
263
+ code = <<-CODE
264
+ $o1 = 1430438400.123456789
265
+ $o2 = 1433116800.123456789
266
+ $o3 = Timestamp('2015-06-01T00:00:00.123456789 UTC')
267
+ notice($o1 > $o3)
268
+ notice($o1 >= $o3)
269
+ notice($o1 < $o3)
270
+ notice($o1 <= $o3)
271
+ notice($o2 > $o3)
272
+ notice($o2 < $o3)
273
+ notice($o2 >= $o3)
274
+ notice($o2 <= $o3)
275
+ CODE
276
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
277
+ end
278
+
279
+ it 'is equal to float that represents seconds with fraction since epoch' do
280
+ code = <<-CODE
281
+ $o1 = Timestamp('2015-06-01T00:00:00.123456789 UTC')
282
+ $o2 = 1433116800.123456789
283
+ notice($o1 == $o2)
284
+ notice($o1 != $o2)
285
+ notice(Float($o1) == $o2)
286
+ CODE
287
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
288
+ end
289
+
290
+ it 'float that represents seconds with fraction is equal to it' do
291
+ code = <<-CODE
292
+ $o1 = 1433116800.123456789
293
+ $o2 = Timestamp('2015-06-01T00:00:00.123456789 UTC')
294
+ notice($o1 == $o2)
295
+ notice($o1 != $o2)
296
+ notice($o1 == Float($o2))
297
+ CODE
298
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
299
+ end
300
+
301
+ it 'it cannot be compared to a Timespan' do
302
+ code = <<-CODE
303
+ notice(Timestamp() > Timespan(3))
304
+ CODE
305
+ expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /Timestamps are only comparable to Timestamps, Integers, and Floats/)
306
+ end
307
+ end
308
+ end
309
+ end
310
+ end
311
+ end