annotate tests/test_algpseudo.py @ 97:dd4eb937485c

A couple of new keywords
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 03 May 2026 15:18:35 +0200
parents aed3204723ac
children aae16e3624e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
87
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
9 import sys
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 import unittest
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 import pygments
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13 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
14 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
15
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
16 import _testhelper
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
17
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
19 class TestSnippets(unittest.TestCase, _testhelper.TokenAssertHelper):
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
20
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
21 def setUp(self):
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
22 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
23 ALGLEXERFILENAME, ALGLEXERCLASS)
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
24
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
25 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
26 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
27 [("Text.Whitespace", "\n")],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
28 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
29
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
30 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
31 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
32 [("Text", "\\\n")],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
33 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
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
35 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
36 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
37 [("Number.Integer", "10"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
38 ("Text.Whitespace", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
39 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
40 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
41
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
42 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
43 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
44 [("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
45 ("Text.Whitespace", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
46 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
47 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
48
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
49 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
50 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
51 [("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
52 ("Text.Whitespace", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
53 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
54 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
55
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
56 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
57 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
58 [("String.Single", "'"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
59 ("String.Single", "HU"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
60 ("String.Single", '"'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
61 ("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
62 ("String.Escape", "\\'"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
63 ("String.Single", "HO"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
64 ("String.Single", "'"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
65 ("Text.Whitespace", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
66 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
67 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
68
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
69 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
70 self.assertTokenStreamEqual(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
71 [("String.Single", "'"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
72 ("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
73 ("Error", "\n"),
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
74 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
75 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
76
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
77 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
78 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
79 [("String.Single", "'''"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
80 ("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
81 ("String.Single", "'''"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
82 ("Text.Whitespace", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
83 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
84 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
85
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
86 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
87 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
88 [("String.Single", "'''"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
89 ("String.Single", "HI"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
90 ("String.Single", "'"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
91 ("String.Single", "HU"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
92 ("String.Single", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
93 ("String.Single", "HE"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
94 ("String.Single", '"'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
95 ("String.Single", "HA"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
96 ("String.Single", "'''"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
97 ("Text.Whitespace", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
98 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
99 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
100
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
101 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
102 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
103 [("String.Double", '"'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
104 ("String.Double", 'HU'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
105 ("String.Double", "'"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
106 ("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
107 ("String.Escape", '\\"'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
108 ("String.Double", 'HO'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
109 ("String.Double", '"'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
110 ("Text.Whitespace", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
111 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
112 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
113
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
114 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
115 self.assertTokenStreamEqual(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
116 [("String.Double", '"'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
117 ("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
118 ("Error", "\n"),
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
119 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
120 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
121
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
122 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
123 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
124 [("String.Double", '"""'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
125 ("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
126 ("String.Double", '"""'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
127 ("Text.Whitespace", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
128 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
129 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
130
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
131 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
132 self.assertTokenStreamEqualComplete(
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
133 [("String.Double", '"""'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
134 ("String.Double", 'HU'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
135 ("String.Double", '"'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
136 ("String.Double", "HO"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
137 ("String.Double", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
138 ("String.Double", "HE"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
139 ("String.Double", "'"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
140 ("String.Double", "HA"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
141 ("String.Double", '"""'),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
142 ("Text.Whitespace", "\n"),
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
143 ],
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
144 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
145
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
146 def test_proc(self):
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
147 self.assertTokenStreamEqualComplete(
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
148 [("Keyword", "PROCEDURE"),
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
149 ("Text.Whitespace", " "),
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
150 ("Name.Entity", "the name"),
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
151 ("Text.Whitespace", "\n"),
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
152 ],
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
153 pygments.lex("\\PROC {the name}", self.lexer))
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
154
79
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
155 def test_proc_with_escape_in_name(self):
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
156 self.assertTokenStreamEqualComplete(
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
157 [("Keyword", "PROCEDURE"),
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
158 ("Text.Whitespace", " "),
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
159 ("Name.Entity", "t"),
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
160 ("Name.Entity", "\\"),
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
161 ("Name.Entity", "he "),
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
162 ("Name.Entity", "\\"),
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
163 ("Name.Entity", "}"),
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
164 ("Name.Entity", "name"),
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
165 ("Text.Whitespace", "\n"),
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
166 ],
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
167 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
168
57
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
169 def test_endproc(self):
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
170 self.assertTokenStreamEqualComplete(
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
171 [("Keyword", "END OF PROCEDURE"),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
172 ("Text.Whitespace", "\n"),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
173 ],
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
174 pygments.lex("\\END-PROCEDURE", self.lexer))
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
175
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
176 def test_endproc_with_entityname(self):
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
177 self.assertTokenStreamEqualComplete(
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
178 [("Keyword", "END OF PROCEDURE"),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
179 ("Text.Whitespace", " "),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
180 ("Name.Entity", "the procedure name"),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
181 ("Text.Whitespace", "\n"),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
182 ],
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
183 pygments.lex("\\ENDPROCEDURE {the procedure name}", self.lexer))
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
184
94
dc17b778a52b Refactor \END variants
Franz Glasner <fzglas.hg@dom66.de>
parents: 92
diff changeset
185 def test_endproc_with_entityname_2(self):
dc17b778a52b Refactor \END variants
Franz Glasner <fzglas.hg@dom66.de>
parents: 92
diff changeset
186 self.assertTokenStreamEqualComplete(
dc17b778a52b Refactor \END variants
Franz Glasner <fzglas.hg@dom66.de>
parents: 92
diff changeset
187 [("Keyword", "END OF PROCEDURE"),
dc17b778a52b Refactor \END variants
Franz Glasner <fzglas.hg@dom66.de>
parents: 92
diff changeset
188 ("Text.Whitespace", " "),
dc17b778a52b Refactor \END variants
Franz Glasner <fzglas.hg@dom66.de>
parents: 92
diff changeset
189 ("Name.Entity", "the procedure name"),
dc17b778a52b Refactor \END variants
Franz Glasner <fzglas.hg@dom66.de>
parents: 92
diff changeset
190 ("Text.Whitespace", "\n"),
dc17b778a52b Refactor \END variants
Franz Glasner <fzglas.hg@dom66.de>
parents: 92
diff changeset
191 ],
dc17b778a52b Refactor \END variants
Franz Glasner <fzglas.hg@dom66.de>
parents: 92
diff changeset
192 pygments.lex("\\END-PROC {the procedure name}", self.lexer))
dc17b778a52b Refactor \END variants
Franz Glasner <fzglas.hg@dom66.de>
parents: 92
diff changeset
193
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
194 def test_proc_de(self):
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
195 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
196 ALGLEXERFILENAME, "AlgPseudocodeLexer_DE")
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
197 self.assertTokenStreamEqualComplete(
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
198 [("Keyword", "PROZEDUR"),
69
b3dd247b27a5 FIX: Add forgotten tests for the new normalized highlighting
Franz Glasner <fzglas.hg@dom66.de>
parents: 66
diff changeset
199 ("Text.Whitespace", " "),
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
200 ("Name.Entity", " also {nichtxs"),
74
c1357674622d Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents: 72
diff changeset
201 ("Name.Entity", "}"),
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
202 ("Name.Entity", " hier"),
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
203 ("Text.Whitespace", "\n"),
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
204 ],
79
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
205 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
206
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
207 def test_function_1(self):
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
208 self.assertTokenStreamEqualComplete(
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
209 [("Keyword", "FUNCTION"),
69
b3dd247b27a5 FIX: Add forgotten tests for the new normalized highlighting
Franz Glasner <fzglas.hg@dom66.de>
parents: 66
diff changeset
210 ("Text.Whitespace", " "),
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
211 ("Name.Entity", "1"),
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
212 ("Text.Whitespace", "\n"),
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
213 ],
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
214 pygments.lex("\\FUNC{1}", self.lexer))
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
215
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
216 def test_function_2(self):
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
217 self.assertTokenStreamEqualComplete(
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
218 [("Keyword", "FUNCTION"),
69
b3dd247b27a5 FIX: Add forgotten tests for the new normalized highlighting
Franz Glasner <fzglas.hg@dom66.de>
parents: 66
diff changeset
219 ("Text.Whitespace", " "),
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
220 ("Name.Entity", "line 1\nline 2\n"),
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
221 ("Text.Whitespace", "\n"),
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
222 ],
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
223 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
224
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
225 def test_function_3(self):
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
226 self.assertTokenStreamEqualComplete(
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
227 [("Keyword", "FUNCTION"),
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
228 ("Text.Whitespace", " "),
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
229 ("Name.Entity", "\\"),
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
230 ("Name.Entity", "n"),
74
c1357674622d Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents: 72
diff changeset
231 ("Name.Entity", "}"),
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
232 ("Text.Whitespace", "\n"),
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
233 ],
79
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
234 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
235
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
236 def test_class(self):
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
237 self.assertTokenStreamEqualComplete(
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
238 [("Keyword", "CLASS"),
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
239 ("Text.Whitespace", " "),
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
240 ("Name.Entity", "\\"),
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
241 ("Name.Entity", "n"),
74
c1357674622d Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents: 72
diff changeset
242 ("Name.Entity", "}"),
40
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
243 ("Text.Whitespace", "\n"),
df08226a6984 Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents: 39
diff changeset
244 ],
79
c14e5fd4d193 More tests with escape characters
Franz Glasner <fzglas.hg@dom66.de>
parents: 78
diff changeset
245 pygments.lex(r"\CLASS {\n\}}", self.lexer))
35
d9a3551a1038 Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 34
diff changeset
246
41
4ccf9a8d0bf2 For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents: 40
diff changeset
247 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
248 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
249 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
250 self.assertTokenStreamEqualComplete(
4ccf9a8d0bf2 For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents: 40
diff changeset
251 [("Keyword", "CLASSE"),
4ccf9a8d0bf2 For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents: 40
diff changeset
252 ("Text.Whitespace", " "),
4ccf9a8d0bf2 For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents: 40
diff changeset
253 ("Name.Entity", "\\"),
4ccf9a8d0bf2 For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents: 40
diff changeset
254 ("Name.Entity", "n"),
74
c1357674622d Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents: 72
diff changeset
255 ("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
256 ("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
257 ],
4ccf9a8d0bf2 For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents: 40
diff changeset
258 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
259
57
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
260 def test_class_de_with_noend_option(self):
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
261 lexer = pygments.lexers.load_lexer_from_file(
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
262 ALGLEXERFILENAME, "AlgPseudocodeLexer_DE", no_end="True")
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
263 self.assertTokenStreamEqualComplete(
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
264 [("Keyword", "KLASSE"),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
265 ("Text.Whitespace", " "),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
266 ("Name.Entity", "\\"),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
267 ("Name.Entity", "n"),
74
c1357674622d Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents: 72
diff changeset
268 ("Name.Entity", "}"),
57
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
269 ("Text.Whitespace", "\n"),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
270 ("Text.Whitespace", "\n"),
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
271 ],
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
272 pygments.lex("\\CLASS {\\n\\}}\n\\ENDCLASS", lexer))
e8f4af9e20a8 Some "ENDxxx" commands
Franz Glasner <fzglas.hg@dom66.de>
parents: 53
diff changeset
273
62
7153e945a3d6 Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents: 57
diff changeset
274 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
275 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
276 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
277 self.assertTokenStreamEqualComplete(
7153e945a3d6 Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents: 57
diff changeset
278 [("Keyword", "KLASSE"),
7153e945a3d6 Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents: 57
diff changeset
279 ("Text.Whitespace", " "),
7153e945a3d6 Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents: 57
diff changeset
280 ("Name.Entity", "\\"),
7153e945a3d6 Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents: 57
diff changeset
281 ("Name.Entity", "n"),
74
c1357674622d Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents: 72
diff changeset
282 ("Name.Entity", "}"),
62
7153e945a3d6 Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents: 57
diff changeset
283 ("Text.Whitespace", "\n"),
7153e945a3d6 Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents: 57
diff changeset
284 ("Text.Whitespace", "\n"),
7153e945a3d6 Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents: 57
diff changeset
285 ],
7153e945a3d6 Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents: 57
diff changeset
286 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
287
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
288 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
289 self.assertTokenStreamEqualComplete(
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
290 [("Comment.Single", "▷"),
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
291 ("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
292 ("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
293 ],
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
294 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
295
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
296 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
297 self.assertTokenStreamEqualComplete(
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
298 [("Comment.Single", "▷"),
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
299 ("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
300 ("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
301 ("Comment.Single", "▷"),
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
302 ("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
303 ("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
304 ],
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
305 pygments.lex(
64
05c53e431c88 Simplify case-handling for "BLOCK" and "REMARK"
Franz Glasner <fzglas.hg@dom66.de>
parents: 62
diff changeset
306 """\\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
307 \\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
308 """, 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
309
70
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
310 def test_expr_and_text(self):
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
311 self.assertTokenStreamEqualComplete(
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
312 [("Name.Entity", "a"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
313 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
314 ("Text", "multiplied by"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
315 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
316 ("Name.Entity", "b"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
317 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
318 ("Text", "is"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
319 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
320 ("Number.Integer", "0"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
321 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
322 ("Text", "mod"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
323 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
324 ("Name.Entity", "p"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
325 ("Text.Whitespace", "\n"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
326 ],
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
327 pygments.lex(
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
328 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
329 self.lexer))
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
330
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
331 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
332 self.assertTokenStreamEqualComplete(
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
333 [("Name.Entity", "a"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
334 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
335 ("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
336 ("Text", "}"),
70
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
337 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
338 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
339 ("Name.Entity", "b"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
340 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
341 ("Text", "is "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
342 ("Text", "\\"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
343 ("Text", " not"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
344 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
345 ("Number.Integer", "0"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
346 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
347 ("Text", "mod"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
348 ("Text", " "),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
349 ("Name.Entity", "p"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
350 ("Text.Whitespace", "\n"),
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
351 ],
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
352 pygments.lex(
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
353 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
354 r" \text{mod} p""",
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
355 self.lexer))
5517b0be67f0 Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents: 69
diff changeset
356
75
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
357 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
358 self.assertTokenStreamEqualComplete(
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
359 [("Punctuation", "{"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
360 ("Punctuation", "}"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
361 ("Punctuation", ":"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
362 ("Punctuation", "("),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
363 ("Punctuation", ")"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
364 ("Punctuation", ","),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
365 ("Punctuation", ";"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
366 ("Punctuation", "["),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
367 ("Punctuation", "]"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
368 ("Text.Whitespace", "\n"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
369 ],
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
370 pygments.lex(r"{}:(),;[]", self.lexer))
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
371
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
372 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
373 self.assertTokenStreamEqualComplete(
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
374 [("Text", "◆"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
375 ("Text.Whitespace", " "),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
376 ("Text.Whitespace", "\n"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
377 ],
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
378 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
379
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
380 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
381 self.assertTokenStreamEqualComplete(
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
382 [("Text", "◆"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
383 ("Text.Whitespace", " "),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
384 ("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
385 ("Text.Whitespace", "\n"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
386 ],
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
387 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
388
76
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
389 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
390 self.assertTokenStreamEqualComplete(
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
391 [("Text", "◆"),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
392 ("Text.Whitespace", " "),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
393 ("Text", "\\"),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
394 ("Name.Entity", "text"),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
395 ("Punctuation", "{"),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
396 ("Name.Entity", "a"),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
397 ("Text", " "),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
398 ("Name.Entity", "b"),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
399 ("Text", " "),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
400 ("Name.Entity", "c"),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
401 ("Punctuation", "}"),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
402 ("Text.Whitespace", "\n"),
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
403 ],
27e12387154d FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents: 75
diff changeset
404 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
405
75
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
406 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
407 self.assertTokenStreamEqualComplete(
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
408 [("Text", "◆"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
409 ("Text.Whitespace", " "),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
410 ("Name.Entity", "a"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
411 ("Text", " "),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
412 ("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
413 ("Text", " "),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
414 ("Punctuation", "{"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
415 ("Name.Entity", "x"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
416 ("Text", " "),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
417 ("Operator.Word", "in"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
418 ("Text", " "),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
419 ("Name.Entity", "X"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
420 ("Punctuation", "}"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
421 ("Text", " "),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
422 ("Name.Entity", "c"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
423 ("Text.Whitespace", "\n"),
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
424 ],
711f8d19e27a New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents: 74
diff changeset
425 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
426
78
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
427 def test_tstate_empty(self):
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
428 self.assertTokenStreamEqualComplete(
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
429 [("Text", "▪"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
430 ("Text.Whitespace", " "),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
431 ("Text.Whitespace", "\n"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
432 ],
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
433 pygments.lex(r"\tstate{}", self.lexer))
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
434
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
435 def test_tstate_with_expr(self):
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
436 self.assertTokenStreamEqualComplete(
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
437 [("Text", "▪"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
438 ("Text.Whitespace", " "),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
439 ("Text", "a 1.2 "),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
440 ("Name.Entity", "x"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
441 ("Text", " "),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
442 ("Operator.Word", "in"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
443 ("Text", " "),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
444 ("Name.Entity", "X"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
445 ("Punctuation", "}"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
446 ("Text", " c"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
447 ("Text.Whitespace", "\n"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
448 ],
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
449 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
450
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
451 def test_tstate_with_escaped_expr(self):
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
452 self.assertTokenStreamEqualComplete(
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
453 [("Text", "▪"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
454 ("Text.Whitespace", " "),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
455 ("Text", "a 1.2 "),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
456 ("Text", "\\"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
457 ("Text", "expr{x in X"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
458 ("Text", "}"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
459 ("Text", " c"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
460 ("Text.Whitespace", "\n"),
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
461 ],
abb2e8c65d0f Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents: 76
diff changeset
462 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
463
92
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
464 def test_text_in_expr(self):
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
465 self.assertTokenStreamEqualComplete(
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
466 [("Name.Entity", "first"),
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
467 ("Text", " "),
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
468 ("Name.Entity", "expression"),
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
469 ("Text", " "),
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
470 ("Name.Entity", "second"),
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
471 ("Text", " "),
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
472 ("Name.Entity", "expression"),
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
473 ("Text.Whitespace", "\n"),
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
474 ],
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
475 pygments.lex(
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
476 r"\TEXT{\EXPRESSION{first expression} "
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
477 r"\EXPR{second expression}}",
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
478 self.lexer))
3f37832c405d FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents: 87
diff changeset
479
84
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
480 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
481 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
482 [("Operator", "%"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
483 ("Text.Whitespace", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
484 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
485 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
486
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
487 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
488 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
489 [("Operator", "{"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
490 ("Text.Whitespace", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
491 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
492 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
493
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
494 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
495 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
496 [("Operator", "<"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
497 ("Text.Whitespace", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
498 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
499 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
500
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
501 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
502 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
503 [("Operator", "("),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
504 ("Text.Whitespace", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
505 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
506 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
507
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
508 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
509 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
510 [("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
511 ("Text.Whitespace", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
512 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
513 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
514
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
515 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
516 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
517 [("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
518 ("Text.Whitespace", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
519 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
520 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
521
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
522 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
523 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
524 [("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
525 ("Text.Whitespace", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
526 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
527 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
528
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
529 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
530 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
531 [("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
532 ("Text.Whitespace", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
533 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
534 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
535
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
536 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
537 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
538 [("Operator", "}"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
539 ("Operator", "/"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
540 ("Text.Whitespace", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
541 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
542 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
543
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
544 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
545 self.assertTokenStreamEqualComplete(
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
546 [("Operator", "\n"),
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
547 ("Operator", "/"),
95
aed3204723ac FIX: Test results because of changed whitespace handling
Franz Glasner <fzglas.hg@dom66.de>
parents: 94
diff changeset
548 ("Text", " "),
aed3204723ac FIX: Test results because of changed whitespace handling
Franz Glasner <fzglas.hg@dom66.de>
parents: 94
diff changeset
549 ("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
550 ],
3ac1c4502ad0 Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents: 79
diff changeset
551 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
552
87
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
553 @unittest.skipIf(sys.version_info[0] <= 2, "Unicode issue on Python 2")
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
554 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
555 self.assertTokenStreamEqualComplete(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
556 [("Operator", "∈ ∌"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
557 ("Text", " "),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
558 ("Comment.Single", "▷"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
559 ("Comment.Single", " ∈ ∌ as (ordinary) operators"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
560 ("Text.Whitespace", "\n"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
561 ],
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
562 pygments.lex(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
563 r"""\ttx-o<∈ ∌> \rem ∈ ∌ as (ordinary) operators""",
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
564 self.lexer))
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
565
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
566 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
567 self.assertTokenStreamEqualComplete(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
568 [("Operator", "new_operator"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
569 ("Text", " "),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
570 ("Comment.Single", "▷"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
571 ("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
572 ("Text.Whitespace", "\n"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
573 ],
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
574 pygments.lex(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
575 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
576 self.lexer))
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
577
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
578 @unittest.skipIf(sys.version_info[0] <= 2, "Unicode issue on Python 2")
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
579 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
580 self.assertTokenStreamEqualComplete(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
581 [("Name.Function", "∈_∌"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
582 ("Punctuation", "("),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
583 ("Name.Entity", "p1"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
584 ("Punctuation", ","),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
585 ("Text", " "),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
586 ("Name.Entity", "p2"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
587 ("Punctuation", ")"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
588 ("Text.Whitespace", "\n"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
589 ],
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
590 pygments.lex(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
591 r"""\ttx-nf<∈_∌>(p1, p2)""",
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
592 self.lexer))
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
593
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
594 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
595 self.assertTokenStreamEqualComplete(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
596 [("Name.Decorator", "a_Decorator"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
597 ("Punctuation", "("),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
598 ("Name.Entity", "p1"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
599 ("Punctuation", ","),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
600 ("Text", " "),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
601 ("Name.Entity", "p2"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
602 ("Punctuation", ")"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
603 ("Text", " "),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
604 ("Comment.Single", "▷"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
605 ("Comment.Single", " (Python) decorator"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
606 ("Text.Whitespace", "\n"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
607 ],
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
608 pygments.lex(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
609 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
610 self.lexer))
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
611
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
612 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
613 self.assertTokenStreamEqualComplete(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
614 [("Name.Decorator", "a_Decorator"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
615 ("Punctuation", "("),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
616 ("Name.Entity", "p1"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
617 ("Punctuation", ","),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
618 ("Text", " "),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
619 ("Name.Entity", "p2"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
620 ("Punctuation", ")"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
621 ("Text", " "),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
622 ("Comment.Single", "▷"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
623 ("Comment.Single", " (Python) annotation"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
624 ("Text.Whitespace", "\n"),
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
625 ],
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
626 pygments.lex(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
627 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
628 self.lexer))
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
629
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
630 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
631 self.assertTokenStreamEqualComplete(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
632 [("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
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(
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
636 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
637 self.lexer))
d8ca835c74ea FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents: 84
diff changeset
638
97
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
639 def test_end_combinations(self):
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
640 self.assertTokenStreamEqualComplete(
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
641 [("Keyword", "BEGIN"),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
642 ("Text", " "),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
643 ("Keyword", "END"),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
644 ("Text", " "),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
645 ("Keyword", "END OF FUNCTION"),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
646 ("Text", " "),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
647 ("Keyword", "END OF FUNCTION"),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
648 ("Text.Whitespace", " "),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
649 ("Name.Entity", "An End of a Function"),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
650 ("Text", " "),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
651 ("Keyword", "END OF FUNCTION"),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
652 ("Text.Whitespace", " "),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
653 ("Name.Entity", "The End of the Next Function"),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
654 ("Text", " "),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
655 ("Text.Whitespace", "\n"),
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
656 ],
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
657 pygments.lex(
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
658 r"""\begin \end \end-fn \end-fn {An End of a Function}"""
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
659 r""" \end fn {The End of the Next Function} """,
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
660 self.lexer))
dd4eb937485c A couple of new keywords
Franz Glasner <fzglas.hg@dom66.de>
parents: 95
diff changeset
661
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
662
66
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
663 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
664
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
665 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
666 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
667 ALGLEXERFILENAME, ALGLEXERCLASS)
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
668
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
669 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
670 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
671 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
672 '"""FOO"""',
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
673 self.lexer,
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
674 html_formatter,
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
675 outfile=None)
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
676 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
677
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
678 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
679 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
680 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
681 '"""FOO"""',
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
682 self.lexer,
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
683 latex_formatter,
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
684 outfile=None)
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
685 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
686
9ba1584d4b4a Also add a test that completely highlights a document with Pygments
Franz Glasner <fzglas.hg@dom66.de>
parents: 64
diff changeset
687
34
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
688 if __name__ == "__main__":
1f741934205e Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
689 unittest.main()