summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/scope.rb
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-06-12 23:24:36 +0200
committerJames Turnbull <james@lovedthanlost.net>2009-08-01 11:15:28 +1000
commit201ae59eacaff289a8a5bb45f7d301c1a490a119 (patch)
tree344cb9a1d52fb5c4a825b4a73f2dd3f90ca88c54 /spec/unit/parser/scope.rb
parentf357a9192647fc5d436d4c934b1912f59996389f (diff)
downloadpuppet-201ae59eacaff289a8a5bb45f7d301c1a490a119.tar.gz
puppet-201ae59eacaff289a8a5bb45f7d301c1a490a119.tar.xz
puppet-201ae59eacaff289a8a5bb45f7d301c1a490a119.zip
Allow variable $0 to $9 to be interpolated, if ephemeral
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser/scope.rb')
-rwxr-xr-xspec/unit/parser/scope.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/unit/parser/scope.rb b/spec/unit/parser/scope.rb
index 641a3f946..665b2ed63 100755
--- a/spec/unit/parser/scope.rb
+++ b/spec/unit/parser/scope.rb
@@ -223,6 +223,36 @@ describe Puppet::Parser::Scope do
end
end
+ describe "when interpolating string" do
+ (0..9).each do |n|
+ it "should allow $#{n} to match" do
+ @scope.setvar(n.to_s, "value", :ephemeral => true)
+
+ @scope.strinterp("$#{n}").should == "value"
+ end
+ end
+
+ (0..9).each do |n|
+ it "should not allow $#{n} to match if not ephemeral" do
+ @scope.setvar(n.to_s, "value", :ephemeral => false)
+
+ @scope.strinterp("$#{n}").should_not == "value"
+ end
+ end
+
+ it "should not allow $10 to match" do
+ @scope.setvar("10", "value", :ephemeral => true)
+
+ @scope.strinterp('==$10==').should_not == "==value=="
+ end
+
+ it "should not allow ${10} to match" do
+ @scope.setvar("10", "value", :ephemeral => true)
+
+ @scope.strinterp('==${10}==').should == "==value=="
+ end
+ end
+
describe "when setting ephemeral vars from matches" do
before :each do
@match = stub 'match', :is_a? => true