Skip to content

Commit 002f275

Browse files
authored
Merge pull request #224 from jay7x/patch-1
Add Binary type to lexer type tokens list
2 parents 167ab94 + 19888c4 commit 002f275

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

lib/puppet-lint/lexer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def heredoc_queue
123123
[:WHITESPACE, %r{\A(#{WHITESPACE_RE}+)}],
124124
# FIXME: Future breaking change, the following :TYPE tokens conflict with
125125
# the :TYPE keyword token.
126-
[: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
126+
[: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
127127
[:CLASSREF, %r{\A(((::){0,1}[A-Z][-\w]*)+)}],
128128
[:NUMBER, %r{\A\b((?:0[xX][0-9A-Fa-f]+|0?\d+(?:\.\d+)?(?:[eE]-?\d+)?))\b}],
129129
[:FUNCTION_NAME, %r{#{NAME_RE}(?=\()}],

spec/unit/puppet-lint/lexer_spec.rb

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,14 @@
13591359
end
13601360

13611361
context ':TYPE' do
1362+
shared_examples 'a type matcher' do |type|
1363+
it "matches #{type}" do
1364+
token = lexer.tokenise(type).first
1365+
expect(token.type).to eq(:TYPE)
1366+
expect(token.value).to eq(type)
1367+
end
1368+
end
1369+
13621370
it 'matches Data Types' do
13631371
token = lexer.tokenise('Integer').first
13641372
expect(token.type).to eq(:TYPE)
@@ -1378,24 +1386,12 @@
13781386
end
13791387

13801388
describe 'Platform Types' do
1381-
it 'matches Callable' do
1382-
token = lexer.tokenise('Callable').first
1383-
expect(token.type).to eq(:TYPE)
1384-
expect(token.value).to eq('Callable')
1385-
end
1386-
1387-
it 'matches Sensitive' do
1388-
token = lexer.tokenise('Sensitive').first
1389-
expect(token.type).to eq(:TYPE)
1390-
expect(token.value).to eq('Sensitive')
1391-
end
1389+
it_behaves_like 'a type matcher', 'Callable'
1390+
it_behaves_like 'a type matcher', 'Sensitive'
13921391
end
13931392

1394-
it 'matches Error type' do
1395-
token = lexer.tokenise('Error').first
1396-
expect(token.type).to eq(:TYPE)
1397-
expect(token.value).to eq('Error')
1398-
end
1393+
it_behaves_like 'a type matcher', 'Error'
1394+
it_behaves_like 'a type matcher', 'Binary'
13991395
end
14001396

14011397
context ':HEREDOC without interpolation' do

0 commit comments

Comments
 (0)