diff options
| author | Matthäus G. Chajdas <dev@anteru.net> | 2020-07-31 13:07:35 +0200 |
|---|---|---|
| committer | Matthäus G. Chajdas <dev@anteru.net> | 2020-07-31 13:07:35 +0200 |
| commit | b6d1d68de705e1cfc28a4188f792b29c545bf7ed (patch) | |
| tree | fd06a33cd189e041ae28a4aaeb796af7ea2b3ebb | |
| parent | eaab40379c0c55e5549f67097701abb99123a6e0 (diff) | |
| download | pygments-git-b6d1d68de705e1cfc28a4188f792b29c545bf7ed.tar.gz | |
Add test case for Angular2 lexer bug.
This test triggers a bug, in which a spurious Token.Text('') appears at
the end. This seems to stem from the ('[^<&]+', Text), rule in the HTML
lexer which matches the \n that gets automatically added during lexing.
| -rw-r--r-- | tests/test_template.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_template.py b/tests/test_template.py new file mode 100644 index 00000000..48226f62 --- /dev/null +++ b/tests/test_template.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Test template formats.""" + +import textwrap +import pytest + +from pygments.lexers import Angular2HtmlLexer +from pygments.token import Token + +@pytest.fixture(scope='module') +def lexer_ng2(): + yield Angular2HtmlLexer() + + +def testAngularFragment(lexer_ng2): + # Not starting with v makes this test work (remove the first token from + # tokens in that case) + fragment = 'v*39j5Sq=' + tokens = [ + (Token.Text, 'v'), + (Token.Punctuation, '*'), + (Token.Name.Attribute, '39j5Sq'), + (Token.Operator, '='), + ] + assert list(lexer_ng2.get_tokens(fragment)) == tokens
\ No newline at end of file |
