summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHenrik Lindberg <henrik.lindberg@puppetlabs.com>2014-10-14 20:08:38 +0000
committerHenrik Lindberg <henrik.lindberg@puppetlabs.com>2014-10-14 20:08:38 +0000
commit6cdd9f87a8604ca417cb3019cb84d91fb8ea777b (patch)
treec3a3c93b1348ec01b0556b339703d30dd4305599 /spec
parent0cff77190db1c2e1852f2e32c137ccc0f31aa94a (diff)
parent277f406293efa64ecb56196d7db127e830d55181 (diff)
downloadpuppet-6cdd9f87a8604ca417cb3019cb84d91fb8ea777b.tar.gz
Merge pull request #3194 from zaphod42/issue/stable/pup-3201-undef-not-working
(PUP-3201) Treat :undef as PNilType
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/parser/future_compiler_spec.rb20
-rw-r--r--spec/unit/pops/types/type_calculator_spec.rb4
2 files changed, 24 insertions, 0 deletions
diff --git a/spec/integration/parser/future_compiler_spec.rb b/spec/integration/parser/future_compiler_spec.rb
index d0fcfcdec..3a27a3aad 100644
--- a/spec/integration/parser/future_compiler_spec.rb
+++ b/spec/integration/parser/future_compiler_spec.rb
@@ -440,6 +440,16 @@ describe "Puppet::Parser::Compiler" do
expect(catalog).to have_resource("Foo[test]").with_parameter(:x, 'say friend')
end
+ it 'accepts undef as the default for an Optional argument' do
+ catalog = compile_to_catalog(<<-MANIFEST)
+ define foo(Optional[String] $x = undef) {
+ notify { "expected": message => $x == undef }
+ }
+ foo { 'test': }
+ MANIFEST
+ expect(catalog).to have_resource("Notify[expected]").with_parameter(:message, true)
+ end
+
it 'accepts anything when parameters are untyped' do
expect do
catalog = compile_to_catalog(<<-MANIFEST)
@@ -489,6 +499,16 @@ describe "Puppet::Parser::Compiler" do
expect(catalog).to have_resource("Class[Foo]").with_parameter(:x, 'say friend')
end
+ it 'accepts undef as the default for an Optional argument' do
+ catalog = compile_to_catalog(<<-MANIFEST)
+ class foo(Optional[String] $x = undef) {
+ notify { "expected": message => $x == undef }
+ }
+ class { 'foo': }
+ MANIFEST
+ expect(catalog).to have_resource("Notify[expected]").with_parameter(:message, true)
+ end
+
it 'accepts anything when parameters are untyped' do
expect do
catalog = compile_to_catalog(<<-MANIFEST)
diff --git a/spec/unit/pops/types/type_calculator_spec.rb b/spec/unit/pops/types/type_calculator_spec.rb
index b11ed23a9..ea38cb318 100644
--- a/spec/unit/pops/types/type_calculator_spec.rb
+++ b/spec/unit/pops/types/type_calculator_spec.rb
@@ -1088,6 +1088,10 @@ describe 'The type calculator' do
calculator.instance?(Puppet::Pops::Types::PRuntimeType.new(:runtime => :ruby, :runtime_type_name => 'Symbol'), :undef).should == true
end
+ it "should consider :undef to be instance of an Optional type" do
+ calculator.instance?(Puppet::Pops::Types::POptionalType.new(), :undef).should == true
+ end
+
it 'should not consider undef to be an instance of any other type than Any, NilType and Data' do
types_to_test = all_types - [
Puppet::Pops::Types::PAnyType,