diff --git a/.travis.yml b/.travis.yml index 1bb188991..66edb2e3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ matrix: allow_failures: - rvm: 2.0.0 - rvm: ruby-head - include: - rvm: 1.8.7 env: PUPPET_GEM_VERSION="~> 2.7" notifications: diff --git a/lib/puppet/parser/functions/abs.rb b/lib/puppet/parser/functions/abs.rb index 11d2d7fea..2533caf23 100644 --- a/lib/puppet/parser/functions/abs.rb +++ b/lib/puppet/parser/functions/abs.rb @@ -3,15 +3,12 @@ # module Puppet::Parser::Functions - newfunction(:abs, :type => :rvalue, :doc => <<-EOS + newfunction(:abs, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns the absolute value of a number, for example -34.56 becomes 34.56. Takes a single integer and float value as an argument. EOS ) do |arguments| - raise(Puppet::ParseError, "abs(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] # Numbers in Puppet are often string-encoded which is troublesome ... diff --git a/lib/puppet/parser/functions/any2array.rb b/lib/puppet/parser/functions/any2array.rb index e71407e89..072428088 100644 --- a/lib/puppet/parser/functions/any2array.rb +++ b/lib/puppet/parser/functions/any2array.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:any2array, :type => :rvalue, :doc => <<-EOS + newfunction(:any2array, :type => :rvalue, :arity => -1, :doc => <<-EOS This converts any object to an array containing that object. Empty argument lists are converted to an empty array. Arrays are left untouched. Hashes are converted to arrays of alternating keys and values. diff --git a/lib/puppet/parser/functions/base64.rb b/lib/puppet/parser/functions/base64.rb index d9a590aec..31077a2f4 100644 --- a/lib/puppet/parser/functions/base64.rb +++ b/lib/puppet/parser/functions/base64.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:base64, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:base64, :type => :rvalue, :arity => 2, :doc => <<-'ENDHEREDOC') do |args| Base64 encode or decode a string based on the command and the string submitted @@ -13,8 +13,6 @@ module Puppet::Parser::Functions require 'base64' - raise Puppet::ParseError, ("base64(): Wrong number of arguments (#{args.length}; must be = 2)") unless args.length == 2 - actions = ['encode','decode'] unless actions.include?(args[0]) diff --git a/lib/puppet/parser/functions/bool2num.rb b/lib/puppet/parser/functions/bool2num.rb index 9a07a8a11..54fa8d349 100644 --- a/lib/puppet/parser/functions/bool2num.rb +++ b/lib/puppet/parser/functions/bool2num.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS + newfunction(:bool2num, :type => :rvalue, :arity => 1, :doc => <<-EOS Converts a boolean to a number. Converts the values: false, f, 0, n, and no to 0 true, t, 1, y, and yes to 1 @@ -11,9 +11,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "bool2num(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/capitalize.rb b/lib/puppet/parser/functions/capitalize.rb index 640d00b82..2ddc7b24e 100644 --- a/lib/puppet/parser/functions/capitalize.rb +++ b/lib/puppet/parser/functions/capitalize.rb @@ -3,15 +3,12 @@ # module Puppet::Parser::Functions - newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS + newfunction(:capitalize, :type => :rvalue, :arity => 1, :doc => <<-EOS Capitalizes the first letter of a string or array of strings. Requires either a single string or an array as an input. EOS ) do |arguments| - raise(Puppet::ParseError, "capitalize(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/chomp.rb b/lib/puppet/parser/functions/chomp.rb index 4564a000a..7522db142 100644 --- a/lib/puppet/parser/functions/chomp.rb +++ b/lib/puppet/parser/functions/chomp.rb @@ -3,16 +3,13 @@ # module Puppet::Parser::Functions - newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS' + newfunction(:chomp, :type => :rvalue, :arity => 1, :doc => <<-'EOS' Removes the record separator from the end of a string or an array of strings, for example `hello\n` becomes `hello`. Requires a single string or array as an input. EOS ) do |arguments| - raise(Puppet::ParseError, "chomp(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/chop.rb b/lib/puppet/parser/functions/chop.rb index f242af39c..11e93b3b9 100644 --- a/lib/puppet/parser/functions/chop.rb +++ b/lib/puppet/parser/functions/chop.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:chop, :type => :rvalue, :doc => <<-'EOS' + newfunction(:chop, :type => :rvalue, :arity => 1, :doc => <<-'EOS' Returns a new string with the last character removed. If the string ends with `\r\n`, both characters are removed. Applying chop to an empty string returns an empty string. If you wish to merely remove record @@ -12,9 +12,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "chop(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/concat.rb b/lib/puppet/parser/functions/concat.rb index c86aa0057..50f4ae469 100644 --- a/lib/puppet/parser/functions/concat.rb +++ b/lib/puppet/parser/functions/concat.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:concat, :type => :rvalue, :doc => <<-EOS + newfunction(:concat, :type => :rvalue, :arity => 2, :doc => <<-EOS Appends the contents of array 2 onto array 1. *Example:* @@ -16,10 +16,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Check that 2 arguments have been given ... - raise(Puppet::ParseError, "concat(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size != 2 - a = arguments[0] b = arguments[1] diff --git a/lib/puppet/parser/functions/defined_with_params.rb b/lib/puppet/parser/functions/defined_with_params.rb index d7df306c7..45ae91880 100644 --- a/lib/puppet/parser/functions/defined_with_params.rb +++ b/lib/puppet/parser/functions/defined_with_params.rb @@ -3,6 +3,7 @@ Puppet::Parser::Functions.newfunction(:defined_with_params, :type => :rvalue, + :arity => -1, :doc => <<-'ENDOFDOC' Takes a resource reference and an optional hash of attributes. diff --git a/lib/puppet/parser/functions/delete.rb b/lib/puppet/parser/functions/delete.rb index f81434409..fdbb8e683 100644 --- a/lib/puppet/parser/functions/delete.rb +++ b/lib/puppet/parser/functions/delete.rb @@ -5,7 +5,7 @@ # TODO(Krzysztof Wilczynski): We need to add support for regular expression ... module Puppet::Parser::Functions - newfunction(:delete, :type => :rvalue, :doc => <<-EOS + newfunction(:delete, :type => :rvalue, :arity => 2, :doc => <<-EOS Deletes all instances of a given element from an array, substring from a string, or key from a hash. @@ -22,11 +22,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - if (arguments.size != 2) then - raise(Puppet::ParseError, "delete(): Wrong number of arguments "+ - "given #{arguments.size} for 2.") - end - collection = arguments[0] item = arguments[1] diff --git a/lib/puppet/parser/functions/delete_at.rb b/lib/puppet/parser/functions/delete_at.rb index 3eb4b5375..11633cd40 100644 --- a/lib/puppet/parser/functions/delete_at.rb +++ b/lib/puppet/parser/functions/delete_at.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS + newfunction(:delete_at, :type => :rvalue, :arity => 2, :doc => <<-EOS Deletes a determined indexed value from an array. *Examples:* @@ -14,9 +14,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "delete_at(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size < 2 - array = arguments[0] unless array.is_a?(Array) diff --git a/lib/puppet/parser/functions/delete_undef_values.rb b/lib/puppet/parser/functions/delete_undef_values.rb index 4eecab275..433e99ed5 100644 --- a/lib/puppet/parser/functions/delete_undef_values.rb +++ b/lib/puppet/parser/functions/delete_undef_values.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-EOS + newfunction(:delete_undef_values, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns a copy of input hash or array with all undefs deleted. *Examples:* @@ -15,10 +15,6 @@ module Puppet::Parser::Functions EOS ) do |args| - raise(Puppet::ParseError, - "delete_undef_values(): Wrong number of arguments given " + - "(#{args.size})") if args.size < 1 - result = args[0] if result.is_a?(Hash) result.delete_if {|key, val| val.equal? :undef} diff --git a/lib/puppet/parser/functions/delete_values.rb b/lib/puppet/parser/functions/delete_values.rb index 17b9d375e..240d9f306 100644 --- a/lib/puppet/parser/functions/delete_values.rb +++ b/lib/puppet/parser/functions/delete_values.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:delete_values, :type => :rvalue, :doc => <<-EOS + newfunction(:delete_values, :type => :rvalue, :arity => 2, :doc => <<-EOS Deletes all instances of a given value from a hash. *Examples:* @@ -11,10 +11,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, - "delete_values(): Wrong number of arguments given " + - "(#{arguments.size} of 2)") if arguments.size != 2 - hash, item = arguments if not hash.is_a?(Hash) diff --git a/lib/puppet/parser/functions/difference.rb b/lib/puppet/parser/functions/difference.rb index cd258f751..ac4758517 100644 --- a/lib/puppet/parser/functions/difference.rb +++ b/lib/puppet/parser/functions/difference.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:difference, :type => :rvalue, :doc => <<-EOS + newfunction(:difference, :type => :rvalue, :arity => 2, :doc => <<-EOS This function returns the difference between two arrays. The returned array is a copy of the original array, removing any items that also appear in the second array. @@ -16,10 +16,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Two arguments are required - raise(Puppet::ParseError, "difference(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size != 2 - first = arguments[0] second = arguments[1] diff --git a/lib/puppet/parser/functions/dirname.rb b/lib/puppet/parser/functions/dirname.rb index ea8cc1e08..eef575193 100644 --- a/lib/puppet/parser/functions/dirname.rb +++ b/lib/puppet/parser/functions/dirname.rb @@ -1,12 +1,9 @@ module Puppet::Parser::Functions - newfunction(:dirname, :type => :rvalue, :doc => <<-EOS + newfunction(:dirname, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns the dirname of a path. EOS ) do |arguments| - raise(Puppet::ParseError, "dirname(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - path = arguments[0] return File.dirname(path) end diff --git a/lib/puppet/parser/functions/downcase.rb b/lib/puppet/parser/functions/downcase.rb index 4066d210f..76734d789 100644 --- a/lib/puppet/parser/functions/downcase.rb +++ b/lib/puppet/parser/functions/downcase.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:downcase, :type => :rvalue, :doc => <<-EOS + newfunction(:downcase, :type => :rvalue, :arity => 1, :doc => <<-EOS Converts the case of a string or all strings in an array to lower case. EOS ) do |arguments| - raise(Puppet::ParseError, "downcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/empty.rb b/lib/puppet/parser/functions/empty.rb index 80ebb86b8..76dfe4f98 100644 --- a/lib/puppet/parser/functions/empty.rb +++ b/lib/puppet/parser/functions/empty.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:empty, :type => :rvalue, :doc => <<-EOS + newfunction(:empty, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the variable is empty. EOS ) do |arguments| diff --git a/lib/puppet/parser/functions/ensure_packages.rb b/lib/puppet/parser/functions/ensure_packages.rb index 450ea026d..c65ed472a 100644 --- a/lib/puppet/parser/functions/ensure_packages.rb +++ b/lib/puppet/parser/functions/ensure_packages.rb @@ -4,13 +4,11 @@ require 'puppet/parser/functions' module Puppet::Parser::Functions - newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS + newfunction(:ensure_packages, :type => :statement, :arity => 1, :doc => <<-EOS Takes a list of packages and only installs them if they don't already exist. EOS ) do |arguments| - raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 raise(Puppet::ParseError, "ensure_packages(): Requires array " + "given (#{arguments[0].class})") if !arguments[0].kind_of?(Array) diff --git a/lib/puppet/parser/functions/ensure_resource.rb b/lib/puppet/parser/functions/ensure_resource.rb index 05e5593fc..7b51b98d4 100644 --- a/lib/puppet/parser/functions/ensure_resource.rb +++ b/lib/puppet/parser/functions/ensure_resource.rb @@ -3,6 +3,7 @@ Puppet::Parser::Functions.newfunction(:ensure_resource, :type => :statement, + :arity => -3, :doc => <<-'ENDOFDOC' Takes a resource type, title, and a list of attributes that describe a resource. @@ -27,8 +28,6 @@ ENDOFDOC ) do |vals| type, title, params = vals - raise(ArgumentError, 'Must specify a type') unless type - raise(ArgumentError, 'Must specify a title') unless title params ||= {} items = [title].flatten diff --git a/lib/puppet/parser/functions/flatten.rb b/lib/puppet/parser/functions/flatten.rb index a1ed18329..2546ff74b 100644 --- a/lib/puppet/parser/functions/flatten.rb +++ b/lib/puppet/parser/functions/flatten.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:flatten, :type => :rvalue, :doc => <<-EOS + newfunction(:flatten, :type => :rvalue, :arity => 1, :doc => <<-EOS This function flattens any deeply nested arrays and returns a single flat array as a result. @@ -15,9 +15,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "flatten(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - array = arguments[0] unless array.is_a?(Array) diff --git a/lib/puppet/parser/functions/floor.rb b/lib/puppet/parser/functions/floor.rb index a40192349..e0ccc79b1 100644 --- a/lib/puppet/parser/functions/floor.rb +++ b/lib/puppet/parser/functions/floor.rb @@ -1,13 +1,10 @@ module Puppet::Parser::Functions - newfunction(:floor, :type => :rvalue, :doc => <<-EOS + newfunction(:floor, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns the largest integer less or equal to the argument. Takes a single numeric value as an argument. EOS ) do |arguments| - raise(Puppet::ParseError, "floor(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - arg = arguments[0] raise(Puppet::ParseError, "floor(): Wrong argument type " + diff --git a/lib/puppet/parser/functions/fqdn_rotate.rb b/lib/puppet/parser/functions/fqdn_rotate.rb index 655820605..383a49fe2 100644 --- a/lib/puppet/parser/functions/fqdn_rotate.rb +++ b/lib/puppet/parser/functions/fqdn_rotate.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:fqdn_rotate, :type => :rvalue, :doc => <<-EOS + newfunction(:fqdn_rotate, :type => :rvalue, :arity => 1, :doc => <<-EOS Rotates an array a random number of times based on a nodes fqdn. EOS ) do |arguments| - raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class require 'digest/md5' diff --git a/lib/puppet/parser/functions/get_module_path.rb b/lib/puppet/parser/functions/get_module_path.rb index 1421b91f5..fa0b5c7bb 100644 --- a/lib/puppet/parser/functions/get_module_path.rb +++ b/lib/puppet/parser/functions/get_module_path.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:get_module_path, :type =>:rvalue, :doc => <<-EOT + newfunction(:get_module_path, :type =>:rvalue, :arity => 1, :doc => <<-EOT Returns the absolute path of the specified module for the current environment. @@ -7,7 +7,6 @@ module Puppet::Parser::Functions $module_path = get_module_path('stdlib') EOT ) do |args| - raise(Puppet::ParseError, "get_module_path(): Wrong number of arguments, expects one") unless args.size == 1 if module_path = Puppet::Module.find(args[0], compiler.environment.to_s) module_path.path else diff --git a/lib/puppet/parser/functions/getparam.rb b/lib/puppet/parser/functions/getparam.rb index 6d510069f..ae1327839 100644 --- a/lib/puppet/parser/functions/getparam.rb +++ b/lib/puppet/parser/functions/getparam.rb @@ -3,6 +3,7 @@ Puppet::Parser::Functions.newfunction(:getparam, :type => :rvalue, + :arity => 2, :doc => <<-'ENDOFDOC' Takes a resource reference and name of the parameter and returns value of resource's parameter. @@ -22,7 +23,6 @@ ENDOFDOC ) do |vals| reference, param = vals - raise(ArgumentError, 'Must specify a reference') unless reference raise(ArgumentError, 'Must specify name of a parameter') unless param and param.instance_of? String return '' if param.empty? diff --git a/lib/puppet/parser/functions/getvar.rb b/lib/puppet/parser/functions/getvar.rb index 162114995..80d2922e4 100644 --- a/lib/puppet/parser/functions/getvar.rb +++ b/lib/puppet/parser/functions/getvar.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:getvar, :type => :rvalue, :arity => 1, :doc => <<-'ENDHEREDOC') do |args| Lookup a variable in a remote namespace. For example: @@ -15,10 +15,6 @@ module Puppet::Parser::Functions # Equivalent to $bar = $site::data::bar ENDHEREDOC - unless args.length == 1 - raise Puppet::ParseError, ("getvar(): wrong number of arguments (#{args.length}; must be 1)") - end - self.lookupvar("#{args[0]}") end diff --git a/lib/puppet/parser/functions/grep.rb b/lib/puppet/parser/functions/grep.rb index ceba9ecc8..9e3bf9f1f 100644 --- a/lib/puppet/parser/functions/grep.rb +++ b/lib/puppet/parser/functions/grep.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:grep, :type => :rvalue, :doc => <<-EOS + newfunction(:grep, :type => :rvalue, :arity => 2, :doc => <<-EOS This function searches through an array and returns any elements that match the provided regular expression. @@ -17,11 +17,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - if (arguments.size != 2) then - raise(Puppet::ParseError, "grep(): Wrong number of arguments "+ - "given #{arguments.size} for 2") - end - a = arguments[0] pattern = Regexp.new(arguments[1]) diff --git a/lib/puppet/parser/functions/has_interface_with.rb b/lib/puppet/parser/functions/has_interface_with.rb index 7f150a717..6722bffb1 100644 --- a/lib/puppet/parser/functions/has_interface_with.rb +++ b/lib/puppet/parser/functions/has_interface_with.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:has_interface_with, :type => :rvalue, :doc => <<-EOS + newfunction(:has_interface_with, :type => :rvalue, :arity => -2, :doc => <<-EOS Returns boolean based on kind and value: * macaddress * netmask @@ -19,8 +19,8 @@ module Puppet::Parser::Functions EOS ) do |args| - raise(Puppet::ParseError, "has_interface_with(): Wrong number of arguments " + - "given (#{args.size} for 1 or 2)") if args.size < 1 or args.size > 2 + raise(ArgumentError, "has_interface_with(): Wrong number of arguments " + + "given (#{args.size} for 1 or 2)") if args.size > 2 interfaces = lookupvar('interfaces') diff --git a/lib/puppet/parser/functions/has_ip_address.rb b/lib/puppet/parser/functions/has_ip_address.rb index 842c8ec67..78530cbe5 100644 --- a/lib/puppet/parser/functions/has_ip_address.rb +++ b/lib/puppet/parser/functions/has_ip_address.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:has_ip_address, :type => :rvalue, :doc => <<-EOS + newfunction(:has_ip_address, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the client has the requested IP address on some interface. This function iterates through the 'interfaces' fact and checks the @@ -11,9 +11,6 @@ module Puppet::Parser::Functions EOS ) do |args| - raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size != 1 - Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) diff --git a/lib/puppet/parser/functions/has_ip_network.rb b/lib/puppet/parser/functions/has_ip_network.rb index 9ccf9024f..b091cb81d 100644 --- a/lib/puppet/parser/functions/has_ip_network.rb +++ b/lib/puppet/parser/functions/has_ip_network.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:has_ip_network, :type => :rvalue, :doc => <<-EOS + newfunction(:has_ip_network, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the client has an IP address within the requested network. This function iterates through the 'interfaces' fact and checks the @@ -11,9 +11,6 @@ module Puppet::Parser::Functions EOS ) do |args| - raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size != 1 - Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) diff --git a/lib/puppet/parser/functions/has_key.rb b/lib/puppet/parser/functions/has_key.rb index 4657cc29c..d6239a28f 100644 --- a/lib/puppet/parser/functions/has_key.rb +++ b/lib/puppet/parser/functions/has_key.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:has_key, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:has_key, :type => :rvalue, :arity => 2, :doc => <<-'ENDHEREDOC') do |args| Determine if a hash has a certain key value. Example: @@ -15,9 +15,6 @@ module Puppet::Parser::Functions ENDHEREDOC - unless args.length == 2 - raise Puppet::ParseError, ("has_key(): wrong number of arguments (#{args.length}; must be 2)") - end unless args[0].is_a?(Hash) raise Puppet::ParseError, "has_key(): expects the first argument to be a hash, got #{args[0].inspect} which is of type #{args[0].class}" end diff --git a/lib/puppet/parser/functions/hash.rb b/lib/puppet/parser/functions/hash.rb index 8cc4823be..911d66619 100644 --- a/lib/puppet/parser/functions/hash.rb +++ b/lib/puppet/parser/functions/hash.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:hash, :type => :rvalue, :doc => <<-EOS + newfunction(:hash, :type => :rvalue, :arity => 1, :doc => <<-EOS This function converts an array into a hash. *Examples:* @@ -14,9 +14,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "hash(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - array = arguments[0] unless array.is_a?(Array) diff --git a/lib/puppet/parser/functions/intersection.rb b/lib/puppet/parser/functions/intersection.rb index 48f02e9d3..1775510dd 100644 --- a/lib/puppet/parser/functions/intersection.rb +++ b/lib/puppet/parser/functions/intersection.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:intersection, :type => :rvalue, :doc => <<-EOS + newfunction(:intersection, :type => :rvalue, :arity => 2, :doc => <<-EOS This function returns an array an intersection of two. *Examples:* @@ -14,10 +14,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Two arguments are required - raise(Puppet::ParseError, "intersection(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size != 2 - first = arguments[0] second = arguments[1] diff --git a/lib/puppet/parser/functions/is_array.rb b/lib/puppet/parser/functions/is_array.rb index b39e184ae..677b7dcca 100644 --- a/lib/puppet/parser/functions/is_array.rb +++ b/lib/puppet/parser/functions/is_array.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:is_array, :type => :rvalue, :doc => <<-EOS + newfunction(:is_array, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the variable passed to this function is an array. EOS ) do |arguments| - raise(Puppet::ParseError, "is_array(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - type = arguments[0] result = type.is_a?(Array) diff --git a/lib/puppet/parser/functions/is_domain_name.rb b/lib/puppet/parser/functions/is_domain_name.rb index 5826dc0d9..f0e2e4087 100644 --- a/lib/puppet/parser/functions/is_domain_name.rb +++ b/lib/puppet/parser/functions/is_domain_name.rb @@ -3,16 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:is_domain_name, :type => :rvalue, :doc => <<-EOS + newfunction(:is_domain_name, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the string passed to this function is a syntactically correct domain name. EOS ) do |arguments| - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - domain = arguments[0] # Limits (rfc1035, 3.1) diff --git a/lib/puppet/parser/functions/is_float.rb b/lib/puppet/parser/functions/is_float.rb index 911f3c2dc..e92a94dde 100644 --- a/lib/puppet/parser/functions/is_float.rb +++ b/lib/puppet/parser/functions/is_float.rb @@ -3,16 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:is_float, :type => :rvalue, :doc => <<-EOS + newfunction(:is_float, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the variable passed to this function is a float. EOS ) do |arguments| - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - value = arguments[0] if value != value.to_f.to_s and !value.is_a? Float then diff --git a/lib/puppet/parser/functions/is_function_available.rb b/lib/puppet/parser/functions/is_function_available.rb index 6cbd35c3d..0affc1704 100644 --- a/lib/puppet/parser/functions/is_function_available.rb +++ b/lib/puppet/parser/functions/is_function_available.rb @@ -3,18 +3,13 @@ # module Puppet::Parser::Functions - newfunction(:is_function_available, :type => :rvalue, :doc => <<-EOS + newfunction(:is_function_available, :type => :rvalue, :arity => 1, :doc => <<-EOS This function accepts a string as an argument, determines whether the Puppet runtime has access to a function by that name. It returns a true if the function exists, false if not. EOS ) do |arguments| - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - function = Puppet::Parser::Functions.function(arguments[0].to_sym) function.is_a?(String) and not function.empty? end diff --git a/lib/puppet/parser/functions/is_hash.rb b/lib/puppet/parser/functions/is_hash.rb index ad907f086..48eee7f21 100644 --- a/lib/puppet/parser/functions/is_hash.rb +++ b/lib/puppet/parser/functions/is_hash.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:is_hash, :type => :rvalue, :doc => <<-EOS + newfunction(:is_hash, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the variable passed to this function is a hash. EOS ) do |arguments| - raise(Puppet::ParseError, "is_hash(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - type = arguments[0] result = type.is_a?(Hash) diff --git a/lib/puppet/parser/functions/is_integer.rb b/lib/puppet/parser/functions/is_integer.rb index 6b29e988e..543f83062 100644 --- a/lib/puppet/parser/functions/is_integer.rb +++ b/lib/puppet/parser/functions/is_integer.rb @@ -3,16 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:is_integer, :type => :rvalue, :doc => <<-EOS + newfunction(:is_integer, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the variable returned to this string is an integer. EOS ) do |arguments| - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_integer(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - value = arguments[0] if value != value.to_i.to_s and !value.is_a? Fixnum then diff --git a/lib/puppet/parser/functions/is_ip_address.rb b/lib/puppet/parser/functions/is_ip_address.rb index a90adabe1..99568126b 100644 --- a/lib/puppet/parser/functions/is_ip_address.rb +++ b/lib/puppet/parser/functions/is_ip_address.rb @@ -3,18 +3,13 @@ # module Puppet::Parser::Functions - newfunction(:is_ip_address, :type => :rvalue, :doc => <<-EOS + newfunction(:is_ip_address, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the string passed to this function is a valid IP address. EOS ) do |arguments| require 'ipaddr' - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - begin ip = IPAddr.new(arguments[0]) rescue ArgumentError diff --git a/lib/puppet/parser/functions/is_mac_address.rb b/lib/puppet/parser/functions/is_mac_address.rb index 1b3088a26..09d9c00dc 100644 --- a/lib/puppet/parser/functions/is_mac_address.rb +++ b/lib/puppet/parser/functions/is_mac_address.rb @@ -3,16 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS + newfunction(:is_mac_address, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the string passed to this function is a valid mac address. EOS ) do |arguments| - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - mac = arguments[0] if /^[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}$/.match(mac) then diff --git a/lib/puppet/parser/functions/is_numeric.rb b/lib/puppet/parser/functions/is_numeric.rb index abf03213c..c8c9a1b10 100644 --- a/lib/puppet/parser/functions/is_numeric.rb +++ b/lib/puppet/parser/functions/is_numeric.rb @@ -3,16 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS + newfunction(:is_numeric, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the variable passed to this function is a number. EOS ) do |arguments| - if (arguments.size != 1) then - raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - value = arguments[0] if value == value.to_f.to_s or value == value.to_i.to_s or value.is_a? Numeric then diff --git a/lib/puppet/parser/functions/is_string.rb b/lib/puppet/parser/functions/is_string.rb index f5bef0457..78fba9dce 100644 --- a/lib/puppet/parser/functions/is_string.rb +++ b/lib/puppet/parser/functions/is_string.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:is_string, :type => :rvalue, :doc => <<-EOS + newfunction(:is_string, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the variable passed to this function is a string. EOS ) do |arguments| - raise(Puppet::ParseError, "is_string(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - type = arguments[0] result = type.is_a?(String) diff --git a/lib/puppet/parser/functions/join.rb b/lib/puppet/parser/functions/join.rb index 005a46ea5..20614e632 100644 --- a/lib/puppet/parser/functions/join.rb +++ b/lib/puppet/parser/functions/join.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:join, :type => :rvalue, :doc => <<-EOS + newfunction(:join, :type => :rvalue, :arity => -2, :doc => <<-EOS This function joins an array into a string using a seperator. *Examples:* @@ -14,10 +14,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "join(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - array = arguments[0] unless array.is_a?(Array) diff --git a/lib/puppet/parser/functions/join_keys_to_values.rb b/lib/puppet/parser/functions/join_keys_to_values.rb index e9924fe2e..bd79dbe13 100644 --- a/lib/puppet/parser/functions/join_keys_to_values.rb +++ b/lib/puppet/parser/functions/join_keys_to_values.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-EOS + newfunction(:join_keys_to_values, :type => :rvalue, :arity => 2, :doc => <<-EOS This function joins each key of a hash to that key's corresponding value with a separator. Keys and values are cast to strings. The return value is an array in which each element is one joined key/value pair. @@ -16,12 +16,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Validate the number of arguments. - if arguments.size != 2 - raise(Puppet::ParseError, "join_keys_to_values(): Takes exactly two " + - "arguments, but #{arguments.size} given.") - end - # Validate the first argument. hash = arguments[0] if not hash.is_a?(Hash) diff --git a/lib/puppet/parser/functions/keys.rb b/lib/puppet/parser/functions/keys.rb index f0d13b647..60d5f45a7 100644 --- a/lib/puppet/parser/functions/keys.rb +++ b/lib/puppet/parser/functions/keys.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:keys, :type => :rvalue, :doc => <<-EOS + newfunction(:keys, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns the keys of a hash as an array. EOS ) do |arguments| - raise(Puppet::ParseError, "keys(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - hash = arguments[0] unless hash.is_a?(Hash) diff --git a/lib/puppet/parser/functions/loadyaml.rb b/lib/puppet/parser/functions/loadyaml.rb index 10c400501..728267933 100644 --- a/lib/puppet/parser/functions/loadyaml.rb +++ b/lib/puppet/parser/functions/loadyaml.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:loadyaml, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:loadyaml, :type => :rvalue, :arity => 1, :doc => <<-'ENDHEREDOC') do |args| Load a YAML file containing an array, string, or hash, and return the data in the corresponding native data type. @@ -9,10 +9,6 @@ module Puppet::Parser::Functions $myhash = loadyaml('/etc/puppet/data/myhash.yaml') ENDHEREDOC - unless args.length == 1 - raise Puppet::ParseError, ("loadyaml(): wrong number of arguments (#{args.length}; must be 1)") - end - YAML.load_file(args[0]) end diff --git a/lib/puppet/parser/functions/lstrip.rb b/lib/puppet/parser/functions/lstrip.rb index 3a64de337..1d84ccbcc 100644 --- a/lib/puppet/parser/functions/lstrip.rb +++ b/lib/puppet/parser/functions/lstrip.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:lstrip, :type => :rvalue, :doc => <<-EOS + newfunction(:lstrip, :type => :rvalue, :arity => 1, :doc => <<-EOS Strips leading spaces to the left of a string. EOS ) do |arguments| - raise(Puppet::ParseError, "lstrip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/max.rb b/lib/puppet/parser/functions/max.rb index 60fb94ac0..9b390cd47 100644 --- a/lib/puppet/parser/functions/max.rb +++ b/lib/puppet/parser/functions/max.rb @@ -1,13 +1,10 @@ module Puppet::Parser::Functions - newfunction(:max, :type => :rvalue, :doc => <<-EOS + newfunction(:max, :type => :rvalue, :arity => -2, :doc => <<-EOS Returns the highest value of all arguments. Requires at least one argument. EOS ) do |args| - raise(Puppet::ParseError, "max(): Wrong number of arguments " + - "need at least one") if args.size == 0 - # Sometimes we get numbers as numerics and sometimes as strings. # We try to compare them as numbers when possible return args.max do |a,b| diff --git a/lib/puppet/parser/functions/member.rb b/lib/puppet/parser/functions/member.rb index 43d76affd..4132a648a 100644 --- a/lib/puppet/parser/functions/member.rb +++ b/lib/puppet/parser/functions/member.rb @@ -6,7 +6,7 @@ # TODO(Krzysztof Wilczynski): Support for strings and hashes too ... module Puppet::Parser::Functions - newfunction(:member, :type => :rvalue, :doc => <<-EOS + newfunction(:member, :type => :rvalue, :arity => 2, :doc => <<-EOS This function determines if a variable is a member of an array. *Examples:* @@ -21,9 +21,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "member(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size < 2 - array = arguments[0] unless array.is_a?(Array) diff --git a/lib/puppet/parser/functions/merge.rb b/lib/puppet/parser/functions/merge.rb index 1b39f2060..70eb7d8fb 100644 --- a/lib/puppet/parser/functions/merge.rb +++ b/lib/puppet/parser/functions/merge.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:merge, :type => :rvalue, :arity => -3, :doc => <<-'ENDHEREDOC') do |args| Merges two or more hashes together and returns the resulting hash. For example: @@ -14,10 +14,6 @@ module Puppet::Parser::Functions ENDHEREDOC - if args.length < 2 - raise Puppet::ParseError, ("merge(): wrong number of arguments (#{args.length}; must be at least 2)") - end - # The hash we accumulate into accumulator = Hash.new # Merge into the accumulator hash diff --git a/lib/puppet/parser/functions/min.rb b/lib/puppet/parser/functions/min.rb index 6bd6ebf20..030edc8fa 100644 --- a/lib/puppet/parser/functions/min.rb +++ b/lib/puppet/parser/functions/min.rb @@ -1,13 +1,10 @@ module Puppet::Parser::Functions - newfunction(:min, :type => :rvalue, :doc => <<-EOS + newfunction(:min, :type => :rvalue, :arity => -2, :doc => <<-EOS Returns the lowest value of all arguments. Requires at least one argument. EOS ) do |args| - raise(Puppet::ParseError, "min(): Wrong number of arguments " + - "need at least one") if args.size == 0 - # Sometimes we get numbers as numerics and sometimes as strings. # We try to compare them as numbers when possible return args.min do |a,b| diff --git a/lib/puppet/parser/functions/num2bool.rb b/lib/puppet/parser/functions/num2bool.rb index af0e6ed78..43b7e7f49 100644 --- a/lib/puppet/parser/functions/num2bool.rb +++ b/lib/puppet/parser/functions/num2bool.rb @@ -3,16 +3,13 @@ # module Puppet::Parser::Functions - newfunction(:num2bool, :type => :rvalue, :doc => <<-EOS + newfunction(:num2bool, :type => :rvalue, :arity => 1, :doc => <<-EOS This function converts a number or a string representation of a number into a true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0 become true. EOS ) do |arguments| - raise(Puppet::ParseError, "num2bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - number = arguments[0] case number diff --git a/lib/puppet/parser/functions/parsejson.rb b/lib/puppet/parser/functions/parsejson.rb index a9a16a452..3bb117e1e 100644 --- a/lib/puppet/parser/functions/parsejson.rb +++ b/lib/puppet/parser/functions/parsejson.rb @@ -3,17 +3,12 @@ # module Puppet::Parser::Functions - newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS + newfunction(:parsejson, :type => :rvalue, :arity => 1, :doc => <<-EOS This function accepts JSON as a string and converts into the correct Puppet structure. EOS ) do |arguments| - if (arguments.size != 1) then - raise(Puppet::ParseError, "parsejson(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - json = arguments[0] # PSON is natively available in puppet diff --git a/lib/puppet/parser/functions/parseyaml.rb b/lib/puppet/parser/functions/parseyaml.rb index 53d54faff..67d30c9dc 100644 --- a/lib/puppet/parser/functions/parseyaml.rb +++ b/lib/puppet/parser/functions/parseyaml.rb @@ -3,17 +3,12 @@ # module Puppet::Parser::Functions - newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS + newfunction(:parseyaml, :type => :rvalue, :arity => 1, :doc => <<-EOS This function accepts YAML as a string and converts it into the correct Puppet structure. EOS ) do |arguments| - if (arguments.size != 1) then - raise(Puppet::ParseError, "parseyaml(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - require 'yaml' YAML::load(arguments[0]) diff --git a/lib/puppet/parser/functions/pick.rb b/lib/puppet/parser/functions/pick.rb index cbc030021..f455b6255 100644 --- a/lib/puppet/parser/functions/pick.rb +++ b/lib/puppet/parser/functions/pick.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:pick, :type => :rvalue, :doc => <<-EOS + newfunction(:pick, :type => :rvalue, :arity => -2, :doc => <<-EOS This function is similar to a coalesce function in SQL in that it will return the first value in a list of values that is not undefined or an empty string diff --git a/lib/puppet/parser/functions/prefix.rb b/lib/puppet/parser/functions/prefix.rb index 62211ae68..95247662a 100644 --- a/lib/puppet/parser/functions/prefix.rb +++ b/lib/puppet/parser/functions/prefix.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:prefix, :type => :rvalue, :doc => <<-EOS + newfunction(:prefix, :type => :rvalue, :arity => -2, :doc => <<-EOS This function applies a prefix to all elements in an array. *Examples:* @@ -14,10 +14,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "prefix(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - array = arguments[0] unless array.is_a?(Array) diff --git a/lib/puppet/parser/functions/range.rb b/lib/puppet/parser/functions/range.rb index 0849491ac..6f58d703d 100644 --- a/lib/puppet/parser/functions/range.rb +++ b/lib/puppet/parser/functions/range.rb @@ -5,7 +5,7 @@ # TODO(Krzysztof Wilczynski): We probably need to approach numeric values differently ... module Puppet::Parser::Functions - newfunction(:range, :type => :rvalue, :doc => <<-EOS + newfunction(:range, :type => :rvalue, :arity => -2, :doc => <<-EOS When given range in the form of (start, stop) it will extrapolate a range as an array. @@ -37,10 +37,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # We support more than one argument but at least one is mandatory ... - raise(Puppet::ParseError, "range(): Wrong number of " + - "arguments given (#{arguments.size} for 1)") if arguments.size < 1 - if arguments.size > 1 start = arguments[0] stop = arguments[1] @@ -48,7 +44,7 @@ module Puppet::Parser::Functions type = '..' # We select simplest type for Range available in Ruby ... - elsif arguments.size > 0 + else value = arguments[0] if m = value.match(/^(\w+)(\.\.\.?|\-)(\w+)$/) diff --git a/lib/puppet/parser/functions/reject.rb b/lib/puppet/parser/functions/reject.rb index 1953ffcf1..4d8d45a7a 100644 --- a/lib/puppet/parser/functions/reject.rb +++ b/lib/puppet/parser/functions/reject.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:reject, :type => :rvalue, :doc => <<-EOS) do |args| + newfunction(:reject, :type => :rvalue, :arity => 2, :doc => <<-EOS) do |args| This function searches through an array and rejects all elements that match the provided regular expression. @@ -16,11 +16,6 @@ module Puppet::Parser::Functions ['bbb','ccc'] EOS - if (args.size != 2) - raise Puppet::ParseError, - "reject(): Wrong number of arguments given #{args.size} for 2" - end - ary = args[0] pattern = Regexp.new(args[1]) diff --git a/lib/puppet/parser/functions/reverse.rb b/lib/puppet/parser/functions/reverse.rb index fe048690c..2e85e7adc 100644 --- a/lib/puppet/parser/functions/reverse.rb +++ b/lib/puppet/parser/functions/reverse.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:reverse, :type => :rvalue, :doc => <<-EOS + newfunction(:reverse, :type => :rvalue, :arity => 1, :doc => <<-EOS Reverses the order of a string or array. EOS ) do |arguments| - raise(Puppet::ParseError, "reverse(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/rstrip.rb b/lib/puppet/parser/functions/rstrip.rb index 29b099820..6591f4acf 100644 --- a/lib/puppet/parser/functions/rstrip.rb +++ b/lib/puppet/parser/functions/rstrip.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:rstrip, :type => :rvalue, :doc => <<-EOS + newfunction(:rstrip, :type => :rvalue, :arity => 1, :doc => <<-EOS Strips leading spaces to the right of the string. EOS ) do |arguments| - raise(Puppet::ParseError, "rstrip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/shuffle.rb b/lib/puppet/parser/functions/shuffle.rb index 18134ab63..a78ca27f6 100644 --- a/lib/puppet/parser/functions/shuffle.rb +++ b/lib/puppet/parser/functions/shuffle.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:shuffle, :type => :rvalue, :doc => <<-EOS + newfunction(:shuffle, :type => :rvalue, :arity => 1, :doc => <<-EOS Randomizes the order of a string or array elements. EOS ) do |arguments| - raise(Puppet::ParseError, "shuffle(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/size.rb b/lib/puppet/parser/functions/size.rb index cc207e3fa..fe48c75e1 100644 --- a/lib/puppet/parser/functions/size.rb +++ b/lib/puppet/parser/functions/size.rb @@ -5,14 +5,11 @@ # TODO(Krzysztof Wilczynski): Support for hashes would be nice too ... module Puppet::Parser::Functions - newfunction(:size, :type => :rvalue, :doc => <<-EOS + newfunction(:size, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns the number of elements in a string or array. EOS ) do |arguments| - raise(Puppet::ParseError, "size(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - item = arguments[0] if item.is_a?(String) diff --git a/lib/puppet/parser/functions/sort.rb b/lib/puppet/parser/functions/sort.rb index cefbe5463..cc38d5842 100644 --- a/lib/puppet/parser/functions/sort.rb +++ b/lib/puppet/parser/functions/sort.rb @@ -3,16 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:sort, :type => :rvalue, :doc => <<-EOS + newfunction(:sort, :type => :rvalue, :arity => 1, :doc => <<-EOS Sorts strings and arrays lexically. EOS ) do |arguments| - if (arguments.size != 1) then - raise(Puppet::ParseError, "sort(): Wrong number of arguments "+ - "given #{arguments.size} for 1") - end - value = arguments[0] if value.is_a?(Array) then diff --git a/lib/puppet/parser/functions/squeeze.rb b/lib/puppet/parser/functions/squeeze.rb index 81fadfdb2..b420f4fff 100644 --- a/lib/puppet/parser/functions/squeeze.rb +++ b/lib/puppet/parser/functions/squeeze.rb @@ -3,13 +3,13 @@ # module Puppet::Parser::Functions - newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS + newfunction(:squeeze, :type => :rvalue, :arity => -2, :doc => <<-EOS Returns a new string where runs of the same character that occur in this set are replaced by a single character. EOS ) do |arguments| - if ((arguments.size != 2) and (arguments.size != 1)) then - raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+ + if (arguments.size > 2) then + raise(ArgumentError, "squeeze(): Wrong number of arguments "+ "given #{arguments.size} for 2 or 1") end diff --git a/lib/puppet/parser/functions/str2bool.rb b/lib/puppet/parser/functions/str2bool.rb index fece7a6f2..679cbec05 100644 --- a/lib/puppet/parser/functions/str2bool.rb +++ b/lib/puppet/parser/functions/str2bool.rb @@ -3,16 +3,13 @@ # module Puppet::Parser::Functions - newfunction(:str2bool, :type => :rvalue, :doc => <<-EOS + newfunction(:str2bool, :type => :rvalue, :arity => 1, :doc => <<-EOS This converts a string to a boolean. This attempt to convert strings that contain things like: y, 1, t, true to 'true' and strings that contain things like: 0, f, n, false, no to 'false'. EOS ) do |arguments| - raise(Puppet::ParseError, "str2bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - string = arguments[0] # If string is already Boolean, return it diff --git a/lib/puppet/parser/functions/str2saltedsha512.rb b/lib/puppet/parser/functions/str2saltedsha512.rb index 7fe7b0128..89d83c4b9 100644 --- a/lib/puppet/parser/functions/str2saltedsha512.rb +++ b/lib/puppet/parser/functions/str2saltedsha512.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-EOS + newfunction(:str2saltedsha512, :type => :rvalue, :arity => 1, :doc => <<-EOS This converts a string to a salted-SHA512 password hash (which is used for OS X versions >= 10.7). Given any simple string, you will get a hex version of a salted-SHA512 password hash that can be inserted into your Puppet @@ -12,9 +12,6 @@ module Puppet::Parser::Functions ) do |arguments| require 'digest/sha2' - raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments " + - "passed (#{arguments.size} but we require 1)") if arguments.size != 1 - password = arguments[0] unless password.is_a?(String) diff --git a/lib/puppet/parser/functions/strftime.rb b/lib/puppet/parser/functions/strftime.rb index 0b52adecd..753aef327 100644 --- a/lib/puppet/parser/functions/strftime.rb +++ b/lib/puppet/parser/functions/strftime.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:strftime, :type => :rvalue, :doc => <<-EOS + newfunction(:strftime, :type => :rvalue, :arity => -2, :doc => <<-EOS This function returns formatted time. *Examples:* @@ -70,10 +70,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "strftime(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - format = arguments[0] raise(Puppet::ParseError, 'strftime(): You must provide ' + diff --git a/lib/puppet/parser/functions/strip.rb b/lib/puppet/parser/functions/strip.rb index 5f4630d7d..e97cceffb 100644 --- a/lib/puppet/parser/functions/strip.rb +++ b/lib/puppet/parser/functions/strip.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:strip, :type => :rvalue, :doc => <<-EOS + newfunction(:strip, :type => :rvalue, :arity => 1, :doc => <<-EOS This function removes leading and trailing whitespace from a string or from every string inside an array. @@ -15,9 +15,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "strip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/suffix.rb b/lib/puppet/parser/functions/suffix.rb index f7792d6f7..03d810224 100644 --- a/lib/puppet/parser/functions/suffix.rb +++ b/lib/puppet/parser/functions/suffix.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:suffix, :type => :rvalue, :doc => <<-EOS + newfunction(:suffix, :type => :rvalue, :arity => -2, :doc => <<-EOS This function applies a suffix to all elements in an array. *Examples:* @@ -14,10 +14,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "suffix(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - array = arguments[0] unless array.is_a?(Array) diff --git a/lib/puppet/parser/functions/swapcase.rb b/lib/puppet/parser/functions/swapcase.rb index b9e663253..2e987b24a 100644 --- a/lib/puppet/parser/functions/swapcase.rb +++ b/lib/puppet/parser/functions/swapcase.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:swapcase, :type => :rvalue, :doc => <<-EOS + newfunction(:swapcase, :type => :rvalue, :arity => 1, :doc => <<-EOS This function will swap the existing case of a string. *Examples:* @@ -14,9 +14,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "swapcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/time.rb b/lib/puppet/parser/functions/time.rb index 0cddaf86b..0f5ba8c7e 100644 --- a/lib/puppet/parser/functions/time.rb +++ b/lib/puppet/parser/functions/time.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:time, :type => :rvalue, :doc => <<-EOS + newfunction(:time, :type => :rvalue, :arity => -1,:doc => <<-EOS This function will return the current time since epoch as an integer. *Examples:* @@ -17,8 +17,8 @@ module Puppet::Parser::Functions # The Time Zone argument is optional ... time_zone = arguments[0] if arguments[0] - if (arguments.size != 0) and (arguments.size != 1) then - raise(Puppet::ParseError, "time(): Wrong number of arguments "+ + if (arguments.size > 1) then + raise(ArgumentError, "time(): Wrong number of arguments "+ "given #{arguments.size} for 0 or 1") end diff --git a/lib/puppet/parser/functions/to_bytes.rb b/lib/puppet/parser/functions/to_bytes.rb index 8ff73d10b..57b55850b 100644 --- a/lib/puppet/parser/functions/to_bytes.rb +++ b/lib/puppet/parser/functions/to_bytes.rb @@ -1,13 +1,10 @@ module Puppet::Parser::Functions - newfunction(:to_bytes, :type => :rvalue, :doc => <<-EOS + newfunction(:to_bytes, :type => :rvalue, :arity => 1, :doc => <<-EOS Converts the argument into bytes, for example 4 kB becomes 4096. Takes a single string value as an argument. EOS ) do |arguments| - raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - arg = arguments[0] return arg if arg.is_a? Numeric diff --git a/lib/puppet/parser/functions/type.rb b/lib/puppet/parser/functions/type.rb index 8d85f1158..cda324991 100644 --- a/lib/puppet/parser/functions/type.rb +++ b/lib/puppet/parser/functions/type.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:type, :type => :rvalue, :doc => <<-EOS + newfunction(:type, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns the type when passed a variable. Type can be one of: * string @@ -15,9 +15,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "type(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/union.rb b/lib/puppet/parser/functions/union.rb index c91bb8053..2fe309ad2 100644 --- a/lib/puppet/parser/functions/union.rb +++ b/lib/puppet/parser/functions/union.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:union, :type => :rvalue, :doc => <<-EOS + newfunction(:union, :type => :rvalue, :arity => 2, :doc => <<-EOS This function returns a union of two arrays. *Examples:* @@ -14,10 +14,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Two arguments are required - raise(Puppet::ParseError, "union(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size != 2 - first = arguments[0] second = arguments[1] diff --git a/lib/puppet/parser/functions/unique.rb b/lib/puppet/parser/functions/unique.rb index 8844a7418..ac80e0f95 100644 --- a/lib/puppet/parser/functions/unique.rb +++ b/lib/puppet/parser/functions/unique.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:unique, :type => :rvalue, :doc => <<-EOS + newfunction(:unique, :type => :rvalue, :arity => 1, :doc => <<-EOS This function will remove duplicates from strings and arrays. *Examples:* @@ -24,9 +24,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "unique(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/upcase.rb b/lib/puppet/parser/functions/upcase.rb index fe6cadc3c..a8c45a15f 100644 --- a/lib/puppet/parser/functions/upcase.rb +++ b/lib/puppet/parser/functions/upcase.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:upcase, :type => :rvalue, :doc => <<-EOS + newfunction(:upcase, :type => :rvalue, :arity => 1, :doc => <<-EOS Converts a string or an array of strings to uppercase. *Examples:* @@ -16,9 +16,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "upcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/uriescape.rb b/lib/puppet/parser/functions/uriescape.rb index 0d81de5d1..7e566cb50 100644 --- a/lib/puppet/parser/functions/uriescape.rb +++ b/lib/puppet/parser/functions/uriescape.rb @@ -4,15 +4,12 @@ require 'uri' module Puppet::Parser::Functions - newfunction(:uriescape, :type => :rvalue, :doc => <<-EOS + newfunction(:uriescape, :type => :rvalue, :arity => 1, :doc => <<-EOS Urlencodes a string or array of strings. Requires either a single string or an array as an input. EOS ) do |arguments| - raise(Puppet::ParseError, "uriescape(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - value = arguments[0] klass = value.class diff --git a/lib/puppet/parser/functions/validate_absolute_path.rb b/lib/puppet/parser/functions/validate_absolute_path.rb index fe279744e..8d9f7db93 100644 --- a/lib/puppet/parser/functions/validate_absolute_path.rb +++ b/lib/puppet/parser/functions/validate_absolute_path.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:validate_absolute_path, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_absolute_path, :arity => -2, :doc => <<-'ENDHEREDOC') do |args| Validate the string represents an absolute path in the filesystem. This function works for windows and unix style paths. @@ -23,10 +23,6 @@ module Puppet::Parser::Functions require 'puppet/util' - unless args.length > 0 then - raise Puppet::ParseError, ("validate_absolute_path(): wrong number of arguments (#{args.length}; must be > 0)") - end - args.each do |arg| # This logic was borrowed from # [lib/puppet/file_serving/base.rb](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/file_serving/base.rb) diff --git a/lib/puppet/parser/functions/validate_array.rb b/lib/puppet/parser/functions/validate_array.rb index 34b511825..3c78015f6 100644 --- a/lib/puppet/parser/functions/validate_array.rb +++ b/lib/puppet/parser/functions/validate_array.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:validate_array, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_array, :arity => -2, :doc => <<-'ENDHEREDOC') do |args| Validate that all passed values are array data structures. Abort catalog compilation if any value fails this check. @@ -18,10 +18,6 @@ module Puppet::Parser::Functions ENDHEREDOC - unless args.length > 0 then - raise Puppet::ParseError, ("validate_array(): wrong number of arguments (#{args.length}; must be > 0)") - end - args.each do |arg| unless arg.is_a?(Array) raise Puppet::ParseError, ("#{arg.inspect} is not an Array. It looks to be a #{arg.class}") diff --git a/lib/puppet/parser/functions/validate_augeas.rb b/lib/puppet/parser/functions/validate_augeas.rb index 154d66091..2316bc339 100644 --- a/lib/puppet/parser/functions/validate_augeas.rb +++ b/lib/puppet/parser/functions/validate_augeas.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:validate_augeas, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_augeas, :arity => -3, :doc => <<-'ENDHEREDOC') do |args| Perform validation of a string using an Augeas lens The first argument of this function should be a string to test, and the second argument should be the name of the Augeas lens to use. @@ -32,8 +32,8 @@ module Puppet::Parser::Functions raise Puppet::ParseError, ("validate_augeas(): this function requires the augeas feature. See http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas#Pre-requisites for how to activate it.") end - if (args.length < 2) or (args.length > 4) then - raise Puppet::ParseError, ("validate_augeas(): wrong number of arguments (#{args.length}; must be 2, 3, or 4)") + if args.length > 4 then + raise ArgumentError, ("validate_augeas(): wrong number of arguments (#{args.length}; must be 2, 3, or 4)") end msg = args[3] || "validate_augeas(): Failed to validate content against #{args[1].inspect}" diff --git a/lib/puppet/parser/functions/validate_bool.rb b/lib/puppet/parser/functions/validate_bool.rb index 62c1d8882..44d6faecb 100644 --- a/lib/puppet/parser/functions/validate_bool.rb +++ b/lib/puppet/parser/functions/validate_bool.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:validate_bool, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_bool, :arity => -2, :doc => <<-'ENDHEREDOC') do |args| Validate that all passed values are either true or false. Abort catalog compilation if any value fails this check. @@ -19,10 +19,6 @@ module Puppet::Parser::Functions ENDHEREDOC - unless args.length > 0 then - raise Puppet::ParseError, ("validate_bool(): wrong number of arguments (#{args.length}; must be > 0)") - end - args.each do |arg| unless (arg.is_a?(TrueClass) || arg.is_a?(FalseClass)) raise Puppet::ParseError, ("#{arg.inspect} is not a boolean. It looks to be a #{arg.class}") diff --git a/lib/puppet/parser/functions/validate_cmd.rb b/lib/puppet/parser/functions/validate_cmd.rb index 344a80cd3..93038698c 100644 --- a/lib/puppet/parser/functions/validate_cmd.rb +++ b/lib/puppet/parser/functions/validate_cmd.rb @@ -1,7 +1,7 @@ require 'puppet/util/execution' module Puppet::Parser::Functions - newfunction(:validate_cmd, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_cmd, :arity => -3, :doc => <<-'ENDHEREDOC') do |args| Perform validation of a string with an external command. The first argument of this function should be a string to test, and the second argument should be a path to a test command @@ -19,8 +19,8 @@ module Puppet::Parser::Functions validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content') ENDHEREDOC - if (args.length < 2) or (args.length > 3) then - raise Puppet::ParseError, ("validate_cmd(): wrong number of arguments (#{args.length}; must be 2 or 3)") + if args.length > 3 then + raise ArgumentError, ("validate_cmd(): wrong number of arguments (#{args.length}; must be 2 or 3)") end msg = args[2] || "validate_cmd(): failed to validate content with command #{args[1].inspect}" diff --git a/lib/puppet/parser/functions/validate_hash.rb b/lib/puppet/parser/functions/validate_hash.rb index 9bdd54328..93919500c 100644 --- a/lib/puppet/parser/functions/validate_hash.rb +++ b/lib/puppet/parser/functions/validate_hash.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:validate_hash, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_hash, :arity => -2, :doc => <<-'ENDHEREDOC') do |args| Validate that all passed values are hash data structures. Abort catalog compilation if any value fails this check. @@ -18,10 +18,6 @@ module Puppet::Parser::Functions ENDHEREDOC - unless args.length > 0 then - raise Puppet::ParseError, ("validate_hash(): wrong number of arguments (#{args.length}; must be > 0)") - end - args.each do |arg| unless arg.is_a?(Hash) raise Puppet::ParseError, ("#{arg.inspect} is not a Hash. It looks to be a #{arg.class}") diff --git a/lib/puppet/parser/functions/validate_ipv4_address.rb b/lib/puppet/parser/functions/validate_ipv4_address.rb index fc02748e8..eeab44ed0 100644 --- a/lib/puppet/parser/functions/validate_ipv4_address.rb +++ b/lib/puppet/parser/functions/validate_ipv4_address.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:validate_ipv4_address, :doc => <<-ENDHEREDOC + newfunction(:validate_ipv4_address, :arity => -2, :doc => <<-ENDHEREDOC Validate that all values passed are valid IPv4 addresses. Fail compilation if any value fails this check. @@ -25,10 +25,6 @@ module Puppet::Parser::Functions rescuable_exceptions << IPAddr::InvalidAddressError end - unless args.length > 0 then - raise Puppet::ParseError, ("validate_ipv4_address(): wrong number of arguments (#{args.length}; must be > 0)") - end - args.each do |arg| unless arg.is_a?(String) raise Puppet::ParseError, "#{arg.inspect} is not a string." diff --git a/lib/puppet/parser/functions/validate_ipv6_address.rb b/lib/puppet/parser/functions/validate_ipv6_address.rb index b0f2558df..af553face 100644 --- a/lib/puppet/parser/functions/validate_ipv6_address.rb +++ b/lib/puppet/parser/functions/validate_ipv6_address.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:validate_ipv6_address, :doc => <<-ENDHEREDOC + newfunction(:validate_ipv6_address, :arity => -2, :doc => <<-ENDHEREDOC Validate that all values passed are valid IPv6 addresses. Fail compilation if any value fails this check. @@ -26,10 +26,6 @@ module Puppet::Parser::Functions rescuable_exceptions << IPAddr::InvalidAddressError end - unless args.length > 0 then - raise Puppet::ParseError, ("validate_ipv6_address(): wrong number of arguments (#{args.length}; must be > 0)") - end - args.each do |arg| unless arg.is_a?(String) raise Puppet::ParseError, "#{arg.inspect} is not a string." diff --git a/lib/puppet/parser/functions/validate_re.rb b/lib/puppet/parser/functions/validate_re.rb index ca25a702c..a2c201b45 100644 --- a/lib/puppet/parser/functions/validate_re.rb +++ b/lib/puppet/parser/functions/validate_re.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:validate_re, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_re, :arity => -3, :doc => <<-'ENDHEREDOC') do |args| Perform simple validation of a string against one or more regular expressions. The first argument of this function should be a string to test, and the second argument should be a stringified regular expression @@ -24,8 +24,8 @@ module Puppet::Parser::Functions validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7') ENDHEREDOC - if (args.length < 2) or (args.length > 3) then - raise Puppet::ParseError, ("validate_re(): wrong number of arguments (#{args.length}; must be 2 or 3)") + if args.length > 3 then + raise ArgumentError, ("validate_re(): wrong number of arguments (#{args.length}; must be 2 or 3)") end msg = args[2] || "validate_re(): #{args[0].inspect} does not match #{args[1].inspect}" diff --git a/lib/puppet/parser/functions/validate_slength.rb b/lib/puppet/parser/functions/validate_slength.rb index 7d534f370..de6f1b8a3 100644 --- a/lib/puppet/parser/functions/validate_slength.rb +++ b/lib/puppet/parser/functions/validate_slength.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:validate_slength, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_slength, :arity => -3, :doc => <<-'ENDHEREDOC') do |args| Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. An optional third parameter can be given a the minimum length. It fails if the first @@ -21,7 +21,7 @@ module Puppet::Parser::Functions ENDHEREDOC - raise Puppet::ParseError, "validate_slength(): Wrong number of arguments (#{args.length}; must be 2 or 3)" unless args.length == 2 or args.length == 3 + raise ArgumentError, "validate_slength(): Wrong number of arguments (#{args.length}; must be 2 or 3)" unless args.length == 2 or args.length == 3 input, max_length, min_length = *args diff --git a/lib/puppet/parser/functions/validate_string.rb b/lib/puppet/parser/functions/validate_string.rb index e667794a6..995926dcd 100644 --- a/lib/puppet/parser/functions/validate_string.rb +++ b/lib/puppet/parser/functions/validate_string.rb @@ -1,6 +1,6 @@ module Puppet::Parser::Functions - newfunction(:validate_string, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_string, :arity => -2, :doc => <<-'ENDHEREDOC') do |args| Validate that all passed values are string data structures. Abort catalog compilation if any value fails this check. @@ -18,10 +18,6 @@ module Puppet::Parser::Functions ENDHEREDOC - unless args.length > 0 then - raise Puppet::ParseError, ("validate_string(): wrong number of arguments (#{args.length}; must be > 0)") - end - args.each do |arg| unless arg.is_a?(String) raise Puppet::ParseError, ("#{arg.inspect} is not a string. It looks to be a #{arg.class}") diff --git a/lib/puppet/parser/functions/values.rb b/lib/puppet/parser/functions/values.rb index 16067561b..ad55ed747 100644 --- a/lib/puppet/parser/functions/values.rb +++ b/lib/puppet/parser/functions/values.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:values, :type => :rvalue, :doc => <<-EOS + newfunction(:values, :type => :rvalue, :arity => 1, :doc => <<-EOS When given a hash this function will return the values of that hash. *Examples:* @@ -21,9 +21,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "values(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 - hash = arguments[0] unless hash.is_a?(Hash) diff --git a/lib/puppet/parser/functions/values_at.rb b/lib/puppet/parser/functions/values_at.rb index d3e69d97f..52f9e9ba3 100644 --- a/lib/puppet/parser/functions/values_at.rb +++ b/lib/puppet/parser/functions/values_at.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:values_at, :type => :rvalue, :doc => <<-EOS + newfunction(:values_at, :type => :rvalue, :arity => 2, :doc => <<-EOS Finds value inside an array based on location. The first argument is the array you want to analyze, and the second element can @@ -29,9 +29,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "values_at(): Wrong number of " + - "arguments given (#{arguments.size} for 2)") if arguments.size < 2 - array = arguments.shift unless array.is_a?(Array) diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 6fd56d5c1..fc73599c3 100644 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -8,7 +8,7 @@ describe 'argument handling' do it 'fails with no arguments' do - should run.with_params().and_raise_error(Puppet::ParseError) + should run.with_params().and_raise_error(ArgumentError) end it 'requires an array' do lambda { scope.function_ensure_packages([['foo']]) }.should_not raise_error diff --git a/spec/unit/puppet/parser/functions/abs_spec.rb b/spec/unit/puppet/parser/functions/abs_spec.rb index c0b42970c..7ffefc968 100755 --- a/spec/unit/puppet/parser/functions/abs_spec.rb +++ b/spec/unit/puppet/parser/functions/abs_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_abs([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_abs([]) }.should( raise_error(ArgumentError)) end it "should convert a negative number into a positive" do diff --git a/spec/unit/puppet/parser/functions/base64_spec.rb b/spec/unit/puppet/parser/functions/base64_spec.rb index 5faa5e66c..334e23a68 100755 --- a/spec/unit/puppet/parser/functions/base64_spec.rb +++ b/spec/unit/puppet/parser/functions/base64_spec.rb @@ -10,9 +10,9 @@ end it "should raise a ParseError if there are other than 2 arguments" do - expect { scope.function_base64([]) }.to(raise_error(Puppet::ParseError)) - expect { scope.function_base64(["asdf"]) }.to(raise_error(Puppet::ParseError)) - expect { scope.function_base64(["asdf","moo","cow"]) }.to(raise_error(Puppet::ParseError)) + expect { scope.function_base64([]) }.to(raise_error(ArgumentError)) + expect { scope.function_base64(["asdf"]) }.to(raise_error(ArgumentError)) + expect { scope.function_base64(["asdf","moo","cow"]) }.to(raise_error(ArgumentError)) end it "should raise a ParseError if argument 1 isn't 'encode' or 'decode'" do diff --git a/spec/unit/puppet/parser/functions/bool2num_spec.rb b/spec/unit/puppet/parser/functions/bool2num_spec.rb index 518ac85ec..020b0c917 100755 --- a/spec/unit/puppet/parser/functions/bool2num_spec.rb +++ b/spec/unit/puppet/parser/functions/bool2num_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_bool2num([]) }.should( raise_error(ArgumentError)) end it "should convert true to 1" do diff --git a/spec/unit/puppet/parser/functions/capitalize_spec.rb b/spec/unit/puppet/parser/functions/capitalize_spec.rb index 69c9758f2..1a8e2d5db 100755 --- a/spec/unit/puppet/parser/functions/capitalize_spec.rb +++ b/spec/unit/puppet/parser/functions/capitalize_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_capitalize([]) }.should( raise_error(ArgumentError)) end it "should capitalize the beginning of a string" do diff --git a/spec/unit/puppet/parser/functions/chomp_spec.rb b/spec/unit/puppet/parser/functions/chomp_spec.rb index e425365fc..3a8417f1e 100755 --- a/spec/unit/puppet/parser/functions/chomp_spec.rb +++ b/spec/unit/puppet/parser/functions/chomp_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_chomp([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_chomp([]) }.should( raise_error(ArgumentError)) end it "should chomp the end of a string" do diff --git a/spec/unit/puppet/parser/functions/chop_spec.rb b/spec/unit/puppet/parser/functions/chop_spec.rb index 9e466de4b..bfc19b166 100755 --- a/spec/unit/puppet/parser/functions/chop_spec.rb +++ b/spec/unit/puppet/parser/functions/chop_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_chop([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_chop([]) }.should( raise_error(ArgumentError)) end it "should chop the end of a string" do diff --git a/spec/unit/puppet/parser/functions/concat_spec.rb b/spec/unit/puppet/parser/functions/concat_spec.rb index 123188bd4..5635d6168 100644 --- a/spec/unit/puppet/parser/functions/concat_spec.rb +++ b/spec/unit/puppet/parser/functions/concat_spec.rb @@ -5,7 +5,7 @@ let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_concat([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_concat([]) }.should( raise_error(ArgumentError)) end it "should be able to concat an array" do diff --git a/spec/unit/puppet/parser/functions/delete_at_spec.rb b/spec/unit/puppet/parser/functions/delete_at_spec.rb index d8d961848..36b663612 100755 --- a/spec/unit/puppet/parser/functions/delete_at_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_at_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_delete_at([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_delete_at([]) }.should( raise_error(ArgumentError)) end it "should delete an item at specified location from an array" do diff --git a/spec/unit/puppet/parser/functions/delete_spec.rb b/spec/unit/puppet/parser/functions/delete_spec.rb index 2f29c93c0..fd132e317 100755 --- a/spec/unit/puppet/parser/functions/delete_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_spec.rb @@ -9,11 +9,11 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_delete([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_delete([]) }.should( raise_error(ArgumentError)) end it "should raise a ParseError if there are greater than 2 arguments" do - lambda { scope.function_delete([[], 'foo', 'bar']) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_delete([[], 'foo', 'bar']) }.should( raise_error(ArgumentError)) end it "should raise a TypeError if a number is passed as the first argument" do diff --git a/spec/unit/puppet/parser/functions/delete_undef_values_spec.rb b/spec/unit/puppet/parser/functions/delete_undef_values_spec.rb index 0536641ca..9fa5bc87c 100644 --- a/spec/unit/puppet/parser/functions/delete_undef_values_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_undef_values_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 argument" do - lambda { scope.function_delete_undef_values([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_delete_undef_values([]) }.should( raise_error(ArgumentError)) end it "should raise a ParseError if the argument is not Array nor Hash" do diff --git a/spec/unit/puppet/parser/functions/delete_values_spec.rb b/spec/unit/puppet/parser/functions/delete_values_spec.rb index c62e55f39..0f4503713 100644 --- a/spec/unit/puppet/parser/functions/delete_values_spec.rb +++ b/spec/unit/puppet/parser/functions/delete_values_spec.rb @@ -9,11 +9,11 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_delete_values([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_delete_values([]) }.should( raise_error(ArgumentError)) end it "should raise a ParseError if there are greater than 2 arguments" do - lambda { scope.function_delete_values([[], 'foo', 'bar']) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_delete_values([[], 'foo', 'bar']) }.should( raise_error(ArgumentError)) end it "should raise a TypeError if the argument is not a hash" do diff --git a/spec/unit/puppet/parser/functions/difference_spec.rb b/spec/unit/puppet/parser/functions/difference_spec.rb index 9feff0918..3243d77e4 100644 --- a/spec/unit/puppet/parser/functions/difference_spec.rb +++ b/spec/unit/puppet/parser/functions/difference_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_difference([]) }.should( raise_error(Puppet::ParseError) ) + lambda { scope.function_difference([]) }.should( raise_error(ArgumentError) ) end it "should return the difference between two arrays" do diff --git a/spec/unit/puppet/parser/functions/dirname_spec.rb b/spec/unit/puppet/parser/functions/dirname_spec.rb index fb3b4feca..cc95dac5d 100755 --- a/spec/unit/puppet/parser/functions/dirname_spec.rb +++ b/spec/unit/puppet/parser/functions/dirname_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_dirname([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_dirname([]) }.should( raise_error(ArgumentError)) end it "should return dirname for an absolute path" do diff --git a/spec/unit/puppet/parser/functions/downcase_spec.rb b/spec/unit/puppet/parser/functions/downcase_spec.rb index acef1f05d..04bf3c2a5 100755 --- a/spec/unit/puppet/parser/functions/downcase_spec.rb +++ b/spec/unit/puppet/parser/functions/downcase_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_downcase([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_downcase([]) }.should( raise_error(ArgumentError)) end it "should downcase a string" do diff --git a/spec/unit/puppet/parser/functions/empty_spec.rb b/spec/unit/puppet/parser/functions/empty_spec.rb index 774587522..cc1b2abf7 100755 --- a/spec/unit/puppet/parser/functions/empty_spec.rb +++ b/spec/unit/puppet/parser/functions/empty_spec.rb @@ -8,7 +8,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_empty([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_empty([]) }.should( raise_error(ArgumentError)) end it "should return a true for an empty string" do diff --git a/spec/unit/puppet/parser/functions/flatten_spec.rb b/spec/unit/puppet/parser/functions/flatten_spec.rb index dba7a6bbd..7b648f4ba 100755 --- a/spec/unit/puppet/parser/functions/flatten_spec.rb +++ b/spec/unit/puppet/parser/functions/flatten_spec.rb @@ -8,11 +8,11 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_flatten([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_flatten([]) }.should( raise_error(ArgumentError)) end it "should raise a ParseError if there is more than 1 argument" do - lambda { scope.function_flatten([[], []]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_flatten([[], []]) }.should( raise_error(ArgumentError)) end it "should flatten a complex data structure" do diff --git a/spec/unit/puppet/parser/functions/floor_spec.rb b/spec/unit/puppet/parser/functions/floor_spec.rb index dbc8c7735..058ca78cd 100644 --- a/spec/unit/puppet/parser/functions/floor_spec.rb +++ b/spec/unit/puppet/parser/functions/floor_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 argument" do - lambda { scope.function_floor([]) }.should( raise_error(Puppet::ParseError, /Wrong number of arguments/)) + lambda { scope.function_floor([]) }.should( raise_error(ArgumentError, /Wrong number of arguments/)) end it "should should raise a ParseError if input isn't numeric (eg. String)" do diff --git a/spec/unit/puppet/parser/functions/fqdn_rotate_spec.rb b/spec/unit/puppet/parser/functions/fqdn_rotate_spec.rb index 257772335..a83b71927 100644 --- a/spec/unit/puppet/parser/functions/fqdn_rotate_spec.rb +++ b/spec/unit/puppet/parser/functions/fqdn_rotate_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_fqdn_rotate([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_fqdn_rotate([]) }.should( raise_error(ArgumentError)) end it "should rotate a string and the result should be the same size" do diff --git a/spec/unit/puppet/parser/functions/get_module_path_spec.rb b/spec/unit/puppet/parser/functions/get_module_path_spec.rb index 486bef6f2..53d5c5786 100644 --- a/spec/unit/puppet/parser/functions/get_module_path_spec.rb +++ b/spec/unit/puppet/parser/functions/get_module_path_spec.rb @@ -15,8 +15,8 @@ def scope(environment = "production") end it 'should only allow one argument' do - expect { scope.function_get_module_path([]) }.to raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) - expect { scope.function_get_module_path(['1','2','3']) }.to raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) + expect { scope.function_get_module_path([]) }.to raise_error(ArgumentError) + expect { scope.function_get_module_path(['1','2','3']) }.to raise_error(ArgumentError) end it 'should raise an exception when the module cannot be found' do expect { scope.function_get_module_path(['foo']) }.to raise_error(Puppet::ParseError, /Could not find module/) diff --git a/spec/unit/puppet/parser/functions/getvar_spec.rb b/spec/unit/puppet/parser/functions/getvar_spec.rb index 5ff834ee7..77994d8a2 100644 --- a/spec/unit/puppet/parser/functions/getvar_spec.rb +++ b/spec/unit/puppet/parser/functions/getvar_spec.rb @@ -10,7 +10,7 @@ Puppet[:code] = '$foo = getvar()' expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError) end it "should not compile when too many arguments are passed" do @@ -18,7 +18,7 @@ Puppet[:code] = '$foo = getvar("foo::bar", "baz")' expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError) end it "should lookup variables in other namespaces" do diff --git a/spec/unit/puppet/parser/functions/grep_spec.rb b/spec/unit/puppet/parser/functions/grep_spec.rb index a93b84253..d8bff2696 100755 --- a/spec/unit/puppet/parser/functions/grep_spec.rb +++ b/spec/unit/puppet/parser/functions/grep_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_grep([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_grep([]) }.should( raise_error(ArgumentError)) end it "should grep contents from an array" do diff --git a/spec/unit/puppet/parser/functions/has_key_spec.rb b/spec/unit/puppet/parser/functions/has_key_spec.rb index 490daeae7..6ad3d37a2 100644 --- a/spec/unit/puppet/parser/functions/has_key_spec.rb +++ b/spec/unit/puppet/parser/functions/has_key_spec.rb @@ -10,7 +10,7 @@ Puppet[:code] = '$x = has_key()' expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError) end it "should not compile when 1 argument is passed" do @@ -18,7 +18,7 @@ Puppet[:code] = "$x = has_key('foo')" expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError) end it "should require the first value to be a Hash" do diff --git a/spec/unit/puppet/parser/functions/hash_spec.rb b/spec/unit/puppet/parser/functions/hash_spec.rb index 7c91be907..16588ea8a 100644 --- a/spec/unit/puppet/parser/functions/hash_spec.rb +++ b/spec/unit/puppet/parser/functions/hash_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_hash([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_hash([]) }.should( raise_error(ArgumentError)) end it "should convert an array to a hash" do diff --git a/spec/unit/puppet/parser/functions/intersection_spec.rb b/spec/unit/puppet/parser/functions/intersection_spec.rb index fd44f7fe3..b4ea774dd 100644 --- a/spec/unit/puppet/parser/functions/intersection_spec.rb +++ b/spec/unit/puppet/parser/functions/intersection_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_intersection([]) }.should( raise_error(Puppet::ParseError) ) + lambda { scope.function_intersection([]) }.should( raise_error(ArgumentError) ) end it "should return the intersection of two arrays" do diff --git a/spec/unit/puppet/parser/functions/is_array_spec.rb b/spec/unit/puppet/parser/functions/is_array_spec.rb index e7f4bcd6d..5b654a0c6 100644 --- a/spec/unit/puppet/parser/functions/is_array_spec.rb +++ b/spec/unit/puppet/parser/functions/is_array_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_array([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_array([]) }.should( raise_error(ArgumentError)) end it "should return true if passed an array" do diff --git a/spec/unit/puppet/parser/functions/is_domain_name_spec.rb b/spec/unit/puppet/parser/functions/is_domain_name_spec.rb index f2ea76dac..0f1ad5e6a 100644 --- a/spec/unit/puppet/parser/functions/is_domain_name_spec.rb +++ b/spec/unit/puppet/parser/functions/is_domain_name_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_domain_name([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_domain_name([]) }.should( raise_error(ArgumentError)) end it "should return true if a valid short domain name" do diff --git a/spec/unit/puppet/parser/functions/is_float_spec.rb b/spec/unit/puppet/parser/functions/is_float_spec.rb index b7d73b04a..b5a18ecbf 100644 --- a/spec/unit/puppet/parser/functions/is_float_spec.rb +++ b/spec/unit/puppet/parser/functions/is_float_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_float([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_float([]) }.should( raise_error(ArgumentError)) end it "should return true if a float" do diff --git a/spec/unit/puppet/parser/functions/is_hash_spec.rb b/spec/unit/puppet/parser/functions/is_hash_spec.rb index bbebf39f9..4242dc3a8 100644 --- a/spec/unit/puppet/parser/functions/is_hash_spec.rb +++ b/spec/unit/puppet/parser/functions/is_hash_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_hash([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_hash([]) }.should( raise_error(ArgumentError)) end it "should return true if passed a hash" do diff --git a/spec/unit/puppet/parser/functions/is_integer_spec.rb b/spec/unit/puppet/parser/functions/is_integer_spec.rb index 433579502..10f27605e 100644 --- a/spec/unit/puppet/parser/functions/is_integer_spec.rb +++ b/spec/unit/puppet/parser/functions/is_integer_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_integer([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_integer([]) }.should( raise_error(ArgumentError)) end it "should return true if an integer" do diff --git a/spec/unit/puppet/parser/functions/is_ip_address_spec.rb b/spec/unit/puppet/parser/functions/is_ip_address_spec.rb index c0debb3d4..4ab5ca88c 100644 --- a/spec/unit/puppet/parser/functions/is_ip_address_spec.rb +++ b/spec/unit/puppet/parser/functions/is_ip_address_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_ip_address([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_ip_address([]) }.should( raise_error(ArgumentError)) end it "should return true if an IPv4 address" do diff --git a/spec/unit/puppet/parser/functions/is_mac_address_spec.rb b/spec/unit/puppet/parser/functions/is_mac_address_spec.rb index ca9c59047..4e965c493 100644 --- a/spec/unit/puppet/parser/functions/is_mac_address_spec.rb +++ b/spec/unit/puppet/parser/functions/is_mac_address_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_mac_address([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_mac_address([]) }.should( raise_error(ArgumentError)) end it "should return true if a valid mac address" do diff --git a/spec/unit/puppet/parser/functions/is_numeric_spec.rb b/spec/unit/puppet/parser/functions/is_numeric_spec.rb index d7440fb0a..a65886bc8 100644 --- a/spec/unit/puppet/parser/functions/is_numeric_spec.rb +++ b/spec/unit/puppet/parser/functions/is_numeric_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 argument" do - lambda { scope.function_is_numeric([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_numeric([]) }.should( raise_error(ArgumentError)) end it "should return true if an integer" do diff --git a/spec/unit/puppet/parser/functions/is_string_spec.rb b/spec/unit/puppet/parser/functions/is_string_spec.rb index 3756bea8b..30abf4442 100644 --- a/spec/unit/puppet/parser/functions/is_string_spec.rb +++ b/spec/unit/puppet/parser/functions/is_string_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_is_string([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_is_string([]) }.should( raise_error(ArgumentError)) end it "should return true if a string" do diff --git a/spec/unit/puppet/parser/functions/join_keys_to_values_spec.rb b/spec/unit/puppet/parser/functions/join_keys_to_values_spec.rb index a52fb719f..126ccf698 100644 --- a/spec/unit/puppet/parser/functions/join_keys_to_values_spec.rb +++ b/spec/unit/puppet/parser/functions/join_keys_to_values_spec.rb @@ -9,11 +9,11 @@ end it "should raise a ParseError if there are fewer than two arguments" do - lambda { scope.function_join_keys_to_values([{}]) }.should raise_error Puppet::ParseError + lambda { scope.function_join_keys_to_values([{}]) }.should raise_error ArgumentError end it "should raise a ParseError if there are greater than two arguments" do - lambda { scope.function_join_keys_to_values([{}, 'foo', 'bar']) }.should raise_error Puppet::ParseError + lambda { scope.function_join_keys_to_values([{}, 'foo', 'bar']) }.should raise_error ArgumentError end it "should raise a TypeError if the first argument is an array" do diff --git a/spec/unit/puppet/parser/functions/join_spec.rb b/spec/unit/puppet/parser/functions/join_spec.rb index aafa1a7f7..291a155b0 100644 --- a/spec/unit/puppet/parser/functions/join_spec.rb +++ b/spec/unit/puppet/parser/functions/join_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_join([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_join([]) }.should( raise_error(ArgumentError)) end it "should join an array into a string" do diff --git a/spec/unit/puppet/parser/functions/keys_spec.rb b/spec/unit/puppet/parser/functions/keys_spec.rb index fdd7a7073..01c8e13d0 100644 --- a/spec/unit/puppet/parser/functions/keys_spec.rb +++ b/spec/unit/puppet/parser/functions/keys_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_keys([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_keys([]) }.should( raise_error(ArgumentError)) end it "should return an array of keys when given a hash" do diff --git a/spec/unit/puppet/parser/functions/lstrip_spec.rb b/spec/unit/puppet/parser/functions/lstrip_spec.rb index b280ae7ac..63e6a0f95 100644 --- a/spec/unit/puppet/parser/functions/lstrip_spec.rb +++ b/spec/unit/puppet/parser/functions/lstrip_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_lstrip([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_lstrip([]) }.should( raise_error(ArgumentError)) end it "should lstrip a string" do diff --git a/spec/unit/puppet/parser/functions/max_spec.rb b/spec/unit/puppet/parser/functions/max_spec.rb index ff6f2b361..26a8dc37b 100755 --- a/spec/unit/puppet/parser/functions/max_spec.rb +++ b/spec/unit/puppet/parser/functions/max_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_max([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_max([]) }.should( raise_error(ArgumentError)) end it "should be able to compare strings" do diff --git a/spec/unit/puppet/parser/functions/member_spec.rb b/spec/unit/puppet/parser/functions/member_spec.rb index 6e9a023fa..bd42d3f04 100644 --- a/spec/unit/puppet/parser/functions/member_spec.rb +++ b/spec/unit/puppet/parser/functions/member_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_member([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_member([]) }.should( raise_error(ArgumentError)) end it "should return true if a member is in an array" do diff --git a/spec/unit/puppet/parser/functions/merge_spec.rb b/spec/unit/puppet/parser/functions/merge_spec.rb index 8a170bb1c..66093d8e3 100644 --- a/spec/unit/puppet/parser/functions/merge_spec.rb +++ b/spec/unit/puppet/parser/functions/merge_spec.rb @@ -11,7 +11,7 @@ Puppet[:code] = '$x = merge()' expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError) end it "should not compile when 1 argument is passed" do @@ -19,7 +19,7 @@ Puppet[:code] = "$my_hash={'one' => 1}\n$x = merge($my_hash)" expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError) end end diff --git a/spec/unit/puppet/parser/functions/min_spec.rb b/spec/unit/puppet/parser/functions/min_spec.rb index 71d593ef0..eb076d44d 100755 --- a/spec/unit/puppet/parser/functions/min_spec.rb +++ b/spec/unit/puppet/parser/functions/min_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_min([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_min([]) }.should( raise_error(ArgumentError)) end it "should be able to compare strings" do diff --git a/spec/unit/puppet/parser/functions/num2bool_spec.rb b/spec/unit/puppet/parser/functions/num2bool_spec.rb index b56196d3c..7798d56b1 100644 --- a/spec/unit/puppet/parser/functions/num2bool_spec.rb +++ b/spec/unit/puppet/parser/functions/num2bool_spec.rb @@ -9,11 +9,11 @@ end it "should raise a ParseError if there are no arguments" do - lambda { scope.function_num2bool([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_num2bool([]) }.should( raise_error(ArgumentError)) end it "should raise a ParseError if there are more than 1 arguments" do - lambda { scope.function_num2bool(["foo","bar"]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_num2bool(["foo","bar"]) }.should( raise_error(ArgumentError)) end it "should raise a ParseError if passed something non-numeric" do diff --git a/spec/unit/puppet/parser/functions/parsejson_spec.rb b/spec/unit/puppet/parser/functions/parsejson_spec.rb index f179ac111..b42009d4b 100644 --- a/spec/unit/puppet/parser/functions/parsejson_spec.rb +++ b/spec/unit/puppet/parser/functions/parsejson_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_parsejson([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_parsejson([]) }.should( raise_error(ArgumentError)) end it "should convert JSON to a data structure" do diff --git a/spec/unit/puppet/parser/functions/parseyaml_spec.rb b/spec/unit/puppet/parser/functions/parseyaml_spec.rb index 0c7aea8a5..97428ff1e 100644 --- a/spec/unit/puppet/parser/functions/parseyaml_spec.rb +++ b/spec/unit/puppet/parser/functions/parseyaml_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_parseyaml([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_parseyaml([]) }.should( raise_error(ArgumentError)) end it "should convert YAML to a data structure" do diff --git a/spec/unit/puppet/parser/functions/pick_spec.rb b/spec/unit/puppet/parser/functions/pick_spec.rb index 761db6be2..37d78d799 100644 --- a/spec/unit/puppet/parser/functions/pick_spec.rb +++ b/spec/unit/puppet/parser/functions/pick_spec.rb @@ -29,6 +29,6 @@ end it 'should error if no values are passed' do - expect { scope.function_pick([]) }.to raise_error(Puppet::Error, /Must provide non empty value./) + expect { scope.function_pick([]) }.to raise_error(ArgumentError) end end diff --git a/spec/unit/puppet/parser/functions/prefix_spec.rb b/spec/unit/puppet/parser/functions/prefix_spec.rb index 5cf592bfb..3e416f613 100644 --- a/spec/unit/puppet/parser/functions/prefix_spec.rb +++ b/spec/unit/puppet/parser/functions/prefix_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_prefix([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_prefix([]) }.should( raise_error(ArgumentError)) end it "should return a prefixed array" do diff --git a/spec/unit/puppet/parser/functions/range_spec.rb b/spec/unit/puppet/parser/functions/range_spec.rb index 0e1ad376f..6abaa420c 100644 --- a/spec/unit/puppet/parser/functions/range_spec.rb +++ b/spec/unit/puppet/parser/functions/range_spec.rb @@ -9,7 +9,7 @@ end it "raises a ParseError if there is less than 1 arguments" do - expect { scope.function_range([]) }.to raise_error Puppet::ParseError, /Wrong number of arguments.*0 for 1/ + expect { scope.function_range([]) }.to raise_error ArgumentError end describe 'with a letter range' do diff --git a/spec/unit/puppet/parser/functions/reject_spec.rb b/spec/unit/puppet/parser/functions/reject_spec.rb index f2cb74193..e179fdd8c 100755 --- a/spec/unit/puppet/parser/functions/reject_spec.rb +++ b/spec/unit/puppet/parser/functions/reject_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_reject([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_reject([]) }.should( raise_error(ArgumentError)) end it "should reject contents from an array" do diff --git a/spec/unit/puppet/parser/functions/reverse_spec.rb b/spec/unit/puppet/parser/functions/reverse_spec.rb index 1b5920654..21d2ba927 100644 --- a/spec/unit/puppet/parser/functions/reverse_spec.rb +++ b/spec/unit/puppet/parser/functions/reverse_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_reverse([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_reverse([]) }.should( raise_error(ArgumentError)) end it "should reverse a string" do diff --git a/spec/unit/puppet/parser/functions/rstrip_spec.rb b/spec/unit/puppet/parser/functions/rstrip_spec.rb index d90de1d06..275bce124 100644 --- a/spec/unit/puppet/parser/functions/rstrip_spec.rb +++ b/spec/unit/puppet/parser/functions/rstrip_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_rstrip([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_rstrip([]) }.should( raise_error(ArgumentError)) end it "should rstrip a string" do diff --git a/spec/unit/puppet/parser/functions/shuffle_spec.rb b/spec/unit/puppet/parser/functions/shuffle_spec.rb index 93346d537..f7f7619f9 100644 --- a/spec/unit/puppet/parser/functions/shuffle_spec.rb +++ b/spec/unit/puppet/parser/functions/shuffle_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_shuffle([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_shuffle([]) }.should( raise_error(ArgumentError)) end it "should shuffle a string and the result should be the same size" do diff --git a/spec/unit/puppet/parser/functions/size_spec.rb b/spec/unit/puppet/parser/functions/size_spec.rb index b1c435a30..456bc6a10 100644 --- a/spec/unit/puppet/parser/functions/size_spec.rb +++ b/spec/unit/puppet/parser/functions/size_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_size([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_size([]) }.should( raise_error(ArgumentError)) end it "should return the size of a string" do diff --git a/spec/unit/puppet/parser/functions/sort_spec.rb b/spec/unit/puppet/parser/functions/sort_spec.rb index 3187a5aec..c8557080b 100644 --- a/spec/unit/puppet/parser/functions/sort_spec.rb +++ b/spec/unit/puppet/parser/functions/sort_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is not 1 arguments" do - lambda { scope.function_sort(['','']) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_sort(['','']) }.should( raise_error(ArgumentError)) end it "should sort an array" do diff --git a/spec/unit/puppet/parser/functions/squeeze_spec.rb b/spec/unit/puppet/parser/functions/squeeze_spec.rb index 60e5a3028..df0ee9efe 100644 --- a/spec/unit/puppet/parser/functions/squeeze_spec.rb +++ b/spec/unit/puppet/parser/functions/squeeze_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 2 arguments" do - lambda { scope.function_squeeze([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_squeeze([]) }.should( raise_error(ArgumentError)) end it "should squeeze a string" do diff --git a/spec/unit/puppet/parser/functions/str2bool_spec.rb b/spec/unit/puppet/parser/functions/str2bool_spec.rb index ef6350f25..77eb126be 100644 --- a/spec/unit/puppet/parser/functions/str2bool_spec.rb +++ b/spec/unit/puppet/parser/functions/str2bool_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_str2bool([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_str2bool([]) }.should( raise_error(ArgumentError)) end it "should convert string 'true' to true" do diff --git a/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb b/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb index df8fb8e90..a23a28986 100644 --- a/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb +++ b/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb @@ -9,11 +9,11 @@ end it "should raise a ParseError if there is less than 1 argument" do - expect { scope.function_str2saltedsha512([]) }.to( raise_error(Puppet::ParseError) ) + expect { scope.function_str2saltedsha512([]) }.to( raise_error(ArgumentError) ) end it "should raise a ParseError if there is more than 1 argument" do - expect { scope.function_str2saltedsha512(['foo', 'bar', 'baz']) }.to( raise_error(Puppet::ParseError) ) + expect { scope.function_str2saltedsha512(['foo', 'bar', 'baz']) }.to( raise_error(ArgumentError) ) end it "should return a salted-sha512 password hash 136 characters in length" do diff --git a/spec/unit/puppet/parser/functions/strftime_spec.rb b/spec/unit/puppet/parser/functions/strftime_spec.rb index df42b6f26..3f9a813b9 100644 --- a/spec/unit/puppet/parser/functions/strftime_spec.rb +++ b/spec/unit/puppet/parser/functions/strftime_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_strftime([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_strftime([]) }.should( raise_error(ArgumentError)) end it "using %s should be higher then when I wrote this test" do diff --git a/spec/unit/puppet/parser/functions/strip_spec.rb b/spec/unit/puppet/parser/functions/strip_spec.rb index fccdd2606..d400512e3 100644 --- a/spec/unit/puppet/parser/functions/strip_spec.rb +++ b/spec/unit/puppet/parser/functions/strip_spec.rb @@ -8,7 +8,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_strip([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_strip([]) }.should( raise_error(ArgumentError)) end it "should strip a string" do diff --git a/spec/unit/puppet/parser/functions/suffix_spec.rb b/spec/unit/puppet/parser/functions/suffix_spec.rb index c28f719c8..a60863122 100644 --- a/spec/unit/puppet/parser/functions/suffix_spec.rb +++ b/spec/unit/puppet/parser/functions/suffix_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_suffix([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_suffix([]) }.should( raise_error(ArgumentError)) end it "should return a suffixed array" do diff --git a/spec/unit/puppet/parser/functions/swapcase_spec.rb b/spec/unit/puppet/parser/functions/swapcase_spec.rb index 808b41587..d2c45ba85 100644 --- a/spec/unit/puppet/parser/functions/swapcase_spec.rb +++ b/spec/unit/puppet/parser/functions/swapcase_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_swapcase([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_swapcase([]) }.should( raise_error(ArgumentError)) end it "should swapcase a string" do diff --git a/spec/unit/puppet/parser/functions/time_spec.rb b/spec/unit/puppet/parser/functions/time_spec.rb index e9fb76e6a..a3100507d 100644 --- a/spec/unit/puppet/parser/functions/time_spec.rb +++ b/spec/unit/puppet/parser/functions/time_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is more than 2 arguments" do - lambda { scope.function_time(['','']) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_time(['','']) }.should( raise_error(ArgumentError)) end it "should return a number" do diff --git a/spec/unit/puppet/parser/functions/to_bytes_spec.rb b/spec/unit/puppet/parser/functions/to_bytes_spec.rb index d1ea4c80c..2482800c6 100755 --- a/spec/unit/puppet/parser/functions/to_bytes_spec.rb +++ b/spec/unit/puppet/parser/functions/to_bytes_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_to_bytes([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_to_bytes([]) }.should( raise_error(ArgumentError)) end it "should convert kB to B" do diff --git a/spec/unit/puppet/parser/functions/type_spec.rb b/spec/unit/puppet/parser/functions/type_spec.rb index 8fec88f26..4f86f3612 100644 --- a/spec/unit/puppet/parser/functions/type_spec.rb +++ b/spec/unit/puppet/parser/functions/type_spec.rb @@ -8,7 +8,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_type([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_type([]) }.should( raise_error(ArgumentError)) end it "should return string when given a string" do diff --git a/spec/unit/puppet/parser/functions/union_spec.rb b/spec/unit/puppet/parser/functions/union_spec.rb index 0d282caa6..3714b0fc1 100644 --- a/spec/unit/puppet/parser/functions/union_spec.rb +++ b/spec/unit/puppet/parser/functions/union_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - lambda { scope.function_union([]) }.should( raise_error(Puppet::ParseError) ) + lambda { scope.function_union([]) }.should( raise_error(ArgumentError) ) end it "should join two arrays together" do diff --git a/spec/unit/puppet/parser/functions/unique_spec.rb b/spec/unit/puppet/parser/functions/unique_spec.rb index 5d48d49b7..f398a300b 100644 --- a/spec/unit/puppet/parser/functions/unique_spec.rb +++ b/spec/unit/puppet/parser/functions/unique_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_unique([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_unique([]) }.should( raise_error(ArgumentError)) end it "should remove duplicate elements in a string" do diff --git a/spec/unit/puppet/parser/functions/upcase_spec.rb b/spec/unit/puppet/parser/functions/upcase_spec.rb index 5db55138a..4fff07263 100644 --- a/spec/unit/puppet/parser/functions/upcase_spec.rb +++ b/spec/unit/puppet/parser/functions/upcase_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_upcase([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_upcase([]) }.should( raise_error(ArgumentError)) end it "should upcase a string" do diff --git a/spec/unit/puppet/parser/functions/uriescape_spec.rb b/spec/unit/puppet/parser/functions/uriescape_spec.rb index 7211c8878..6af8b1305 100644 --- a/spec/unit/puppet/parser/functions/uriescape_spec.rb +++ b/spec/unit/puppet/parser/functions/uriescape_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_uriescape([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_uriescape([]) }.should( raise_error(ArgumentError)) end it "should uriescape a string" do diff --git a/spec/unit/puppet/parser/functions/validate_bool_spec.rb b/spec/unit/puppet/parser/functions/validate_bool_spec.rb index 261fb2352..ec0aa5241 100644 --- a/spec/unit/puppet/parser/functions/validate_bool_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_bool_spec.rb @@ -27,7 +27,7 @@ it "should not compile when no arguments are passed" do Puppet[:code] = 'validate_bool()' - expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + expect { scope.compiler.compile }.to raise_error(Puppet::ParseError) end it "should compile when multiple boolean arguments are passed" do diff --git a/spec/unit/puppet/parser/functions/validate_cmd_spec.rb b/spec/unit/puppet/parser/functions/validate_cmd_spec.rb index 69ea7f496..f36a5321a 100644 --- a/spec/unit/puppet/parser/functions/validate_cmd_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_cmd_spec.rb @@ -24,7 +24,7 @@ inputs.each do |input| it "validate_cmd(#{input.inspect}) should fail" do - expect { subject.call [input] }.to raise_error Puppet::ParseError + expect { subject.call [input] }.to raise_error ArgumentError end end end diff --git a/spec/unit/puppet/parser/functions/validate_ipv4_address_spec.rb b/spec/unit/puppet/parser/functions/validate_ipv4_address_spec.rb index 85536d364..2a3b286a5 100644 --- a/spec/unit/puppet/parser/functions/validate_ipv4_address_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_ipv4_address_spec.rb @@ -58,7 +58,7 @@ Puppet[:code] = "validate_ipv4_address()" expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError) end end end diff --git a/spec/unit/puppet/parser/functions/validate_ipv6_address_spec.rb b/spec/unit/puppet/parser/functions/validate_ipv6_address_spec.rb index 1fe530468..77a753b19 100644 --- a/spec/unit/puppet/parser/functions/validate_ipv6_address_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_ipv6_address_spec.rb @@ -61,7 +61,7 @@ Puppet[:code] = "validate_ipv6_address()" expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError) end end end diff --git a/spec/unit/puppet/parser/functions/validate_re_spec.rb b/spec/unit/puppet/parser/functions/validate_re_spec.rb index d189efb66..0da646132 100644 --- a/spec/unit/puppet/parser/functions/validate_re_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_re_spec.rb @@ -24,7 +24,7 @@ inputs.each do |input| it "validate_re(#{input.inspect}) should fail" do - expect { subject.call [input] }.to raise_error Puppet::ParseError + expect { subject.call [input] }.to raise_error ArgumentError end end end diff --git a/spec/unit/puppet/parser/functions/validate_slength_spec.rb b/spec/unit/puppet/parser/functions/validate_slength_spec.rb index 851835fa1..e676708f0 100755 --- a/spec/unit/puppet/parser/functions/validate_slength_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_slength_spec.rb @@ -11,11 +11,11 @@ describe "validating the input argument types" do it "raises an error if there are less than two arguments" do - expect { scope.function_validate_slength([]) }.to raise_error Puppet::ParseError, /Wrong number of arguments/ + expect { scope.function_validate_slength([]) }.to raise_error ArgumentError end it "raises an error if there are more than three arguments" do - expect { scope.function_validate_slength(['input', 1, 2, 3]) }.to raise_error Puppet::ParseError, /Wrong number of arguments/ + expect { scope.function_validate_slength(['input', 1, 2, 3]) }.to raise_error ArgumentError end it "raises an error if the first argument is not a string" do diff --git a/spec/unit/puppet/parser/functions/values_at_spec.rb b/spec/unit/puppet/parser/functions/values_at_spec.rb index 08e95a567..6848df8d9 100644 --- a/spec/unit/puppet/parser/functions/values_at_spec.rb +++ b/spec/unit/puppet/parser/functions/values_at_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_values_at([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_values_at([]) }.should( raise_error(ArgumentError)) end it "should raise a ParseError if you try to use a range where stop is greater then start" do diff --git a/spec/unit/puppet/parser/functions/values_spec.rb b/spec/unit/puppet/parser/functions/values_spec.rb index 14ae41763..298751746 100644 --- a/spec/unit/puppet/parser/functions/values_spec.rb +++ b/spec/unit/puppet/parser/functions/values_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - lambda { scope.function_values([]) }.should( raise_error(Puppet::ParseError)) + lambda { scope.function_values([]) }.should( raise_error(ArgumentError)) end it "should return values from a hash" do