diff options
author | Erik Dalén <dalen@spotify.com> | 2012-09-30 21:54:17 -0700 |
---|---|---|
committer | Erik Dalén <dalen@spotify.com> | 2012-10-05 18:55:24 +0200 |
commit | 9ed6fcea48591cda58db1379b58cd39dfbdca684 (patch) | |
tree | 02f1b9719be6e4f2469d21b469d6bb443d843f5e | |
parent | a5b6c2a9fffbc83f35f04837a32626cc5efd09f8 (diff) | |
download | puppet-9ed6fcea48591cda58db1379b58cd39dfbdca684.tar.gz |
(#15989) Set arity on functions
Set the arity on builtin functions.
36 files changed, 52 insertions, 54 deletions
diff --git a/lib/puppet/parser/functions/create_resources.rb b/lib/puppet/parser/functions/create_resources.rb index e8497c2f3..6c8923dac 100644 --- a/lib/puppet/parser/functions/create_resources.rb +++ b/lib/puppet/parser/functions/create_resources.rb @@ -1,4 +1,4 @@ -Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC') do |args| +Puppet::Parser::Functions::newfunction(:create_resources, :arity => -3, :doc => <<-'ENDHEREDOC') do |args| Converts a hash into a set of resources and adds them to the catalog. This function takes two mandatory arguments: a resource type, and a hash describing @@ -32,7 +32,7 @@ Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC This function can be used to create defined resources and classes, as well as native resources. ENDHEREDOC - raise ArgumentError, ("create_resources(): wrong number of arguments (#{args.length}; must be 2 or 3)") if args.length < 2 || args.length > 3 + raise ArgumentError, ("create_resources(): wrong number of arguments (#{args.length}; must be 2 or 3)") if args.length > 3 # figure out what kind of resource we are type_of_resource = nil diff --git a/lib/puppet/parser/functions/defined.rb b/lib/puppet/parser/functions/defined.rb index 2aeaa9ba0..314cc45a0 100644 --- a/lib/puppet/parser/functions/defined.rb +++ b/lib/puppet/parser/functions/defined.rb @@ -1,5 +1,5 @@ # Test whether a given class or definition is defined -Puppet::Parser::Functions::newfunction(:defined, :type => :rvalue, :doc => "Determine whether +Puppet::Parser::Functions::newfunction(:defined, :type => :rvalue, :arity => -2, :doc => "Determine whether a given class or resource type is defined. This function can also determine whether a specific resource has been declared. Returns true or false. Accepts class names, type names, and resource references. diff --git a/lib/puppet/parser/functions/extlookup.rb b/lib/puppet/parser/functions/extlookup.rb index dbc319dde..d012bcd72 100644 --- a/lib/puppet/parser/functions/extlookup.rb +++ b/lib/puppet/parser/functions/extlookup.rb @@ -3,6 +3,7 @@ require 'csv' module Puppet::Parser::Functions newfunction(:extlookup, :type => :rvalue, + :arity => -2, :doc => "This is a parser function to read data from external files, this version uses CSV files but the concept can easily be adjust for databases, yaml or any other queryable data source. @@ -89,7 +90,7 @@ This is for back compatibility to interpolate variables with %. % interpolation default = args[1] datafile = args[2] - raise Puppet::ParseError, ("extlookup(): wrong number of arguments (#{args.length}; must be <= 3)") if args.length > 3 + raise ArgumentError, ("extlookup(): wrong number of arguments (#{args.length}; must be <= 3)") if args.length > 3 extlookup_datadir = undef_as('',self['::extlookup_datadir']) diff --git a/lib/puppet/parser/functions/fail.rb b/lib/puppet/parser/functions/fail.rb index 5bef6c7e3..34c99b638 100644 --- a/lib/puppet/parser/functions/fail.rb +++ b/lib/puppet/parser/functions/fail.rb @@ -1,4 +1,4 @@ -Puppet::Parser::Functions::newfunction(:fail, :doc => "Fail with a parse error.") do |vals| +Puppet::Parser::Functions::newfunction(:fail, :arity => -1, :doc => "Fail with a parse error.") do |vals| vals = vals.collect { |s| s.to_s }.join(" ") if vals.is_a? Array raise Puppet::ParseError, vals.to_s end diff --git a/lib/puppet/parser/functions/file.rb b/lib/puppet/parser/functions/file.rb index 2b9a709de..569266a3b 100644 --- a/lib/puppet/parser/functions/file.rb +++ b/lib/puppet/parser/functions/file.rb @@ -1,7 +1,7 @@ # Returns the contents of a file Puppet::Parser::Functions::newfunction( - :file, :type => :rvalue, + :file, :arity => -2, :type => :rvalue, :doc => "Return the contents of a file. Multiple files can be passed, and the first file that exists will be read in." ) do |vals| diff --git a/lib/puppet/parser/functions/fqdn_rand.rb b/lib/puppet/parser/functions/fqdn_rand.rb index 916338e98..b39c0bb77 100644 --- a/lib/puppet/parser/functions/fqdn_rand.rb +++ b/lib/puppet/parser/functions/fqdn_rand.rb @@ -1,6 +1,6 @@ require 'digest/md5' -Puppet::Parser::Functions::newfunction(:fqdn_rand, :type => :rvalue, :doc => +Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalue, :doc => "Generates random numbers based on the node's fqdn. Generated random values will be a range from 0 up to and excluding n, where n is the first parameter. The second argument specifies a number to add to the seed and is optional, for example: diff --git a/lib/puppet/parser/functions/generate.rb b/lib/puppet/parser/functions/generate.rb index 1f8286c1c..71bd0b19f 100644 --- a/lib/puppet/parser/functions/generate.rb +++ b/lib/puppet/parser/functions/generate.rb @@ -1,5 +1,5 @@ # Runs an external command and returns the results -Puppet::Parser::Functions::newfunction(:generate, :type => :rvalue, +Puppet::Parser::Functions::newfunction(:generate, :arity => -2, :type => :rvalue, :doc => "Calls an external command on the Puppet master and returns the results of the command. Any arguments are passed to the external command as arguments. If the generator does not exit with return code of 0, diff --git a/lib/puppet/parser/functions/hiera.rb b/lib/puppet/parser/functions/hiera.rb index 4c75b8ee5..9de4f70f1 100644 --- a/lib/puppet/parser/functions/hiera.rb +++ b/lib/puppet/parser/functions/hiera.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:hiera, :type => :rvalue) do |*args| + newfunction(:hiera, :type => :rvalue, :arity => -2) do |*args| require 'hiera_puppet' key, default, override = HieraPuppet.parse_args(args) HieraPuppet.lookup(key, default, self, override, :priority) diff --git a/lib/puppet/parser/functions/hiera_array.rb b/lib/puppet/parser/functions/hiera_array.rb index dc87b28fb..61ad5e6aa 100644 --- a/lib/puppet/parser/functions/hiera_array.rb +++ b/lib/puppet/parser/functions/hiera_array.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:hiera_array, :type => :rvalue) do |*args| + newfunction(:hiera_array, :type => :rvalue, :arity => -2) do |*args| require 'hiera_puppet' key, default, override = HieraPuppet.parse_args(args) HieraPuppet.lookup(key, default, self, override, :array) diff --git a/lib/puppet/parser/functions/hiera_hash.rb b/lib/puppet/parser/functions/hiera_hash.rb index baae15169..7f26a0924 100644 --- a/lib/puppet/parser/functions/hiera_hash.rb +++ b/lib/puppet/parser/functions/hiera_hash.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:hiera_hash, :type => :rvalue) do |*args| + newfunction(:hiera_hash, :type => :rvalue, :arity => -2) do |*args| require 'hiera_puppet' key, default, override = HieraPuppet.parse_args(args) HieraPuppet.lookup(key, default, self, override, :hash) diff --git a/lib/puppet/parser/functions/hiera_include.rb b/lib/puppet/parser/functions/hiera_include.rb index bede00336..1c74448d6 100644 --- a/lib/puppet/parser/functions/hiera_include.rb +++ b/lib/puppet/parser/functions/hiera_include.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:hiera_include) do |*args| + newfunction(:hiera_include, :arity => -2) do |*args| require 'hiera_puppet' key, default, override = HieraPuppet.parse_args(args) answer = HieraPuppet.lookup(key, default, self, override, :array) diff --git a/lib/puppet/parser/functions/include.rb b/lib/puppet/parser/functions/include.rb index 5e24e4942..ca8819176 100644 --- a/lib/puppet/parser/functions/include.rb +++ b/lib/puppet/parser/functions/include.rb @@ -1,5 +1,5 @@ # Include the specified classes -Puppet::Parser::Functions::newfunction(:include, :doc => "Evaluate one or more classes.") do |vals| +Puppet::Parser::Functions::newfunction(:include, :arity => -2, :doc => "Evaluate one or more classes.") do |vals| if vals.is_a?(Array) # Protect against array inside array vals = vals.flatten diff --git a/lib/puppet/parser/functions/inline_template.rb b/lib/puppet/parser/functions/inline_template.rb index 9759ff6e1..d86024154 100644 --- a/lib/puppet/parser/functions/inline_template.rb +++ b/lib/puppet/parser/functions/inline_template.rb @@ -1,4 +1,4 @@ -Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :doc => +Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :arity => -2, :doc => "Evaluate a template string and return its value. See [the templating docs](http://docs.puppetlabs.com/guides/templating.html) for more information. Note that if multiple template strings are specified, their diff --git a/lib/puppet/parser/functions/md5.rb b/lib/puppet/parser/functions/md5.rb index d1e1efae2..d9e1ee802 100644 --- a/lib/puppet/parser/functions/md5.rb +++ b/lib/puppet/parser/functions/md5.rb @@ -1,5 +1,5 @@ require 'digest/md5' -Puppet::Parser::Functions::newfunction(:md5, :type => :rvalue, :doc => "Returns a MD5 hash value from a provided string.") do |args| +Puppet::Parser::Functions::newfunction(:md5, :type => :rvalue, :arity => 1, :doc => "Returns a MD5 hash value from a provided string.") do |args| Digest::MD5.hexdigest(args[0]) end diff --git a/lib/puppet/parser/functions/realize.rb b/lib/puppet/parser/functions/realize.rb index c21ccd14a..4d1567de1 100644 --- a/lib/puppet/parser/functions/realize.rb +++ b/lib/puppet/parser/functions/realize.rb @@ -1,7 +1,7 @@ # This is just syntactic sugar for a collection, although it will generally # be a good bit faster. -Puppet::Parser::Functions::newfunction(:realize, :doc => "Make a virtual object real. This is useful +Puppet::Parser::Functions::newfunction(:realize, :arity => -2, :doc => "Make a virtual object real. This is useful when you want to know the name of the virtual object and don't want to bother with a full collection. It is slightly faster than a collection, and, of course, is a bit shorter. You must pass the object using a diff --git a/lib/puppet/parser/functions/regsubst.rb b/lib/puppet/parser/functions/regsubst.rb index 397d2b2ee..e88e70023 100644 --- a/lib/puppet/parser/functions/regsubst.rb +++ b/lib/puppet/parser/functions/regsubst.rb @@ -28,6 +28,7 @@ module Puppet::Parser::Functions newfunction( :regsubst, :type => :rvalue, + :arity => -4, :doc => " Perform regexp replacement on a string or array of strings. @@ -61,7 +62,7 @@ Put angle brackets around each octet in the node's IP address: unless args.length.between?(3, 5) raise( - Puppet::ParseError, + ArgumentError, "regsubst(): got #{args.length} arguments, expected 3 to 5") end diff --git a/lib/puppet/parser/functions/require.rb b/lib/puppet/parser/functions/require.rb index 44aca854d..819b82619 100644 --- a/lib/puppet/parser/functions/require.rb +++ b/lib/puppet/parser/functions/require.rb @@ -2,6 +2,7 @@ Puppet::Parser::Functions::newfunction( :require, + :arity => -2, :doc =>"Evaluate one or more classes, adding the required class as a dependency. The relationship metaparameters work well for specifying relationships diff --git a/lib/puppet/parser/functions/search.rb b/lib/puppet/parser/functions/search.rb index 8a9c7c8be..04c7579d7 100644 --- a/lib/puppet/parser/functions/search.rb +++ b/lib/puppet/parser/functions/search.rb @@ -1,4 +1,4 @@ -Puppet::Parser::Functions::newfunction(:search, :doc => "Add another namespace for this class to search. +Puppet::Parser::Functions::newfunction(:search, :arity => -2, :doc => "Add another namespace for this class to search. This allows you to create classes with sets of definitions and add those classes to another class's search path.") do |vals| vals.each do |val| diff --git a/lib/puppet/parser/functions/sha1.rb b/lib/puppet/parser/functions/sha1.rb index c52df4d28..7c565cf61 100644 --- a/lib/puppet/parser/functions/sha1.rb +++ b/lib/puppet/parser/functions/sha1.rb @@ -1,5 +1,5 @@ require 'digest/sha1' -Puppet::Parser::Functions::newfunction(:sha1, :type => :rvalue, :doc => "Returns a SHA1 hash value from a provided string.") do |args| +Puppet::Parser::Functions::newfunction(:sha1, :type => :rvalue, :arity => 1, :doc => "Returns a SHA1 hash value from a provided string.") do |args| Digest::SHA1.hexdigest(args[0]) end diff --git a/lib/puppet/parser/functions/shellquote.rb b/lib/puppet/parser/functions/shellquote.rb index e30df904c..1cf6b1b22 100644 --- a/lib/puppet/parser/functions/shellquote.rb +++ b/lib/puppet/parser/functions/shellquote.rb @@ -24,7 +24,7 @@ # other dealings in this Software without prior written authorization # from Thomas Bellman. -Puppet::Parser::Functions.newfunction(:shellquote, :type => :rvalue, :doc => "\ +Puppet::Parser::Functions.newfunction(:shellquote, :type => :rvalue, :arity => -1, :doc => "\ Quote and concatenate arguments for use in Bourne shell. Each argument is quoted separately, and then all are concatenated diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb index ad027865b..0485a5ef5 100644 --- a/lib/puppet/parser/functions/split.rb +++ b/lib/puppet/parser/functions/split.rb @@ -2,6 +2,7 @@ module Puppet::Parser::Functions newfunction( :split, :type => :rvalue, + :arity => 2, :doc => "\ Split a string variable into an array using the specified split regexp. @@ -22,8 +23,6 @@ a regexp meta-character (.), which must be escaped. A simple way to do that for a single character is to enclose it in square brackets; a backslash will also escape a single character.") do |args| - raise Puppet::ParseError, ("split(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2 - return args[0].split(Regexp.compile(args[1])) end end diff --git a/lib/puppet/parser/functions/sprintf.rb b/lib/puppet/parser/functions/sprintf.rb index 118020412..c4b5df3b0 100644 --- a/lib/puppet/parser/functions/sprintf.rb +++ b/lib/puppet/parser/functions/sprintf.rb @@ -28,11 +28,11 @@ module Puppet::Parser::Functions newfunction( :sprintf, :type => :rvalue, + :arity => -2, :doc => "Perform printf-style formatting of text. The first parameter is format string describing how the rest of the parameters should be formatted. See the documentation for the `Kernel::sprintf` function in Ruby for all the details.") do |args| - raise Puppet::ParseError, 'sprintf() needs at least one argument' if args.length < 1 fmt = args.shift return sprintf(fmt, *args) end diff --git a/lib/puppet/parser/functions/tag.rb b/lib/puppet/parser/functions/tag.rb index 84df175eb..b4b1b6907 100644 --- a/lib/puppet/parser/functions/tag.rb +++ b/lib/puppet/parser/functions/tag.rb @@ -1,5 +1,5 @@ # Tag the current scope with each passed name -Puppet::Parser::Functions::newfunction(:tag, :doc => "Add the specified tags to the containing class +Puppet::Parser::Functions::newfunction(:tag, :arity => -2, :doc => "Add the specified tags to the containing class or definition. All contained objects will then acquire that tag, also. ") do |vals| self.resource.tag(*vals) diff --git a/lib/puppet/parser/functions/tagged.rb b/lib/puppet/parser/functions/tagged.rb index aaa2adfad..72fb16ed7 100644 --- a/lib/puppet/parser/functions/tagged.rb +++ b/lib/puppet/parser/functions/tagged.rb @@ -1,5 +1,5 @@ # Test whether a given tag is set. This functions as a big OR -- if any of the specified tags are unset, we return false. -Puppet::Parser::Functions::newfunction(:tagged, :type => :rvalue, :doc => "A boolean function that +Puppet::Parser::Functions::newfunction(:tagged, :type => :rvalue, :arity => -2, :doc => "A boolean function that tells you whether the current container is tagged with the specified tags. The tags are ANDed, so that all of the specified tags must be included for the function to return true.") do |vals| diff --git a/lib/puppet/parser/functions/template.rb b/lib/puppet/parser/functions/template.rb index 5e4b00e1e..d9b48408e 100644 --- a/lib/puppet/parser/functions/template.rb +++ b/lib/puppet/parser/functions/template.rb @@ -1,4 +1,4 @@ -Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc => +Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :arity => -2, :doc => "Evaluate a template and return its value. See [the templating docs](http://docs.puppetlabs.com/guides/templating.html) for more information. diff --git a/lib/puppet/parser/functions/versioncmp.rb b/lib/puppet/parser/functions/versioncmp.rb index a7905a6d0..302250d4f 100644 --- a/lib/puppet/parser/functions/versioncmp.rb +++ b/lib/puppet/parser/functions/versioncmp.rb @@ -1,6 +1,6 @@ require 'puppet/util/package' -Puppet::Parser::Functions::newfunction( :versioncmp, :type => :rvalue, :doc => +Puppet::Parser::Functions::newfunction( :versioncmp, :type => :rvalue, :arity => 2, :doc => "Compares two version numbers. Prototype: @@ -26,9 +26,5 @@ This function uses the same version comparison algorithm used by Puppet's ") do |args| - unless args.length == 2 - raise Puppet::ParseError, "versioncmp should have 2 arguments" - end - return Puppet::Util::Package.versioncmp(args[0], args[1]) end diff --git a/spec/unit/parser/functions/create_resources_spec.rb b/spec/unit/parser/functions/create_resources_spec.rb index a7a6e0074..f768eaccf 100755 --- a/spec/unit/parser/functions/create_resources_spec.rb +++ b/spec/unit/parser/functions/create_resources_spec.rb @@ -19,7 +19,7 @@ describe 'function for dynamically creating resources' do end it 'should require two or three arguments' do - expect { @scope.function_create_resources(['foo']) }.to raise_error(ArgumentError, 'create_resources(): wrong number of arguments (1; must be 2 or 3)') + expect { @scope.function_create_resources(['foo']) }.to raise_error(ArgumentError, 'create_resources(): Wrong number of arguments given (1 for minimum 2)') expect { @scope.function_create_resources(['foo', 'bar', 'blah', 'baz']) }.to raise_error(ArgumentError, 'create_resources(): wrong number of arguments (4; must be 2 or 3)') end diff --git a/spec/unit/parser/functions/extlookup_spec.rb b/spec/unit/parser/functions/extlookup_spec.rb index 4bc2702b7..fae32fa97 100755 --- a/spec/unit/parser/functions/extlookup_spec.rb +++ b/spec/unit/parser/functions/extlookup_spec.rb @@ -19,12 +19,12 @@ describe "the extlookup function" do Puppet::Parser::Functions.function("extlookup").should == "function_extlookup" end - it "should raise a ParseError if there is less than 1 arguments" do - lambda { @scope.function_extlookup([]) }.should( raise_error(Puppet::ParseError)) + it "should raise a ArgumentError if there is less than 1 arguments" do + lambda { @scope.function_extlookup([]) }.should( raise_error(ArgumentError)) end - it "should raise a ParseError if there is more than 3 arguments" do - lambda { @scope.function_extlookup(["foo", "bar", "baz", "gazonk"]) }.should( raise_error(Puppet::ParseError)) + it "should raise a ArgumentError if there is more than 3 arguments" do + lambda { @scope.function_extlookup(["foo", "bar", "baz", "gazonk"]) }.should( raise_error(ArgumentError)) end it "should return the default" do diff --git a/spec/unit/parser/functions/hiera_array_spec.rb b/spec/unit/parser/functions/hiera_array_spec.rb index d9e25cef0..e8efb727f 100644 --- a/spec/unit/parser/functions/hiera_array_spec.rb +++ b/spec/unit/parser/functions/hiera_array_spec.rb @@ -8,7 +8,7 @@ describe 'Puppet::Parser::Functions#hiera_array' do let :scope do Puppet::Parser::Scope.new_for_test_harness('foo') end it 'should require a key argument' do - expect { scope.function_hiera_array([]) }.to raise_error(Puppet::ParseError) + expect { scope.function_hiera_array([]) }.to raise_error(ArgumentError) end it 'should raise a useful error when nil is returned' do diff --git a/spec/unit/parser/functions/hiera_hash_spec.rb b/spec/unit/parser/functions/hiera_hash_spec.rb index c7c9d4432..a345a6c7f 100644 --- a/spec/unit/parser/functions/hiera_hash_spec.rb +++ b/spec/unit/parser/functions/hiera_hash_spec.rb @@ -4,7 +4,7 @@ describe 'Puppet::Parser::Functions#hiera_hash' do let :scope do Puppet::Parser::Scope.new_for_test_harness('foo') end it 'should require a key argument' do - expect { scope.function_hiera_hash([]) }.to raise_error(Puppet::ParseError) + expect { scope.function_hiera_hash([]) }.to raise_error(ArgumentError) end it 'should raise a useful error when nil is returned' do diff --git a/spec/unit/parser/functions/hiera_include_spec.rb b/spec/unit/parser/functions/hiera_include_spec.rb index 355afdd8d..de35293d3 100644 --- a/spec/unit/parser/functions/hiera_include_spec.rb +++ b/spec/unit/parser/functions/hiera_include_spec.rb @@ -4,7 +4,7 @@ describe 'Puppet::Parser::Functions#hiera_include' do let :scope do Puppet::Parser::Scope.new_for_test_harness('foo') end it 'should require a key argument' do - expect { scope.function_hiera_include([]) }.to raise_error(Puppet::ParseError) + expect { scope.function_hiera_include([]) }.to raise_error(ArgumentError) end it 'should raise a useful error when nil is returned' do diff --git a/spec/unit/parser/functions/hiera_spec.rb b/spec/unit/parser/functions/hiera_spec.rb index 657d4f6fb..0abcb1b28 100755 --- a/spec/unit/parser/functions/hiera_spec.rb +++ b/spec/unit/parser/functions/hiera_spec.rb @@ -6,7 +6,7 @@ describe 'Puppet::Parser::Functions#hiera' do let :scope do Puppet::Parser::Scope.new_for_test_harness('foo') end it 'should require a key argument' do - expect { scope.function_hiera([]) }.to raise_error(Puppet::ParseError) + expect { scope.function_hiera([]) }.to raise_error(ArgumentError) end it 'should raise a useful error when nil is returned' do diff --git a/spec/unit/parser/functions/regsubst_spec.rb b/spec/unit/parser/functions/regsubst_spec.rb index 439c16270..c75b16c0e 100755 --- a/spec/unit/parser/functions/regsubst_spec.rb +++ b/spec/unit/parser/functions/regsubst_spec.rb @@ -16,12 +16,12 @@ describe "the regsubst function" do Puppet::Parser::Functions.function("regsubst").should == "function_regsubst" end - it "should raise a ParseError if there is less than 3 arguments" do - lambda { @scope.function_regsubst(["foo", "bar"]) }.should( raise_error(Puppet::ParseError)) + it "should raise a ArgumentError if there is less than 3 arguments" do + lambda { @scope.function_regsubst(["foo", "bar"]) }.should( raise_error(ArgumentError)) end - it "should raise a ParseError if there is more than 5 arguments" do - lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "del", "x", "y"]) }.should( raise_error(Puppet::ParseError)) + it "should raise a ArgumentError if there is more than 5 arguments" do + lambda { @scope.function_regsubst(["foo", "bar", "gazonk", "del", "x", "y"]) }.should( raise_error(ArgumentError)) end diff --git a/spec/unit/parser/functions/split_spec.rb b/spec/unit/parser/functions/split_spec.rb index 20a6f4204..5ddbe8d44 100755 --- a/spec/unit/parser/functions/split_spec.rb +++ b/spec/unit/parser/functions/split_spec.rb @@ -16,12 +16,12 @@ describe "the split function" do Puppet::Parser::Functions.function("split").should == "function_split" end - it "should raise a ParseError if there is less than 2 arguments" do - lambda { @scope.function_split(["foo"]) }.should( raise_error(Puppet::ParseError)) + it "should raise a ArgumentError if there is less than 2 arguments" do + lambda { @scope.function_split(["foo"]) }.should( raise_error(ArgumentError)) end - it "should raise a ParseError if there is more than 2 arguments" do - lambda { @scope.function_split(["foo", "bar", "gazonk"]) }.should( raise_error(Puppet::ParseError)) + it "should raise a ArgumentError if there is more than 2 arguments" do + lambda { @scope.function_split(["foo", "bar", "gazonk"]) }.should( raise_error(ArgumentError)) end it "should raise a RegexpError if the regexp is malformed" do diff --git a/spec/unit/parser/functions/sprintf_spec.rb b/spec/unit/parser/functions/sprintf_spec.rb index e1d738e66..36c0ae1b7 100755 --- a/spec/unit/parser/functions/sprintf_spec.rb +++ b/spec/unit/parser/functions/sprintf_spec.rb @@ -16,8 +16,8 @@ describe "the sprintf function" do Puppet::Parser::Functions.function("sprintf").should == "function_sprintf" end - it "should raise a ParseError if there is less than 1 argument" do - lambda { @scope.function_sprintf([]) }.should( raise_error(Puppet::ParseError)) + it "should raise a ArgumentError if there is less than 1 argument" do + lambda { @scope.function_sprintf([]) }.should( raise_error(ArgumentError)) end it "should format integers" do diff --git a/spec/unit/parser/functions/versioncmp_spec.rb b/spec/unit/parser/functions/versioncmp_spec.rb index 5a6668678..760a286c5 100755 --- a/spec/unit/parser/functions/versioncmp_spec.rb +++ b/spec/unit/parser/functions/versioncmp_spec.rb @@ -16,12 +16,12 @@ describe "the versioncmp function" do Puppet::Parser::Functions.function("versioncmp").should == "function_versioncmp" end - it "should raise a ParseError if there is less than 2 arguments" do - lambda { @scope.function_versioncmp(["1.2"]) }.should raise_error(Puppet::ParseError) + it "should raise a ArgumentError if there is less than 2 arguments" do + lambda { @scope.function_versioncmp(["1.2"]) }.should raise_error(ArgumentError) end - it "should raise a ParseError if there is more than 2 arguments" do - lambda { @scope.function_versioncmp(["1.2", "2.4.5", "3.5.6"]) }.should raise_error(Puppet::ParseError) + it "should raise a ArgumentError if there is more than 2 arguments" do + lambda { @scope.function_versioncmp(["1.2", "2.4.5", "3.5.6"]) }.should raise_error(ArgumentError) end it "should call Puppet::Util::Package.versioncmp (included in scope)" do |