Skip to content

Commit 6dfd7f6

Browse files
committed
Merge branch '4.x'
2 parents 5a11279 + 2c1b2c0 commit 6dfd7f6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/puppet/parser/functions/str2bool.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ module Puppet::Parser::Functions
1414
"given (#{arguments.size} for 1)") if arguments.size < 1
1515

1616
string = arguments[0]
17+
18+
# If string is already Boolean, return it
19+
if !!string == string
20+
return string
21+
end
1722

1823
unless string.is_a?(String)
1924
raise(Puppet::ParseError, 'str2bool(): Requires either ' +

spec/unit/puppet/parser/functions/str2bool_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,11 @@
2121
result = scope.function_str2bool(["undef"])
2222
result.should(eq(false))
2323
end
24+
25+
it "should return the boolean it was called with" do
26+
result = scope.function_str2bool([true])
27+
result.should(eq(true))
28+
result = scope.function_str2bool([false])
29+
result.should(eq(false))
30+
end
2431
end

0 commit comments

Comments
 (0)