forked from lark-parser/lark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pattern_matching.py
52 lines (40 loc) · 1.11 KB
/
test_pattern_matching.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
48
49
50
51
52
from unittest import TestCase, main
from lark import Token
class TestPatternMatching(TestCase):
token = Token('A', 'a')
def setUp(self):
pass
def test_matches_with_string(self):
match self.token:
case 'a':
pass
case _:
assert False
def test_matches_with_str_positional_arg(self):
match self.token:
case str('a'):
pass
case _:
assert False
def test_matches_with_token_positional_arg(self):
match self.token:
case Token('a'):
assert False
case Token('A'):
pass
case _:
assert False
def test_matches_with_token_kwarg_type(self):
match self.token:
case Token(type='A'):
pass
case _:
assert False
def test_matches_with_bad_token_type(self):
match self.token:
case Token(type='B'):
assert False
case _:
pass
if __name__ == '__main__':
main()