Ejemplo n.º 1
0
    def test_stdin_is_contents_of_string_source_WHEN_program_defines_single_stdin(
            self):
        # ARRANGE #
        test_setup = SingleStdinOfProgramTestSetup(self, exit_code=0)

        for pgm_and_args_case in pgm_and_args_cases.cases_w_and_wo_argument_list__including_program_reference(
        ):
            all_symbols = list(
                pgm_and_args_case.symbols) + [CONST_TRUE_INT_MATCHER_SYMBOL]
            with self.subTest(pgm_and_args_case.name):
                # ACT & ASSERT #
                CHECKER.check__abs_stx__source_variants(
                    self,
                    InstructionArguments(
                        test_setup.program_w_stdin_syntax(
                            pgm_and_args_case.pgm_and_args),
                        CONST_TRUE_INT_MATCHER_SYMBOL.abstract_syntax,
                    ),
                    ArrangementPostAct2(
                        symbols=SymbolContext.symbol_table_of_contexts(
                            all_symbols),
                        process_execution=test_setup.
                        proc_exe_env__w_stdin_check,
                        tcds=TcdsArrangementPostAct(
                            tcds_contents=pgm_and_args_case.tcds, ),
                    ),
                    MultiSourceExpectation(
                        symbol_usages=SymbolContext.
                        usages_assertion_of_contexts(all_symbols),
                        execution=ExecutionExpectation(
                            main_result=asrt_pfh.is_pass()),
                    ),
                )
Ejemplo n.º 2
0
def _check(put: unittest.TestCase,
           integer_matcher: IntegerMatcherAbsStx,
           integer_matcher_symbols: List[SymbolContext]):
    # ARRANGE #
    program_symbol = ProgramSymbolContext.of_arbitrary_value('PROGRAM_SYMBOL')
    all_symbols = [program_symbol] + integer_matcher_symbols

    command_execution_counter = recording.Counter(initial_value=0)
    # ACT & ASSERT #
    CHECKER.check__abs_stx(
        put,
        InstructionArguments(
            program_symbol.abstract_syntax,
            integer_matcher,
        ),
        ArrangementPostAct2(
            symbols=SymbolContext.symbol_table_of_contexts(all_symbols),
            process_execution=ProcessExecutionArrangement(
                os_services=os_services_w_cmd_exe_counting__w_wrapped(
                    command_execution_counter,
                    CommandExecutorThatJustReturnsConstant(1)
                ),
            )
        ),
        Expectation2(
            ParseExpectation(
                symbol_usages=SymbolContext.usages_assertion_of_contexts(all_symbols)
            )
        ),
    )
    put.assertEqual(1,
                    command_execution_counter.value,
                    'number of times the program has been executed')
Ejemplo n.º 3
0
    def runTest(self):
        # ARRANGE #
        valid_program_symbol = ProgramSymbolContext.of_arbitrary_value(
            'VALID_PROGRAM')

        for invalid_matcher_case in im_validation_case.failing_validation_cases(
        ):
            invalid_matcher_symbol = invalid_matcher_case.value.symbol_context
            all_symbols = [valid_program_symbol, invalid_matcher_symbol]
            with self.subTest(invalid_matcher_case.name):
                # ACT & ASSERT #
                invalid_matcher_symbol = invalid_matcher_case.value.symbol_context
                CHECKER.check__abs_stx(
                    self,
                    InstructionArguments(
                        valid_program_symbol.abstract_syntax,
                        invalid_matcher_symbol.abstract_syntax,
                    ),
                    ArrangementPostAct2(
                        symbols=SymbolContext.symbol_table_of_contexts(
                            all_symbols), ),
                    Expectation2(
                        ParseExpectation(
                            symbol_usages=SymbolContext.
                            usages_assertion_of_contexts(all_symbols)),
                        ExecutionExpectation.
                        validation_corresponding_to__post_sds_as_hard_error(
                            invalid_matcher_case.value.actual, ),
                    ))
