diff --git a/lib/puppet/parser/functions/min.rb b/lib/puppet/parser/functions/min.rb deleted file mode 100644 index 1734222d3..000000000 --- a/lib/puppet/parser/functions/min.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# -# min.rb -# -module Puppet::Parser::Functions - newfunction(:min, type: :rvalue, doc: <<-DOC - @summary - **Deprecated:** Returns the lowest value of all arguments. - - Requires at least one argument. - - @return - The lowest value among the given arguments - - > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a - built-in [`min`](https://puppet.com/docs/puppet/latest/function.html#min) function. - DOC - ) do |args| - raise(Puppet::ParseError, 'min(): Wrong number of arguments need at least one') if args.empty? - - # Sometimes we get numbers as numerics and sometimes as strings. - # We try to compare them as numbers when possible - return args.min do |a, b| - if a.to_s =~ %r{\A^-?\d+(.\d+)?\z} && b.to_s =~ %r{\A-?\d+(.\d+)?\z} - a.to_f <=> b.to_f - else - a.to_s <=> b.to_s - end - end - end -end diff --git a/spec/functions/min_spec.rb b/spec/functions/min_spec.rb deleted file mode 100644 index 4b730127b..000000000 --- a/spec/functions/min_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'min', if: Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1).and_return(1) } - it { is_expected.to run.with_params(1, 2).and_return(1) } - it { is_expected.to run.with_params(1, 2, 3).and_return(1) } - it { is_expected.to run.with_params(3, 2, 1).and_return(1) } - it { is_expected.to run.with_params(12, 8).and_return(8) } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params('one', 'two').and_return('one') } - it { is_expected.to run.with_params('one', 'two', 'three').and_return('one') } - it { is_expected.to run.with_params('three', 'two', 'one').and_return('one') } - it { is_expected.to run.with_params('the', 'public', 'art', 'galleries').and_return('art') } - - describe 'implementation artifacts' do - it { is_expected.to run.with_params(1, 'one').and_return(1) } - it { is_expected.to run.with_params('1', 'one').and_return('1') } - it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.3e1') } - it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.4e0) } - end -end