Skip to content

Commit

Permalink
Added simple test for rule name capitalization
Browse files Browse the repository at this point in the history
  • Loading branch information
acw1251 authored and apalala committed Nov 26, 2017
1 parent 05ba00f commit 34ac3a2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/parsing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ def test_rule_name(self):
ast = tatsu.parse(grammar, "test", rule_name='start')
self.assertEqual(ast, "test")

def test_rule_capitalization(self):
grammar = '''
start = ['test' {rulename}] ;
{rulename} = /[a-zA-Z0-9]+/ ;
'''
test_string = 'test 12'
lowercase_rule_names = ['nocaps', 'camelCase', 'tEST']
uppercase_rule_names = ['Capitalized', 'CamelCase', 'TEST']
ref_lowercase_result = tatsu.parse(grammar.format(rulename='reflowercase'), test_string, rule_name='start')
ref_uppercase_result = tatsu.parse(grammar.format(rulename='Refuppercase'), test_string, rule_name='start')
for rulename in lowercase_rule_names:
result = tatsu.parse(grammar.format(rulename=rulename), test_string, rule_name='start')
self.assertEqual(result, ref_lowercase_result)
for rulename in uppercase_rule_names:
result = tatsu.parse(grammar.format(rulename=rulename), test_string, rule_name='start')
self.assertEqual(result, ref_uppercase_result)


def suite():
return unittest.TestLoader().loadTestsFromTestCase(ParsingTests)
Expand Down

0 comments on commit 34ac3a2

Please sign in to comment.