Example #1
0
 def test_raise_exception_when_syntax_is_invalid(self):
     source_cases = [
         NameAndValue(
             'empty - missing all arguments',
             CustomAbsStx.empty(),
         ),
         NameAndValue(
             'superfluous arguments',
             SequenceAbsStx.followed_by_superfluous(
                 InstructionArgumentsAbsStx(
                     DefaultRelPathAbsStx('actual.txt'),
                     StringMatcherSymbolReferenceAbsStx('STRING_MATCHER'),
                 )
             ),
         ),
         NameAndValue(
             'invalid matcher',
             SequenceAbsStx.followed_by_superfluous(
                 InstructionArgumentsAbsStx(
                     DefaultRelPathAbsStx('actual.txt'),
                     StringMatcherSymbolReferenceAbsStx(
                         NOT_A_PRIMITIVE_EXPR_NAME_AND_NOT_A_VALID_SYMBOL_NAME
                     ),
                 )
             ),
         )
     ]
     for source_case in source_cases:
         with self.subTest(source_case.name):
             PARSE_CHECKER.check_invalid_syntax__src_var_consume_last_line_abs_stx(
                 self,
                 source_case.value,
             )
Example #2
0
 def test_failing_parse(self):
     cases = [
         NameAndValue(
             'missing argument',
             CustomAbsStx.empty(),
         ),
         NameAndValue(
             'missing end quote in file name',
             LiteralFilesSourceAbsStx([
                 abs_stx.regular_file_spec(
                     MISSING_END_QUOTE__SOFT,
                     abs_stx.FileContentsEmptyAbsStx(),
                 )
             ])
         ),
         NameAndValue(
             'superfluous arguments',
             SequenceAbsStx.followed_by_superfluous(
                 LiteralFilesSourceAbsStx([])
             ),
         ),
     ]
     # ARRANGE #
     for case in cases:
         with self.subTest(case.name):
             PARSE_CHECKER.check_invalid_syntax__abs_stx(
                 self,
                 _syntax_of(case.value)
             )
Example #3
0
 def test_superfluous_arguments(self):
     # ARRANGE #
     valid_path = RelOptPathAbsStx(RelOptionType.REL_ACT, 'valid-file-name')
     valid_syntax = abs_stx.without_contents(valid_path)
     invalid_syntax = SequenceAbsStx.followed_by_superfluous(valid_syntax)
     # ACT & ASSERT #
     check_invalid_syntax__abs_stx(self, invalid_syntax)
Example #4
0
 def runTest(self):
     self.configuration.parse_checker.check_invalid_syntax__src_var_consume_last_line_abs_stx(
         self,
         self.configuration.syntax_for_matcher(
             SequenceAbsStx([
                 self.configuration.syntax_for_matcher(EmptyAbsStx()),
                 HereDocAbsStx('single line\n'),
             ])))
Example #5
0
 def runTest(self):
     # ARRANGE #
     for phase_spec in PHASE_SPECS:
         cases = [
             NameAndValue(
                 'invalid quoting',
                 UnsetVariableArgumentsAbsStx.of_str(
                     MISSING_END_QUOTE_STR__HARD, phase_spec=phase_spec),
             ),
             NameAndValue(
                 'missing arguments',
                 UnsetVariableArgumentsAbsStx(StringLiteralAbsStx(''),
                                              phase_spec=phase_spec),
             ),
             NameAndValue(
                 'more than one argument',
                 SequenceAbsStx.followed_by_superfluous(
                     UnsetVariableArgumentsAbsStx(
                         StringLiteralAbsStx('name'),
                         phase_spec=phase_spec))),
             NameAndValue(
                 'unset identifier must not be quoted',
                 SequenceAbsStx([
                     StringLiteralAbsStx(defs.UNSET_IDENTIFIER,
                                         QuoteType.HARD),
                     StringLiteralAbsStx('var_name'),
                 ])),
         ]
         for case in cases:
             # ACT & ASSERT #
             PARSE_CHECKER.check_invalid_syntax__abs_stx(
                 self,
                 case.value,
                 {
                     'phase_spec': phase_spec,
                     'variant': case.name,
                 },
             )
Example #6
0
 def test_failing_parse(self):
     cases = [
         NameAndValue(
             'missing argument',
             CustomAbsStx.empty(),
         ),
         NameAndValue(
             'missing end quote',
             StringSourceOfStringAbsStx(MISSING_END_QUOTE__SOFT),
         ),
         NameAndValue(
             'superfluous arguments',
             SequenceAbsStx.followed_by_superfluous(
                 StringSourceOfStringAbsStx.of_str_hard('valid string')
             ),
         ),
     ]
     # ARRANGE #
     for case in cases:
         with self.subTest(case.name):
             PARSE_CHECKER.check_invalid_syntax__abs_stx(
                 self,
                 _syntax_of(case.value)
             )
Example #7
0
 def test_fail_when_superfluous_arguments(self):
     invalid_syntax = SequenceAbsStx.followed_by_superfluous(
         NewDirArguments.implicitly_empty(
             PathStringAbsStx.of_plain_str('valid_file_name')))
     PARSE_CHECKER.check_invalid_syntax__abs_stx(self, invalid_syntax)
Example #8
0
 def runTest(self):
     self.configuration.parse_checker.check_invalid_syntax__src_var_consume_last_line_abs_stx(
         self,
         self.configuration.syntax_for_matcher(
             SequenceAbsStx.followed_by_superfluous(
                 self.configuration.syntax_for_matcher(EmptyAbsStx()), )))