From 44596e73da1b157ea931d5111f842e108ca203bb Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Thu, 7 Apr 2016 22:22:17 +0100 Subject: (MODULES-3246) Fix concat with Hash arguments. 85d5ead Updated the concat function so that it wouldn't modify the original array. A side-effect of this change is that it now always calls `Array()` on the second argument. If thit is a Hash, this results in `to_a` being called on the hash, which converts it to an array or tuples. This is undesired. Update the behaviour so that it doesn't (indirectly) call `to_a` on anything, instead test for the type of the argument, wrapping it in an array if it's not already an array. --- spec/acceptance/concat_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec/acceptance/concat_spec.rb') diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 06b649f..c472db6 100755 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -34,6 +34,20 @@ describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper } EOS + apply_manifest(pp, :catch_failures => true) + end + it 'should concat hash arguments' do + pp = <<-EOS + $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"}) + validate_array($output) + if size($output) != 2 { + fail("${output} should have 2 elements.") + } + if $output[1] != {"c" => "d", "e" => "f"} { + fail("${output} does not have the expected hash for the second element.") + } + EOS + apply_manifest(pp, :catch_failures => true) end end -- cgit v1.2.3