-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtpg_tests_py2.py
More file actions
executable file
·65 lines (53 loc) · 1.96 KB
/
tpg_tests_py2.py
File metadata and controls
executable file
·65 lines (53 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
import unittest
import tpg
print("*"*70)
print("*")
print("* Unit tests for %(__name__)s %(__version__)s (%(__date__)s)"%tpg.__dict__)
print("*")
print("* Platform : %s"%sys.platform.replace('\n', ' '))
print("* Version : %s"%sys.version.replace('\n', ' '))
print("*")
print("* Please report bug to %(__author__)s (%(__email__)s)"%tpg.__dict__)
print("* for further detail read %(__url__)s"%tpg.__dict__)
print("*")
print("*"*70)
for PARSER, VERBOSE in ( (tpg.Parser, None),
(tpg.VerboseParser, 0),
(tpg.VerboseParser, 1),
(tpg.VerboseParser, 2),
):
for LEXER in tpg.TPGParser.Options.option_dict['lexer'][0]:
print("*"*70)
if VERBOSE is None:
print("* %s %s"%(PARSER.__name__, LEXER))
else:
print("* %s verbose=%s %s"%(PARSER.__name__, VERBOSE, LEXER))
print("*"*70)
class UnicodeTestCase(unittest.TestCase):
class Parser(PARSER):
__doc__ = ur"""
set lexer = %(LEXER)s
set lexer_unicode = True
token single_quote '[‘’]' ;
token double_quote '["“”]' ;
token word '\w+' ;
START/x -> double_quote word/x double_quote
| single_quote word/x single_quote
| '`' word/x '´'
;
"""%tpg.Py()
def testExpr(self):
p = self.Parser()
self.assertEquals(p(u'"woah"'), "woah")
self.assertEquals(p(u"“woah”"), "woah")
self.assertEquals(p(u"‘woah’"), "woah")
self.assertEquals(p(u"`woah´"), "woah")
try:
unittest.main()
except SystemExit:
if tpg.exc().args[0]:
raise