Skip to content

Commit

Permalink
Merge pull request #224 from jay7x/patch-1
Browse files Browse the repository at this point in the history
Add Binary type to lexer type tokens list
  • Loading branch information
david22swan authored Dec 11, 2024
2 parents 167ab94 + 19888c4 commit 002f275
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/puppet-lint/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def heredoc_queue
[:WHITESPACE, %r{\A(#{WHITESPACE_RE}+)}],
# FIXME: Future breaking change, the following :TYPE tokens conflict with
# the :TYPE keyword token.
[:TYPE, %r{\A(Any|Array|Boolean|Callable|CatalogEntry|Class|Collection|Data|Default|Enum|Error|Float|Hash|Integer|NotUndef|Numeric|Optional|Pattern|Regexp|Resource|Runtime|Scalar|Sensitive|String|Struct|Tuple|Type|Undef|Variant)\b}], # rubocop:disable Layout/LineLength
[:TYPE, %r{\A(Any|Array|Binary|Boolean|Callable|CatalogEntry|Class|Collection|Data|Default|Enum|Error|Float|Hash|Integer|NotUndef|Numeric|Optional|Pattern|Regexp|Resource|Runtime|Scalar|Sensitive|String|Struct|Tuple|Type|Undef|Variant)\b}], # rubocop:disable Layout/LineLength
[:CLASSREF, %r{\A(((::){0,1}[A-Z][-\w]*)+)}],
[:NUMBER, %r{\A\b((?:0[xX][0-9A-Fa-f]+|0?\d+(?:\.\d+)?(?:[eE]-?\d+)?))\b}],
[:FUNCTION_NAME, %r{#{NAME_RE}(?=\()}],
Expand Down
28 changes: 12 additions & 16 deletions spec/unit/puppet-lint/lexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,14 @@
end

context ':TYPE' do
shared_examples 'a type matcher' do |type|
it "matches #{type}" do
token = lexer.tokenise(type).first
expect(token.type).to eq(:TYPE)
expect(token.value).to eq(type)
end
end

it 'matches Data Types' do
token = lexer.tokenise('Integer').first
expect(token.type).to eq(:TYPE)
Expand All @@ -1378,24 +1386,12 @@
end

describe 'Platform Types' do
it 'matches Callable' do
token = lexer.tokenise('Callable').first
expect(token.type).to eq(:TYPE)
expect(token.value).to eq('Callable')
end

it 'matches Sensitive' do
token = lexer.tokenise('Sensitive').first
expect(token.type).to eq(:TYPE)
expect(token.value).to eq('Sensitive')
end
it_behaves_like 'a type matcher', 'Callable'
it_behaves_like 'a type matcher', 'Sensitive'
end

it 'matches Error type' do
token = lexer.tokenise('Error').first
expect(token.type).to eq(:TYPE)
expect(token.value).to eq('Error')
end
it_behaves_like 'a type matcher', 'Error'
it_behaves_like 'a type matcher', 'Binary'
end

context ':HEREDOC without interpolation' do
Expand Down

0 comments on commit 002f275

Please sign in to comment.