mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +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 }
|
extract_sgml_tokens(token).each { |t| tokens << t }
|
||||||
|
|
||||||
# Common programming punctuation
|
# Common programming punctuation
|
||||||
elsif token = s.scan(/;|\{|\}|\(|\)/)
|
elsif token = s.scan(/;|\{|\}|\(|\)|\[|\]/)
|
||||||
tokens << token
|
tokens << token
|
||||||
|
|
||||||
# Regular token
|
# Regular token
|
||||||
|
|||||||
@@ -78,13 +78,17 @@ class TestTokenizer < Test::Unit::TestCase
|
|||||||
def test_objective_c_tokens
|
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 <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 @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
|
end
|
||||||
|
|
||||||
def test_javascript_tokens
|
def test_javascript_tokens
|
||||||
assert_equal %w( \( function \( \) { console.log \( \) ; } \) .call \( this \) ;), tokenize(:"JavaScript/hello.js")
|
assert_equal %w( \( function \( \) { console.log \( \) ; } \) .call \( this \) ;), tokenize(:"JavaScript/hello.js")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_json_tokens
|
||||||
|
assert_equal %w( { [ ] { } } ), tokenize(:"JSON/product.json")
|
||||||
|
end
|
||||||
|
|
||||||
def test_ruby_tokens
|
def test_ruby_tokens
|
||||||
assert_equal %w(module Foo end), tokenize(:"Ruby/foo.rb")
|
assert_equal %w(module Foo end), tokenize(:"Ruby/foo.rb")
|
||||||
assert_equal %w(# /usr/bin/env ruby puts), tokenize(:"Ruby/script.rb")
|
assert_equal %w(# /usr/bin/env ruby puts), tokenize(:"Ruby/script.rb")
|
||||||
|
|||||||
Reference in New Issue
Block a user