puppetlabs-stdlib/lib/puppet/parser/functions
Leonardo Rodrigues de Mello c14cbf31e2 bug # 20681 delete() function should not remove elements from original list
The setup: list with 3 elements, delete one:
$test_list = [‘a’, ‘b’, ‘c’]
$test_deleted = delete($test_list, ‘a’)

Print out the elements in ‘test_deleted’:
notify { ‘group_output2’:  withpath => true, name     => “$cfeng::test_deleted”, }
Notice: /Stage[main]/Syslog/Notify[group_output2]/message: bc

Good!  Run-on output shows that ‘a’ was deleted

Print out the elements in ‘test_list’:
notify { ‘group_output1’: withpath => true, name     => “$cfeng::test_list”, }
Notice: /Stage[main]/Syslog/Notify[group_output1]/message: bc

WHAT!?  'a' was deleted from ‘test_list’ as well! Expected abc as output!

This behaviour is confirmed for string, hash and array.
This is fixed on this commit, I had  added two spec tests to cover that cases.

bug #20681 spec test for delete() function.

I had forgot in the last commit the spec test for hash in the
delete function.

bug # 20681 delete() function change aproach.

Instead of rejecting elements from the original list, we use
collection = arguments[0].dup .
then latter we could continue to use delete and gsub! on collection
without impact on original argument.

this is a better solution than the previous one, and works on ruby
1.8.7, 1.9.3 and 2.0.0.

The previous solution does not work on ruby 1.8.7.

delete function remove typo whitespace.