Ejemplo n.º 4
0
    def runTest(self):
        # ARRANGE #
        checked_dir = Dir.empty('the-checked-dir')

        fsm_1 = FilesMatcherSymbolContextOfPrimitiveConstant('fsm_1', True)
        fsm_2 = FilesMatcherSymbolContextOfPrimitiveConstant('fsm_2', False)
        symbols = [fsm_1, fsm_2]

        rel_conf = rel_opt_conf.conf_rel_any(RelOptionType.REL_ACT)

        arguments = args.recursive(
            rel_conf.path_argument_of_rel_name(checked_dir.name),
            fsm_args.disjunction([fsm_1.argument, fsm_2.argument]),
        )
        is_pass = fsm_1.result_value or fsm_2.result_value
        # ACT # & ASSERT #
        INSTRUCTION_CHECKER.check_2(
            self, arguments.as_remaining_source,
            ArrangementPostAct2(
                symbols=SymbolContext.symbol_table_of_contexts(symbols),
                tcds=TcdsArrangementPostAct(
                    tcds_contents=rel_conf.
                    populator_for_relativity_option_root(
                        DirContents([checked_dir])))),
            Expectation2(
                ParseExpectation(
                    source=asrt_source.source_is_at_end,
                    symbol_usages=SymbolContext.usages_assertion_of_contexts(
                        symbols),
                ),
                ExecutionExpectation(
                    main_result=asrt_pfh.is_non_hard_error(is_pass), ),
            ))
Ejemplo n.º 5
0
    def runTest(self):
        # ARRANGE #
        valid_int_matcher_symbol = IntegerMatcherSymbolContext.of_arbitrary_value(
            'VALID_INT_MATCHER')

        for invalid_program_case in pgm_validation_cases.failing_validation_cases(
        ):
            all_symbols = list(invalid_program_case.value.symbol_contexts) + [
                valid_int_matcher_symbol
            ]
            directly_referenced_symbols = [
                invalid_program_case.value.program_symbol_context,
                valid_int_matcher_symbol
            ]
            with self.subTest(invalid_program_case.name):
                # ACT & ASSERT #
                CHECKER.check__abs_stx(
                    self,
                    InstructionArguments(
                        invalid_program_case.value.abstract_syntax,
                        valid_int_matcher_symbol.abstract_syntax,
                    ),
                    ArrangementPostAct2(
                        symbols=SymbolContext.symbol_table_of_contexts(
                            all_symbols), ),
                    Expectation2(
                        ParseExpectation(symbol_usages=SymbolContext.
                                         usages_assertion_of_contexts(
                                             directly_referenced_symbols), ),
                        ExecutionExpectation.
                        validation_corresponding_to__post_sds_as_hard_error(
                            invalid_program_case.value.actual, ),
                    ))
Ejemplo n.º 6
0
 def _arrangement(self, validator: DdvValidator) -> ArrangementPostAct2:
     return ArrangementPostAct2(symbols=FilesMatcherSymbolContext.of_sdv(
         self.name_of_referenced_symbol,
         sdv_ddv.sdv_from_bool(
             unconditional_result=True,
             validator=validator,
         )).symbol_table, )
Ejemplo n.º 7
0
    def _do_check(
        self,
        program: ProgramAbsStx,
        process_execution_w_stdin_check: ProcessExecutionArrangement,
        program_symbols: Sequence[SymbolContext],
        tcds_contents: tcds_populators.TcdsPopulator = tcds_populators.empty(),
    ):
        # ARRANGE #
        string_matcher_const_true = StringMatcherSymbolContext.of_primitive(
            'CONSTANT_TRUE',
            ConstantMatcherWithCustomName('const true', True),
        )
        symbols = list(program_symbols) + [string_matcher_const_true]
        copy_stdin_and_check_via_matcher = StdoutErrFromProgramAbsStx(
            program,
            string_matcher_const_true.abstract_syntax,
        )

        checker = instruction_check.Checker(self.configuration.parser())
        # ACT & ASSERT #
        checker.check__abs_stx__source_variants(
            self,
            copy_stdin_and_check_via_matcher,
            ArrangementPostAct2(
                symbols=SymbolContext.symbol_table_of_contexts(symbols),
                tcds=TcdsArrangementPostAct(tcds_contents=tcds_contents),
                process_execution=process_execution_w_stdin_check,
            ),
            MultiSourceExpectation(symbol_usages=SymbolContext.
                                   usages_assertion_of_contexts(symbols)),
        )
