Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
annotate tests/test_algpseudo.py @ 286:051c8877ee22
Implement lexer option "strict_tokentype".
It allows the \ttX command to synthesize not yet existing token types.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 21 May 2026 09:32:35 +0200 |
| parents | afbca50b7dc1 |
| children | 298841bc4dee |
| 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 |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
14 from pygments.token import Token |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
15 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
16 import _testhelper |
|
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 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
19 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
|
20 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
21 def setUp(self): |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
22 # The standard lexer |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
23 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
|
24 ALGLEXERFILENAME, ALGLEXERCLASS) |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
25 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
26 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
|
27 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
28 [("Text.Whitespace", "\n")], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
29 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
|
30 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
31 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
|
32 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
33 [("Text", "\\\n")], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
34 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
|
35 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
36 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
|
37 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
38 [("Number.Integer", "10"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
39 ("Text.Whitespace", "\n"), |
|
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 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
|
42 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
43 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
|
44 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
45 [("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
|
46 ("Text.Whitespace", "\n"), |
|
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 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
|
49 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
50 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
|
51 self.assertTokenStreamEqualComplete( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
52 [("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
|
53 ("Text.Whitespace", "\n"), |
|
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 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
|
56 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
57 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
|
58 self.assertTokenStreamEqualComplete( |
|
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", "HU"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
61 ("String.Single", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
62 ("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
|
63 ("String.Escape", "\\'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
64 ("String.Single", "HO"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
65 ("String.Single", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
66 ("Text.Whitespace", "\n"), |
|
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 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
|
69 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
70 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
|
71 self.assertTokenStreamEqual( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
72 [("String.Single", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
73 ("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
|
74 ("Error", "\n"), |
|
34
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 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
|
77 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
78 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
|
79 self.assertTokenStreamEqualComplete( |
|
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 ("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
|
82 ("String.Single", "'''"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
83 ("Text.Whitespace", "\n"), |
|
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 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
|
86 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
87 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
|
88 self.assertTokenStreamEqualComplete( |
|
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", "HI"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
91 ("String.Single", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
92 ("String.Single", "HU"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
93 ("String.Single", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
94 ("String.Single", "HE"), |
|
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 ("String.Single", "HA"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
97 ("String.Single", "'''"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
98 ("Text.Whitespace", "\n"), |
|
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 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
|
101 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
102 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
|
103 self.assertTokenStreamEqualComplete( |
|
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", 'HU'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
106 ("String.Double", "'"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
107 ("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
|
108 ("String.Escape", '\\"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
109 ("String.Double", 'HO'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
110 ("String.Double", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
111 ("Text.Whitespace", "\n"), |
|
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 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
|
114 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
115 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
|
116 self.assertTokenStreamEqual( |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
117 [("String.Double", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
118 ("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
|
119 ("Error", "\n"), |
|
34
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 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
|
122 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
123 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
|
124 self.assertTokenStreamEqualComplete( |
|
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 ("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
|
127 ("String.Double", '"""'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
128 ("Text.Whitespace", "\n"), |
|
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 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
|
131 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
132 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
|
133 self.assertTokenStreamEqualComplete( |
|
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", 'HU'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
136 ("String.Double", '"'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
137 ("String.Double", "HO"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
138 ("String.Double", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
139 ("String.Double", "HE"), |
|
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 ("String.Double", "HA"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
142 ("String.Double", '"""'), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
143 ("Text.Whitespace", "\n"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
144 ], |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
145 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
|
146 |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
147 def test_proc(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
148 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
149 [("Keyword", "PROCEDURE"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
150 ("Text.Whitespace", " "), |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
151 ("Name.Entity", "the name"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
152 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
153 ], |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
154 pygments.lex("\\PROC {the name}", self.lexer)) |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
155 |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
156 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
|
157 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
158 [("Keyword", "PROCEDURE"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
159 ("Text.Whitespace", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
160 ("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
|
161 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
162 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
163 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
|
164 |
|
79
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
165 def test_proc_with_escape_in_name(self): |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
166 self.assertTokenStreamEqualComplete( |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
167 [("Keyword", "PROCEDURE"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
168 ("Text.Whitespace", " "), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
169 ("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
|
170 ("Generic.Error", "\\"), |
|
79
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
171 ("Name.Entity", "he "), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
172 ("Name.Entity", "\\"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
173 ("Name.Entity", "}"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
174 ("Name.Entity", "name"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
175 ("Text.Whitespace", "\n"), |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
176 ], |
|
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
177 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
|
178 |
| 57 | 179 def test_endproc(self): |
| 180 self.assertTokenStreamEqualComplete( | |
| 181 [("Keyword", "END OF PROCEDURE"), | |
| 182 ("Text.Whitespace", "\n"), | |
| 183 ], | |
| 184 pygments.lex("\\END-PROCEDURE", self.lexer)) | |
| 185 | |
| 186 def test_endproc_with_entityname(self): | |
| 187 self.assertTokenStreamEqualComplete( | |
| 188 [("Keyword", "END OF PROCEDURE"), | |
| 189 ("Text.Whitespace", " "), | |
| 190 ("Name.Entity", "the procedure name"), | |
| 191 ("Text.Whitespace", "\n"), | |
| 192 ], | |
| 193 pygments.lex("\\ENDPROCEDURE {the procedure name}", self.lexer)) | |
| 194 | |
| 94 | 195 def test_endproc_with_entityname_2(self): |
| 196 self.assertTokenStreamEqualComplete( | |
| 197 [("Keyword", "END OF PROCEDURE"), | |
| 198 ("Text.Whitespace", " "), | |
| 199 ("Name.Entity", "the procedure name"), | |
| 200 ("Text.Whitespace", "\n"), | |
| 201 ], | |
| 202 pygments.lex("\\END-PROC {the procedure name}", self.lexer)) | |
| 203 | |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
204 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
|
205 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
206 [("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
|
207 ("Text.Whitespace", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
208 ("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
|
209 ("Name.Entity", "}"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
210 ("Name.Entity", "<-"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
211 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
212 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
213 pygments.lex( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
214 "\\END-PROC" |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
215 " {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
|
216 self.lexer)) |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
217 |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
218 def test_proc_de(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
219 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
|
220 ALGLEXERFILENAME, "AlgPseudocodeLexer_DE") |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
221 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
222 [("Keyword", "PROZEDUR"), |
|
69
b3dd247b27a5
FIX: Add forgotten tests for the new normalized highlighting
Franz Glasner <fzglas.hg@dom66.de>
parents:
66
diff
changeset
|
223 ("Text.Whitespace", " "), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
224 ("Name.Entity", " also {nichtxs"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
225 ("Name.Entity", "}"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
226 ("Name.Entity", " hier"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
227 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
228 ], |
|
79
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
229 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
|
230 |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
231 def test_loop_de_not_yet_translated(self): |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
232 lexer = pygments.lexers.load_lexer_from_file( |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
233 ALGLEXERFILENAME, "AlgPseudocodeLexer_DE") |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
234 self.assertTokenStreamEqualComplete( |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
235 [("Keyword", "LOOP"), |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
236 ("Text", " "), |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
237 ("Name.Entity", "a"), |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
238 ("Text.Whitespace", "\n"), |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
239 ], |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
240 pygments.lex(r"\LOOP a", lexer)) |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
241 |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
242 def test_function_1(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
243 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
244 [("Keyword", "FUNCTION"), |
|
69
b3dd247b27a5
FIX: Add forgotten tests for the new normalized highlighting
Franz Glasner <fzglas.hg@dom66.de>
parents:
66
diff
changeset
|
245 ("Text.Whitespace", " "), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
246 ("Name.Entity", "1"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
247 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
248 ], |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
249 pygments.lex("\\FUNC{1}", self.lexer)) |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
250 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
251 def test_function_2(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
252 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
253 [("Keyword", "FUNCTION"), |
|
69
b3dd247b27a5
FIX: Add forgotten tests for the new normalized highlighting
Franz Glasner <fzglas.hg@dom66.de>
parents:
66
diff
changeset
|
254 ("Text.Whitespace", " "), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
255 ("Name.Entity", "line 1\nline 2\n"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
256 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
257 ], |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
258 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
|
259 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
260 def test_function_3(self): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
261 self.assertTokenStreamEqualComplete( |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
262 [("Keyword", "FUNCTION"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
263 ("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
|
264 ("Generic.Error", "\\"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
265 ("Name.Entity", "n"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
266 ("Name.Entity", "}"), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
267 ("Text.Whitespace", "\n"), |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
268 ], |
|
79
c14e5fd4d193
More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
269 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
|
270 |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
271 def test_class(self): |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
272 self.assertTokenStreamEqualComplete( |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
273 [("Keyword", "CLASS"), |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
274 ("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
|
275 ("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
|
276 ("Name.Entity", "n"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
277 ("Name.Entity", "\\"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
278 ("Name.Entity", "}"), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
279 ("Text.Whitespace", "\n"), |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
280 ], |
|
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
|
281 pygments.lex(r"\CLASS {\n\\\}}", self.lexer)) |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
282 |
|
41
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
283 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
|
284 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
|
285 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
|
286 self.assertTokenStreamEqualComplete( |
|
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
287 [("Keyword", "CLASSE"), |
|
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
288 ("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
|
289 ("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
|
290 ("Name.Entity", "n"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
291 ("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
|
292 ("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
|
293 ], |
|
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
294 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
|
295 |
| 57 | 296 def test_class_de_with_noend_option(self): |
| 297 lexer = pygments.lexers.load_lexer_from_file( | |
| 298 ALGLEXERFILENAME, "AlgPseudocodeLexer_DE", no_end="True") | |
| 299 self.assertTokenStreamEqualComplete( | |
| 300 [("Keyword", "KLASSE"), | |
| 301 ("Text.Whitespace", " "), | |
| 302 ("Name.Entity", "\\"), | |
| 303 ("Name.Entity", "n"), | |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
304 ("Name.Entity", "}"), |
| 57 | 305 ("Text.Whitespace", "\n"), |
| 306 ("Text.Whitespace", "\n"), | |
| 307 ], | |
|
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
|
308 pygments.lex("\\CLASS {\\\\n\\}}\n\\ENDCLASS", lexer)) |
| 57 | 309 |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
310 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
|
311 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
|
312 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
|
313 self.assertTokenStreamEqualComplete( |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
314 [("Keyword", "KLASSE"), |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
315 ("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
|
316 ("Generic.Error", "\\"), |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
317 ("Name.Entity", "n"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
318 ("Name.Entity", "}"), |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
319 ("Text.Whitespace", "\n"), |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
320 ("Text.Whitespace", "\n"), |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
321 ], |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
322 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
|
323 |
|
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
|
324 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
|
325 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
|
326 [("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
|
327 ("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
|
328 ("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
|
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 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
|
331 |
|
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
|
332 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
|
333 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
|
334 [("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
|
335 ("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
|
336 ("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
|
337 ("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
|
338 ("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
|
339 ("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
|
340 ], |
|
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 pygments.lex( |
|
64
05c53e431c88
Simplify case-handling for "BLOCK" and "REMARK"
Franz Glasner <fzglas.hg@dom66.de>
parents:
62
diff
changeset
|
342 """\\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
|
343 \\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
|
344 """, 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
|
345 |
|
117
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
346 def test_remark_custom(self): |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
347 # With the APL comment symbol |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
348 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
|
349 ALGLEXERFILENAME, ALGLEXERCLASS, remark=u"⍝") |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
350 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
|
351 [("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
|
352 ("Comment.Single", " another remark"), |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
353 ("Text.Whitespace", "\n"), |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
354 ], |
|
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
|
355 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
|
356 |
|
108
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
357 def test_remark_in_text(self): |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
358 self.assertTokenStreamEqualComplete( |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
359 [("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
|
360 ("Comment.Single", u"▷"), |
|
108
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
361 ("Comment.Single", " the remark"), |
|
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 ("Text", "the next text line"), |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
364 ("Text.Whitespace", "\n"), |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
365 ], |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
366 pygments.lex( |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
367 """\\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
|
368 self.lexer)) |
|
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
105
diff
changeset
|
369 |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
370 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
|
371 self.assertTokenStreamEqualComplete( |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
372 [("Text", "the text "), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
373 ("Text", "nested"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
374 ("Text", " trailer"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
375 ("Text.Whitespace", "\n"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
376 ], |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
377 pygments.lex( |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
378 """\\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
|
379 self.lexer)) |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
380 |
|
101
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
381 def test_comment_single_1(self): |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
382 self.assertTokenStreamEqualComplete( |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
383 [("Comment.Single", "// foo bar"), |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
384 ("Text.Whitespace", "\n"), |
|
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 pygments.lex(r"// foo bar", self.lexer)) |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
387 |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
388 def test_comment_single_2(self): |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
389 self.assertTokenStreamEqualComplete( |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
390 [("Comment.Single", "# foo bar"), |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
391 ("Text.Whitespace", "\n"), |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
392 ], |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
393 pygments.lex(r"# foo bar", self.lexer)) |
|
aae16e3624e2
Tests for single-line comments (// and #)
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
394 |
|
70
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
395 def test_expr_and_text(self): |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
396 self.assertTokenStreamEqualComplete( |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
397 [("Name.Entity", "a"), |
|
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 ("Text", "multiplied by"), |
|
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 ("Name.Entity", "b"), |
|
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 ("Text", "is"), |
|
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 ("Number.Integer", "0"), |
|
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 ("Text", "mod"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
408 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
409 ("Name.Entity", "p"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
410 ("Text.Whitespace", "\n"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
411 ], |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
412 pygments.lex( |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
413 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
|
414 self.lexer)) |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
415 |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
416 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
|
417 self.assertTokenStreamEqualComplete( |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
418 [("Name.Entity", "a"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
419 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
420 ("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
|
421 ("Text", "}"), |
|
70
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
422 ("Text", " "), |
|
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 ("Name.Entity", "b"), |
|
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", "is "), |
|
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 ("Text", " not"), |
|
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 ("Number.Integer", "0"), |
|
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 ("Text", "mod"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
433 ("Text", " "), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
434 ("Name.Entity", "p"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
435 ("Text.Whitespace", "\n"), |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
436 ], |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
437 pygments.lex( |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
438 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
|
439 r" \text{mod} p""", |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
440 self.lexer)) |
|
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
69
diff
changeset
|
441 |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
442 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
|
443 self.assertTokenStreamEqualComplete( |
|
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", ";"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
451 ("Punctuation", "["), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
452 ("Punctuation", "]"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
453 ("Punctuation", "?"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
454 ("Punctuation", "@"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
455 ("Text.Whitespace", "\n"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
456 ], |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
457 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
|
458 |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
459 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
|
460 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
|
461 [("Text", u"◆"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
462 ("Text.Whitespace", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
463 ("Text.Whitespace", "\n"), |
|
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 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
|
466 |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
467 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
|
468 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
|
469 [("Text", u"◆"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
470 ("Text.Whitespace", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
471 ("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
|
472 ("Text.Whitespace", "\n"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
473 ], |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
474 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
|
475 |
|
76
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
476 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
|
477 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
|
478 [("Text", u"◆"), |
|
76
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
479 ("Text.Whitespace", " "), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
480 ("Text", "\\"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
481 ("Name.Entity", "text"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
482 ("Punctuation", "{"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
483 ("Name.Entity", "a"), |
|
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", "b"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
486 ("Text", " "), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
487 ("Name.Entity", "c"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
488 ("Punctuation", "}"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
489 ("Text.Whitespace", "\n"), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
490 ], |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
491 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
|
492 |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
493 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
|
494 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
|
495 [("Text", u"◆"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
496 ("Text.Whitespace", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
497 ("Name.Entity", "a"), |
|
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 ("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
|
500 ("Text", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
501 ("Punctuation", "{"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
502 ("Name.Entity", "x"), |
|
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 ("Operator.Word", "in"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
505 ("Text", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
506 ("Name.Entity", "X"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
507 ("Punctuation", "}"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
508 ("Text", " "), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
509 ("Name.Entity", "c"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
510 ("Text.Whitespace", "\n"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
511 ], |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
512 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
|
513 |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
514 def test_tstate_empty(self): |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
515 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
|
516 [("Text", u"▪"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
517 ("Text.Whitespace", " "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
518 ("Text.Whitespace", "\n"), |
|
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 pygments.lex(r"\tstate{}", self.lexer)) |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
521 |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
522 def test_tstate_with_expr(self): |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
523 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
|
524 [("Text", u"▪"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
525 ("Text.Whitespace", " "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
526 ("Text", "a 1.2 "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
527 ("Name.Entity", "x"), |
|
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 ("Operator.Word", "in"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
530 ("Text", " "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
531 ("Name.Entity", "X"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
532 ("Punctuation", "}"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
533 ("Text", " c"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
534 ("Text.Whitespace", "\n"), |
|
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 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
|
537 |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
538 def test_tstate_with_escaped_expr(self): |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
539 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
|
540 [("Text", u"▪"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
541 ("Text.Whitespace", " "), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
542 ("Text", "a 1.2 "), |
|
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", "expr{x in X"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
545 ("Text", "}"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
546 ("Text", " c"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
547 ("Text.Whitespace", "\n"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
548 ], |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
549 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
|
550 |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
551 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
|
552 self.assertTokenStreamEqualComplete( |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
553 [("Name.Entity", "foo"), |
|
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 ("Name.Entity", "bar"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
556 ("Text", " "), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
557 ("Text", "bar +"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
558 ("Text.Whitespace", "\n"), |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
559 ], |
|
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
560 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
|
561 |
|
92
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
562 def test_text_in_expr(self): |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
563 self.assertTokenStreamEqualComplete( |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
564 [("Name.Entity", "first"), |
|
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", "expression"), |
|
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", "second"), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
569 ("Text", " "), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
570 ("Name.Entity", "expression"), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
571 ("Text.Whitespace", "\n"), |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
572 ], |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
573 pygments.lex( |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
574 r"\TEXT{\EXPRESSION{first expression} " |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
575 r"\EXPR{second expression}}", |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
576 self.lexer)) |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
577 |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
578 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
|
579 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
580 [("Operator", "%"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
581 ("Text.Whitespace", "\n"), |
|
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 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
|
584 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
585 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
|
586 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
587 [("Operator", "{"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
588 ("Text.Whitespace", "\n"), |
|
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 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
|
591 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
592 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
|
593 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
594 [("Operator", "<"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
595 ("Text.Whitespace", "\n"), |
|
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 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
|
598 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
599 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
|
600 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
601 [("Operator", "("), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
602 ("Text.Whitespace", "\n"), |
|
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 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
|
605 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
606 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
|
607 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
608 [("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
|
609 ("Text.Whitespace", "\n"), |
|
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 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
|
612 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
613 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
|
614 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
615 [("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
|
616 ("Text.Whitespace", "\n"), |
|
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 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
|
619 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
620 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
|
621 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
622 [("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
|
623 ("Text.Whitespace", "\n"), |
|
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 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
|
626 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
627 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
|
628 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
629 [("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
|
630 ("Text.Whitespace", "\n"), |
|
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 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
|
633 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
634 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
|
635 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
636 [("Operator", "}"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
637 ("Operator", "/"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
638 ("Text.Whitespace", "\n"), |
|
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 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
|
641 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
642 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
|
643 self.assertTokenStreamEqualComplete( |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
644 [("Operator", "\n"), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
645 ("Operator", "/"), |
|
95
aed3204723ac
FIX: Test results because of changed whitespace handling
Franz Glasner <fzglas.hg@dom66.de>
parents:
94
diff
changeset
|
646 ("Text", " "), |
|
aed3204723ac
FIX: Test results because of changed whitespace handling
Franz Glasner <fzglas.hg@dom66.de>
parents:
94
diff
changeset
|
647 ("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
|
648 ], |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
79
diff
changeset
|
649 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
|
650 |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
651 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
|
652 self.assertTokenStreamEqualComplete( |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
653 [("Operator", u"∈ ∌"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
654 ("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
|
655 ("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
|
656 ("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
|
657 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
658 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
659 pygments.lex( |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
660 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
|
661 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
662 |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
663 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
|
664 self.assertTokenStreamEqualComplete( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
665 [("Operator", "new_operator"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
666 ("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
|
667 ("Comment.Single", u"▷"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
668 ("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
|
669 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
670 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
671 pygments.lex( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
672 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
|
673 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
674 |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
675 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
|
676 self.assertTokenStreamEqualComplete( |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
677 [("Name.Function", u"∈_∌"), |
|
87
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 ("Name.Entity", "p1"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
680 ("Punctuation", ","), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
681 ("Text", " "), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
682 ("Name.Entity", "p2"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
683 ("Punctuation", ")"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
684 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
685 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
686 pygments.lex( |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
687 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
|
688 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
689 |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
690 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
|
691 self.assertTokenStreamEqualComplete( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
692 [("Name.Decorator", "a_Decorator"), |
|
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 ("Name.Entity", "p1"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
695 ("Punctuation", ","), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
696 ("Text", " "), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
697 ("Name.Entity", "p2"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
698 ("Punctuation", ")"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
699 ("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
|
700 ("Comment.Single", u"▷"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
701 ("Comment.Single", " (Python) decorator"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
702 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
703 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
704 pygments.lex( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
705 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
|
706 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
707 |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
708 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
|
709 self.assertTokenStreamEqualComplete( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
710 [("Name.Decorator", "a_Decorator"), |
|
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 ("Name.Entity", "p1"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
713 ("Punctuation", ","), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
714 ("Text", " "), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
715 ("Name.Entity", "p2"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
716 ("Punctuation", ")"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
717 ("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
|
718 ("Comment.Single", u"▷"), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
719 ("Comment.Single", " (Python) annotation"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
720 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
721 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
722 pygments.lex( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
723 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
|
724 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
725 |
|
275
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
726 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
|
727 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
|
728 self.assertTokenStreamEqualComplete( |
|
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
729 [("Name.Decorator", "word"), |
|
276
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
730 ("Text", sep), |
|
275
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
731 ("Text.Whitespace", "\n"), |
|
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
732 ], |
|
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
733 pygments.lex( |
|
276
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
734 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
|
735 self.lexer)) |
|
f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
Franz Glasner <fzglas.hg@dom66.de>
parents:
212
diff
changeset
|
736 |
|
276
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
737 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
|
738 self.assertTokenStreamEqualComplete( |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
739 [("Name.Decorator", "word"), |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
740 ("Text", "\\"), |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
741 ("Text", " "), |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
742 ("Text.Whitespace", "\n"), |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
743 ], |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
744 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
|
745 |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
746 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
|
747 self.assertTokenStreamEqualComplete( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
748 [("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
|
749 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
750 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
751 pygments.lex( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
752 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
|
753 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
754 |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
755 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
|
756 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
757 [("Text.Whitespace", "\n")], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
758 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
759 r"""\ttX{nd}{}""", self.lexer)) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
760 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
761 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
|
762 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
763 [("Name.Decorator", "simple\nline 2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
764 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
765 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
766 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
767 """\\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
|
768 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
769 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
|
770 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
771 [("Name.Decorator", "simple"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
772 ("Name.Decorator", "}"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
773 ("Name.Decorator", "part 2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
774 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
775 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
776 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
777 """\\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
|
778 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
779 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
|
780 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
781 [("Name.Decorator", "simple"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
782 ("Name.Decorator", "\\"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
783 ("Name.Decorator", "part 2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
784 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
785 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
786 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
787 """\\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
|
788 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
789 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
|
790 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
791 [("Name.Variable", "simple"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
792 ("Generic.Error", "\\"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
793 ("Name.Variable", "part 2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
794 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
795 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
796 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
797 """\\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
|
798 |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
799 def test_extended_explicit_tokentype_non_existing_type_strict(self): |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
800 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
801 [("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
|
802 ("Generic.Error", u"∈_∌"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
803 ("Generic.Error", u"}"), |
|
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 ("Name.Entity", "p1"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
806 ("Punctuation", ","), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
807 ("Text", " "), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
808 ("Name.Entity", "p2"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
809 ("Punctuation", ")"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
810 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
811 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
812 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
813 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
|
814 |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
815 def test_extended_explicit_tokentype_non_existing_type_lenient(self): |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
816 lexer = pygments.lexers.load_lexer_from_file( |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
817 ALGLEXERFILENAME, ALGLEXERCLASS, strict_tokentype=False) |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
818 self.assertTokenStreamEqualComplete( |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
819 [(getattr(getattr(getattr(Token, "DOES"), "IT"), "NOT-EXIST"), |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
820 u"∈_∌"), |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
821 ("Punctuation", "("), |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
822 ("Name.Entity", "p1"), |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
823 ("Punctuation", ","), |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
824 ("Text", " "), |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
825 ("Name.Entity", "p2"), |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
826 ("Punctuation", ")"), |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
827 ("Text.Whitespace", "\n"), |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
828 ], |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
829 pygments.lex( |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
830 u"\\ttX{DOES.IT.NOT-EXIST}{∈_∌}(p1, p2)", lexer)) |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
831 |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
832 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
|
833 self.assertTokenStreamEqualComplete( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
834 [("Punctuation", "{"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
835 ("Name.Entity", "foo"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
836 ("Text", " "), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
837 ("Name.Entity", "bar"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
838 ("Punctuation", "}"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
839 ("Text.Whitespace", "\n"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
840 ], |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
841 pygments.lex( |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
842 r"{foo bar}", self.lexer)) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
843 |
| 97 | 844 def test_end_combinations(self): |
| 845 self.assertTokenStreamEqualComplete( | |
| 846 [("Keyword", "BEGIN"), | |
| 847 ("Text", " "), | |
| 848 ("Keyword", "END"), | |
| 849 ("Text", " "), | |
| 850 ("Keyword", "END OF FUNCTION"), | |
| 851 ("Text", " "), | |
| 852 ("Keyword", "END OF FUNCTION"), | |
| 853 ("Text.Whitespace", " "), | |
| 854 ("Name.Entity", "An End of a Function"), | |
| 855 ("Text", " "), | |
| 856 ("Keyword", "END OF FUNCTION"), | |
| 857 ("Text.Whitespace", " "), | |
| 858 ("Name.Entity", "The End of the Next Function"), | |
| 859 ("Text", " "), | |
| 860 ("Text.Whitespace", "\n"), | |
| 861 ], | |
| 862 pygments.lex( | |
| 863 r"""\begin \end \end-fn \end-fn {An End of a Function}""" | |
| 864 r""" \end fn {The End of the Next Function} """, | |
| 865 self.lexer)) | |
| 866 | |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
867 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
|
868 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
869 [("Operator", u"∈"), |
|
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(u"∈", 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(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", "="), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
877 ("Operator", "!"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
878 ("Operator", "&"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
879 ("Operator", "<"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
880 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
881 ("Operator", ">"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
882 ("Operator", "+"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
883 ("Operator", "-"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
884 ("Operator", "*"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
885 ("Operator", "/"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
886 ("Operator", "%"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
887 ("Operator", "|"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
888 ("Operator", "~"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
889 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
890 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
891 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
|
892 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
893 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
|
894 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
895 [("Operator", u"⇔"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
896 ("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
|
897 ("Operator", u"⟷"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
898 ("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
|
899 ("Operator", u"⟵"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
900 ("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
|
901 ("Operator", u"⟶"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
902 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
903 ("Operator", u"⇒"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
904 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
905 ("Operator", u"≤"), |
|
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", u"≥"), |
|
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", u"≠"), |
|
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", u"≠"), |
|
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", u"∶="), # u"≔"), |
|
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", u"=∶"), # u"≕"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
916 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
917 ("Operator", u"≟"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
918 ("Text.Whitespace", "\n"), |
|
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 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
|
921 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
922 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
|
923 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
924 [("Operator.Word", "IN"), |
|
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 ("Operator.Word", "is"), |
|
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 ("Operator.Word", "And"), |
|
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 ("Operator.Word", "Or"), |
|
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 ("Operator.Word", "XOR"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
933 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
934 ("Operator.Word", "not"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
935 ("Text.Whitespace", "\n"), |
|
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 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
|
938 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
939 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
|
940 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
941 [("Keyword.Constant", "true"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
942 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
943 ("Keyword.Constant", "FALSE"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
944 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
945 ("Keyword.Constant", "None"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
946 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
947 ("Keyword.Constant", "nil"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
948 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
949 ("Keyword.Constant", "NULL"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
950 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
951 ("Keyword.Constant", "Empty"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
952 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
953 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
954 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
|
955 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
956 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
|
957 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
958 [("Name.Builtin", "sqrt"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
959 ("Punctuation", "("), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
960 ("Name.Entity", "Foo"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
961 ("Punctuation", ")"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
962 ("Punctuation", ";"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
963 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
964 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
965 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
|
966 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
967 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
|
968 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
969 [("Name.Builtin", "pow"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
970 ("Punctuation", "("), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
971 ("Number.Integer", "2"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
972 ("Punctuation", ","), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
973 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
974 ("Number.Integer", "8"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
975 ("Punctuation", ")"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
976 ("Punctuation", ";"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
977 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
978 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
979 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
|
980 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
981 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
|
982 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
983 [("Name.Entity", "a"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
984 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
985 ("Operator.Word", "in"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
986 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
987 ("Name.Entity", u"ℂ"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
988 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
989 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
990 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
|
991 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
992 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
|
993 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
994 [("Name.Entity", "b"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
995 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
996 ("Operator.Word", "in"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
997 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
998 ("Text", u"℀"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
999 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1000 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1001 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
|
1002 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1003 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
|
1004 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1005 [("Text", "flow "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1006 ("Name.Entity", "f"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1007 ("Punctuation", "'"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1008 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1009 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1010 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
|
1011 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1012 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
|
1013 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1014 [("Text", "flow "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1015 ("Name.Entity", "f"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1016 ("Punctuation", '"'), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1017 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1018 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
1019 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
|
1020 |
| 113 | 1021 def test_gets_default(self): |
| 1022 self.assertTokenStreamEqualComplete( | |
| 1023 [("Name.Entity", "a"), | |
| 1024 ("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
|
1025 ("Operator", u"⟵"), # U+27F5 (Supplemental Arrows-A) |
| 113 | 1026 ("Text", " "), |
| 1027 ("Number.Integer", "2"), | |
| 1028 ("Text.Whitespace", "\n"), | |
| 1029 ], | |
| 1030 pygments.lex(r"a \gets 2", self.lexer)) | |
| 1031 | |
| 1032 def test_gets_custom(self): | |
| 1033 lexer = pygments.lexers.load_lexer_from_file( | |
| 1034 ALGLEXERFILENAME, ALGLEXERCLASS, gets="::=") | |
| 1035 self.assertTokenStreamEqualComplete( | |
| 1036 [("Name.Entity", "a"), | |
| 1037 ("Text", " "), | |
| 1038 ("Operator", "::="), | |
| 1039 ("Text", " "), | |
| 1040 ("Number.Float", "2.7"), | |
| 1041 ("Text.Whitespace", "\n"), | |
| 1042 ], | |
| 1043 pygments.lex(r"a \gets 2.7", lexer)) | |
| 1044 | |
| 114 | 1045 def test_call(self): |
| 1046 self.assertTokenStreamEqualComplete( | |
| 1047 [("Name.Entity", "a function"), | |
| 1048 ("Punctuation", "("), | |
| 1049 ("Name.Entity", "p1"), | |
| 1050 ("Punctuation", ","), | |
| 1051 ("Text", " "), | |
| 1052 ("Name.Entity", "p2"), | |
| 1053 ("Punctuation", ")"), | |
| 1054 ("Text.Whitespace", "\n"), | |
| 1055 ], | |
| 1056 pygments.lex(r"\CALL{a function}(p1, p2)", self.lexer)) | |
| 1057 | |
| 1058 def test_call_in_expr(self): | |
| 1059 self.assertTokenStreamEqualComplete( | |
| 1060 [("Name.Entity", "a procedure"), | |
| 1061 ("Punctuation", "("), | |
| 1062 ("Name.Entity", "arg1"), | |
| 1063 ("Punctuation", ","), | |
| 1064 ("Text", " "), | |
| 1065 ("Name.Entity", "arg2"), | |
| 1066 ("Punctuation", ","), | |
| 1067 ("Text", " "), | |
| 1068 ("Name.Entity", "arg3"), | |
| 1069 ("Punctuation", ")"), | |
| 1070 ("Text.Whitespace", "\n"), | |
| 1071 ], | |
| 1072 pygments.lex(r"\TEXT{\EXPR{\CALL{a procedure}(arg1, arg2, arg3)}}", | |
| 1073 self.lexer)) | |
| 1074 | |
|
149
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1075 def test_name(self): |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1076 self.assertTokenStreamEqualComplete( |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1077 [("Name.Entity", "an entity"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1078 ("Punctuation", "("), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1079 ("Name.Entity", "p1"), |
|
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", " "), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1082 ("Name.Entity", "p2"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1083 ("Punctuation", ")"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1084 ("Text.Whitespace", "\n"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1085 ], |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1086 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
|
1087 |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1088 def test_name_in_expr(self): |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1089 self.assertTokenStreamEqualComplete( |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1090 [("Name.Entity", "an entity"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1091 ("Punctuation", "("), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1092 ("Name.Entity", "arg1"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1093 ("Punctuation", ","), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1094 ("Text", " "), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1095 ("Name.Entity", "arg2"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1096 ("Punctuation", ","), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1097 ("Text", " "), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1098 ("Name.Entity", "arg3"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1099 ("Punctuation", ")"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1100 ("Text.Whitespace", "\n"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1101 ], |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1102 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
|
1103 self.lexer)) |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
1104 |
|
115
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1105 def test_comment_multi(self): |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1106 self.assertTokenStreamEqualComplete( |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1107 [("Comment.Multiline", "/*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1108 ("Comment.Multiline", " word1 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1109 ("Comment.Multiline", "*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1110 ("Comment.Multiline", " word2 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1111 ("Comment.Multiline", "/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1112 ("Comment.Multiline", " word3 "), |
|
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", "/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1115 ("Comment.Multiline", " word4 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1116 ("Comment.Multiline", "*/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1117 ("Text.Whitespace", "\n"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1118 ], |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1119 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
|
1120 |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1121 def test_comment_multi_alt(self): |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1122 self.assertTokenStreamEqualComplete( |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1123 [("Comment.Multiline", "(*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1124 ("Comment.Multiline", " word1 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1125 ("Comment.Multiline", "*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1126 ("Comment.Multiline", " word2 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1127 ("Comment.Multiline", "("), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1128 ("Comment.Multiline", " word3 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1129 ("Comment.Multiline", ")"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1130 ("Comment.Multiline", " word4 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1131 ("Comment.Multiline", "("), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1132 ("Comment.Multiline", ")"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1133 ("Comment.Multiline", " word5 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1134 ("Comment.Multiline", "*)"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1135 ("Text.Whitespace", "\n"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1136 ], |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1137 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
|
1138 self.lexer)) |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1139 |
|
159
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1140 def test_dots_one(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1141 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1142 [("Punctuation", "."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1143 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1144 ], |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1145 pygments.lex(r".", self.lexer)) |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1146 |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1147 def test_dots_two(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1148 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1149 [("Punctuation", ".."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1150 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1151 ], |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1152 pygments.lex(r"..", self.lexer)) |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1153 |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1154 def test_dots_three(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1155 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1156 [("Punctuation", "..."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1157 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1158 ], |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1159 pygments.lex(r"...", self.lexer)) |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1160 |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1161 def test_dots_four(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1162 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1163 [("Punctuation", "...."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1164 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1165 ], |
|
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
|
1166 pygments.lex(r"....", self.lexer)) |
|
159
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1167 |
|
212
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1168 def test_nested_expr(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1169 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1170 [("Name.Entity", "foo"), |
|
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 ("Operator", "+"), |
|
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 ("Name.Entity", "bar"), |
|
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 ("Operator", "*"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1177 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1178 ("Number.Integer", '7'), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1179 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1180 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1181 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
|
1182 |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1183 def test_nested_expr_in_block(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1184 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1185 [("Text", u"◆"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1186 ("Text.Whitespace", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1187 ("Name.Entity", "foo"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1188 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1189 ("Operator", "+"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1190 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1191 ("Name.Entity", "bar"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1192 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1193 ("Operator", "*"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1194 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1195 ("Number.Integer", '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"\\BLOCK{\\EXPR{\\EXPR{foo + bar} * 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 |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1201 def test_nested_text(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1202 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1203 [("Text", "foo + bar"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1204 ("Text", " * 7"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1205 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1206 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1207 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
|
1208 |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1209 def test_nested_text_in_tblock(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1210 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1211 [("Text", u"▪"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1212 ("Text.Whitespace", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1213 ("Text", "bar + Foo"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1214 ("Text", " * 7"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1215 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1216 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1217 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
|
1218 self.lexer)) |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1219 |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1220 |
|
66
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1221 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
|
1222 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1223 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
|
1224 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
|
1225 ALGLEXERFILENAME, ALGLEXERCLASS) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1226 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1227 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
|
1228 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
|
1229 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
|
1230 '"""FOO"""', |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1231 self.lexer, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1232 html_formatter, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1233 outfile=None) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1234 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
|
1235 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1236 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
|
1237 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
|
1238 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
|
1239 '"""FOO"""', |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1240 self.lexer, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1241 latex_formatter, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1242 outfile=None) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1243 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
|
1244 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1245 |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1246 if __name__ == "__main__": |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1247 unittest.main() |
