mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Add brackets to tokens
This commit is contained in:
@@ -76,7 +76,7 @@ module Linguist
|
||||
extract_sgml_tokens(token).each { |t| tokens << t }
|
||||
|
||||
# Common programming punctuation
|
||||
elsif token = s.scan(/;|\{|\}|\(|\)/)
|
||||
elsif token = s.scan(/;|\{|\}|\(|\)|\[|\]/)
|
||||
tokens << token
|
||||
|
||||
# Regular token
|
||||
|
||||
@@ -78,13 +78,17 @@ class TestTokenizer < Test::Unit::TestCase
|
||||
def test_objective_c_tokens
|
||||
assert_equal %w(#import <Foundation/Foundation.h> @interface Foo NSObject { } @end), tokenize(:"Objective-C/Foo.h")
|
||||
assert_equal %w(#import @implementation Foo @end), tokenize(:"Objective-C/Foo.m")
|
||||
assert_equal %w(#import <Cocoa/Cocoa.h> int main \( int argc char *argv \) { NSLog \( @ \) ; return ; }), tokenize(:"Objective-C/hello.m")
|
||||
assert_equal %w(#import <Cocoa/Cocoa.h> int main \( int argc char *argv [ ] \) { NSLog \( @ \) ; return ; }), tokenize(:"Objective-C/hello.m")
|
||||
end
|
||||
|
||||
def test_javascript_tokens
|
||||
assert_equal %w( \( function \( \) { console.log \( \) ; } \) .call \( this \) ;), tokenize(:"JavaScript/hello.js")
|
||||
end
|
||||
|
||||
def test_json_tokens
|
||||
assert_equal %w( { [ ] { } } ), tokenize(:"JSON/product.json")
|
||||
end
|
||||
|
||||
def test_ruby_tokens
|
||||
assert_equal %w(module Foo end), tokenize(:"Ruby/foo.rb")
|
||||
assert_equal %w(# /usr/bin/env ruby puts), tokenize(:"Ruby/script.rb")
|
||||
|
||||
Reference in New Issue
Block a user