Ejemplo n.º 8
0
    def runTest(self):
        # ARRANGE #
        contents_of_stdin = 'the contents of stdin'
        string_matcher_that_checks_model = StringMatcherSymbolContext.of_primitive(
            'SM_THAT_CHECKS_MODEL',
            EqualsConstant(contents_of_stdin),
        )
        checker = instruction_check.Checker(self.configuration.parser())
        program_that_copies_stdin_to_output = ProgramOfPythonInterpreterAbsStx.of_execute_python_src_string(
            py_programs.copy_stdin_to__single_line(
                self.configuration.output_file()))
        copy_stdin_and_check_via_matcher = StdoutErrFromProgramAbsStx(
            FullProgramAbsStx(program_that_copies_stdin_to_output,
                              stdin=StringSourceOfStringAbsStx.of_str(
                                  contents_of_stdin, QuoteType.HARD)),
            string_matcher_that_checks_model.abstract_syntax,
        )

        # ACT & ASSERT #
        checker.check__abs_stx__source_variants(
            self,
            copy_stdin_and_check_via_matcher,
            ArrangementPostAct2(
                symbols=string_matcher_that_checks_model.symbol_table, ),
            MultiSourceExpectation(
                symbol_usages=string_matcher_that_checks_model.usages_assertion
            ),
        )
Ejemplo n.º 9
0
 def test_invalid_arguments_with_symbol_references(self):
     symbol_name = SymbolWithReferenceSyntax('symbol_name')
     operand_arg_with_symbol_ref_list = [
         IntegerMatcherComparisonAbsStx.of_cmp_op(
             comparators.EQ,
             StringSymbolAbsStx(symbol_name.name),
         ),
     ]
     invalid_symbol_values = [
         'not_a_number',
         '1.5',
         '72 87',
     ]
     for invalid_symbol_value in invalid_symbol_values:
         symbol = StringConstantSymbolContext(symbol_name.name,
                                              invalid_symbol_value)
         for operand_arg_with_symbol_ref in operand_arg_with_symbol_ref_list:
             full_syntax = self._conf().arguments_constructor.apply(
                 operand_arg_with_symbol_ref)
             with self.subTest(argument=full_syntax.as_str__default(),
                               invalid_symbol_value=invalid_symbol_value):
                 self._check(
                     full_syntax,
                     ArrangementPostAct2(symbols=symbol.symbol_table),
                     MultiSourceExpectation(
                         symbol_usages=asrt.matches_sequence([
                             symbol.
                             reference_assertion__string__w_all_indirect_refs_are_strings
                         ]),
                         execution=ExecutionExpectation(
                             validation_pre_sds=svh_asrt.
                             is_validation_error(), ),
                     ),
                 )
Ejemplo n.º 10
0
    def test_stdin_is_concatenation_of_string_sources_WHEN_program_defines_multiple_stdin(
            self):
        # ARRANGE #
        test_setup = MultipleStdinOfProgramTestSetup(self, exit_code=0)
        all_symbols = [
            test_setup.program_symbol, CONST_TRUE_INT_MATCHER_SYMBOL
        ]

        # ACT & ASSERT #
        CHECKER.check__abs_stx__source_variants(
            self,
            InstructionArguments(
                test_setup.program_w_stdin_syntax,
                CONST_TRUE_INT_MATCHER_SYMBOL.abstract_syntax,
            ),
            ArrangementPostAct2(
                symbols=SymbolContext.symbol_table_of_contexts(all_symbols),
                process_execution=test_setup.proc_exe_env__w_stdin_check,
            ),
            MultiSourceExpectation(
                symbol_usages=SymbolContext.usages_assertion_of_contexts(
                    all_symbols),
                execution=ExecutionExpectation(main_result=asrt_pfh.is_pass()),
            ),
        )
