Skip to content

Commit

Permalink
Merge pull request #594 from rodjek/regex_prev_tokens
Browse files Browse the repository at this point in the history
(#517) Update the allowed tokens prior to a regex
  • Loading branch information
binford2k authored Dec 22, 2016
2 parents b0aa025 + e01a7c0 commit 6626073
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/puppet-lint/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def initialize
:NOMATCH => true,
:COMMA => true,
:LBRACK => true,
:IF => true,
:ELSIF => true,
}

# Internal: An Array of Arrays containing tokens that can be described by
Expand Down
11 changes: 11 additions & 0 deletions spec/puppet-lint/lexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,17 @@
tokens = @lexer.tokenise('$x = $a/$b/$c')
expect(tokens.select { |r| r.type == :REGEX }).to be_empty
end

it 'should properly parse when regex follows an if' do
tokens = @lexer.tokenise('if /^icinga_service_icon_.*/ in $location_info { }')
expect(tokens[2].type).to eq(:REGEX)
end

it 'should properly parse when a regex follows an elsif' do
tokens = @lexer.tokenise('if /a/ in $location_info { } elsif /b/ in $location_info { }')
expect(tokens[2].type).to eq(:REGEX)
expect(tokens[14].type).to eq(:REGEX)
end
end

context ':STRING' do
Expand Down

0 comments on commit 6626073

Please sign in to comment.