コード例 #1
0
 def test_scanner_none():
     """
     Ensure overwriting the scanner property works as expected when given
     proper input as None.
     """
     generator = Generator()
     generator.scanner = None
     assert generator.scanner is None, 'Invalid scanner set/retrieved'
コード例 #2
0
 def test_encoding_direct():
     """
     Ensure overwriting the encoding property works as expected when given
     proper input as the string 'direct'.
     """
     generator = Generator()
     generator.encoding = 'direct'
     assert generator.encoding == 'direct', 'Invalid encoding set/retrieved'
コード例 #3
0
 def test_filename_valid():
     """
     Ensure overwriting the filename property works as expected when given
     proper input as a non empty string.
     """
     generator = Generator()
     generator.filename = 'foobar'
     assert generator.filename == 'foobar', 'Invalid filename set/retrieved'
コード例 #4
0
ファイル: test_generator.py プロジェクト: rrozansk/SPaG
 def test_translate_not_implemented():
     """
     Ensure a NotImplementedError is raised if generation to source language
     is attempted with the base Generator.
     """
     generator = Generator()
     generator.scanner = RegularGrammar('test', {'foo': ['b', 'a', 'r']})
     generator.parser = ContextFreeGrammar('test', {'S': [['a']]}, 'S')
     generator.generate()
コード例 #5
0
 def test_parser_valid():
     """
     Ensure overwriting the paser property works as expected when given
     proper input as a ContextFreeGrammar.
     """
     parser = ContextFreeGrammar('test', {'S': [['a']]}, 'S')
     generator = Generator()
     generator.parser = parser
     assert generator.parser is parser, 'Invalid parser set/retrieved'
コード例 #6
0
 def test_scanner_valid():
     """
     Ensure overwriting the scanner property works as expected when given
     proper input as a RegularGrammar.
     """
     scanner = RegularGrammar('test', {'foo': 'bar'})
     generator = Generator()
     generator.scanner = scanner
     assert generator.scanner is scanner, 'Invalid scanner set/retrieved'
コード例 #7
0
ファイル: test_generator.py プロジェクト: rrozansk/SPaG
 def test_constructor():
     """
     Ensure successful creation of a Generator object.
     """
     generator = Generator()
     assert generator is not None, 'No Generator produced'