Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
annotate tests/test_algpseudo.py @ 285:afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Uses a generic two-argument syntax and allows escaping of characters using
the common excaping rules.
For this to work the AlgPseudocodeLexer is now based on Pygment's
ExtendedRegexLexer instead of RegexLexer.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 20 May 2026 20:35:37 +0200 |
| parents | ee512932d603 |
| children | 051c8877ee22 |
| rev | line source |
|---|---|
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2 # :- |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
3 # SPDX-FileCopyrightText: © 2026 Franz Glasner |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
4 # SPDX-License-Identifier: MIT |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
5 # :- |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
6 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
43
diff
changeset
|
7 from _tsetup import ALGLEXERFILENAME, ALGLEXERCLASS |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
8 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
9 import unittest |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
10 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
11 import pygments |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
12 import pygments.lexers |
|
66
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
13 import pygments.formatters |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
14 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
15 import _testhelper |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
16 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
17 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
18 class TestSnippets(unittest.TestCase, _testhelper.TokenAssertHelper): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
19 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
20 def setUp(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
21 self.lexer = pygments.lexers.load_lexer_from_file( |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
43
diff
changeset
|
22 ALGLEXERFILENAME, ALGLEXERCLASS) |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
23 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
24 def test_lf(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
25 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
26 [("Text.Whitespace", "\n")], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
27 pygments.lex("\n", self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
28 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
29 def test_protected_lf(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
30 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
31 [("Text", "\\\n")], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
32 pygments.lex("\\\n", self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
33 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
34 def test_number_int(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
35 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
36 [("Number.Integer", "10"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
37 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
38 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
39 pygments.lex("10", self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
40 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
41 def test_number_float_1(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
42 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
43 [("Number.Float", "3.1415926"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
44 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
45 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
46 pygments.lex("3.1415926", self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
47 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
48 def test_number_float_2(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
49 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
50 [("Number.Float", "3.14e-12"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
51 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
52 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
53 pygments.lex("3.14e-12", self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
54 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
55 def test_string_s_1(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
56 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
57 [("String.Single", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
58 ("String.Single", "HU"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
59 ("String.Single", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
60 ("String.Single", "HE HA"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
61 ("String.Escape", "\\'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
62 ("String.Single", "HO"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
63 ("String.Single", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
64 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
65 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
66 pygments.lex("""'HU"HE HA\\'HO'""", self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
67 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
68 def test_string_s_2(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
69 self.assertTokenStreamEqual( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
70 [("String.Single", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
71 ("String.Single", "HUHU"), |
|
43
bbef0ac6cfcf
FIX: Proper string parsing: explicitely error out when single-line strings contain a linefeed
Franz Glasner <fzglas.hg@dom66.de>
parents:
41
diff
changeset
|
72 ("Error", "\n"), |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
73 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
74 pygments.lex("'HUHU\nHEHE'", self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
75 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
76 def test_string_ts_1(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
77 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
78 [("String.Single", "'''"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
79 ("String.Single", "HUHU HEHE"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
80 ("String.Single", "'''"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
81 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
82 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
83 pygments.lex("'''HUHU HEHE'''", self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
84 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
85 def test_string_ts_2(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
86 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
87 [("String.Single", "'''"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
88 ("String.Single", "HI"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
89 ("String.Single", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
90 ("String.Single", "HU"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
91 ("String.Single", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
92 ("String.Single", "HE"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
93 ("String.Single", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
94 ("String.Single", "HA"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
95 ("String.Single", "'''"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
96 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
97 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
98 pygments.lex("""'''HI'HU\nHE"HA'''""", self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
99 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
100 def test_string_d_1(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
101 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
102 [("String.Double", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
103 ("String.Double", 'HU'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
104 ("String.Double", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
105 ("String.Double", 'HE HA'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
106 ("String.Escape", '\\"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
107 ("String.Double", 'HO'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
108 ("String.Double", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
109 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
110 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
111 pygments.lex('''"HU'HE HA\\"HO"''', self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
112 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
113 def test_string_d_2(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
114 self.assertTokenStreamEqual( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
115 [("String.Double", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
116 ("String.Double", "HUHU"), |
|
43
bbef0ac6cfcf
FIX: Proper string parsing: explicitely error out when single-line strings contain a linefeed
Franz Glasner <fzglas.hg@dom66.de>
parents:
41
diff
changeset
|
117 ("Error", "\n"), |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
118 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
119 pygments.lex('"HUHU\nHEHE"', self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
120 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
121 def test_string_td_1(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
122 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
123 [("String.Double", '"""'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
124 ("String.Double", 'HUHU HAHA'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
125 ("String.Double", '"""'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
126 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
127 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
128 pygments.lex('"""HUHU HAHA"""', self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
129 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
130 def test_string_td_2(self): |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
131 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
132 [("String.Double", '"""'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
133 ("String.Double", 'HU'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
134 ("String.Double", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
135 ("String.Double", "HO"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
136 ("String.Double", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
137 ("String.Double", "HE"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
138 ("String.Double", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
139 ("String.Double", "HA"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
140 ("String.Double", '"""'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
141 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
142 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
143 pygments.lex('''"""HU"HO\nHE'HA"""''', self.lexer)) |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
144 |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
145 def test_proc(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
146 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
147 [("Keyword", "PROCEDURE"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
148 ("Text.Whitespace", " "), |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
149 ("Name.Entity", "the name"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
150 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
151 ], |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
152 pygments.lex("\\PROC {the name}", self.lexer)) |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
153 |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
154 def test_proc_with_symbols_in_name(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
155 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
156 [("Keyword", "PROCEDURE"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
157 ("Text.Whitespace", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
158 ("Name.Entity", "the name sqrt ! <="), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
159 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
160 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
161 pygments.lex("\\PROC {the name sqrt ! <=}", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
162 |
|
79
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
163 def test_proc_with_escape_in_name(self): |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
164 self.assertTokenStreamEqualComplete( |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
165 [("Keyword", "PROCEDURE"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
166 ("Text.Whitespace", " "), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
167 ("Name.Entity", "t"), |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
168 ("Generic.Error", "\\"), |
|
79
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
169 ("Name.Entity", "he "), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
170 ("Name.Entity", "\\"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
171 ("Name.Entity", "}"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
172 ("Name.Entity", "name"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
173 ("Text.Whitespace", "\n"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
174 ], |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
175 pygments.lex(r"\PROC {t\he \\\}name}", self.lexer)) |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
176 |
| 57 | 177 def test_endproc(self): |
| 178 self.assertTokenStreamEqualComplete( | |
| 179 [("Keyword", "END OF PROCEDURE"), | |
| 180 ("Text.Whitespace", "\n"), | |
| 181 ], | |
| 182 pygments.lex("\\END-PROCEDURE", self.lexer)) | |
| 183 | |
| 184 def test_endproc_with_entityname(self): | |
| 185 self.assertTokenStreamEqualComplete( | |
| 186 [("Keyword", "END OF PROCEDURE"), | |
| 187 ("Text.Whitespace", " "), | |
| 188 ("Name.Entity", "the procedure name"), | |
| 189 ("Text.Whitespace", "\n"), | |
| 190 ], | |
| 191 pygments.lex("\\ENDPROCEDURE {the procedure name}", self.lexer)) | |
| 192 | |
| 94 | 193 def test_endproc_with_entityname_2(self): |
| 194 self.assertTokenStreamEqualComplete( | |
| 195 [("Keyword", "END OF PROCEDURE"), | |
| 196 ("Text.Whitespace", " "), | |
| 197 ("Name.Entity", "the procedure name"), | |
| 198 ("Text.Whitespace", "\n"), | |
| 199 ], | |
| 200 pygments.lex("\\END-PROC {the procedure name}", self.lexer)) | |
| 201 | |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
202 def test_endproc_with_entityname_3(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
203 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
204 [("Keyword", "END OF PROCEDURE"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
205 ("Text.Whitespace", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
206 ("Name.Entity", "the procedure name with pow and symbols ! <= "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
207 ("Name.Entity", "}"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
208 ("Name.Entity", "<-"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
209 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
210 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
211 pygments.lex( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
212 "\\END-PROC" |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
213 " {the procedure name with pow and symbols ! <= \\}<-}", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
214 self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
215 |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
216 def test_proc_de(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
217 lexer = pygments.lexers.load_lexer_from_file( |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
43
diff
changeset
|
218 ALGLEXERFILENAME, "AlgPseudocodeLexer_DE") |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
219 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
220 [("Keyword", "PROZEDUR"), |
|
69
b3dd247b27a5
FIX: Add forgotten tests for the new normalized highlighting
Franz Glasner <fzglas.hg@dom66.de>
parents:
66
diff
changeset
|
221 ("Text.Whitespace", " "), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
222 ("Name.Entity", " also {nichtxs"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
223 ("Name.Entity", "}"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
224 ("Name.Entity", " hier"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
225 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
226 ], |
|
79
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
227 pygments.lex(r"\PROC { also {nichtxs\} hier}", lexer)) |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
228 |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
229 def test_loop_de_not_yet_translated(self): |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
230 lexer = pygments.lexers.load_lexer_from_file( |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
231 ALGLEXERFILENAME, "AlgPseudocodeLexer_DE") |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
232 self.assertTokenStreamEqualComplete( |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
233 [("Keyword", "LOOP"), |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
234 ("Text", " "), |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
235 ("Name.Entity", "a"), |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
236 ("Text.Whitespace", "\n"), |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
237 ], |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
238 pygments.lex(r"\LOOP a", lexer)) |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
239 |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
240 def test_function_1(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
241 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
242 [("Keyword", "FUNCTION"), |
|
69
b3dd247b27a5
FIX: Add forgotten tests for the new normalized highlighting
Franz Glasner <fzglas.hg@dom66.de>
parents:
66
diff
changeset
|
243 ("Text.Whitespace", " "), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
244 ("Name.Entity", "1"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
245 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
246 ], |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
247 pygments.lex("\\FUNC{1}", self.lexer)) |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
248 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
249 def test_function_2(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
250 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
251 [("Keyword", "FUNCTION"), |
|
69
b3dd247b27a5
FIX: Add forgotten tests for the new normalized highlighting
Franz Glasner <fzglas.hg@dom66.de>
parents:
66
diff
changeset
|
252 ("Text.Whitespace", " "), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
253 ("Name.Entity", "line 1\nline 2\n"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
254 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
255 ], |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
256 pygments.lex("\\FUNCTION{line 1\nline 2\n}", self.lexer)) |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
257 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
258 def test_function_3(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
259 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
260 [("Keyword", "FUNCTION"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
261 ("Text.Whitespace", " "), |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
262 ("Generic.Error", "\\"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
263 ("Name.Entity", "n"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
264 ("Name.Entity", "}"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
265 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
266 ], |
|
79
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
267 pygments.lex(r"\FN {\n\}}", self.lexer)) |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
268 |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
269 def test_class(self): |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
270 self.assertTokenStreamEqualComplete( |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
271 [("Keyword", "CLASS"), |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
272 ("Text.Whitespace", " "), |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
273 ("Generic.Error", "\\"), |
|
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
274 ("Name.Entity", "n"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
275 ("Name.Entity", "\\"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
276 ("Name.Entity", "}"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
277 ("Text.Whitespace", "\n"), |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
278 ], |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
279 pygments.lex(r"\CLASS {\n\\\}}", self.lexer)) |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
280 |
|
41
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
281 def test_class_fr(self): |
|
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
282 lexer = pygments.lexers.load_lexer_from_file( |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
43
diff
changeset
|
283 ALGLEXERFILENAME, "AlgPseudocodeLexer_FR") |
|
41
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
284 self.assertTokenStreamEqualComplete( |
|
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
285 [("Keyword", "CLASSE"), |
|
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
286 ("Text.Whitespace", " "), |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
287 ("Generic.Error", "\\"), |
|
41
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
288 ("Name.Entity", "n"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
289 ("Name.Entity", "}"), |
|
41
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
290 ("Text.Whitespace", "\n"), |
|
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
291 ], |
|
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
292 pygments.lex("\\CLASS {\\n\\}}", lexer)) |
|
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
293 |
| 57 | 294 def test_class_de_with_noend_option(self): |
| 295 lexer = pygments.lexers.load_lexer_from_file( | |
| 296 ALGLEXERFILENAME, "AlgPseudocodeLexer_DE", no_end="True") | |
| 297 self.assertTokenStreamEqualComplete( | |
| 298 [("Keyword", "KLASSE"), | |
| 299 ("Text.Whitespace", " "), | |
| 300 ("Name.Entity", "\\"), | |
| 301 ("Name.Entity", "n"), | |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
302 ("Name.Entity", "}"), |
| 57 | 303 ("Text.Whitespace", "\n"), |
| 304 ("Text.Whitespace", "\n"), | |
| 305 ], | |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
306 pygments.lex("\\CLASS {\\\\n\\}}\n\\ENDCLASS", lexer)) |
| 57 | 307 |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
308 def test_class_de_with_noend_option_and_name(self): |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
309 lexer = pygments.lexers.load_lexer_from_file( |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
310 ALGLEXERFILENAME, "AlgPseudocodeLexer_DE", no_end="True") |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
311 self.assertTokenStreamEqualComplete( |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
312 [("Keyword", "KLASSE"), |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
313 ("Text.Whitespace", " "), |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
314 ("Generic.Error", "\\"), |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
315 ("Name.Entity", "n"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
316 ("Name.Entity", "}"), |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
317 ("Text.Whitespace", "\n"), |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
318 ("Text.Whitespace", "\n"), |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
319 ], |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
320 pygments.lex("\\CLASS {\\n\\}}\n\\ENDCLASS {end class}", lexer)) |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
321 |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
322 def test_remark_1(self): |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
323 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
324 [("Comment.Single", u"▷"), |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
325 ("Comment.Single", " the remark"), |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
326 ("Text.Whitespace", "\n"), |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
327 ], |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
328 pygments.lex("\\REMARK the remark\n", self.lexer)) |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
329 |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
330 def test_remark_2(self): |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
331 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
332 [("Comment.Single", u"▷"), |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
333 ("Comment.Single", " the remark 1"), |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
334 ("Text.Whitespace", "\n"), |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
335 ("Comment.Single", u"▷"), |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
336 ("Comment.Single", " the remark 2"), |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
337 ("Text.Whitespace", "\n"), |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
338 ], |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
339 pygments.lex( |
|
64
05c53e431c88
Simplify case-handling for "BLOCK" and "REMARK"
Franz Glasner <fzglas.hg@dom66.de>
parents:
62
diff
changeset
|
340 """\\remArk the remark 1 |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
341 \\Rem the remark 2 |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
342 """, self.lexer)) |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
343 |
|
117
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
344 def test_remark_custom(self): |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
345 # With the APL comment symbol |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
346 lexer = pygments.lexers.load_lexer_from_file( |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
347 ALGLEXERFILENAME, ALGLEXERCLASS, remark=u"⍝") |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
348 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
349 [("Comment.Single", u"⍝"), # U+235D ⍝ APL FUNC. SYMBOL UP SHOE JOT |
|
117
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
350 ("Comment.Single", " another remark"), |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
351 ("Text.Whitespace", "\n"), |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
352 ], |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
353 pygments.lex(u"\\REMARK another remark\n", lexer)) |
|
117
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
354 |
|
108
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
355 def test_remark_in_text(self): |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
356 self.assertTokenStreamEqualComplete( |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
357 [("Text", "the text "), |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
358 ("Comment.Single", u"▷"), |
|
108
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
359 ("Comment.Single", " the remark"), |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
360 ("Text.Whitespace", "\n"), |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
361 ("Text", "the next text line"), |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
362 ("Text.Whitespace", "\n"), |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
363 ], |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
364 pygments.lex( |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
365 """\\TEXT{the text \\rem the remark\nthe next text line}""", |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
366 self.lexer)) |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
367 |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
368 def test_text_short_alias(self): |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
369 self.assertTokenStreamEqualComplete( |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
370 [("Text", "the text "), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
371 ("Text", "nested"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
372 ("Text", " trailer"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
373 ("Text.Whitespace", "\n"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
374 ], |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
375 pygments.lex( |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
376 """\\T{the text \\t{nested} trailer}""", |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
377 self.lexer)) |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
378 |
|
101
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
379 def test_comment_single_1(self): |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
380 self.assertTokenStreamEqualComplete( |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
381 [("Comment.Single", "// foo bar"), |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
382 ("Text.Whitespace", "\n"), |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
383 ], |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
384 pygments.lex(r"// foo bar", self.lexer)) |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
385 |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
386 def test_comment_single_2(self): |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
387 self.assertTokenStreamEqualComplete( |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
388 [("Comment.Single", "# foo bar"), |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
389 ("Text.Whitespace", "\n"), |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
390 ], |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
391 pygments.lex(r"# foo bar", self.lexer)) |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
392 |
|
70
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
393 def test_expr_and_text(self): |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
394 self.assertTokenStreamEqualComplete( |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
395 [("Name.Entity", "a"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
396 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
397 ("Text", "multiplied by"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
398 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
399 ("Name.Entity", "b"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
400 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
401 ("Text", "is"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
402 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
403 ("Number.Integer", "0"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
404 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
405 ("Text", "mod"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
406 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
407 ("Name.Entity", "p"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
408 ("Text.Whitespace", "\n"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
409 ], |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
410 pygments.lex( |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
411 r"""a \TEXT{multiplied by} b \text{is} 0 \text{mod} p""", |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
412 self.lexer)) |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
413 |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
414 def test_expr_and_text_with_escaped_characters(self): |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
415 self.assertTokenStreamEqualComplete( |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
416 [("Name.Entity", "a"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
417 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
418 ("Text", "multiplied by {escaped"), |
|
72
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
419 ("Text", "}"), |
|
70
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
420 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
421 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
422 ("Name.Entity", "b"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
423 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
424 ("Text", "is "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
425 ("Text", "\\"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
426 ("Text", " not"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
427 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
428 ("Number.Integer", "0"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
429 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
430 ("Text", "mod"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
431 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
432 ("Name.Entity", "p"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
433 ("Text.Whitespace", "\n"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
434 ], |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
435 pygments.lex( |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
436 r"""a \TEXT{multiplied by {escaped\} } b \text{is \ not} 0""" |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
437 r" \text{mod} p""", |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
438 self.lexer)) |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
439 |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
440 def test_punctuation(self): |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
441 self.assertTokenStreamEqualComplete( |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
442 [("Punctuation", "{"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
443 ("Punctuation", "}"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
444 ("Punctuation", ":"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
445 ("Punctuation", "("), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
446 ("Punctuation", ")"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
447 ("Punctuation", ","), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
448 ("Punctuation", ";"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
449 ("Punctuation", "["), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
450 ("Punctuation", "]"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
451 ("Punctuation", "?"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
452 ("Punctuation", "@"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
453 ("Text.Whitespace", "\n"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
454 ], |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
455 pygments.lex(r"{}:(),;[]?@", self.lexer)) |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
456 |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
457 def test_block_empty(self): |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
458 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
459 [("Text", u"◆"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
460 ("Text.Whitespace", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
461 ("Text.Whitespace", "\n"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
462 ], |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
463 pygments.lex(r"\block{}", self.lexer)) |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
464 |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
465 def test_block_with_text(self): |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
466 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
467 [("Text", u"◆"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
468 ("Text.Whitespace", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
469 ("Text", "a b c"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
470 ("Text.Whitespace", "\n"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
471 ], |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
472 pygments.lex(r"\block{\text{a b c}}", self.lexer)) |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
473 |
|
76
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
474 def test_block_with_escaped_text(self): |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
475 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
476 [("Text", u"◆"), |
|
76
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
477 ("Text.Whitespace", " "), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
478 ("Text", "\\"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
479 ("Name.Entity", "text"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
480 ("Punctuation", "{"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
481 ("Name.Entity", "a"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
482 ("Text", " "), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
483 ("Name.Entity", "b"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
484 ("Text", " "), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
485 ("Name.Entity", "c"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
486 ("Punctuation", "}"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
487 ("Text.Whitespace", "\n"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
488 ], |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
489 pygments.lex(r"\block{\\text{a b c\}}", self.lexer)) |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
490 |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
491 def test_block(self): |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
492 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
493 [("Text", u"◆"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
494 ("Text.Whitespace", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
495 ("Name.Entity", "a"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
496 ("Text", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
497 ("Number.Float", "1.2"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
498 ("Text", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
499 ("Punctuation", "{"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
500 ("Name.Entity", "x"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
501 ("Text", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
502 ("Operator.Word", "in"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
503 ("Text", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
504 ("Name.Entity", "X"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
505 ("Punctuation", "}"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
506 ("Text", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
507 ("Name.Entity", "c"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
508 ("Text.Whitespace", "\n"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
509 ], |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
510 pygments.lex(r"\state{a 1.2 {x in X\} c}", self.lexer)) |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
511 |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
512 def test_tstate_empty(self): |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
513 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
514 [("Text", u"▪"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
515 ("Text.Whitespace", " "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
516 ("Text.Whitespace", "\n"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
517 ], |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
518 pygments.lex(r"\tstate{}", self.lexer)) |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
519 |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
520 def test_tstate_with_expr(self): |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
521 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
522 [("Text", u"▪"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
523 ("Text.Whitespace", " "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
524 ("Text", "a 1.2 "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
525 ("Name.Entity", "x"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
526 ("Text", " "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
527 ("Operator.Word", "in"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
528 ("Text", " "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
529 ("Name.Entity", "X"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
530 ("Punctuation", "}"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
531 ("Text", " c"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
532 ("Text.Whitespace", "\n"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
533 ], |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
534 pygments.lex(r"\tstate{a 1.2 \expr{x in X\}} c}", self.lexer)) |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
535 |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
536 def test_tstate_with_escaped_expr(self): |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
537 self.assertTokenStreamEqualComplete( |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
538 [("Text", u"▪"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
539 ("Text.Whitespace", " "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
540 ("Text", "a 1.2 "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
541 ("Text", "\\"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
542 ("Text", "expr{x in X"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
543 ("Text", "}"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
544 ("Text", " c"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
545 ("Text.Whitespace", "\n"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
546 ], |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
547 pygments.lex(r"\tstate{a 1.2 \\expr{x in X\} c}", self.lexer)) |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
548 |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
549 def test_expr_short_alias(self): |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
550 self.assertTokenStreamEqualComplete( |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
551 [("Name.Entity", "foo"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
552 ("Text", " "), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
553 ("Name.Entity", "bar"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
554 ("Text", " "), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
555 ("Text", "bar +"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
556 ("Text.Whitespace", "\n"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
557 ], |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
558 pygments.lex(r"foo \e{bar} \t{bar +}", self.lexer)) |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
559 |
|
92
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
560 def test_text_in_expr(self): |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
561 self.assertTokenStreamEqualComplete( |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
562 [("Name.Entity", "first"), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
563 ("Text", " "), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
564 ("Name.Entity", "expression"), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
565 ("Text", " "), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
566 ("Name.Entity", "second"), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
567 ("Text", " "), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
568 ("Name.Entity", "expression"), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
569 ("Text.Whitespace", "\n"), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
570 ], |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
571 pygments.lex( |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
572 r"\TEXT{\EXPRESSION{first expression} " |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
573 r"\EXPR{second expression}}", |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
574 self.lexer)) |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
575 |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
576 def test_explicit_extended_single_tokentype_1(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
577 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
578 [("Operator", "%"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
579 ("Text.Whitespace", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
580 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
581 pygments.lex(r"\ttx-o:%:", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
582 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
583 def test_explicit_extended_single_tokentype_2(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
584 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
585 [("Operator", "{"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
586 ("Text.Whitespace", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
587 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
588 pygments.lex(r"\ttx-o{{}", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
589 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
590 def test_explicit_extended_single_tokentype_3(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
591 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
592 [("Operator", "<"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
593 ("Text.Whitespace", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
594 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
595 pygments.lex(r"\ttx-o<<>", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
596 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
597 def test_explicit_extended_single_tokentype_4(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
598 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
599 [("Operator", "("), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
600 ("Text.Whitespace", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
601 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
602 pygments.lex(r"\ttx-o(()", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
603 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
604 def test_explicit_extended_multi_tokentype_1(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
605 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
606 [("Operator", "xxx in A"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
607 ("Text.Whitespace", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
608 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
609 pygments.lex(r"\ttx-o/xxx in A/", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
610 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
611 def test_explicit_extended_multi_tokentype_2(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
612 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
613 [("Operator", "xxx in B"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
614 ("Text.Whitespace", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
615 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
616 pygments.lex(r"\ttx-o{xxx in B}", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
617 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
618 def test_explicit_extended_multi_tokentype_3(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
619 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
620 [("Operator", "xxx in C"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
621 ("Text.Whitespace", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
622 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
623 pygments.lex(r"\ttx-o<xxx in C>", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
624 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
625 def test_explicit_extended_multi_tokentype_4(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
626 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
627 [("Operator", "xxx in D"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
628 ("Text.Whitespace", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
629 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
630 pygments.lex(r"\ttx-o(xxx in D)", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
631 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
632 def test_explicit_tokentype_simple_1(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
633 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
634 [("Operator", "}"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
635 ("Operator", "/"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
636 ("Text.Whitespace", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
637 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
638 pygments.lex(r"\tt-o/}\tt-o//", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
639 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
640 def test_explicit_tokentype_simple_2(self): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
641 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
642 [("Operator", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
643 ("Operator", "/"), |
|
95
aed3204723ac
FIX: Test results because of changed whitespace handling
Franz Glasner <fzglas.hg@dom66.de>
parents:
94
diff
changeset
|
644 ("Text", " "), |
|
aed3204723ac
FIX: Test results because of changed whitespace handling
Franz Glasner <fzglas.hg@dom66.de>
parents:
94
diff
changeset
|
645 ("Text.Whitespace", "\n"), |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
646 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
647 pygments.lex("\\tt-o/\n\\tt-o// ", self.lexer)) |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
648 |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
649 def test_explicit_tokentype_with_remark(self): |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
650 self.assertTokenStreamEqualComplete( |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
651 [("Operator", u"∈ ∌"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
652 ("Text", " "), |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
653 ("Comment.Single", u"▷"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
654 ("Comment.Single", u" ∈ ∌ as (ordinary) operators"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
655 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
656 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
657 pygments.lex( |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
658 u"""\\ttx-o<∈ ∌> \\rem ∈ ∌ as (ordinary) operators""", |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
659 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
660 |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
661 def test_explicit_tokentype_with_remark_2(self): |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
662 self.assertTokenStreamEqualComplete( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
663 [("Operator", "new_operator"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
664 ("Text", " "), |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
665 ("Comment.Single", u"▷"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
666 ("Comment.Single", " a (synthesized) operator"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
667 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
668 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
669 pygments.lex( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
670 r"""\ttx-o<new_operator> \rem a (synthesized) operator""", |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
671 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
672 |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
673 def test_explicit_tokentype_with_possibly_conflicting_parens(self): |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
674 self.assertTokenStreamEqualComplete( |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
675 [("Name.Function", u"∈_∌"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
676 ("Punctuation", "("), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
677 ("Name.Entity", "p1"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
678 ("Punctuation", ","), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
679 ("Text", " "), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
680 ("Name.Entity", "p2"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
681 ("Punctuation", ")"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
682 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
683 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
684 pygments.lex( |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
685 u"""\\ttx-nf<∈_∌>(p1, p2)""", |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
686 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
687 |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
688 def test_explicit_tokentype_with_possibly_conflicting_parens_2(self): |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
689 self.assertTokenStreamEqualComplete( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
690 [("Name.Decorator", "a_Decorator"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
691 ("Punctuation", "("), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
692 ("Name.Entity", "p1"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
693 ("Punctuation", ","), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
694 ("Text", " "), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
695 ("Name.Entity", "p2"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
696 ("Punctuation", ")"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
697 ("Text", " "), |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
698 ("Comment.Single", u"▷"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
699 ("Comment.Single", " (Python) decorator"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
700 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
701 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
702 pygments.lex( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
703 r"""\ttx-nd<a_Decorator>(p1, p2) \rem (Python) decorator""", |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
704 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
705 |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
706 def test_explicit_tokentype_with_possibly_conflicting_parens_3(self): |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
707 self.assertTokenStreamEqualComplete( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
708 [("Name.Decorator", "a_Decorator"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
709 ("Punctuation", "("), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
710 ("Name.Entity", "p1"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
711 ("Punctuation", ","), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
712 ("Text", " "), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
713 ("Name.Entity", "p2"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
714 ("Punctuation", ")"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
715 ("Text", " "), |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
716 ("Comment.Single", u"▷"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
717 ("Comment.Single", " (Python) annotation"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
718 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
719 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
720 pygments.lex( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
721 r"""\ttx-nd[a_Decorator](p1, p2) \rem (Python) annotation""", |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
722 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
723 |
|
275
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
724 def test_explicit_tokentype_all_seps(self): |
|
276
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
725 for sep in r"""/?.,:;%|=*+!$"'~_-#@""": |
|
275
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
726 self.assertTokenStreamEqualComplete( |
|
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
727 [("Name.Decorator", "word"), |
|
276
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
728 ("Text", sep), |
|
275
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
729 ("Text.Whitespace", "\n"), |
|
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
730 ], |
|
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
731 pygments.lex( |
|
276
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
732 r"\text{\ttx-nd%sword%s%s}" % (sep, sep, sep), |
|
275
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
733 self.lexer)) |
|
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
734 |
|
276
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
735 def test_explicit_tokentype_backslash(self): |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
736 self.assertTokenStreamEqualComplete( |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
737 [("Name.Decorator", "word"), |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
738 ("Text", "\\"), |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
739 ("Text", " "), |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
740 ("Text.Whitespace", "\n"), |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
741 ], |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
742 pygments.lex(r"\text{\ttx-nd\word\\ }", self.lexer)) |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
743 |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
744 def test_explicit_tokentype_error(self): |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
745 self.assertTokenStreamEqualComplete( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
746 [("Generic.Error", r"""\ttx-non-existing[a_Decorator]"""), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
747 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
748 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
749 pygments.lex( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
750 r"""\ttx-non-existing[a_Decorator]""", |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
751 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
752 |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
753 def test_extended_explicit_tokentype_empty(self): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
754 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
755 [("Text.Whitespace", "\n")], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
756 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
757 r"""\ttX{nd}{}""", self.lexer)) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
758 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
759 def test_extended_explicit_tokentype_simple(self): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
760 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
761 [("Name.Decorator", "simple\nline 2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
762 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
763 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
764 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
765 """\\ttX{nd}{simple\nline 2}""", self.lexer)) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
766 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
767 def test_extended_explicit_tokentype_escaped_brace(self): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
768 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
769 [("Name.Decorator", "simple"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
770 ("Name.Decorator", "}"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
771 ("Name.Decorator", "part 2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
772 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
773 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
774 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
775 """\\ttX{nd}{simple\\}part 2}""", self.lexer)) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
776 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
777 def test_extended_explicit_tokentype_escaped_backslash(self): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
778 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
779 [("Name.Decorator", "simple"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
780 ("Name.Decorator", "\\"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
781 ("Name.Decorator", "part 2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
782 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
783 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
784 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
785 """\\ttX{nd}{simple\\\\part 2}""", self.lexer)) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
786 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
787 def test_extended_explicit_tokentype_single_backslash(self): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
788 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
789 [("Name.Variable", "simple"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
790 ("Generic.Error", "\\"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
791 ("Name.Variable", "part 2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
792 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
793 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
794 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
795 """\\ttX{nv}{simple\\part 2}""", self.lexer)) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
796 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
797 def test_extended_explicit_tokentype_non_existing_type(self): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
798 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
799 [("Generic.Error", u"\\ttX{NON_EXISTING}{"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
800 ("Generic.Error", u"∈_∌"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
801 ("Generic.Error", u"}"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
802 ("Punctuation", "("), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
803 ("Name.Entity", "p1"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
804 ("Punctuation", ","), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
805 ("Text", " "), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
806 ("Name.Entity", "p2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
807 ("Punctuation", ")"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
808 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
809 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
810 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
811 u"\\ttX{NON_EXISTING}{∈_∌}(p1, p2)", self.lexer)) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
812 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
813 def test_just_braces_in_expressions(self): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
814 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
815 [("Punctuation", "{"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
816 ("Name.Entity", "foo"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
817 ("Text", " "), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
818 ("Name.Entity", "bar"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
819 ("Punctuation", "}"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
820 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
821 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
822 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
823 r"{foo bar}", self.lexer)) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
824 |
| 97 | 825 def test_end_combinations(self): |
| 826 self.assertTokenStreamEqualComplete( | |
| 827 [("Keyword", "BEGIN"), | |
| 828 ("Text", " "), | |
| 829 ("Keyword", "END"), | |
| 830 ("Text", " "), | |
| 831 ("Keyword", "END OF FUNCTION"), | |
| 832 ("Text", " "), | |
| 833 ("Keyword", "END OF FUNCTION"), | |
| 834 ("Text.Whitespace", " "), | |
| 835 ("Name.Entity", "An End of a Function"), | |
| 836 ("Text", " "), | |
| 837 ("Keyword", "END OF FUNCTION"), | |
| 838 ("Text.Whitespace", " "), | |
| 839 ("Name.Entity", "The End of the Next Function"), | |
| 840 ("Text", " "), | |
| 841 ("Text.Whitespace", "\n"), | |
| 842 ], | |
| 843 pygments.lex( | |
| 844 r"""\begin \end \end-fn \end-fn {An End of a Function}""" | |
| 845 r""" \end fn {The End of the Next Function} """, | |
| 846 self.lexer)) | |
| 847 | |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
848 def test_unicode_math_operator(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
849 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
850 [("Operator", u"∈"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
851 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
852 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
853 pygments.lex(u"∈", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
854 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
855 def test_ascii_math_operator(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
856 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
857 [("Operator", "="), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
858 ("Operator", "!"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
859 ("Operator", "&"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
860 ("Operator", "<"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
861 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
862 ("Operator", ">"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
863 ("Operator", "+"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
864 ("Operator", "-"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
865 ("Operator", "*"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
866 ("Operator", "/"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
867 ("Operator", "%"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
868 ("Operator", "|"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
869 ("Operator", "~"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
870 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
871 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
872 pygments.lex("=!&< >+-*/%|~", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
873 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
874 def test_ascii_math_operator_with_replacements(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
875 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
876 [("Operator", u"⇔"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
877 ("Text", " "), |
|
116
9bfd87544902
Use arrows from Supplemental Arrows-A Unicode block where appropriate: better readability
Franz Glasner <fzglas.hg@dom66.de>
parents:
115
diff
changeset
|
878 ("Operator", u"⟷"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
879 ("Text", " "), |
|
116
9bfd87544902
Use arrows from Supplemental Arrows-A Unicode block where appropriate: better readability
Franz Glasner <fzglas.hg@dom66.de>
parents:
115
diff
changeset
|
880 ("Operator", u"⟵"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
881 ("Text", " "), |
|
116
9bfd87544902
Use arrows from Supplemental Arrows-A Unicode block where appropriate: better readability
Franz Glasner <fzglas.hg@dom66.de>
parents:
115
diff
changeset
|
882 ("Operator", u"⟶"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
883 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
884 ("Operator", u"⇒"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
885 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
886 ("Operator", u"≤"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
887 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
888 ("Operator", u"≥"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
889 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
890 ("Operator", u"≠"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
891 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
892 ("Operator", u"≠"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
893 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
894 ("Operator", u"∶="), # u"≔"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
895 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
896 ("Operator", u"=∶"), # u"≕"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
897 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
898 ("Operator", u"≟"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
899 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
900 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
901 pygments.lex(u"<=> <-> <- -> => <= >= <> != := =: ?=", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
902 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
903 def test_word_operators(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
904 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
905 [("Operator.Word", "IN"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
906 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
907 ("Operator.Word", "is"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
908 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
909 ("Operator.Word", "And"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
910 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
911 ("Operator.Word", "Or"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
912 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
913 ("Operator.Word", "XOR"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
914 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
915 ("Operator.Word", "not"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
916 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
917 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
918 pygments.lex("IN is And Or XOR not", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
919 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
920 def test_keyword_constants(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
921 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
922 [("Keyword.Constant", "true"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
923 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
924 ("Keyword.Constant", "FALSE"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
925 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
926 ("Keyword.Constant", "None"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
927 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
928 ("Keyword.Constant", "nil"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
929 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
930 ("Keyword.Constant", "NULL"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
931 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
932 ("Keyword.Constant", "Empty"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
933 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
934 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
935 pygments.lex("true FALSE None nil NULL Empty", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
936 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
937 def test_math_builtins(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
938 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
939 [("Name.Builtin", "sqrt"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
940 ("Punctuation", "("), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
941 ("Name.Entity", "Foo"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
942 ("Punctuation", ")"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
943 ("Punctuation", ";"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
944 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
945 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
946 pygments.lex("sqrt(Foo);", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
947 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
948 def test_math_builtins_nested(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
949 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
950 [("Name.Builtin", "pow"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
951 ("Punctuation", "("), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
952 ("Number.Integer", "2"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
953 ("Punctuation", ","), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
954 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
955 ("Number.Integer", "8"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
956 ("Punctuation", ")"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
957 ("Punctuation", ";"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
958 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
959 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
960 pygments.lex("\\text{\\expr{pow(2, 8);}}", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
961 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
962 def test_math_letters(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
963 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
964 [("Name.Entity", "a"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
965 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
966 ("Operator.Word", "in"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
967 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
968 ("Name.Entity", u"ℂ"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
969 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
970 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
971 pygments.lex(u"a in ℂ", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
972 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
973 def test_other_symbols(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
974 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
975 [("Name.Entity", "b"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
976 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
977 ("Operator.Word", "in"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
978 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
979 ("Text", u"℀"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
980 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
981 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
982 pygments.lex(u"b in ℀", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
983 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
984 def test_escaped_string_start_1(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
985 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
986 [("Text", "flow "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
987 ("Name.Entity", "f"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
988 ("Punctuation", "'"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
989 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
990 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
991 pygments.lex(r"\TEXT{flow \expr{f\'}}", self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
992 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
993 def test_escaped_string_start_2(self): |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
994 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
995 [("Text", "flow "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
996 ("Name.Entity", "f"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
997 ("Punctuation", '"'), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
998 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
999 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1000 pygments.lex(r'\TEXT{flow \expr{f\"}}', self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1001 |
| 113 | 1002 def test_gets_default(self): |
| 1003 self.assertTokenStreamEqualComplete( | |
| 1004 [("Name.Entity", "a"), | |
| 1005 ("Text", " "), | |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
1006 ("Operator", u"⟵"), # U+27F5 (Supplemental Arrows-A) |
| 113 | 1007 ("Text", " "), |
| 1008 ("Number.Integer", "2"), | |
| 1009 ("Text.Whitespace", "\n"), | |
| 1010 ], | |
| 1011 pygments.lex(r"a \gets 2", self.lexer)) | |
| 1012 | |
| 1013 def test_gets_custom(self): | |
| 1014 lexer = pygments.lexers.load_lexer_from_file( | |
| 1015 ALGLEXERFILENAME, ALGLEXERCLASS, gets="::=") | |
| 1016 self.assertTokenStreamEqualComplete( | |
| 1017 [("Name.Entity", "a"), | |
| 1018 ("Text", " "), | |
| 1019 ("Operator", "::="), | |
| 1020 ("Text", " "), | |
| 1021 ("Number.Float", "2.7"), | |
| 1022 ("Text.Whitespace", "\n"), | |
| 1023 ], | |
| 1024 pygments.lex(r"a \gets 2.7", lexer)) | |
| 1025 | |
| 114 | 1026 def test_call(self): |
| 1027 self.assertTokenStreamEqualComplete( | |
| 1028 [("Name.Entity", "a function"), | |
| 1029 ("Punctuation", "("), | |
| 1030 ("Name.Entity", "p1"), | |
| 1031 ("Punctuation", ","), | |
| 1032 ("Text", " "), | |
| 1033 ("Name.Entity", "p2"), | |
| 1034 ("Punctuation", ")"), | |
| 1035 ("Text.Whitespace", "\n"), | |
| 1036 ], | |
| 1037 pygments.lex(r"\CALL{a function}(p1, p2)", self.lexer)) | |
| 1038 | |
| 1039 def test_call_in_expr(self): | |
| 1040 self.assertTokenStreamEqualComplete( | |
| 1041 [("Name.Entity", "a procedure"), | |
| 1042 ("Punctuation", "("), | |
| 1043 ("Name.Entity", "arg1"), | |
| 1044 ("Punctuation", ","), | |
| 1045 ("Text", " "), | |
| 1046 ("Name.Entity", "arg2"), | |
| 1047 ("Punctuation", ","), | |
| 1048 ("Text", " "), | |
| 1049 ("Name.Entity", "arg3"), | |
| 1050 ("Punctuation", ")"), | |
| 1051 ("Text.Whitespace", "\n"), | |
| 1052 ], | |
| 1053 pygments.lex(r"\TEXT{\EXPR{\CALL{a procedure}(arg1, arg2, arg3)}}", | |
| 1054 self.lexer)) | |
| 1055 | |
|
149
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1056 def test_name(self): |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1057 self.assertTokenStreamEqualComplete( |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1058 [("Name.Entity", "an entity"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1059 ("Punctuation", "("), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1060 ("Name.Entity", "p1"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1061 ("Punctuation", ","), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1062 ("Text", " "), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1063 ("Name.Entity", "p2"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1064 ("Punctuation", ")"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1065 ("Text.Whitespace", "\n"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1066 ], |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1067 pygments.lex(r"\NAME{an entity}(p1, p2)", self.lexer)) |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1068 |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1069 def test_name_in_expr(self): |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1070 self.assertTokenStreamEqualComplete( |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1071 [("Name.Entity", "an entity"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1072 ("Punctuation", "("), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1073 ("Name.Entity", "arg1"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1074 ("Punctuation", ","), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1075 ("Text", " "), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1076 ("Name.Entity", "arg2"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1077 ("Punctuation", ","), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1078 ("Text", " "), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1079 ("Name.Entity", "arg3"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1080 ("Punctuation", ")"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1081 ("Text.Whitespace", "\n"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1082 ], |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1083 pygments.lex(r"\TEXT{\EXPR{\NAME{an entity}(arg1, arg2, arg3)}}", |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1084 self.lexer)) |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1085 |
|
115
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1086 def test_comment_multi(self): |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1087 self.assertTokenStreamEqualComplete( |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1088 [("Comment.Multiline", "/*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1089 ("Comment.Multiline", " word1 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1090 ("Comment.Multiline", "*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1091 ("Comment.Multiline", " word2 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1092 ("Comment.Multiline", "/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1093 ("Comment.Multiline", " word3 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1094 ("Comment.Multiline", "/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1095 ("Comment.Multiline", "/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1096 ("Comment.Multiline", " word4 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1097 ("Comment.Multiline", "*/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1098 ("Text.Whitespace", "\n"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1099 ], |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1100 pygments.lex(r"/* word1 * word2 / word3 // word4 */", self.lexer)) |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1101 |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1102 def test_comment_multi_alt(self): |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1103 self.assertTokenStreamEqualComplete( |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1104 [("Comment.Multiline", "(*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1105 ("Comment.Multiline", " word1 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1106 ("Comment.Multiline", "*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1107 ("Comment.Multiline", " word2 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1108 ("Comment.Multiline", "("), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1109 ("Comment.Multiline", " word3 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1110 ("Comment.Multiline", ")"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1111 ("Comment.Multiline", " word4 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1112 ("Comment.Multiline", "("), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1113 ("Comment.Multiline", ")"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1114 ("Comment.Multiline", " word5 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1115 ("Comment.Multiline", "*)"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1116 ("Text.Whitespace", "\n"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1117 ], |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1118 pygments.lex(r"(* word1 * word2 ( word3 ) word4 () word5 *)", |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1119 self.lexer)) |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1120 |
|
159
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1121 def test_dots_one(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1122 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1123 [("Punctuation", "."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1124 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1125 ], |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1126 pygments.lex(r".", self.lexer)) |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1127 |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1128 def test_dots_two(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1129 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1130 [("Punctuation", ".."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1131 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1132 ], |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1133 pygments.lex(r"..", self.lexer)) |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1134 |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1135 def test_dots_three(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1136 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1137 [("Punctuation", "..."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1138 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1139 ], |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1140 pygments.lex(r"...", self.lexer)) |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1141 |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1142 def test_dots_four(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1143 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1144 [("Punctuation", "...."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1145 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1146 ], |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
1147 pygments.lex(r"....", self.lexer)) |
|
159
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1148 |
|
212
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1149 def test_nested_expr(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1150 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1151 [("Name.Entity", "foo"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1152 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1153 ("Operator", "+"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1154 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1155 ("Name.Entity", "bar"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1156 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1157 ("Operator", "*"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1158 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1159 ("Number.Integer", '7'), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1160 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1161 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1162 pygments.lex(r"\EXPR{\EXPR{foo + bar} * 7}", self.lexer)) |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1163 |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1164 def test_nested_expr_in_block(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1165 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1166 [("Text", u"◆"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1167 ("Text.Whitespace", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1168 ("Name.Entity", "foo"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1169 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1170 ("Operator", "+"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1171 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1172 ("Name.Entity", "bar"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1173 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1174 ("Operator", "*"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1175 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1176 ("Number.Integer", '7'), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1177 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1178 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1179 pygments.lex(u"\\BLOCK{\\EXPR{\\EXPR{foo + bar} * 7}}", |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1180 self.lexer)) |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1181 |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1182 def test_nested_text(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1183 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1184 [("Text", "foo + bar"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1185 ("Text", " * 7"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1186 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1187 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1188 pygments.lex(r"\TEXT{\TEXT{foo + bar} * 7}", self.lexer)) |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1189 |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1190 def test_nested_text_in_tblock(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1191 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1192 [("Text", u"▪"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1193 ("Text.Whitespace", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1194 ("Text", "bar + Foo"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1195 ("Text", " * 7"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1196 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1197 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1198 pygments.lex(u"\\TBLOCK{\\TEXT{\\TEXT{bar + Foo} * 7}}", |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1199 self.lexer)) |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1200 |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1201 |
|
66
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1202 class PygmentizeCompletely(unittest.TestCase): |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1203 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1204 def setUp(self): |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1205 self.lexer = pygments.lexers.load_lexer_from_file( |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1206 ALGLEXERFILENAME, ALGLEXERCLASS) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1207 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1208 def test_pygmentize_html(self): |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1209 html_formatter = pygments.formatters.get_formatter_by_name("html") |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1210 highlighted = pygments.highlight( |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1211 '"""FOO"""', |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1212 self.lexer, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1213 html_formatter, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1214 outfile=None) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1215 self.assertTrue(highlighted.startswith("""<div class="highlight">""")) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1216 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1217 def test_pygmentize_latex(self): |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1218 latex_formatter = pygments.formatters.get_formatter_by_name("latex") |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1219 highlighted = pygments.highlight( |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1220 '"""FOO"""', |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1221 self.lexer, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1222 latex_formatter, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1223 outfile=None) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1224 self.assertTrue(highlighted.startswith(r"""\begin{Verbatim}""")) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1225 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1226 |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1227 if __name__ == "__main__": |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1228 unittest.main() |
