File tree Expand file tree Collapse file tree 6 files changed +22
-3
lines changed
lib/puppet/parser/functions
spec/unit/puppet/parser/functions Expand file tree Collapse file tree 6 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module Puppet::Parser::Functions
1515
1616 value = arguments [ 0 ]
1717
18- if value != value . to_f . to_s then
18+ if value != value . to_f . to_s and ! value . is_a? Float then
1919 return false
2020 else
2121 return true
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module Puppet::Parser::Functions
1515
1616 value = arguments [ 0 ]
1717
18- if value != value . to_i . to_s then
18+ if value != value . to_i . to_s and ! value . is_a? Fixnum then
1919 return false
2020 else
2121 return true
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module Puppet::Parser::Functions
1515
1616 value = arguments [ 0 ]
1717
18- if value == value . to_f . to_s or value == value . to_i . to_s then
18+ if value == value . to_f . to_s or value == value . to_i . to_s or value . is_a? Numeric then
1919 return true
2020 else
2121 return false
Original file line number Diff line number Diff line change 2626 result = scope . function_is_float ( [ "3" ] )
2727 result . should ( eq ( false ) )
2828 end
29+ it "should return true if a float is created from an arithmetical operation" do
30+ result = scope . function_is_float ( [ 3.2 *2 ] )
31+ result . should ( eq ( true ) )
32+ end
2933end
Original file line number Diff line number Diff line change 2626 result = scope . function_is_integer ( [ "asdf" ] )
2727 result . should ( eq ( false ) )
2828 end
29+
30+ it "should return true if an integer is created from an arithmetical operation" do
31+ result = scope . function_is_integer ( [ 3 *2 ] )
32+ result . should ( eq ( true ) )
33+ end
2934end
Original file line number Diff line number Diff line change 2222 result . should ( eq ( true ) )
2323 end
2424
25+ it "should return true if an integer is created from an arithmetical operation" do
26+ result = scope . function_is_numeric ( [ 3 *2 ] )
27+ result . should ( eq ( true ) )
28+ end
29+
30+ it "should return true if a float is created from an arithmetical operation" do
31+ result = scope . function_is_numeric ( [ 3.2 *2 ] )
32+ result . should ( eq ( true ) )
33+ end
34+
2535 it "should return false if a string" do
2636 result = scope . function_is_numeric ( [ "asdf" ] )
2737 result . should ( eq ( false ) )
You can’t perform that action at this time.
0 commit comments