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