summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-09-03 17:22:08 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-09-04 11:58:31 +1000
commit19815dd32891eb182a3ad4d5937ba6ec9eda1261 (patch)
tree8d63d32c4fb41e22d99e36cc2f8b2aadff54316f /spec/unit/parser
parentea5847875b5fd7e2d13470d9e74bb0f671ee4d95 (diff)
Fixing #2592 - you can escape slashes in regexes
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/lexer.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/unit/parser/lexer.rb b/spec/unit/parser/lexer.rb
index 8b73de195..1c3e91bd6 100755
--- a/spec/unit/parser/lexer.rb
+++ b/spec/unit/parser/lexer.rb
@@ -460,6 +460,20 @@ describe Puppet::Parser::Lexer::TOKENS[:REGEX] do
@token.regex.should =~ '/this is a regex/'
end
+ describe "when including escaped slashes" do
+ before { @lexer = Puppet::Parser::Lexer.new }
+
+ it "should not consider escaped slashes to be the end of a regex" do
+ @lexer.string = "/this \\/ foo/"
+ tokens = []
+ @lexer.scan do |name, value|
+ tokens << value
+ end
+ tokens[0][:value].should == Regexp.new("this / foo")
+ end
+ end
+
+
it "should return the REGEX token and a Regexp" do
@token.convert(stub("lexer"), "/myregex/").should == [Puppet::Parser::Lexer::TOKENS[:REGEX], Regexp.new(/myregex/)]
end