-
-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
132 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() |