Skip to content

Commit

Permalink
Merge pull request #3856 from puppetlabs/3.x
Browse files Browse the repository at this point in the history
merge 3.x to master
  • Loading branch information
hlindberg committed Apr 21, 2015
2 parents 0102311 + 5badbff commit ffaffb9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/puppet/functions.rb
Expand Up @@ -328,6 +328,7 @@ def repeated_param(type, name)
# @api public
def required_repeated_param(type, name)
internal_param(type, name)
raise ArgumentError, 'A required repeated parameter cannot be added after an optional parameter' if @min != @max
@min += 1
@max = :default
end
Expand Down
16 changes: 16 additions & 0 deletions spec/unit/functions4_spec.rb
Expand Up @@ -240,6 +240,10 @@ def test(x)
expect { create_function_with_rq_after_opt }.to raise_error(ArgumentError, 'A required parameter cannot be added after an optional parameter')
end

it 'a function can not be created with required repeated parameters declared after optional ones' do
expect { create_function_with_rq_repeated_after_opt }.to raise_error(ArgumentError, 'A required repeated parameter cannot be added after an optional parameter')
end

it 'an error is raised with reference to multiple methods when called with mis-matched arguments' do
f = create_min_function_class_disptaching_to_two_methods()
# TODO: Bogus parameters, not yet used
Expand Down Expand Up @@ -658,6 +662,18 @@ def t1(*x)
end
end

def create_function_with_rq_repeated_after_opt
f = Puppet::Functions.create_function('t1') do
dispatch :t1 do
optional_param 'Numeric', :x
required_repeated_param 'Numeric', :y
end
def t1(x, *y)
x
end
end
end

def create_function_with_param_after_repeated
f = Puppet::Functions.create_function('t1') do
dispatch :t1 do
Expand Down

0 comments on commit ffaffb9

Please sign in to comment.