diff --git a/.travis.yml b/.travis.yml index 3ed11532c..e534f5ae3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,7 @@ matrix: fast_finish: true include: - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.0.0 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 617ba31b6..5a0361f47 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 @@ -12,9 +12,7 @@ module Puppet::Parser::Functions ENDHEREDOC 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/bool2str.rb b/lib/puppet/parser/functions/bool2str.rb index fcd379178..704e4cb5a 100644 --- a/lib/puppet/parser/functions/bool2str.rb +++ b/lib/puppet/parser/functions/bool2str.rb @@ -3,15 +3,12 @@ # module Puppet::Parser::Functions - newfunction(:bool2str, :type => :rvalue, :doc => <<-EOS + newfunction(:bool2str, :type => :rvalue, :arity => 1, :doc => <<-EOS Converts a boolean to a string. Requires a single boolean as an input. EOS ) do |arguments| - raise(Puppet::ParseError, "bool2str(): 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/camelcase.rb b/lib/puppet/parser/functions/camelcase.rb index d7f43f7a7..85ffa50f9 100644 --- a/lib/puppet/parser/functions/camelcase.rb +++ b/lib/puppet/parser/functions/camelcase.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:camelcase, :type => :rvalue, :doc => <<-EOS + newfunction(:camelcase, :type => :rvalue, :arity => 1, :doc => <<-EOS Converts the case of a string or all strings in an array to camel case. EOS ) do |arguments| - raise(Puppet::ParseError, "camelcase(): 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 0d35b07eb..084467ee5 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/deep_merge.rb b/lib/puppet/parser/functions/deep_merge.rb index 6df32e9c5..e11eff9ed 100644 --- a/lib/puppet/parser/functions/deep_merge.rb +++ b/lib/puppet/parser/functions/deep_merge.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:deep_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:deep_merge, :type => :rvalue, :arity => -3, :doc => <<-'ENDHEREDOC') do |args| Recursively merges two or more hashes together and returns the resulting hash. For example: @@ -15,10 +15,6 @@ module Puppet::Parser::Functions ENDHEREDOC - if args.length < 2 - raise Puppet::ParseError, ("deep_merge(): wrong number of arguments (#{args.length}; must be at least 2)") - end - deep_merge = Proc.new do |hash1,hash2| hash1.merge(hash2) do |key,old_value,new_value| if old_value.is_a?(Hash) && new_value.is_a?(Hash) 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 d03a29355..fbbb427da 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].dup 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 f94d4da8d..787678a6a 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 - unless args[0].is_a? Array or args[0].is_a? Hash raise(Puppet::ParseError, "delete_undef_values(): expected an array or hash, got #{args[0]} type #{args[0].class} ") diff --git a/lib/puppet/parser/functions/delete_values.rb b/lib/puppet/parser/functions/delete_values.rb index f6c8c0e6b..96d11e814 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 f1da4aaaa..c9796c092 100644 --- a/lib/puppet/parser/functions/ensure_packages.rb +++ b/lib/puppet/parser/functions/ensure_packages.rb @@ -3,18 +3,18 @@ # module Puppet::Parser::Functions - newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS + newfunction(:ensure_packages, :type => :statement, :arity => -2, :doc => <<-EOS Takes a list of packages and only installs them if they don't already exist. It optionally takes a hash as a second parameter that will be passed as the third argument to the ensure_resource() function. EOS ) do |arguments| - if arguments.size > 2 or arguments.size == 0 - raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments " + + if arguments.size > 2 + raise(ArgumentError, "ensure_packages(): Wrong number of arguments " + "given (#{arguments.size} for 1 or 2)") - elsif arguments.size == 2 and !arguments[1].is_a?(Hash) - raise(Puppet::ParseError, 'ensure_packages(): Requires second argument to be a Hash') + elsif arguments.size == 2 and !arguments[1].is_a?(Hash) + raise(ArgumentError, 'ensure_packages(): Requires second argument to be a Hash') end packages = Array(arguments[0]) 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 9a6f014d7..718653e64 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 - begin arg = Float(arguments[0]) rescue TypeError, ArgumentError => e 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 fb336b6ac..2238732a8 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 - begin self.lookupvar("#{args[0]}") rescue Puppet::ParseError # Eat the exception if strict_variables = true is set 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 10ad5427c..12c4d87a6 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_bool.rb b/lib/puppet/parser/functions/is_bool.rb index 8bbdbc8a1..da91a0f2f 100644 --- a/lib/puppet/parser/functions/is_bool.rb +++ b/lib/puppet/parser/functions/is_bool.rb @@ -3,14 +3,11 @@ # module Puppet::Parser::Functions - newfunction(:is_bool, :type => :rvalue, :doc => <<-EOS + newfunction(:is_bool, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the variable passed to this function is a boolean. EOS ) do |arguments| - raise(Puppet::ParseError, "is_bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 - type = arguments[0] result = type.is_a?(TrueClass) || type.is_a?(FalseClass) diff --git a/lib/puppet/parser/functions/is_domain_name.rb b/lib/puppet/parser/functions/is_domain_name.rb index b3fee965a..9a0471421 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 a2da94385..a0c4cfcd4 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] # Only allow Numeric or String types diff --git a/lib/puppet/parser/functions/is_function_available.rb b/lib/puppet/parser/functions/is_function_available.rb index 6da82c8c1..4bdcea91f 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 - # Only allow String types return false unless arguments[0].is_a?(String) 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 c03d28df9..cbd70da92 100644 --- a/lib/puppet/parser/functions/is_integer.rb +++ b/lib/puppet/parser/functions/is_integer.rb @@ -3,7 +3,7 @@ # 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 passed to this function is an Integer or a decimal (base 10) integer in String form. The string may start with a '-' (minus). A value of '0' is allowed, but a leading '0' digit may not @@ -13,11 +13,6 @@ module Puppet::Parser::Functions 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] # Regex is taken from the lexer of puppet 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 e7e1d2a74..9b2f11ebc 100644 --- a/lib/puppet/parser/functions/is_numeric.rb +++ b/lib/puppet/parser/functions/is_numeric.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS + newfunction(:is_numeric, :type => :rvalue, :arity => 1, :doc => <<-EOS Returns true if the given argument is a Numeric (Integer or Float), or a String containing either a valid integer in decimal base 10 form, or a valid floating point string representation. @@ -24,11 +24,6 @@ module Puppet::Parser::Functions 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] # Regex is taken from the lexer of puppet 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 6c0a6ba02..299394565 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 separator. *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 fdd0aefd7..ebc4ed182 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/pick_default.rb b/lib/puppet/parser/functions/pick_default.rb index 36e33abfa..ac10a6dea 100644 --- a/lib/puppet/parser/functions/pick_default.rb +++ b/lib/puppet/parser/functions/pick_default.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:pick_default, :type => :rvalue, :doc => <<-EOS + newfunction(:pick_default, :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 @@ -23,7 +23,6 @@ module Puppet::Parser::Functions EOS ) do |args| - fail "Must receive at least one argument." if args.empty? default = args.last args = args[0..-2].compact args.delete(:undef) diff --git a/lib/puppet/parser/functions/prefix.rb b/lib/puppet/parser/functions/prefix.rb index d02286afa..480b8871c 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/private.rb b/lib/puppet/parser/functions/private.rb index 60210d335..0545ef8a2 100644 --- a/lib/puppet/parser/functions/private.rb +++ b/lib/puppet/parser/functions/private.rb @@ -3,13 +3,13 @@ # module Puppet::Parser::Functions - newfunction(:private, :doc => <<-'EOS' + newfunction(:private, :arity => -1, :doc => <<-'EOS' Sets the current class or definition as private. Calling the class or definition from outside the current module will fail. EOS ) do |args| - raise(Puppet::ParseError, "private(): Wrong number of arguments "+ + raise(ArgumentError, "private(): Wrong number of arguments "+ "given (#{args.size}}) for 0 or 1)") if args.size > 1 scope = self diff --git a/lib/puppet/parser/functions/range.rb b/lib/puppet/parser/functions/range.rb index ffbdf8463..f39494c7a 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 446732ece..a952d3db0 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 59a08056b..d18d0814a 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 function_is_bool([arg]) 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 2ebe91cf7..0c5fe5e1b 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 c841f6abb..15be7ca36 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. @@ -23,10 +23,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/lib/puppet/parser/functions/zip.rb b/lib/puppet/parser/functions/zip.rb index 2b56e9ca0..afdfb08fa 100644 --- a/lib/puppet/parser/functions/zip.rb +++ b/lib/puppet/parser/functions/zip.rb @@ -3,7 +3,7 @@ # module Puppet::Parser::Functions - newfunction(:zip, :type => :rvalue, :doc => <<-EOS + newfunction(:zip, :type => :rvalue, :arity => -2, :doc => <<-EOS Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments. *Example:* @@ -16,10 +16,6 @@ module Puppet::Parser::Functions EOS ) do |arguments| - # Technically we support three arguments but only first is mandatory ... - raise(Puppet::ParseError, "zip(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size < 2 - a = arguments[0] b = arguments[1] diff --git a/spec/functions/abs_spec.rb b/spec/functions/abs_spec.rb index 3c25ce28f..ece2bc834 100755 --- a/spec/functions/abs_spec.rb +++ b/spec/functions/abs_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_abs([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_abs([]) }.to( raise_error(ArgumentError)) end it "should convert a negative number into a positive" do diff --git a/spec/functions/base64_spec.rb b/spec/functions/base64_spec.rb index e93fafcd0..f8a180bbe 100755 --- a/spec/functions/base64_spec.rb +++ b/spec/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/functions/bool2num_spec.rb b/spec/functions/bool2num_spec.rb index fbf461b14..315924138 100755 --- a/spec/functions/bool2num_spec.rb +++ b/spec/functions/bool2num_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_bool2num([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_bool2num([]) }.to( raise_error(ArgumentError)) end it "should convert true to 1" do diff --git a/spec/functions/capitalize_spec.rb b/spec/functions/capitalize_spec.rb index 0cc2d760b..090c7a5ae 100755 --- a/spec/functions/capitalize_spec.rb +++ b/spec/functions/capitalize_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_capitalize([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_capitalize([]) }.to( raise_error(ArgumentError)) end it "should capitalize the beginning of a string" do diff --git a/spec/functions/chomp_spec.rb b/spec/functions/chomp_spec.rb index d2ae28749..ddf29ff4b 100755 --- a/spec/functions/chomp_spec.rb +++ b/spec/functions/chomp_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_chomp([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_chomp([]) }.to( raise_error(ArgumentError)) end it "should chomp the end of a string" do diff --git a/spec/functions/chop_spec.rb b/spec/functions/chop_spec.rb index d9dbb88a5..922974d8d 100755 --- a/spec/functions/chop_spec.rb +++ b/spec/functions/chop_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_chop([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_chop([]) }.to( raise_error(ArgumentError)) end it "should chop the end of a string" do diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index 49cb2ad7f..711c633d2 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -5,7 +5,7 @@ let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should raise a ParseError if the client does not provide two arguments" do - expect { scope.function_concat([]) }.to(raise_error(Puppet::ParseError)) + expect { scope.function_concat([]) }.to(raise_error(ArgumentError)) end it "should raise a ParseError if the first parameter is not an array" do diff --git a/spec/functions/deep_merge_spec.rb b/spec/functions/deep_merge_spec.rb index 7087904a8..1213b58ce 100755 --- a/spec/functions/deep_merge_spec.rb +++ b/spec/functions/deep_merge_spec.rb @@ -11,7 +11,7 @@ Puppet[:code] = '$x = deep_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 = deep_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/functions/delete_at_spec.rb b/spec/functions/delete_at_spec.rb index 7c20aec42..ab3128a34 100755 --- a/spec/functions/delete_at_spec.rb +++ b/spec/functions/delete_at_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_delete_at([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_delete_at([]) }.to( raise_error(ArgumentError)) end it "should delete an item at specified location from an array" do diff --git a/spec/functions/delete_spec.rb b/spec/functions/delete_spec.rb index 39b3176d0..13dba1442 100755 --- a/spec/functions/delete_spec.rb +++ b/spec/functions/delete_spec.rb @@ -9,11 +9,11 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - expect { scope.function_delete([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_delete([]) }.to( raise_error(ArgumentError)) end it "should raise a ParseError if there are greater than 2 arguments" do - expect { scope.function_delete([[], 'foo', 'bar']) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_delete([[], 'foo', 'bar']) }.to( raise_error(ArgumentError)) end it "should raise a TypeError if a number is passed as the first argument" do diff --git a/spec/functions/delete_undef_values_spec.rb b/spec/functions/delete_undef_values_spec.rb index dc679535f..fad5a8571 100755 --- a/spec/functions/delete_undef_values_spec.rb +++ b/spec/functions/delete_undef_values_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 argument" do - expect { scope.function_delete_undef_values([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_delete_undef_values([]) }.to( raise_error(ArgumentError)) end it "should raise a ParseError if the argument is not Array nor Hash" do diff --git a/spec/functions/delete_values_spec.rb b/spec/functions/delete_values_spec.rb index 4f4d411b8..f85095181 100755 --- a/spec/functions/delete_values_spec.rb +++ b/spec/functions/delete_values_spec.rb @@ -9,11 +9,11 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - expect { scope.function_delete_values([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_delete_values([]) }.to( raise_error(ArgumentError)) end it "should raise a ParseError if there are greater than 2 arguments" do - expect { scope.function_delete_values([[], 'foo', 'bar']) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_delete_values([[], 'foo', 'bar']) }.to( raise_error(ArgumentError)) end it "should raise a TypeError if the argument is not a hash" do diff --git a/spec/functions/difference_spec.rb b/spec/functions/difference_spec.rb index 24b2b1bc6..6016929d6 100755 --- a/spec/functions/difference_spec.rb +++ b/spec/functions/difference_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - expect { scope.function_difference([]) }.to( raise_error(Puppet::ParseError) ) + expect { scope.function_difference([]) }.to( raise_error(ArgumentError) ) end it "should return the difference between two arrays" do diff --git a/spec/functions/dirname_spec.rb b/spec/functions/dirname_spec.rb index 8a3bcabfc..8c17de743 100755 --- a/spec/functions/dirname_spec.rb +++ b/spec/functions/dirname_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_dirname([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_dirname([]) }.to( raise_error(ArgumentError)) end it "should return dirname for an absolute path" do diff --git a/spec/functions/downcase_spec.rb b/spec/functions/downcase_spec.rb index a844780b1..8c6cad967 100755 --- a/spec/functions/downcase_spec.rb +++ b/spec/functions/downcase_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_downcase([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_downcase([]) }.to( raise_error(ArgumentError)) end it "should downcase a string" do diff --git a/spec/functions/empty_spec.rb b/spec/functions/empty_spec.rb index 1f2ace4ca..8ed1d325c 100755 --- a/spec/functions/empty_spec.rb +++ b/spec/functions/empty_spec.rb @@ -8,7 +8,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_empty([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_empty([]) }.to( raise_error(ArgumentError)) end it "should return a true for an empty string" do diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 436be10bc..d092dbe5c 100755 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -32,7 +32,7 @@ it 'fails with no arguments' do expect { scope.function_ensure_packages([]) - }.to raise_error(Puppet::ParseError, /0 for 1 or 2/) + }.to raise_error(ArgumentError) end it 'accepts an array of values' do diff --git a/spec/functions/flatten_spec.rb b/spec/functions/flatten_spec.rb index de8c66d66..22d506cf1 100755 --- a/spec/functions/flatten_spec.rb +++ b/spec/functions/flatten_spec.rb @@ -8,11 +8,11 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_flatten([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_flatten([]) }.to( raise_error(ArgumentError)) end it "should raise a ParseError if there is more than 1 argument" do - expect { scope.function_flatten([[], []]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_flatten([[], []]) }.to( raise_error(ArgumentError)) end it "should flatten a complex data structure" do diff --git a/spec/functions/floor_spec.rb b/spec/functions/floor_spec.rb index 12a691798..9bdb3cb04 100755 --- a/spec/functions/floor_spec.rb +++ b/spec/functions/floor_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 argument" do - expect { scope.function_floor([]) }.to( raise_error(Puppet::ParseError, /Wrong number of arguments/)) + expect { scope.function_floor([]) }.to( raise_error(ArgumentError, /Wrong number of arguments/)) end it "should should raise a ParseError if input isn't numeric (eg. String)" do @@ -36,4 +36,3 @@ expect(result).to(eq(3)) end end - diff --git a/spec/functions/fqdn_rotate_spec.rb b/spec/functions/fqdn_rotate_spec.rb index b2dc1f5a3..aad2cf03a 100755 --- a/spec/functions/fqdn_rotate_spec.rb +++ b/spec/functions/fqdn_rotate_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_fqdn_rotate([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_fqdn_rotate([]) }.to( raise_error(ArgumentError)) end it "should rotate a string and the result should be the same size" do diff --git a/spec/functions/get_module_path_spec.rb b/spec/functions/get_module_path_spec.rb index 38ce64597..851e1fcf4 100755 --- a/spec/functions/get_module_path_spec.rb +++ b/spec/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/functions/getvar_spec.rb b/spec/functions/getvar_spec.rb index 87ab9b5ac..dea8c0fbd 100755 --- a/spec/functions/getvar_spec.rb +++ b/spec/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/functions/grep_spec.rb b/spec/functions/grep_spec.rb index 9c671dd86..0e92f6fdb 100755 --- a/spec/functions/grep_spec.rb +++ b/spec/functions/grep_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_grep([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_grep([]) }.to( raise_error(ArgumentError)) end it "should grep contents from an array" do diff --git a/spec/functions/has_key_spec.rb b/spec/functions/has_key_spec.rb index 6b718005a..0c3bbdb05 100755 --- a/spec/functions/has_key_spec.rb +++ b/spec/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/functions/hash_spec.rb b/spec/functions/hash_spec.rb index ec2988b02..7217eb304 100755 --- a/spec/functions/hash_spec.rb +++ b/spec/functions/hash_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_hash([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_hash([]) }.to( raise_error(ArgumentError)) end it "should convert an array to a hash" do diff --git a/spec/functions/intersection_spec.rb b/spec/functions/intersection_spec.rb index 6361304fe..aea215c8d 100755 --- a/spec/functions/intersection_spec.rb +++ b/spec/functions/intersection_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - expect { scope.function_intersection([]) }.to( raise_error(Puppet::ParseError) ) + expect { scope.function_intersection([]) }.to( raise_error(ArgumentError) ) end it "should return the intersection of two arrays" do diff --git a/spec/functions/is_array_spec.rb b/spec/functions/is_array_spec.rb index 94920a4cb..123adbedb 100755 --- a/spec/functions/is_array_spec.rb +++ b/spec/functions/is_array_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_is_array([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_array([]) }.to( raise_error(ArgumentError)) end it "should return true if passed an array" do diff --git a/spec/functions/is_bool_spec.rb b/spec/functions/is_bool_spec.rb index 4a342ba4f..386518746 100755 --- a/spec/functions/is_bool_spec.rb +++ b/spec/functions/is_bool_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_is_bool([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_bool([]) }.to( raise_error(ArgumentError)) end it "should return true if passed a TrueClass" do diff --git a/spec/functions/is_domain_name_spec.rb b/spec/functions/is_domain_name_spec.rb index 4d05f5cdc..8477bc14e 100755 --- a/spec/functions/is_domain_name_spec.rb +++ b/spec/functions/is_domain_name_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_is_domain_name([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_domain_name([]) }.to( raise_error(ArgumentError)) end it "should return true if a valid short domain name" do diff --git a/spec/functions/is_float_spec.rb b/spec/functions/is_float_spec.rb index d926634e8..4a92883f9 100755 --- a/spec/functions/is_float_spec.rb +++ b/spec/functions/is_float_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_is_float([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_float([]) }.to( raise_error(ArgumentError)) end it "should return true if a float" do diff --git a/spec/functions/is_hash_spec.rb b/spec/functions/is_hash_spec.rb index a84941111..ca85c5e3f 100755 --- a/spec/functions/is_hash_spec.rb +++ b/spec/functions/is_hash_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_is_hash([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_hash([]) }.to( raise_error(ArgumentError)) end it "should return true if passed a hash" do diff --git a/spec/functions/is_integer_spec.rb b/spec/functions/is_integer_spec.rb index f0cbca807..4a9b0056d 100755 --- a/spec/functions/is_integer_spec.rb +++ b/spec/functions/is_integer_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_is_integer([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_integer([]) }.to( raise_error(ArgumentError)) end it "should return true if an integer" do diff --git a/spec/functions/is_ip_address_spec.rb b/spec/functions/is_ip_address_spec.rb index c16d12b16..a10780504 100755 --- a/spec/functions/is_ip_address_spec.rb +++ b/spec/functions/is_ip_address_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_is_ip_address([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_ip_address([]) }.to( raise_error(ArgumentError)) end it "should return true if an IPv4 address" do diff --git a/spec/functions/is_mac_address_spec.rb b/spec/functions/is_mac_address_spec.rb index 66edd197e..3f185b4ba 100755 --- a/spec/functions/is_mac_address_spec.rb +++ b/spec/functions/is_mac_address_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_is_mac_address([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_mac_address([]) }.to( raise_error(ArgumentError)) end it "should return true if a valid mac address" do diff --git a/spec/functions/is_numeric_spec.rb b/spec/functions/is_numeric_spec.rb index 4176961d7..ebf56b491 100755 --- a/spec/functions/is_numeric_spec.rb +++ b/spec/functions/is_numeric_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 argument" do - expect { scope.function_is_numeric([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_numeric([]) }.to( raise_error(ArgumentError)) end it "should return true if an integer" do diff --git a/spec/functions/is_string_spec.rb b/spec/functions/is_string_spec.rb index 6a0801ae8..674dd1f48 100755 --- a/spec/functions/is_string_spec.rb +++ b/spec/functions/is_string_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_is_string([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_is_string([]) }.to( raise_error(ArgumentError)) end it "should return true if a string" do diff --git a/spec/functions/join_keys_to_values_spec.rb b/spec/functions/join_keys_to_values_spec.rb index 4a9ae87a2..de0a30d7b 100755 --- a/spec/functions/join_keys_to_values_spec.rb +++ b/spec/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 - expect { scope.function_join_keys_to_values([{}]) }.to raise_error Puppet::ParseError + expect { scope.function_join_keys_to_values([{}]) }.to raise_error ArgumentError end it "should raise a ParseError if there are greater than two arguments" do - expect { scope.function_join_keys_to_values([{}, 'foo', 'bar']) }.to raise_error Puppet::ParseError + expect { scope.function_join_keys_to_values([{}, 'foo', 'bar']) }.to raise_error ArgumentError end it "should raise a TypeError if the first argument is an array" do diff --git a/spec/functions/join_spec.rb b/spec/functions/join_spec.rb index 793c36fa3..91d61412a 100755 --- a/spec/functions/join_spec.rb +++ b/spec/functions/join_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_join([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_join([]) }.to( raise_error(ArgumentError)) end it "should join an array into a string" do diff --git a/spec/functions/keys_spec.rb b/spec/functions/keys_spec.rb index f2e7d428e..6bd3a2380 100755 --- a/spec/functions/keys_spec.rb +++ b/spec/functions/keys_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_keys([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_keys([]) }.to( raise_error(ArgumentError)) end it "should return an array of keys when given a hash" do diff --git a/spec/functions/loadyaml_spec.rb b/spec/functions/loadyaml_spec.rb index cdc3d6f51..b10ffba8a 100755 --- a/spec/functions/loadyaml_spec.rb +++ b/spec/functions/loadyaml_spec.rb @@ -11,7 +11,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_loadyaml([]) }.to raise_error(Puppet::ParseError) + expect { scope.function_loadyaml([]) }.to raise_error(ArgumentError) end it "should convert YAML file to a data structure" do diff --git a/spec/functions/lstrip_spec.rb b/spec/functions/lstrip_spec.rb index 7025f97b8..1dafee3d3 100755 --- a/spec/functions/lstrip_spec.rb +++ b/spec/functions/lstrip_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_lstrip([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_lstrip([]) }.to( raise_error(ArgumentError)) end it "should lstrip a string" do diff --git a/spec/functions/max_spec.rb b/spec/functions/max_spec.rb index c3d8a132f..edca4d7c0 100755 --- a/spec/functions/max_spec.rb +++ b/spec/functions/max_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_max([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_max([]) }.to( raise_error(ArgumentError)) end it "should be able to compare strings" do diff --git a/spec/functions/member_spec.rb b/spec/functions/member_spec.rb index cee611082..c2eec4da8 100755 --- a/spec/functions/member_spec.rb +++ b/spec/functions/member_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_member([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_member([]) }.to( raise_error(ArgumentError)) end it "should return true if a member is in an array" do diff --git a/spec/functions/merge_spec.rb b/spec/functions/merge_spec.rb index 2abf97622..9d4bef94d 100755 --- a/spec/functions/merge_spec.rb +++ b/spec/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/functions/min_spec.rb b/spec/functions/min_spec.rb index 35a08900b..a2f034406 100755 --- a/spec/functions/min_spec.rb +++ b/spec/functions/min_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_min([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_min([]) }.to( raise_error(ArgumentError)) end it "should be able to compare strings" do diff --git a/spec/functions/num2bool_spec.rb b/spec/functions/num2bool_spec.rb index d0ba93548..97b8be2c1 100755 --- a/spec/functions/num2bool_spec.rb +++ b/spec/functions/num2bool_spec.rb @@ -9,11 +9,11 @@ end it "should raise a ParseError if there are no arguments" do - expect { scope.function_num2bool([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_num2bool([]) }.to( raise_error(ArgumentError)) end it "should raise a ParseError if there are more than 1 arguments" do - expect { scope.function_num2bool(["foo","bar"]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_num2bool(["foo","bar"]) }.to( raise_error(ArgumentError)) end it "should raise a ParseError if passed something non-numeric" do diff --git a/spec/functions/parsejson_spec.rb b/spec/functions/parsejson_spec.rb index 1dd41b960..0278386fd 100755 --- a/spec/functions/parsejson_spec.rb +++ b/spec/functions/parsejson_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_parsejson([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_parsejson([]) }.to( raise_error(ArgumentError)) end it "should convert JSON to a data structure" do diff --git a/spec/functions/parseyaml_spec.rb b/spec/functions/parseyaml_spec.rb index e5f145ba1..e7e022822 100755 --- a/spec/functions/parseyaml_spec.rb +++ b/spec/functions/parseyaml_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_parseyaml([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_parseyaml([]) }.to( raise_error(ArgumentError)) end it "should convert YAML to a data structure" do diff --git a/spec/functions/pick_default_spec.rb b/spec/functions/pick_default_spec.rb index db10cc354..eda307230 100755 --- a/spec/functions/pick_default_spec.rb +++ b/spec/functions/pick_default_spec.rb @@ -53,6 +53,6 @@ end it 'should error if no values are passed' do - expect { scope.function_pick_default([]) }.to raise_error(Puppet::Error, /Must receive at least one argument./) + expect { scope.function_pick_default([]) }.to raise_error(ArgumentError) end end diff --git a/spec/functions/pick_spec.rb b/spec/functions/pick_spec.rb index 8be8f5875..bc0109c11 100755 --- a/spec/functions/pick_spec.rb +++ b/spec/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::ParseError, "pick(): must receive at least one non empty value")) + expect { scope.function_pick([]) }.to( raise_error(ArgumentError)) end end diff --git a/spec/functions/prefix_spec.rb b/spec/functions/prefix_spec.rb index 34cac5305..ea92c2f02 100755 --- a/spec/functions/prefix_spec.rb +++ b/spec/functions/prefix_spec.rb @@ -5,7 +5,7 @@ let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "raises a ParseError if there is less than 1 arguments" do - expect { scope.function_prefix([]) }.to raise_error(Puppet::ParseError, /number of arguments/) + expect { scope.function_prefix([]) }.to raise_error(ArgumentError) end it "raises an error if the first argument is not an array" do @@ -14,7 +14,6 @@ }.to raise_error(Puppet::ParseError, /expected first argument to be an Array/) end - it "raises an error if the second argument is not a string" do expect { scope.function_prefix([['first', 'second'], 42]) diff --git a/spec/functions/range_spec.rb b/spec/functions/range_spec.rb index 9b9ece024..a0b9d21a7 100755 --- a/spec/functions/range_spec.rb +++ b/spec/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/functions/reject_spec.rb b/spec/functions/reject_spec.rb index 88a992efc..c70fe447c 100755 --- a/spec/functions/reject_spec.rb +++ b/spec/functions/reject_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_reject([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_reject([]) }.to( raise_error(ArgumentError)) end it "should reject contents from an array" do diff --git a/spec/functions/reverse_spec.rb b/spec/functions/reverse_spec.rb index bfeabfb84..ffe7518ac 100755 --- a/spec/functions/reverse_spec.rb +++ b/spec/functions/reverse_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_reverse([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_reverse([]) }.to( raise_error(ArgumentError)) end it "should reverse a string" do diff --git a/spec/functions/rstrip_spec.rb b/spec/functions/rstrip_spec.rb index 81321d766..777119692 100755 --- a/spec/functions/rstrip_spec.rb +++ b/spec/functions/rstrip_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_rstrip([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_rstrip([]) }.to( raise_error(ArgumentError)) end it "should rstrip a string" do diff --git a/spec/functions/shuffle_spec.rb b/spec/functions/shuffle_spec.rb index ee0e2ffb2..9050347b1 100755 --- a/spec/functions/shuffle_spec.rb +++ b/spec/functions/shuffle_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_shuffle([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_shuffle([]) }.to( raise_error(ArgumentError)) end it "should shuffle a string and the result should be the same size" do diff --git a/spec/functions/size_spec.rb b/spec/functions/size_spec.rb index 18eb48f96..8250c0527 100755 --- a/spec/functions/size_spec.rb +++ b/spec/functions/size_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_size([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_size([]) }.to( raise_error(ArgumentError)) end it "should return the size of a string" do diff --git a/spec/functions/sort_spec.rb b/spec/functions/sort_spec.rb index 4c2a66cf8..4c984fac7 100755 --- a/spec/functions/sort_spec.rb +++ b/spec/functions/sort_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is not 1 arguments" do - expect { scope.function_sort(['','']) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_sort(['','']) }.to( raise_error(ArgumentError)) end it "should sort an array" do diff --git a/spec/functions/squeeze_spec.rb b/spec/functions/squeeze_spec.rb index cd0eb37fc..0cdf6f8c3 100755 --- a/spec/functions/squeeze_spec.rb +++ b/spec/functions/squeeze_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 2 arguments" do - expect { scope.function_squeeze([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_squeeze([]) }.to( raise_error(ArgumentError)) end it "should squeeze a string" do diff --git a/spec/functions/str2bool_spec.rb b/spec/functions/str2bool_spec.rb index 1d205d75d..14943e8a7 100755 --- a/spec/functions/str2bool_spec.rb +++ b/spec/functions/str2bool_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_str2bool([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_str2bool([]) }.to( raise_error(ArgumentError)) end it "should convert string 'true' to true" do diff --git a/spec/functions/str2saltedsha512_spec.rb b/spec/functions/str2saltedsha512_spec.rb index ab7f57f11..a9d4cff9d 100755 --- a/spec/functions/str2saltedsha512_spec.rb +++ b/spec/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/functions/strftime_spec.rb b/spec/functions/strftime_spec.rb index ebec54b80..cab5d4692 100755 --- a/spec/functions/strftime_spec.rb +++ b/spec/functions/strftime_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_strftime([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_strftime([]) }.to( raise_error(ArgumentError)) end it "using %s should be higher then when I wrote this test" do diff --git a/spec/functions/strip_spec.rb b/spec/functions/strip_spec.rb index e228761d0..3a4d8d53d 100755 --- a/spec/functions/strip_spec.rb +++ b/spec/functions/strip_spec.rb @@ -8,7 +8,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_strip([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_strip([]) }.to( raise_error(ArgumentError)) end it "should strip a string" do diff --git a/spec/functions/suffix_spec.rb b/spec/functions/suffix_spec.rb index c7783c64d..f6f359fb0 100755 --- a/spec/functions/suffix_spec.rb +++ b/spec/functions/suffix_spec.rb @@ -5,7 +5,7 @@ let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "raises a ParseError if there is less than 1 arguments" do - expect { scope.function_suffix([]) }.to raise_error(Puppet::ParseError, /number of arguments/) + expect { scope.function_suffix([]) }.to raise_error(ArgumentError) end it "raises an error if the first argument is not an array" do diff --git a/spec/functions/swapcase_spec.rb b/spec/functions/swapcase_spec.rb index c6838ab4e..36d7be1d1 100755 --- a/spec/functions/swapcase_spec.rb +++ b/spec/functions/swapcase_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_swapcase([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_swapcase([]) }.to( raise_error(ArgumentError)) end it "should swapcase a string" do diff --git a/spec/functions/time_spec.rb b/spec/functions/time_spec.rb index 6e22515f1..3515cdb91 100755 --- a/spec/functions/time_spec.rb +++ b/spec/functions/time_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is more than 2 arguments" do - expect { scope.function_time(['','']) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_time(['','']) }.to( raise_error(ArgumentError)) end it "should return a number" do diff --git a/spec/functions/to_bytes_spec.rb b/spec/functions/to_bytes_spec.rb index 68a1eb8b7..5ec1edc93 100755 --- a/spec/functions/to_bytes_spec.rb +++ b/spec/functions/to_bytes_spec.rb @@ -10,7 +10,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_to_bytes([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_to_bytes([]) }.to( raise_error(ArgumentError)) end it "should convert kB to B" do diff --git a/spec/functions/type_spec.rb b/spec/functions/type_spec.rb index 9dfe9d7f5..ee371ef94 100755 --- a/spec/functions/type_spec.rb +++ b/spec/functions/type_spec.rb @@ -8,7 +8,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_type([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_type([]) }.to( raise_error(ArgumentError)) end it "should return string when given a string" do diff --git a/spec/functions/union_spec.rb b/spec/functions/union_spec.rb index 706f4cbcd..05e661fb9 100755 --- a/spec/functions/union_spec.rb +++ b/spec/functions/union_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there are fewer than 2 arguments" do - expect { scope.function_union([]) }.to( raise_error(Puppet::ParseError) ) + expect { scope.function_union([]) }.to( raise_error(ArgumentError) ) end it "should join two arrays together" do diff --git a/spec/functions/unique_spec.rb b/spec/functions/unique_spec.rb index 8ec1464eb..585543514 100755 --- a/spec/functions/unique_spec.rb +++ b/spec/functions/unique_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_unique([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_unique([]) }.to( raise_error(ArgumentError)) end it "should remove duplicate elements in a string" do diff --git a/spec/functions/upcase_spec.rb b/spec/functions/upcase_spec.rb index 78e55ddf1..1059cc7f9 100755 --- a/spec/functions/upcase_spec.rb +++ b/spec/functions/upcase_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_upcase([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_upcase([]) }.to( raise_error(ArgumentError)) end it "should upcase a string" do diff --git a/spec/functions/uriescape_spec.rb b/spec/functions/uriescape_spec.rb index c44e9c19b..beec729a0 100755 --- a/spec/functions/uriescape_spec.rb +++ b/spec/functions/uriescape_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_uriescape([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_uriescape([]) }.to( raise_error(ArgumentError)) end it "should uriescape a string" do diff --git a/spec/functions/validate_bool_spec.rb b/spec/functions/validate_bool_spec.rb index a352d3b55..97edb741e 100755 --- a/spec/functions/validate_bool_spec.rb +++ b/spec/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/functions/validate_ipv4_address_spec.rb b/spec/functions/validate_ipv4_address_spec.rb index 45401a423..172cf0ee2 100755 --- a/spec/functions/validate_ipv4_address_spec.rb +++ b/spec/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/functions/validate_ipv6_address_spec.rb b/spec/functions/validate_ipv6_address_spec.rb index a839d902c..7e1d37c5d 100755 --- a/spec/functions/validate_ipv6_address_spec.rb +++ b/spec/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/functions/validate_re_spec.rb b/spec/functions/validate_re_spec.rb index d29988bf0..e7d42983a 100755 --- a/spec/functions/validate_re_spec.rb +++ b/spec/functions/validate_re_spec.rb @@ -25,7 +25,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/functions/validate_slength_spec.rb b/spec/functions/validate_slength_spec.rb index e23f61a20..b666ed2fe 100755 --- a/spec/functions/validate_slength_spec.rb +++ b/spec/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/functions/values_at_spec.rb b/spec/functions/values_at_spec.rb index 86e3c31c6..34cedb82c 100755 --- a/spec/functions/values_at_spec.rb +++ b/spec/functions/values_at_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_values_at([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_values_at([]) }.to( 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/functions/values_spec.rb b/spec/functions/values_spec.rb index 08d21b037..70e786faa 100755 --- a/spec/functions/values_spec.rb +++ b/spec/functions/values_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_values([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_values([]) }.to( raise_error(ArgumentError)) end it "should return values from a hash" do diff --git a/spec/functions/zip_spec.rb b/spec/functions/zip_spec.rb index 744bdd786..861e44a02 100755 --- a/spec/functions/zip_spec.rb +++ b/spec/functions/zip_spec.rb @@ -5,7 +5,7 @@ let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_zip([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_zip([]) }.to( raise_error(ArgumentError)) end it "should be able to zip an array" do diff --git a/spec/unit/puppet/parser/functions/bool2str_spec.rb b/spec/unit/puppet/parser/functions/bool2str_spec.rb index b87889180..f19dd4428 100755 --- a/spec/unit/puppet/parser/functions/bool2str_spec.rb +++ b/spec/unit/puppet/parser/functions/bool2str_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_bool2str([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_bool2str([]) }.to( raise_error(ArgumentError)) end it "should convert true to 'true'" do diff --git a/spec/unit/puppet/parser/functions/camelcase_spec.rb b/spec/unit/puppet/parser/functions/camelcase_spec.rb index 70382adb1..94282afae 100755 --- a/spec/unit/puppet/parser/functions/camelcase_spec.rb +++ b/spec/unit/puppet/parser/functions/camelcase_spec.rb @@ -9,7 +9,7 @@ end it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_camelcase([]) }.to( raise_error(Puppet::ParseError)) + expect { scope.function_camelcase([]) }.to( raise_error(ArgumentError)) end it "should capitalize the beginning of a normal string" do