Ejemplo n.º 11
0
    def runTest(self):
        file_in_root = File.empty('file-in-root.txt')
        files_in_root_dir = [file_in_root]

        file_matcher_symbol = FileMatcherSymbolContext.of_primitive_constant(
            'FILE_MATCHER_SYMBOL',
            True,
        )

        file_matcher_cases = [
            NInpArr(
                'wo file matcher',
                None,
                (),
            ),
            NInpArr(
                'w file matcher',
                file_matcher_symbol.abstract_syntax,
                [file_matcher_symbol],
            ),
        ]
        relativity_cases = [
            rel_opt_conf.conf_rel_any(RelOptionType.REL_TMP),
            rel_opt_conf.conf_rel_any(RelOptionType.REL_HDS_CASE),
        ]

        for expectation_type in ExpectationType:
            for file_matcher_case in file_matcher_cases:
                for rel_conf in relativity_cases:
                    with self.subTest(relativity=rel_conf.relativity,
                                      file_matcher=file_matcher_case.name,
                                      expectation_type=expectation_type):
                        CHECKER.check__abs_stx__source_variants(
                            self,
                            InstructionArguments(
                                rel_conf.path_abs_stx_of_name__c([
                                    file_in_root.name,
                                    'path-to-check'
                                ]),
                                expectation_type=expectation_type,
                                file_matcher=file_matcher_case.input,
                            ),
                            ArrangementPostAct2(
                                symbols=SymbolContext.symbol_table_of_contexts(file_matcher_case.arrangement),
                                tcds=TcdsArrangementPostAct(
                                    tcds_contents=rel_conf.populator_for_relativity_option_root(
                                        DirContents(files_in_root_dir)
                                    )
                                )
                            ),
                            MultiSourceExpectation(
                                symbol_usages=SymbolContext.usages_assertion_of_contexts(file_matcher_case.arrangement),
                                execution=ExecutionExpectation(
                                    main_result=pfh_assertions.is_pass_of_fail(
                                        expectation_type is ExpectationType.NEGATIVE
                                    )
                                )
                            )
                        )
Ejemplo n.º 12
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,
                )
Ejemplo n.º 13
0
 def runTest(self):
     # ARRANGE #
     actual_file_name = 'actual'
     invalid_file_cases = [
         NameAndValue(
             'file does not exist',
             [],
         ),
         NameAndValue(
             'file is a dir',
             [Dir.empty(actual_file_name)],
         ),
         NameAndValue(
             'sym-link to dir',
             [
                 Dir.empty('a-dir'),
                 fs.sym_link(actual_file_name, 'a-dir')
             ],
         ),
         NameAndValue(
             'broken sym-link',
             [fs.sym_link(actual_file_name, 'non-existing-target')],
         ),
     ]
     for invalid_file_case in invalid_file_cases:
         for rel_conf in RELATIVITY_OPTION_CONFIGURATIONS_FOR_ACTUAL_FILE:
             with self.subTest(invalid_cause=invalid_file_case,
                               path_variant=rel_conf.name):
                 CHECKER.check__abs_stx__source_variants(
                     self,
                     InstructionArgumentsAbsStx(
                         rel_conf.path_abs_stx_of_name(actual_file_name),
                         EmptyAbsStx(),
                     ),
                     ArrangementPostAct2(
                         symbols=rel_conf.symbols.in_arrangement(),
                         tcds=TcdsArrangementPostAct(
                             tcds_contents=rel_conf.populator_for_relativity_option_root(
                                 DirContents(invalid_file_case.value)),
                             post_population_action=MK_SUB_DIR_OF_ACT_AND_MAKE_IT_CURRENT_DIRECTORY,
                         )
                     ),
                     MultiSourceExpectation(
                         symbol_usages=rel_conf.symbols.usages_expectation(),
                         execution=ExecutionExpectation.validation_corresponding_to_dsp__post_sds_as_hard_error(
                             rel_conf.directory_structure_partition,
                         )
                     ),
                 )
