diff --git a/lib/puppet/parser/functions/round.rb b/lib/puppet/parser/functions/round.rb deleted file mode 100644 index a528e0cdb..000000000 --- a/lib/puppet/parser/functions/round.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -# -# round.rb -# -module Puppet::Parser::Functions - newfunction(:round, type: :rvalue, doc: <<-DOC - @summary - Rounds a number to the nearest integer - - @return - the rounded value as integer - - @example Example usage - round(2.9) #=> 3 - round(2.4) #=> 2 - - > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. - DOC - ) do |args| - raise Puppet::ParseError, "round(): Wrong number of arguments given #{args.size} for 1" if args.size != 1 - raise Puppet::ParseError, "round(): Expected a Numeric, got #{args[0].class}" unless args[0].is_a? Numeric - - value = args[0] - - if value >= 0 - Integer(value + 0.5) - else - Integer(value - 0.5) - end - end -end diff --git a/spec/functions/round_spec.rb b/spec/functions/round_spec.rb deleted file mode 100644 index 7b3baf1b3..000000000 --- a/spec/functions/round_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'round', 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(34.3).and_return(34) } - it { is_expected.to run.with_params(-34.3).and_return(-34) } - it { is_expected.to run.with_params(34.5).and_return(35) } - it { is_expected.to run.with_params(-34.5).and_return(-35) } - it { is_expected.to run.with_params(34.7).and_return(35) } - it { is_expected.to run.with_params(-34.7).and_return(-35) } - it { is_expected.to run.with_params('test').and_raise_error Puppet::ParseError } - it { is_expected.to run.with_params('test', 'best').and_raise_error Puppet::ParseError } - it { is_expected.to run.with_params(3, 4).and_raise_error Puppet::ParseError } -end