-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_lex.py
47 lines (46 loc) · 1.27 KB
/
test_lex.py
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
import unittest
import visp
class TestLexer(unittest.TestCase):
def test_lparen(self):
self.assertEqual(
next(visp.lex('(')).type,
'lparen')
def test_wspace(self):
self.assertEqual(
len(list(visp.lex(' '))),
0)
def test_rparen(self):
self.assertEqual(
next(visp.lex(')')).type,
'rparen')
def test_dot(self):
self.assertEqual(
next(visp.lex('.')).type,
'dot')
def test_number(self):
self.assertEqual(
next(visp.lex('12345')).type,
'number')
def test_symbol(self):
self.assertEqual(
next(visp.lex('foo%$!')).type,
'symbol')
def test_hashsym1(self):
self.assertEqual(
next(visp.lex('#e')).type,
'hashsym')
def test_hashsym3(self):
self.assertEqual(
next(visp.lex('#hello')).type,
'hashsym')
def test_quote(self):
self.assertEqual(
next(visp.lex('\'')).type,
'quote')
def test_empty_string(self):
self.assertEqual(
next(visp.lex('""')).type,
'string')
self.assertEqual(
next(visp.lex('""')).string,
'')