Fix number of arguments check in flatten()
The function only uses the first argument, so raise an error with too few arguments *and* with too many arguments.
This commit is contained in:
parent
1e2ee5bd01
commit
e80207bede
2 changed files with 5 additions and 1 deletions
|
@ -16,7 +16,7 @@ Would return: ['a','b','c']
|
|||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "flatten(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
"given (#{arguments.size} for 1)") if arguments.size != 1
|
||||
|
||||
array = arguments[0]
|
||||
|
||||
|
|
|
@ -11,6 +11,10 @@ describe "the flatten function" do
|
|||
lambda { scope.function_flatten([]) }.should( raise_error(Puppet::ParseError))
|
||||
end
|
||||
|
||||
it "should raise a ParseError if there is more than 1 argument" do
|
||||
lambda { scope.function_flatten([[], []]) }.should( raise_error(Puppet::ParseError))
|
||||
end
|
||||
|
||||
it "should flatten a complex data structure" do
|
||||
result = scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]])
|
||||
result.should(eq(["a","b","c","d","e","f","g"]))
|
||||
|
|
Loading…
Reference in a new issue