fix typo whitespaces.
2013-09-16 10:19:35 -03:00
..
abs.rb puppet-lint cleanup 2012-11-15 10:38:03 -06:00
any2array.rb Remove resundant code 2013-04-03 14:05:20 -07:00
base64.rb Adding base64 function 2013-05-24 16:33:24 +01:00
bool2num.rb Added doc strings for first five functions 2011-07-30 04:22:30 +10:00
capitalize.rb Added doc strings for first five functions 2011-07-30 04:22:30 +10:00
chomp.rb puppet-lint cleanup 2012-11-15 10:38:03 -06:00
chop.rb puppet-lint cleanup 2012-11-15 10:38:03 -06:00
concat.rb (#19201) Add concat function to join two arrays 2013-02-12 10:00:09 -08:00
count.rb Add a count function 2013-04-10 14:39:25 +02:00
defined_with_params.rb Handle undef for parameter argument 2012-10-25 10:54:33 -07:00
delete.rb bug # 20681 delete() function should not remove elements from original list 2013-09-16 10:19:35 -03:00
delete_at.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
delete_undef_values.rb added delete_values() and delete_undef_values() functions 2013-08-05 22:12:26 +02:00
delete_values.rb minor corrections to delete_values() 2013-08-08 16:56:32 +02:00
difference.rb (#20684) Add array comparison functions, difference, intersection and union. 2013-05-13 12:14:15 -04:00
dirname.rb Add a dirname function 2013-05-02 15:17:35 +02:00
downcase.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
empty.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
ensure_packages.rb Add an ensure_packages function. 2012-11-27 16:16:28 -08:00
ensure_resource.rb ensure_resource: fix documentation typo 2013-06-27 17:51:36 +01:00
flatten.rb Fix number of arguments check in flatten() 2013-03-18 15:07:13 -07:00
floor.rb Add floor function implementation and unit tests 2013-03-19 10:00:57 +01:00
fqdn_rotate.rb (#13205) Rotate array/string randomley based on fqdn, fqdn_rotate() 2012-03-18 12:19:48 +01:00
get_module_path.rb (Maint) Fix up the get_module_path parser function 2012-07-23 09:21:22 -07:00
getparam.rb (maint) Fix getparam() spec failure on MRI 1.8 2013-01-14 18:38:27 -08:00
getvar.rb Docs: Copyedit function doc strings 2011-08-18 12:39:04 -07:00
grep.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
has_interface_with.rb (#13974) Add predicate functions for interface facts 2012-11-07 14:00:44 -08:00
has_ip_address.rb (#13974) Add predicate functions for interface facts 2012-11-07 14:00:44 -08:00
has_ip_network.rb (#13974) Add predicate functions for interface facts 2012-11-07 14:00:44 -08:00
has_key.rb Docs: Correct indentation of markdown code examples 2011-08-18 12:39:04 -07:00
hash.rb (maint) Fix a small typo in hash() description 2013-04-29 17:17:46 -07:00
intersection.rb (#20684) Add array comparison functions, difference, intersection and union. 2013-05-13 12:14:15 -04:00
is_array.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
is_domain_name.rb Check according to rfc1035 2012-01-11 19:17:03 -08:00
is_float.rb Add test/validation for is_float if created from an arithmetical operation 2013-01-03 13:37:55 -08:00
is_function_available.rb (#13610) Add is_function_available to stdlib 2013-03-18 15:44:50 -07:00
is_hash.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
is_integer.rb Add test/validation for is_integer if created from an arithmetical operation 2013-01-03 13:37:55 -08:00
is_ip_address.rb puppet-lint cleanup 2012-11-15 10:38:03 -06:00
is_mac_address.rb Prep for stdlib merge 2011-08-05 08:25:03 +01:00
is_numeric.rb Add test/validation for is_numeric if created from an arithmetical operation 2013-01-03 13:37:55 -08:00
is_string.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
join.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
join_keys_to_values.rb Add join_keys_to_values function 2012-11-20 16:16:03 -05:00
keys.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
loadyaml.rb Docs: Copyedit function doc strings 2011-08-18 12:39:04 -07:00
lstrip.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
max.rb Allow comparisons of Numeric and number as String 2013-03-27 14:03:31 -07:00
member.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
merge.rb fix in merge.rb: refine the checking if an argument is an empty string 2013-05-08 18:24:07 +02:00
min.rb Allow comparisons of Numeric and number as String 2013-03-27 14:03:31 -07:00
num2bool.rb Cleanup per adrianthebo suggestions 2013-04-01 11:44:09 -04:00
parsejson.rb (#10285) Refactor json to use pson instead. 2011-10-25 15:54:47 -07:00
parseyaml.rb puppet-lint cleanup 2012-11-15 10:38:03 -06:00
pick.rb Add the pick() function 2012-11-15 08:52:19 -05:00
prefix.rb (maint) better error reporting for prefix and suffix 2013-03-27 13:37:25 -07:00
range.rb Merge remote-tracking branch 'pr/56' into pull-56 2013-05-28 11:07:41 -07:00
reject.rb Add reject() function 2012-11-28 14:28:31 -08:00
reverse.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
rstrip.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
shuffle.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
size.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
sort.rb Fix some ruby 1.9.2 issues. 2011-07-30 00:44:02 +01:00
squeeze.rb puppet-lint cleanup 2012-11-15 10:38:03 -06:00
str2bool.rb Merge branch '4.x' 2013-03-18 15:38:14 -07:00
str2saltedsha512.rb New str2saltedsha512 function for OS X Passwords 2012-01-09 11:30:47 -08:00
strftime.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
strip.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
suffix.rb (maint) better error reporting for prefix and suffix 2013-03-27 13:37:25 -07:00
swapcase.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
time.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
to_bytes.rb (#15872) Add to_bytes function 2012-08-14 08:43:36 -07:00
type.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
union.rb (#20684) Add array comparison functions, difference, intersection and union. 2013-05-13 12:14:15 -04:00
unique.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
upcase.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
uriescape.rb Adjust to use default URI.escape escape list 2013-07-22 13:12:28 -07:00
validate_absolute_path.rb (#12357) Fix broken compatibility with Puppet 2.6 2012-03-12 15:59:50 -07:00
validate_array.rb Docs: Copyedit function doc strings 2011-08-18 12:39:04 -07:00
validate_augeas.rb Add an URL to a doc on how to activate augeas in puppet 2013-01-20 13:15:22 +01:00
validate_bool.rb Docs: Remove author emails from stdlib functions 2011-08-18 12:39:05 -07:00
validate_cmd.rb validate_cmd(): Use Puppet::Util::Execution.execute when available 2013-02-07 08:56:52 +01:00
validate_hash.rb Docs: Remove author emails from stdlib functions 2011-08-18 12:39:05 -07:00
validate_ipv4_address.rb Ruby 2.0 introduces IPAddr::InvalidAddressError 2013-05-22 17:21:38 -07:00
validate_ipv6_address.rb Ruby 2.0 introduces IPAddr::InvalidAddressError 2013-05-22 17:21:38 -07:00
validate_re.rb (maint) Comment Ken's fix to String#any? 2012-03-09 14:08:54 -08:00
validate_slength.rb (maint) Validate input argument in a single location 2013-08-12 12:56:00 -07:00
validate_string.rb Docs: Copyedit function doc strings 2011-08-18 12:39:04 -07:00
values.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
values_at.rb Fix some ruby 1.9.2 issues. 2011-07-30 00:44:02 +01:00
zip.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00