def test_find_grammars_standalone(self, command): grammars = command._find_grammars(pathlib.Path('standalone')) some_grammar = AntlrGrammar(pathlib.Path('standalone/SomeGrammar.g4')) assert len(grammars) == 1 assert some_grammar in grammars
def test_find_grammars_standalone(self, command): grammars = command._find_grammars(pathlib.Path('standalone')) some_grammar = AntlrGrammar(pathlib.Path('standalone/SomeGrammar.g4')) assert len(grammars) == 1 assert some_grammar in grammars
def test_find_grammars_distributed(self, command): g = command._find_grammars(pathlib.Path('distributed')) assert len(g) == 1 assert g[0].name == 'SomeGrammar' d = g[0].dependencies assert len(d) == 2 assert d[0].name == 'CommonTerminals' assert d[1].name == 'SharedRules' dd = g[0].dependencies[0].dependencies assert len(dd) == 0 dd = g[0].dependencies[1].dependencies assert len(dd) == 1 assert dd[0].name == 'CommonTerminals'
def test_find_grammars_distributed(self, command): grammars = command._find_grammars(pathlib.Path('distributed')) common_terminals = AntlrGrammar(pathlib.Path('distributed/CommonTerminals.g4')) shared_rules = AntlrGrammar(pathlib.Path('distributed/SharedRules.g4')) some_grammar = AntlrGrammar(pathlib.Path('distributed/SomeGrammar.g4')) shared_rules.dependencies.append(common_terminals) some_grammar.dependencies.append(common_terminals) some_grammar.dependencies.append(shared_rules) assert len(grammars) == 3 assert common_terminals in grammars assert shared_rules in grammars assert some_grammar in grammars
def test_find_grammars_distributed(self, command): grammars = command._find_grammars(pathlib.Path('distributed')) common_terminals = AntlrGrammar( pathlib.Path('distributed/CommonTerminals.g4')) shared_rules = AntlrGrammar(pathlib.Path('distributed/SharedRules.g4')) some_grammar = AntlrGrammar(pathlib.Path('distributed/SomeGrammar.g4')) shared_rules.dependencies.append(common_terminals) some_grammar.dependencies.append(common_terminals) some_grammar.dependencies.append(shared_rules) assert len(grammars) == 3 assert common_terminals in grammars assert shared_rules in grammars assert some_grammar in grammars
def test_find_grammars_incomplete(self, command): # check if DistutilsFileError was thrown with pytest.raises(distutils.errors.DistutilsFileError) as excinfo: command._find_grammars(pathlib.Path('incomplete')) assert excinfo.match('CommonTerminals')
def test_find_grammars_standalone(self, command): g = command._find_grammars(pathlib.Path('standalone')) assert len(g) == 1 assert g[0].name == 'SomeGrammar'
def test_find_grammars_empty(self, tmpdir, command): dsl_dir = tmpdir.mkdir('dsl') g = command._find_grammars(pathlib.Path(str(dsl_dir))) assert len(g) == 0
def test_find_grammars_incomplete(self, command): # check if DistutilsFileError was thrown with pytest.raises(distutils.errors.DistutilsFileError) as excinfo: command._find_grammars(pathlib.Path('incomplete')) assert excinfo.match('CommonTerminals')
def test_find_grammars_empty(self, tmpdir, command): dsl_dir = tmpdir.mkdir('dsl') grammars = command._find_grammars(pathlib.Path(str(dsl_dir))) assert len(grammars) == 0