diff options
author | Yiyang Hao <haoyiyang@nnthink.com> | 2020-08-24 16:39:44 +0800 |
---|---|---|
committer | Yiyang Hao <haoyiyang@nnthink.com> | 2020-08-24 16:39:44 +0800 |
commit | 4c5564dedef1d78cf377c0e6ab3726db0bba68f1 (patch) | |
tree | 0799d554d371532b167647437bbdf2f8b9ad5baa | |
parent | 4cdc28fc5b1640ea781a6086bd79c91f399068b0 (diff) | |
download | pygments-git-4c5564dedef1d78cf377c0e6ab3726db0bba68f1.tar.gz |
add test_function_definition
-rw-r--r-- | tests/test_javascript.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/test_javascript.py b/tests/test_javascript.py index 25e06fdc..2d27576e 100644 --- a/tests/test_javascript.py +++ b/tests/test_javascript.py @@ -9,7 +9,7 @@ import pytest -from pygments.lexers import CoffeeScriptLexer +from pygments.lexers import CoffeeScriptLexer, TypeScriptLexer from pygments.token import Token COFFEE_SLASH_GOLDEN = [ @@ -83,3 +83,25 @@ def test_beware_infinite_loop(lexer): (Token.Text, '\n'), ] assert list(lexer.get_tokens(fragment)) == tokens + +@pytest.fixture(scope='module') +def ts_lexer(): + yield TypeScriptLexer() + +def test_function_definition(ts_lexer): + fragment = u'async function main() {\n}' + tokens = [ + (Token.Name.Other, u'async'), + (Token.Text, u' '), + (Token.Keyword.Declaration, u'function'), + (Token.Text, u' '), + (Token.Name.Other, u'main'), + (Token.Punctuation, u'('), + (Token.Punctuation, u')'), + (Token.Text, u' '), + (Token.Punctuation, u'{'), + (Token.Text, u'\n'), + (Token.Punctuation, u'}'), + (Token.Text, u'\n'), + ] + assert list(ts_lexer.get_tokens(fragment)) == tokens |