Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
annotate tests/test_algpseudo.py @ 251:733f1661fcb4
Implement TeX commands to allow to suppress the output of section numbers for some levels.
Prepare for suppressing section numbering for changlog entries.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 17 May 2026 11:38:47 +0200 |
| parents | 18553f595b34 |
| children | f365d9d2c0ad |
| 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 |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
702 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
|
703 self.assertTokenStreamEqualComplete( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
704 [("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
|
705 ("Text.Whitespace", "\n"), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
706 ], |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
707 pygments.lex( |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
708 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
|
709 self.lexer)) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
710 |
| 97 | 711 def test_end_combinations(self): |
| 712 self.assertTokenStreamEqualComplete( | |
| 713 [("Keyword", "BEGIN"), | |
| 714 ("Text", " "), | |
| 715 ("Keyword", "END"), | |
| 716 ("Text", " "), | |
| 717 ("Keyword", "END OF FUNCTION"), | |
| 718 ("Text", " "), | |
| 719 ("Keyword", "END OF FUNCTION"), | |
| 720 ("Text.Whitespace", " "), | |
| 721 ("Name.Entity", "An End of a Function"), | |
| 722 ("Text", " "), | |
| 723 ("Keyword", "END OF FUNCTION"), | |
| 724 ("Text.Whitespace", " "), | |
| 725 ("Name.Entity", "The End of the Next Function"), | |
| 726 ("Text", " "), | |
| 727 ("Text.Whitespace", "\n"), | |
| 728 ], | |
| 729 pygments.lex( | |
| 730 r"""\begin \end \end-fn \end-fn {An End of a Function}""" | |
| 731 r""" \end fn {The End of the Next Function} """, | |
| 732 self.lexer)) | |
| 733 | |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
734 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
|
735 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
736 [("Operator", u"∈"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
737 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
738 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
739 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
|
740 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
741 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
|
742 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
743 [("Operator", "="), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
744 ("Operator", "!"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
745 ("Operator", "&"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
746 ("Operator", "<"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
747 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
748 ("Operator", ">"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
749 ("Operator", "+"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
750 ("Operator", "-"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
751 ("Operator", "*"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
752 ("Operator", "/"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
753 ("Operator", "%"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
754 ("Operator", "|"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
755 ("Operator", "~"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
756 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
757 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
758 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
|
759 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
760 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
|
761 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
762 [("Operator", u"⇔"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
763 ("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
|
764 ("Operator", u"⟷"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
765 ("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
|
766 ("Operator", u"⟵"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
767 ("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
|
768 ("Operator", u"⟶"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
769 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
770 ("Operator", u"⇒"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
771 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
772 ("Operator", u"≤"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
773 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
774 ("Operator", u"≥"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
775 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
776 ("Operator", u"≠"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
777 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
778 ("Operator", u"≠"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
779 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
780 ("Operator", u"∶="), # u"≔"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
781 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
782 ("Operator", u"=∶"), # u"≕"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
783 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
784 ("Operator", u"≟"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
785 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
786 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
787 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
|
788 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
789 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
|
790 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
791 [("Operator.Word", "IN"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
792 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
793 ("Operator.Word", "is"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
794 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
795 ("Operator.Word", "And"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
796 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
797 ("Operator.Word", "Or"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
798 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
799 ("Operator.Word", "XOR"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
800 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
801 ("Operator.Word", "not"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
802 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
803 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
804 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
|
805 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
806 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
|
807 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
808 [("Keyword.Constant", "true"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
809 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
810 ("Keyword.Constant", "FALSE"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
811 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
812 ("Keyword.Constant", "None"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
813 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
814 ("Keyword.Constant", "nil"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
815 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
816 ("Keyword.Constant", "NULL"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
817 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
818 ("Keyword.Constant", "Empty"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
819 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
820 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
821 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
|
822 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
823 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
|
824 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
825 [("Name.Builtin", "sqrt"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
826 ("Punctuation", "("), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
827 ("Name.Entity", "Foo"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
828 ("Punctuation", ")"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
829 ("Punctuation", ";"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
830 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
831 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
832 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
|
833 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
834 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
|
835 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
836 [("Name.Builtin", "pow"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
837 ("Punctuation", "("), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
838 ("Number.Integer", "2"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
839 ("Punctuation", ","), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
840 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
841 ("Number.Integer", "8"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
842 ("Punctuation", ")"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
843 ("Punctuation", ";"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
844 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
845 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
846 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
|
847 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
848 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
|
849 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
850 [("Name.Entity", "a"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
851 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
852 ("Operator.Word", "in"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
853 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
854 ("Name.Entity", u"ℂ"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
855 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
856 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
857 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
|
858 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
859 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
|
860 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
861 [("Name.Entity", "b"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
862 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
863 ("Operator.Word", "in"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
864 ("Text", " "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
865 ("Text", u"℀"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
866 ("Text.Whitespace", "\n"), |
|
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 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
|
869 |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
870 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
|
871 self.assertTokenStreamEqualComplete( |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
872 [("Text", "flow "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
873 ("Name.Entity", "f"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
874 ("Punctuation", "'"), |
|
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(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
|
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_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
|
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 [("Text", "flow "), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
882 ("Name.Entity", "f"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
883 ("Punctuation", '"'), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
884 ("Text.Whitespace", "\n"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
885 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
101
diff
changeset
|
886 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
|
887 |
| 113 | 888 def test_gets_default(self): |
| 889 self.assertTokenStreamEqualComplete( | |
| 890 [("Name.Entity", "a"), | |
| 891 ("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
|
892 ("Operator", u"⟵"), # U+27F5 (Supplemental Arrows-A) |
| 113 | 893 ("Text", " "), |
| 894 ("Number.Integer", "2"), | |
| 895 ("Text.Whitespace", "\n"), | |
| 896 ], | |
| 897 pygments.lex(r"a \gets 2", self.lexer)) | |
| 898 | |
| 899 def test_gets_custom(self): | |
| 900 lexer = pygments.lexers.load_lexer_from_file( | |
| 901 ALGLEXERFILENAME, ALGLEXERCLASS, gets="::=") | |
| 902 self.assertTokenStreamEqualComplete( | |
| 903 [("Name.Entity", "a"), | |
| 904 ("Text", " "), | |
| 905 ("Operator", "::="), | |
| 906 ("Text", " "), | |
| 907 ("Number.Float", "2.7"), | |
| 908 ("Text.Whitespace", "\n"), | |
| 909 ], | |
| 910 pygments.lex(r"a \gets 2.7", lexer)) | |
| 911 | |
| 114 | 912 def test_call(self): |
| 913 self.assertTokenStreamEqualComplete( | |
| 914 [("Name.Entity", "a function"), | |
| 915 ("Punctuation", "("), | |
| 916 ("Name.Entity", "p1"), | |
| 917 ("Punctuation", ","), | |
| 918 ("Text", " "), | |
| 919 ("Name.Entity", "p2"), | |
| 920 ("Punctuation", ")"), | |
| 921 ("Text.Whitespace", "\n"), | |
| 922 ], | |
| 923 pygments.lex(r"\CALL{a function}(p1, p2)", self.lexer)) | |
| 924 | |
| 925 def test_call_in_expr(self): | |
| 926 self.assertTokenStreamEqualComplete( | |
| 927 [("Name.Entity", "a procedure"), | |
| 928 ("Punctuation", "("), | |
| 929 ("Name.Entity", "arg1"), | |
| 930 ("Punctuation", ","), | |
| 931 ("Text", " "), | |
| 932 ("Name.Entity", "arg2"), | |
| 933 ("Punctuation", ","), | |
| 934 ("Text", " "), | |
| 935 ("Name.Entity", "arg3"), | |
| 936 ("Punctuation", ")"), | |
| 937 ("Text.Whitespace", "\n"), | |
| 938 ], | |
| 939 pygments.lex(r"\TEXT{\EXPR{\CALL{a procedure}(arg1, arg2, arg3)}}", | |
| 940 self.lexer)) | |
| 941 | |
|
149
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
942 def test_name(self): |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
943 self.assertTokenStreamEqualComplete( |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
944 [("Name.Entity", "an entity"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
945 ("Punctuation", "("), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
946 ("Name.Entity", "p1"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
947 ("Punctuation", ","), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
948 ("Text", " "), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
949 ("Name.Entity", "p2"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
950 ("Punctuation", ")"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
951 ("Text.Whitespace", "\n"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
952 ], |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
953 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
|
954 |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
955 def test_name_in_expr(self): |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
956 self.assertTokenStreamEqualComplete( |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
957 [("Name.Entity", "an entity"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
958 ("Punctuation", "("), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
959 ("Name.Entity", "arg1"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
960 ("Punctuation", ","), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
961 ("Text", " "), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
962 ("Name.Entity", "arg2"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
963 ("Punctuation", ","), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
964 ("Text", " "), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
965 ("Name.Entity", "arg3"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
966 ("Punctuation", ")"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
967 ("Text.Whitespace", "\n"), |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
968 ], |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
969 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
|
970 self.lexer)) |
|
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
971 |
|
115
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
972 def test_comment_multi(self): |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
973 self.assertTokenStreamEqualComplete( |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
974 [("Comment.Multiline", "/*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
975 ("Comment.Multiline", " word1 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
976 ("Comment.Multiline", "*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
977 ("Comment.Multiline", " word2 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
978 ("Comment.Multiline", "/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
979 ("Comment.Multiline", " word3 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
980 ("Comment.Multiline", "/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
981 ("Comment.Multiline", "/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
982 ("Comment.Multiline", " word4 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
983 ("Comment.Multiline", "*/"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
984 ("Text.Whitespace", "\n"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
985 ], |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
986 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
|
987 |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
988 def test_comment_multi_alt(self): |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
989 self.assertTokenStreamEqualComplete( |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
990 [("Comment.Multiline", "(*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
991 ("Comment.Multiline", " word1 "), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
992 ("Comment.Multiline", "*"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
993 ("Comment.Multiline", " word2 "), |
|
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", " word3 "), |
|
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", " word4 "), |
|
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", ")"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1000 ("Comment.Multiline", " word5 "), |
|
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 ("Text.Whitespace", "\n"), |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1003 ], |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1004 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
|
1005 self.lexer)) |
|
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
1006 |
|
159
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1007 def test_dots_one(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1008 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1009 [("Punctuation", "."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1010 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1011 ], |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1012 pygments.lex(r".", self.lexer)) |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1013 |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1014 def test_dots_two(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1015 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1016 [("Punctuation", ".."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1017 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1018 ], |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1019 pygments.lex(r"..", self.lexer)) |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1020 |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1021 def test_dots_three(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1022 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1023 [("Punctuation", "..."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1024 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1025 ], |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1026 pygments.lex(r"...", self.lexer)) |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1027 |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1028 def test_dots_four(self): |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1029 self.assertTokenStreamEqualComplete( |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1030 [("Punctuation", "...."), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1031 ("Text.Whitespace", "\n"), |
|
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1032 ], |
|
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
|
1033 pygments.lex(r"....", self.lexer)) |
|
159
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
1034 |
|
212
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1035 def test_nested_expr(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1036 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1037 [("Name.Entity", "foo"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1038 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1039 ("Operator", "+"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1040 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1041 ("Name.Entity", "bar"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1042 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1043 ("Operator", "*"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1044 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1045 ("Number.Integer", '7'), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1046 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1047 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1048 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
|
1049 |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1050 def test_nested_expr_in_block(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1051 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1052 [("Text", u"◆"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1053 ("Text.Whitespace", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1054 ("Name.Entity", "foo"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1055 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1056 ("Operator", "+"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1057 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1058 ("Name.Entity", "bar"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1059 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1060 ("Operator", "*"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1061 ("Text", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1062 ("Number.Integer", '7'), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1063 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1064 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1065 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
|
1066 self.lexer)) |
|
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 def test_nested_text(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1069 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1070 [("Text", "foo + bar"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1071 ("Text", " * 7"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1072 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1073 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1074 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
|
1075 |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1076 def test_nested_text_in_tblock(self): |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1077 self.assertTokenStreamEqualComplete( |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1078 [("Text", u"▪"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1079 ("Text.Whitespace", " "), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1080 ("Text", "bar + Foo"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1081 ("Text", " * 7"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1082 ("Text.Whitespace", "\n"), |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1083 ], |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1084 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
|
1085 self.lexer)) |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
1086 |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1087 |
|
66
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1088 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
|
1089 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1090 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
|
1091 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
|
1092 ALGLEXERFILENAME, ALGLEXERCLASS) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1093 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1094 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
|
1095 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
|
1096 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
|
1097 '"""FOO"""', |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1098 self.lexer, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1099 html_formatter, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1100 outfile=None) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1101 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
|
1102 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1103 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
|
1104 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
|
1105 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
|
1106 '"""FOO"""', |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1107 self.lexer, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1108 latex_formatter, |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1109 outfile=None) |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1110 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
|
1111 |
|
9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
1112 |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1113 if __name__ == "__main__": |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1114 unittest.main() |
