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')
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, ), ))
def runTest(self): # ARRANGE # program_symbol = ProgramSymbolContext.of_arbitrary_value( 'PROGRAM_SYMBOL') executor_that_do_not_run_any_program = CommandExecutorThatJustReturnsConstant( 0) for may_depend_on_external_resources in [False, True]: for with_ignored_exit_code in [False, True]: with self.subTest( with_ignored_exit_code=with_ignored_exit_code, may_depend_on_external_resources= may_depend_on_external_resources): # ACT && ASSERT # pass integration_check.CHECKER__PARSE_SIMPLE.check( self, args.syntax_for_run( program_args.symbol_ref_command_elements( program_symbol.name), ignore_exit_code=with_ignored_exit_code, ).as_remaining_source, model_constructor.empty(self, may_depend_on_external_resources= may_depend_on_external_resources), arrangement_w_tcds( symbols=program_symbol.symbol_table, process_execution=ProcessExecutionArrangement( os_services=os_services_access.new_for_cmd_exe( executor_that_do_not_run_any_program)), ), Expectation( ParseExpectation(symbol_references=program_symbol. references_assertion, ), ExecutionExpectation( main_result=asrt_string_source. pre_post_freeze__matches_lines( asrt.anything_goes(), may_depend_on_external_resources=asrt.equals( True), frozen_may_depend_on_external_resources=asrt. anything_goes(), )), prim_asrt__constant( asrt_string_transformer.is_identity_transformer( False)), ), )
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()), ))
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) ) ), ) )