File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
lib/puppet/parser/functions Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,18 @@ module Puppet::Parser::Functions
1313
1414 value = arguments [ 0 ]
1515
16- unless value . is_a? ( Array ) || value . is_a? ( Hash ) || value . is_a? ( String )
16+ unless value . is_a? ( Array ) || value . is_a? ( Hash ) || value . is_a? ( String ) || value . is_a? ( Numeric )
1717 raise ( Puppet ::ParseError , 'empty(): Requires either ' +
18- 'array, hash or string to work with' )
18+ 'array, hash, string or integer to work with' )
1919 end
2020
21- result = value . empty?
21+ if value . is_a? ( Numeric )
22+ return false
23+ else
24+ result = value . empty?
2225
23- return result
26+ return result
27+ end
2428 end
2529end
2630
Original file line number Diff line number Diff line change 33describe 'empty' do
44 it { is_expected . not_to eq ( nil ) }
55 it { is_expected . to run . with_params ( ) . and_raise_error ( Puppet ::ParseError ) }
6- it { is_expected . to run . with_params ( 0 ) . and_raise_error ( Puppet ::ParseError ) }
76 it {
87 pending ( "Current implementation ignores parameters after the first." )
98 is_expected . to run . with_params ( 'one' , 'two' ) . and_raise_error ( Puppet ::ParseError )
109 }
10+ it { is_expected . to run . with_params ( 0 ) . and_return ( false ) }
1111 it { is_expected . to run . with_params ( '' ) . and_return ( true ) }
1212 it { is_expected . to run . with_params ( 'one' ) . and_return ( false ) }
1313
You can’t perform that action at this time.
0 commit comments