summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-10-21 20:39:33 -0700
committerNick Lewis <nick@puppetlabs.com>2011-04-12 12:47:31 -0700
commit1954bbfe175ae7f18316e57af43362eb4ed73553 (patch)
tree77cdb4a0fed83f841d950abb9181b2e25952137c /spec/unit/parser
parent31f8e660c8f4c0ec01f140322cf7c585144a0888 (diff)
Refactor on the road to #5027 -- remove unused Scope#strinterp
One of the uses of lookupvar was in the method Scope#strinterp; this method is no longer used (string interpolation is now handled by the parser (for the syntax) and AST nodes (for the semantics)) so this use of lookupvar can be excised, along with a fair amount of surrounding code.
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/scope_spec.rb143
1 files changed, 0 insertions, 143 deletions
diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb
index b37cb4add..17f485c03 100755
--- a/spec/unit/parser/scope_spec.rb
+++ b/spec/unit/parser/scope_spec.rb
@@ -376,149 +376,6 @@ 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
-
- describe "with qualified variables" do
- before do
- @scopes = {}
- klass = @scope.known_resource_types.add(Puppet::Resource::Type.new(:hostclass, ""))
- Puppet::Parser::Resource.new("class", :main, :scope => @scope, :source => mock('source')).evaluate
- @scopes[""] = @scope.class_scope(klass)
- @scopes[""].setvar("test", "value")
-
- %w{one one::two one::two::three}.each do |name|
- klass = @scope.known_resource_types.add(Puppet::Resource::Type.new(:hostclass, name))
- Puppet::Parser::Resource.new("class", name, :scope => @scope, :source => mock('source')).evaluate
- @scopes[name] = @scope.class_scope(klass)
- @scopes[name].setvar("test", "value-#{name.sub(/.+::/,'')}")
- end
- end
- {
- "===${one::two::three::test}===" => "===value-three===",
- "===$one::two::three::test===" => "===value-three===",
- "===${one::two::test}===" => "===value-two===",
- "===$one::two::test===" => "===value-two===",
- "===${one::test}===" => "===value-one===",
- "===$one::test===" => "===value-one===",
- "===${::test}===" => "===value===",
- "===$::test===" => "===value==="
- }.each do |input, output|
- it "should parse '#{input}' correctly" do
- @scope.strinterp(input).should == output
- end
- end
- end
-
- tests = {
- "===${test}===" => "===value===",
- "===${test} ${test} ${test}===" => "===value value value===",
- "===$test ${test} $test===" => "===value value value===",
- "===\\$test===" => "===$test===",
- '===\\$test string===' => "===$test string===",
- '===$test string===' => "===value string===",
- '===a testing $===' => "===a testing $===",
- '===a testing \$===' => "===a testing $===",
- "===an escaped \\\n carriage return===" => "===an escaped carriage return===",
- '\$' => "$",
- '\s' => "\s",
- '\t' => "\t",
- '\n' => "\n"
- }
-
- tests.each do |input, output|
- it "should parse '#{input}' correctly" do
- @scope.setvar("test", "value")
- @scope.strinterp(input).should == output
- end
- end
-
- # #523
- %w{d f h l w z}.each do |l|
- it "should parse '#{l}' when escaped" do
- string = "\\#{l}"
- @scope.strinterp(string).should == string
- end
- end
- end
-
- def test_strinterp
- # Make and evaluate our classes so the qualified lookups work
- parser = mkparser
- klass = parser.newclass("")
- scope = mkscope(:parser => parser)
- Puppet::Parser::Resource.new(:type => "class", :title => :main, :scope => scope, :source => mock('source')).evaluate
-
- assert_nothing_raised {
- scope.setvar("test","value")
- }
-
- scopes = {"" => scope}
-
- %w{one one::two one::two::three}.each do |name|
- klass = parser.newclass(name)
- Puppet::Parser::Resource.new(:type => "class", :title => name, :scope => scope, :source => mock('source')).evaluate
- scopes[name] = scope.class_scope(klass)
- scopes[name].setvar("test", "value-#{name.sub(/.+::/,'')}")
- end
-
- assert_equal("value", scope.lookupvar("::test"), "did not look up qualified value correctly")
- tests.each do |input, output|
- assert_nothing_raised("Failed to scan #{input.inspect}") do
- assert_equal(output, scope.strinterp(input), 'did not parserret %s correctly' % input.inspect)
- end
- end
-
- logs = []
- Puppet::Util::Log.close
- Puppet::Util::Log.newdestination(logs)
-
- # #523
- %w{d f h l w z}.each do |l|
- string = "\\#{l}"
- assert_nothing_raised do
-
- assert_equal(
- string, scope.strinterp(string),
-
- 'did not parserret %s correctly' % string)
- end
-
-
- assert(
- logs.detect { |m| m.message =~ /Unrecognised escape/ },
-
- "Did not get warning about escape sequence with #{string}")
- logs.clear
- end
- end
-
describe "when setting ephemeral vars from matches" do
before :each do
@match = stub 'match', :is_a? => true