Ejemplo n.º 14
0
 def runTest(self):
     # ARRANGE #
     actual_file_name = 'actual'
     file_type_cases = [
         NameAndValue(
             'regular file',
             [fs.File.empty(actual_file_name)],
         ),
         NameAndValue(
             'sym-link to regular file',
             [
                 fs.File.empty('a-regular-file'),
                 fs.sym_link(actual_file_name, 'a-regular-file')
             ],
         ),
     ]
     for file_type_case in file_type_cases:
         for rel_conf in RELATIVITY_OPTION_CONFIGURATIONS_FOR_ACTUAL_FILE:
             for matcher_result in [False, True]:
                 matcher_symbol = StringMatcherSymbolContextOfPrimitiveConstant('STRING_MATCHER', matcher_result)
                 all_symbols = list(rel_conf.symbols.contexts_for_arrangement()) + [matcher_symbol]
                 with self.subTest(file_type=file_type_case,
                                   path_variant=rel_conf.name,
                                   matcher_result=matcher_result):
                     CHECKER.check__abs_stx__source_variants(
                         self,
                         InstructionArgumentsAbsStx(
                             rel_conf.path_abs_stx_of_name(actual_file_name),
                             matcher_symbol.abstract_syntax,
                         ),
                         ArrangementPostAct2(
                             symbols=SymbolContext.symbol_table_of_contexts(all_symbols),
                             tcds=TcdsArrangementPostAct(
                                 tcds_contents=rel_conf.populator_for_relativity_option_root(
                                     DirContents(file_type_case.value)),
                                 post_population_action=MK_SUB_DIR_OF_ACT_AND_MAKE_IT_CURRENT_DIRECTORY,
                             )
                         ),
                         MultiSourceExpectation(
                             symbol_usages=SymbolContext.usages_assertion_of_contexts(all_symbols),
                             execution=ExecutionExpectation(
                                 main_result=asrt_pfh.is_pass_of_fail(matcher_symbol.result_value)
                             )
                         ),
                     )
Ejemplo n.º 15
0
 def runTest(self):
     test_setup = test_setups__proc_exe_set.TimeoutTestSetup(
         self, expected_timeout=72)
     # ACT & ASSERT #
     CHECKER.check__abs_stx(
         self,
         InstructionArguments(
             test_setup.valid_program_wo_sym_refs(),
             CONST_TRUE_INT_MATCHER_SYMBOL.abstract_syntax,
         ),
         ArrangementPostAct2(
             symbols=CONST_TRUE_INT_MATCHER_SYMBOL.symbol_table,
             process_execution=test_setup.proc_exe_arr__w_settings_check,
         ),
         Expectation2(
             ParseExpectation(symbol_usages=CONST_TRUE_INT_MATCHER_SYMBOL.
                              usages_assertion),
             ExecutionExpectation(main_result=asrt_pfh.is_pass()),
         ))
Ejemplo n.º 16
0
class ExecutorOfCaseGeneratorForDirContents(ExecutorOfCaseGenerator):
    def execute_single(
        self,
        put: unittest.TestCase,
        case: SingleCaseGenerator,
    ):
        INSTRUCTION_CHECKER.check_2(
            put,
            source=_arguments(
                case.model_file,
                case.arguments(),
            ).as_remaining_source,
            arrangement=ArrangementPostAct2(
                tcds=_mk_tcds_arrangement_post_act(case.tcds_arrangement()),
                symbols=case.symbols(put),
            ),
            expectation=Expectation2(
                ParseExpectation(symbol_usages=_symbol_usages_assertion(
                    case.expected_symbols())),
                _execution_expectation_of(case.execution_result())))
