Ejemplo n.º 1
0
 def arguments(self) -> FileMatcherArg:
     return _as_arguments(
         RecWLimArguments(
             self._helper.files_matcher_sym_ref_arg(),
             SymbolReferenceArgument(self.min_depth.name),
             SymbolReferenceArgument(self.max_depth.name),
         ))
Ejemplo n.º 2
0
    def runTest(self):
        # ARRANGE #

        files_matcher_name = 'the_files_matcher'
        checked_dir_location = RelOptionType.REL_ACT
        checked_dir = Dir.empty('checked-dir')

        matcher_argument = SymbolReferenceArgument(files_matcher_name).as_str

        tcds = TcdsArrangementPostAct(
            TcdsPopulatorForRelOptionType(checked_dir_location,
                                          DirContents([checked_dir])))

        source_cases = [
            NameAndValue(
                'All arguments on separate lines',
                Arguments(checked_dir.name, [
                    reserved_words.COLON, args.RECURSION_OPTION_STR,
                    matcher_argument
                ]),
            ),
            NameAndValue(
                'Empty lines between arguments',
                Arguments(checked_dir.name, [
                    '',
                    reserved_words.COLON,
                    '',
                    args.RECURSION_OPTION_STR,
                    '',
                    matcher_argument,
                ]),
            ),
        ]

        execution_cases = [
            NExArr(
                'matcher gives ' + str(matcher_result),
                ExecutionExpectation(
                    main_result=asrt_pfh.is_non_hard_error(matcher_result)),
                ArrangementPostAct2(
                    tcds,
                    symbols=FilesMatcherSymbolContext.of_primitive_constant(
                        files_matcher_name, matcher_result).symbol_table))
            for matcher_result in [False, True]
        ]
        # ACT & ASSERT #

        for source_case in source_cases:
            with self.subTest(source_case=source_case.name):
                INSTRUCTION_CHECKER.check_multi__with_source_variants(
                    self,
                    SourceArrangement.new_w_arbitrary_fs_location(
                        source_case.value),
                    symbol_usages=asrt.matches_singleton_sequence(
                        is_reference_to_files_matcher__usage(
                            files_matcher_name)),
                    execution=execution_cases,
                )
    def runTest(self):
        # ARRANGE #

        symbol_in_program_source = NameAndValue('SYMBOL_IN_PROGRAM_SOURCE',
                                                data_restrictions_assertions.is__w_str_rendering())

        symbol_in_matcher = NameAndValue('SYMBOL_IN_MATCHER',
                                         ss_references.IS_STRING_SOURCE_OR_STRING_REFERENCE_RESTRICTION)

        symbol_in_transformer_of_program = NameAndValue('SYMBOL_IN_TRANSFORMER_OF_PROGRAM',
                                                        is_reference_restrictions__value_type(
                                                            [ValueType.STRING_TRANSFORMER]))

        symbol_in_transformer_of_instruction = NameAndValue('SYMBOL_IN_TRANSFORMER_OF_INSTRUCTION',
                                                            is_reference_restrictions__value_type(
                                                                [ValueType.STRING_TRANSFORMER]))

        program_with_ref_to_symbols = pgm_args.program(
            pgm_args.interpret_py_source_line(
                self.configuration.py_source_for_print(
                    symbol_reference_syntax_for_name(symbol_in_program_source.name))),
            transformation=symbol_in_transformer_of_program.name
        )
        matcher_with_ref_to_symbol = matcher_arguments.equals_matcher(SymbolReferenceArgument(symbol_in_matcher.name))

        arguments = po_ab.from_program(program_with_ref_to_symbols,
                                       matcher_with_ref_to_symbol,
                                       transformation=symbol_in_transformer_of_instruction.name)

        symbol_usages_assertion = asrt.matches_sequence([
            matches_reference(symbol_in_program_source),
            matches_reference(symbol_in_transformer_of_program),
            matches_reference(symbol_in_transformer_of_instruction),
            matches_reference(symbol_in_matcher),
        ])

        source = arguments.as_remaining_source

        # ACT #

        actual = self.configuration.parser().parse(ARBITRARY_FS_LOCATION_INFO, source)
        actual_symbol_usages = actual.symbol_usages()

        # ASSERT #

        symbol_usages_assertion.apply_without_message(self, actual_symbol_usages)
Ejemplo n.º 4
0
    def runTest(self):
        # ARRANGE #
        checked_dir_location = RelOptionType.REL_TMP
        checked_dir_name = 'the-model-dir'
        checked_dir_path = path_sdvs.of_rel_option_with_const_file_name(
            checked_dir_location, checked_dir_name)

        model_checker_symbol_name = 'symbol_that_checks_model'

        arguments = args.recursive(
            RelOptPathArgument(checked_dir_name, checked_dir_location),
            SymbolReferenceArgument(model_checker_symbol_name),
        )

        contents_cases = test_data.strip_file_type_info_s([
            test_data.identical_expected_and_actual(case.name, case.value)
            for case in test_data.cases()
        ])
Ejemplo n.º 5
0
 def files_matcher_reference_argument(self) -> ArgumentElementsRenderer:
     return SymbolReferenceArgument(self.name_of_referenced_symbol)