Skip to content

Commit 4492913

Browse files
author
Jeff McCune
committed
(Maint) Fix mis-use of rvalue functions as statements
Without this patch applied the spec tests are invalid because they call rvalue functions as if they were statements. This is a problem because Puppet 2.7.x currently throws an exception if a rvalue function is invoked as if it were a statement function. This exception from Puppet is causing tests to fail. This patch fixes the problem by changing the tests to assign the return value of the functions to a variable. This fixes the problem by invoking the functions properly. Paired-with: Andrew Parker <[email protected]>
1 parent 88789e8 commit 4492913

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ def get_scope
2323
describe 'when calling getvar from puppet' do
2424

2525
it "should not compile when no arguments are passed" do
26-
Puppet[:code] = 'getvar()'
26+
Puppet[:code] = '$rval = getvar()'
2727
get_scope
2828
expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/)
2929
end
3030
it "should not compile when too many arguments are passed" do
31-
Puppet[:code] = 'getvar("foo::bar", "baz")'
31+
Puppet[:code] = '$rval = getvar("foo::bar", "baz")'
3232
get_scope
3333
expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/)
3434
end

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222

2323
describe 'when calling has_key from puppet' do
2424
it "should not compile when no arguments are passed" do
25-
Puppet[:code] = 'has_key()'
25+
Puppet[:code] = '$rval = has_key()'
2626
expect { compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/)
2727
end
2828
it "should not compile when 1 argument is passed" do
29-
Puppet[:code] = "has_key('foo')"
29+
Puppet[:code] = "$rval = has_key('foo')"
3030
expect { compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/)
3131
end
3232
it "should require the first value to be a Hash" do
33-
Puppet[:code] = "has_key('foo', 'bar')"
33+
Puppet[:code] = "$rval = has_key('foo', 'bar')"
3434
expect { compiler.compile }.should raise_error(Puppet::ParseError, /expects the first argument to be a hash/)
3535
end
3636
end

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
describe 'when calling merge from puppet' do
2424
it "should not compile when no arguments are passed" do
25-
Puppet[:code] = 'merge()'
25+
Puppet[:code] = '$rval = merge()'
2626
expect { compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/)
2727
end
2828
it "should not compile when 1 argument is passed" do
29-
Puppet[:code] = "$my_hash={'one' => 1}\nmerge($my_hash)"
29+
Puppet[:code] = "$my_hash={'one' => 1}\n$rval = merge($my_hash)"
3030
expect { compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/)
3131
end
3232
end

0 commit comments

Comments
 (0)