Ejemplo n.º 17
0
 def test_invalid_arguments_without_symbol_references(self):
     test_cases = [
         IntegerMatcherComparisonAbsStx.of_cmp_op__str(comparators.EQ, 'a'),
         IntegerMatcherComparisonAbsStx.of_cmp_op__str(
             comparators.GT, '1.5'),
     ]
     for condition_syntax in test_cases:
         with self.subTest(condition_syntax.as_str__default()):
             instr_arg = self._conf().arguments_constructor.apply(
                 condition_syntax)
             self._check(
                 instr_arg,
                 ArrangementPostAct2(),
                 MultiSourceExpectation(
                     symbol_usages=asrt.is_empty_sequence,
                     execution=ExecutionExpectation(
                         validation_pre_sds=svh_asrt.is_validation_error(),
                     ),
                 ),
             )
Ejemplo n.º 18
0
 def runTest(self):
     # ARRANGE #
     test_setup = StdinCheckWithProgramWExitCode0ForSuccess()
     # ACT & ASSERT #
     CHECKER.check__abs_stx(
         self,
         InstructionArguments(
             test_setup.program_that_checks_stdin__syntax(
                 'the contents of stdin'),
             CONST_TRUE_INT_MATCHER_SYMBOL.abstract_syntax,
         ),
         ArrangementPostAct2(
             symbols=CONST_TRUE_INT_MATCHER_SYMBOL.symbol_table,
             tcds=TcdsArrangementPostAct(
                 tcds_contents=test_setup.tcds_contents, )),
         Expectation2(
             ParseExpectation(symbol_usages=CONST_TRUE_INT_MATCHER_SYMBOL.
                              usages_assertion, ),
             execution=ExecutionExpectation(main_result=asrt_pfh.is_pass()),
         ),
     )
 def runTest(self):
     # ARRANGE #
     program_symbol = ProgramSymbolContext.of_arbitrary_value('PROGRAM_SYMBOL')
     const_true_int_matcher_symbol = IntegerMatcherSymbolContext.of_primitive_constant(
         'CONST_TRUE_INT_MATCHER',
         result=True,
     )
     all_symbols = [program_symbol,
                    const_true_int_matcher_symbol,
                    ]
     hard_error_message = 'the err msg'
     # ACT & ASSERT #
     CHECKER.check__abs_stx(
         self,
         InstructionArguments(
             program_symbol.abstract_syntax,
             const_true_int_matcher_symbol.abstract_syntax,
         ),
         ArrangementPostAct2(
             symbols=SymbolContext.symbol_table_of_contexts(all_symbols),
             process_execution=ProcessExecutionArrangement(
                 os_services_access.new_for_cmd_exe(
                     CommandExecutorThatRaisesHardError(
                         asrt_text_doc.new_single_string_text_for_test(hard_error_message)
                     ),
                 ),
             ),
         ),
         Expectation2(
             ParseExpectation(
                 symbol_usages=SymbolContext.usages_assertion_of_contexts(all_symbols),
             ),
             ExecutionExpectation(
                 main_result=asrt_pfh.is_hard_error(
                     asrt_text_doc.is_string_for_test_that_equals(hard_error_message)
                 )
             ),
         )
     )
Ejemplo n.º 20
0
 def runTest(self):
     # ARRANGE #
     program_symbol = ProgramSymbolContext.of_arbitrary_value(
         'PROGRAM_SYMBOL')
     const_true_int_matcher_symbol = IntegerMatcherSymbolContext.of_primitive_constant(
         'CONST_TRUE_INT_MATCHER',
         result=True,
     )
     string_transformer_that_reports_failure_if_applied = StringTransformerSymbolContext.of_primitive(
         'STRING_TRANSFORMER_THAT_MUST_NOT_BE_USED',
         StringTransformerThatFailsTestIfApplied(self))
     all_symbols = [
         program_symbol,
         string_transformer_that_reports_failure_if_applied,
         const_true_int_matcher_symbol,
     ]
     # ACT & ASSERT #
     CHECKER.check__abs_stx(
         self,
         InstructionArguments(
             FullProgramAbsStx(
                 program_symbol.abstract_syntax,
                 transformation=
                 string_transformer_that_reports_failure_if_applied.
                 abstract_syntax),
             const_true_int_matcher_symbol.abstract_syntax,
         ),
         ArrangementPostAct2(
             symbols=SymbolContext.symbol_table_of_contexts(all_symbols),
             process_execution=ProcessExecutionArrangement(
                 os_services_access.new_for_cmd_exe(
                     CommandExecutorThatJustReturnsConstant(1), ), ),
         ),
         Expectation2(
             ParseExpectation(
                 symbol_usages=SymbolContext.usages_assertion_of_contexts(
                     all_symbols), ),
             ExecutionExpectation(main_result=asrt_pfh.is_pass()),
         ))
