class TestModelWNumLines10(unittest.TestCase): INPUT = ['{}\n'.format(n + 1) for n in range(10)] _SINGLE_NEG__MIDDLE = ArrEx(single(-5), [6]) _SINGLE_NEG__FIRST = ArrEx(single(-10), [1]) _TO_NEG = ArrEx(to_(-2), _int_list(1, 9)) _TO_POS = ArrEx(to_(4), _int_list(1, 4)) _TO_AFTER_MAX = ArrEx(to_(10 + 1), _int_list(1, 10)) _FROM_NEG = ArrEx(from_(-3), _int_list(8, 10)) _FROM_POS = ArrEx(from_(7), _int_list(7, 10)) _FROM_MAX = ArrEx(from_(10), [10]) _FROM_AFTER_MAX = ArrEx(from_(10 + 1), []) _FROM_TO__2_3 = ArrEx(from_to(2, 3), _int_list(2, 3)) _FROM_TO_NEG_NEG = ArrEx(from_to(-3, -2), _int_list(8, 9)) _FROM_TO_NEG_POS = ArrEx(from_to(-9, 3), _int_list(2, 3)) _FROM_TO_POS_NEG = ArrEx(from_to(7, -4), [7]) _FROM_TO_POS_POS = ArrEx(from_to(10, 12), [10]) RANGES_CASES = [ [_TO_NEG, _TO_POS], [_FROM_NEG, _FROM_POS], [_FROM_NEG, _TO_AFTER_MAX], [_FROM_TO_NEG_NEG, _FROM_TO_POS_NEG], [_FROM_TO_POS_POS, _FROM_TO_NEG_POS], [ _TO_NEG, _FROM_POS, _FROM_TO_NEG_POS, _FROM_TO_NEG_POS, _FROM_TO_POS_POS ], [_SINGLE_NEG__MIDDLE, _SINGLE_NEG__FIRST], ] CASES = [_case_of(case) for case in RANGES_CASES]
def _check_int_arg__wo_max_lines_from_iter( put: unittest.TestCase, range_expr: int, input_and_expected: InputAndExpected, ): _integration_check.check__w_max_as_lines_invocations__wo_max_lines_from_iter( put, [ranges.to_(range_expr).as_arg], input_and_expected)
def argument_cases(self) -> List[str]: return [ args.filter_line_nums(ranges.single(7).as_arg).as_str, args.filter_line_nums(ranges.single(-7).as_arg).as_str, args.filter_line_nums(ranges.to_(5).as_arg).as_str, args.filter_line_nums(ranges.to_(-5).as_arg).as_str, args.filter_line_nums(ranges.from_(5).as_arg).as_str, args.filter_line_nums(ranges.from_(-5).as_arg).as_str, args.filter_line_nums(ranges.from_to(5, 6).as_arg).as_str, args.filter_line_nums(ranges.from_to(-8, 8).as_arg).as_str, args.filter_line_nums(ranges.from_to(2, -2).as_arg).as_str, args.filter_line_nums(ranges.from_to(-5, -3).as_arg).as_str, args.filter_line_nums__multi( [ranges.single(5).as_arg, ranges.single(6).as_arg]).as_str, args.filter_line_nums__multi( [ranges.single(-5).as_arg, ranges.single(-6).as_arg]).as_str, ]
def _check_int_arg__w_access_of_all_model_properties( put: unittest.TestCase, range_expr: int, input_and_expected: InputAndExpected, ): the_range = ranges.to_(range_expr) _integration_check.check__w_access_of_all_model_properties( put, [the_range.as_arg], inp_exp__w_ext_deps(input_and_expected, the_range), )
def _check_int_arg__w_max_lines_from_iter( put: unittest.TestCase, arg: int, input_and_expected: InputAndExpected, ): return _integration_check.check__w_max_lines_from_iter( put, [ranges.to_(arg).as_arg], arg, input_and_expected, )
class TestModelWNumLines1(unittest.TestCase): INPUT = ['1\n'] _SINGLE_NEG__1 = ArrEx(single(-1), [1]) _SINGLE_NEG__BEFORE = ArrEx(single(-2 - 1), []) _TO_NEG__BEFORE = ArrEx(to_(-2), []) _TO_NEG__1 = ArrEx(to_(-1), [1]) _TO_POS__AFTER = ArrEx(to_(2), [1]) _FROM_NEG__BEFORE = ArrEx(from_(-2), [1]) _FROM_NEG__1 = ArrEx(from_(-1), [1]) _FROM_POS__AFTER = ArrEx(from_(2), []) _FROM_TO__m1_m1 = ArrEx(from_to(-1, -1), [1]) _FROM_TO__m2_m1 = ArrEx(from_to(-2, -1), [1]) _FROM_TO__m1_2 = ArrEx(from_to(-1, 2), [1]) RANGES_CASES = [ [_SINGLE_NEG__1, _SINGLE_NEG__BEFORE], [_TO_NEG__BEFORE, _TO_NEG__BEFORE], [_TO_NEG__BEFORE, _TO_NEG__1], [_TO_NEG__BEFORE, _TO_POS__AFTER], [_FROM_NEG__BEFORE, _FROM_NEG__BEFORE], [_FROM_NEG__BEFORE, _FROM_NEG__1], [_FROM_NEG__BEFORE, _FROM_POS__AFTER], [_FROM_TO__m1_m1, _FROM_TO__m1_m1], [_FROM_TO__m1_m1, _FROM_TO__m1_2], [_FROM_TO__m2_m1, _FROM_TO__m1_2], [_SINGLE_NEG__1, _FROM_TO__m2_m1], [_SINGLE_NEG__1, _FROM_TO__m2_m1], [_SINGLE_NEG__BEFORE, _FROM_POS__AFTER], [_TO_NEG__BEFORE, _FROM_TO__m1_2, _SINGLE_NEG__1, _FROM_POS__AFTER], ] CASES = [_case_of(case) for case in RANGES_CASES]
class TestModelWNumLines0(unittest.TestCase): INPUT = [] RANGES_CASES = [ [to_(-2), to_(3)], [to_(-2), to_(-3)], [to_(-2), from_(2)], [to_(-2), from_(-2)], [to_(-3), from_to(2, -2)], [from_(-3), from_to(2, -2)], [from_(3), from_to(-4, -2)], [from_(3), from_to(2, 5)], ] def test_with_model_access__only_as_lines_is_used(self): checker = CheckerOfConstInput( self, self.INPUT, max_as_lines_invocations__when_only_checking_via_as_lines=2, ) for ranges in self.RANGES_CASES: with self.subTest([str(r) for r in ranges]): checker.check__wo_max_lines_from_iter( ranges, [], ) def test_with_model_access__check_all_model_properties(self): checker = CheckerOfConstInput( self, self.INPUT, max_as_lines_invocations__when_only_checking_via_as_lines=2, ) for ranges in self.RANGES_CASES: with self.subTest([str(r) for r in ranges]): checker.check__w_access_of_all_model_properties( ranges, [], )
model_constructor.of_lines(self, input_lines, may_depend_on_external_resources=False), arrangement_w_tcds( symbols=SymbolContext.symbol_table_of_contexts(symbols), ), integration_check.expectation_of_successful_execution_2( symbol_references=SymbolContext. references_assertion_of_contexts(symbols), output_lines=expected_output_lines, may_depend_on_external_resources=False, is_identity_transformer=False, )) CASES__HEAD = [ Case.w_upper_limit('two head, max=1', [to_(1), to_(1)], lines_in_ranges__increasing=[1]), Case.w_upper_limit('two head, max=5', [to_(4), to_(5)], lines_in_ranges__increasing=[1, 2, 3, 4, 5]), Case.w_upper_limit('two head, max=9', [to_(4), to_(9)], lines_in_ranges__increasing=[1, 2, 3, 4, 5, 6, 7, 8, 9]), Case.w_upper_limit( 'two head, max=10', [to_(4), to_(10)], lines_in_ranges__increasing=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), Case.w_upper_limit( 'two head, max=11', [to_(4), to_(11)], lines_in_ranges__increasing=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), Case.w_upper_limit( 'two head, max=12', [to_(4), to_(12)], lines_in_ranges__increasing=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),