File tree 4 files changed +7
-9
lines changed
4 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ class DebugLint < Debug
18
18
register_for :debug_lint
19
19
20
20
def text_token text , kind
21
- raise Lint ::EmptyToken , 'empty token' if text . empty?
21
+ raise Lint ::EmptyToken , 'empty token for %p' % [ kind ] if text . empty?
22
+ raise Lint ::UnknownTokenKind , 'unknown token kind %p (text was %p)' % [ kind , text ] unless TokenKinds . has_key? kind
22
23
super
23
24
end
24
25
Original file line number Diff line number Diff line change @@ -17,10 +17,12 @@ class Lint < Debug
17
17
18
18
InvalidTokenStream = Class . new StandardError
19
19
EmptyToken = Class . new InvalidTokenStream
20
+ UnknownTokenKind = Class . new InvalidTokenStream
20
21
IncorrectTokenGroupNesting = Class . new InvalidTokenStream
21
22
22
23
def text_token text , kind
23
- raise EmptyToken , 'empty token' if text . empty?
24
+ raise EmptyToken , 'empty token for %p' % [ kind ] if text . empty?
25
+ raise UnknownTokenKind , 'unknown token kind %p (text was %p)' % [ kind , text ] unless TokenKinds . has_key? kind
24
26
end
25
27
26
28
def begin_group kind
Original file line number Diff line number Diff line change 1
1
module CodeRay
2
2
3
3
# A Hash of all known token kinds and their associated CSS classes.
4
- TokenKinds = Hash . new do |h , k |
5
- warn 'Undefined Token kind: %p' % [ k ] if $CODERAY_DEBUG
6
- false
7
- end
4
+ TokenKinds = Hash . new ( false )
8
5
9
6
# speedup
10
7
TokenKinds . compare_by_identity if TokenKinds . respond_to? :compare_by_identity
Original file line number Diff line number Diff line change @@ -164,9 +164,7 @@ def test_token_kinds
164
164
end
165
165
end
166
166
assert_equal 'reserved' , CodeRay ::TokenKinds [ :reserved ]
167
- assert_warning 'Undefined Token kind: :shibboleet' do
168
- assert_equal false , CodeRay ::TokenKinds [ :shibboleet ]
169
- end
167
+ assert_equal false , CodeRay ::TokenKinds [ :shibboleet ]
170
168
end
171
169
172
170
class Milk < CodeRay ::Encoders ::Encoder
You can’t perform that action at this time.
0 commit comments