4 describe "the flatten function" do
6 Puppet::Parser::Functions.autoloader.loadall
10 @scope = Puppet::Parser::Scope.new
14 Puppet::Parser::Functions.function("flatten").should == "function_flatten"
17 it "should raise a ParseError if there is less than 1 arguments" do
18 lambda { @scope.function_flatten([]) }.should( raise_error(Puppet::ParseError))
21 it "should flatten a complex data structure" do
22 result = @scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]])
23 result.should(eq(["a","b","c","d","e","f","g"]))
26 it "should do nothing to a structure that is already flat" do
27 result = @scope.function_flatten([["a","b","c","d"]])
28 result.should(eq(["a","b","c","d"]))