Esempio n. 1
0
 def test_exception_SHOULD_be_raised_WHEN_invalid_syntax_of_second_element(
         self):
     for case in TOKENS_WITH_INVALID_SYNTAX:
         source = remaining_source('valid' + ' ' + case.value)
         with self.subTest(name=case.name, source=case.value):
             with self.assertRaises(
                     SingleInstructionInvalidArgumentException):
                 sut.parser().parse(source)
Esempio n. 2
0
 def test_exception_SHOULD_be_raised_WHEN_second_element_is_reserved_word(
         self):
     for reserved_word in set(reserved_words.RESERVED_TOKENS).difference(
             reserved_words.PAREN_END):
         source = remaining_source('valid' + ' ' + reserved_word)
         with self.subTest(reserved_word):
             with self.assertRaises(
                     SingleInstructionInvalidArgumentException):
                 sut.parser().parse(source)
Esempio n. 3
0
def _test_case(
    put: unittest.TestCase,
    arrangement: Arrangement,
    expectation: Expectation,
    source: ParseSource,
    expected_source_after_parse: Assertion[ParseSource],
):
    parser = sut.parser()
    # ACT #

    actual = parser.parse(source)

    # ASSERT #

    expected_source_after_parse.apply_with_message(put, source,
                                                   'source after parse')

    test_of_list.check_elements(put, expectation.elements,
                                actual.arguments_list)

    expectation.references.apply_with_message(put, actual.references,
                                              'symbol references')

    actual_ddv = actual.resolve(arrangement.symbols)
    expectation.validators.apply_with_message(put, actual_ddv.validators,
                                              'validators')
Esempio n. 4
0
 def __init__(self):
     super().__init__(consume_last_line_if_is_at_eol_after_parse=False)
     self._arguments_parser = parse_arguments.parser()
Esempio n. 5
0
 def _parse_program_with_arguments(
         self) -> _SourceInfoForInterpreterWithArgumentList:
     source_file = self._parse_path()
     arguments = parse_arguments.parser().parse(self._source)
     return _SourceInfoForInterpreterWithArgumentList(
         source_file, arguments)
 def __init__(self, relativity_of_exe_file: RelOptionArgumentConfiguration):
     super().__init__(consume_last_line_if_is_at_eol_after_parse=False,
                      consume_last_line_if_is_at_eof_after_parse=False)
     self._arguments_parser = parse_arguments.parser()
     self._exe_file_parser = parse_executable_file_path.parser(
         relativity_of_exe_file)