From 2440fe9fc146b69ed3bb0fbcd06d48f6b1929d80 Mon Sep 17 00:00:00 2001 From: martyewings Date: Tue, 25 Apr 2023 11:54:11 +0100 Subject: [PATCH] Remove deprecated max function --- lib/puppet/parser/functions/max.rb | 32 ------------------------------ spec/functions/max_spec.rb | 23 --------------------- 2 files changed, 55 deletions(-) delete mode 100644 lib/puppet/parser/functions/max.rb delete mode 100644 spec/functions/max_spec.rb diff --git a/lib/puppet/parser/functions/max.rb b/lib/puppet/parser/functions/max.rb deleted file mode 100644 index b0eac1613..000000000 --- a/lib/puppet/parser/functions/max.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# -# max.rb -# -module Puppet::Parser::Functions - newfunction(:max, type: :rvalue, doc: <<-DOC - @summary - **Deprecated:** Returns the highest value of all arguments. - - Requires at least one argument. - - @return - The highest value among those passed in - - > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a - built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function. - DOC - ) do |args| - raise(Puppet::ParseError, 'max(): 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.max 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/max_spec.rb b/spec/functions/max_spec.rb deleted file mode 100644 index b3868d798..000000000 --- a/spec/functions/max_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'max', 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(2) } - it { is_expected.to run.with_params(1, 2, 3).and_return(3) } - it { is_expected.to run.with_params(3, 2, 1).and_return(3) } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params('one', 'two').and_return('two') } - it { is_expected.to run.with_params('one', 'two', 'three').and_return('two') } - it { is_expected.to run.with_params('three', 'two', 'one').and_return('two') } - - describe 'implementation artifacts' do - it { is_expected.to run.with_params(1, 'one').and_return('one') } - it { is_expected.to run.with_params('1', 'one').and_return('one') } - it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.4e0') } - it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.3e1) } - end -end