Ejemplo n.º 21
0
 def execute_multi(self, put: unittest.TestCase,
                   generator: MultipleExecutionCasesGenerator):
     INSTRUCTION_CHECKER.check_multi(
         put,
         source=SourceArrangement.new_w_arbitrary_fs_location(
             _arguments(generator.model_file,
                        generator.arguments()).as_arguments),
         parse_expectation=ParseExpectation(
             symbol_usages=_symbol_usages_assertion(
                 generator.expected_symbols())),
         execution=[
             NExArr(
                 case.name,
                 _execution_expectation_of(case.expected),
                 ArrangementPostAct2(
                     tcds=_mk_tcds_arrangement_post_act(
                         case.arrangement.tcds),
                     symbols=case.arrangement.symbols,
                 ),
             ) for case in generator.execution_cases()
         ],
     )
Ejemplo n.º 22
0
 def runTest(self):
     test_cases = [
         (_actual_exitcode(0), of_op(EQ, 72), IS_FAIL),
         (_actual_exitcode(72), of_op(EQ, 72), IS_PASS),
         (_actual_exitcode(72), of_neg_op(EQ, 72), IS_FAIL),
         (_actual_exitcode(72), of_neg_op(EQ, 73), IS_PASS),
         (_actual_exitcode(72), of_op(NE, 72), IS_FAIL),
         (_actual_exitcode(72), of_op(NE, 73), IS_PASS),
         (_actual_exitcode(72), of_op(LT, 28), IS_FAIL),
         (_actual_exitcode(72), of_op(LT, 72), IS_FAIL),
         (_actual_exitcode(72), of_op(LT, 87), IS_PASS),
     ]
     for program_syntax, matcher_syntax, expectation in test_cases:
         instruction_syntax = InstructionArguments(
             program_syntax,
             matcher_syntax,
         )
         with self.subTest(instruction_syntax.as_str__default()):
             CHECKER.check__abs_stx__source_variants(
                 self,
                 instruction_syntax,
                 ArrangementPostAct2(),
                 expectation,
             )
Ejemplo n.º 23
0
 def _arrangement(self,
                  tcds: TcdsArrangementPostAct) -> ArrangementPostAct2:
     return ArrangementPostAct2(
         symbols=self.symbols(),
         tcds=tcds,
     )
Ejemplo n.º 24
0
            SourceArrangement.new_w_arbitrary_fs_location(
                arguments.as_arguments),
            ParseExpectation(symbol_usages=asrt.matches_singleton_sequence(
                is_reference_to_files_matcher__usage(
                    model_checker_symbol_name))),
            execution=[
                NExArr(
                    contents_case.name,
                    ExecutionExpectation(),
                    ArrangementPostAct2(
                        tcds=TcdsArrangementPostAct(
                            tcds_contents=tcds_populators.
                            TcdsPopulatorForRelOptionType(
                                checked_dir_location,
                                DirContents([
                                    Dir(checked_dir_name, contents_case.actual)
                                ]))),
                        symbols=SymbolTable({
                            model_checker_symbol_name:
                            model_checker.matcher__sym_tbl_container(
                                self, checked_dir_path, contents_case.expected)
                        })),
                ) for contents_case in contents_cases
            ],
        )


class TestMultiLineSyntax(unittest.TestCase):
    def runTest(self):
        # ARRANGE #