예제 #1
0
 def runTest(self):
     _check_single(
         self,
         sut.UpperLimit(-5),
         matches_upper_limit(-5),
         matches_lower_limit(-5 + 1),
     )
예제 #2
0
 def runTest(self):
     _check_single(
         self,
         sut.WithCustomInversion(
             int_interval.point(5),
             int_interval.upper_limit(12)
         ),
         matches_point(5),
         matches_upper_limit(12),
     )
예제 #3
0
 def runTest(self):
     _check_adaption_variant_cases(
         self,
         interval_of_unknown_class=UpperLimit(100),
         cases=[
             CaseWAdaptionVariants('wo interval', _matcher_wo_interval(), [
                 _without_adaption(_equals_interval(UpperLimit(100))),
                 _w_max_upper_adaption(
                     50, asrt_interval.matches_upper_limit(50)),
             ]),
         ],
     )
예제 #4
0
 def runTest(self):
     self._check_cases([
         NArrEx('equals (within line-num-range)',
                im_args.comparison2(comparators.EQ, 2),
                asrt_interval.matches_point(2)),
         NArrEx('equals (outside line-num-range)',
                im_args.comparison2(comparators.EQ, -2),
                asrt_interval.matches_empty()),
         NArrEx('greater-than (within line-num-range)',
                im_args.comparison2(comparators.GT, 7),
                asrt_interval.matches_lower_limit(7 + 1)),
         NArrEx('greater-than (outside line-num-range)',
                im_args.comparison2(comparators.GTE, -7),
                asrt_interval.matches_unlimited()),
         NArrEx('greater-than-eq (FIRST-LINE-NUMBER)',
                im_args.comparison2(comparators.GTE, FIRST_LINE_NUMBER),
                asrt_interval.matches_unlimited()),
         NArrEx(
             'greater-than && less-than (within line-num-range)',
             arg_rend.within_paren(
                 arg_rend.conjunction([
                     im_args.comparison2(comparators.GT, 7),
                     im_args.comparison2(comparators.LTE, 12),
                 ])), asrt_interval.matches_finite(7 + 1, 12)),
         NArrEx(
             'greater-than && less-than (outside line-num-range)',
             arg_rend.within_paren(
                 arg_rend.conjunction([
                     im_args.comparison2(comparators.GT, -7),
                     im_args.comparison2(comparators.LTE, 12),
                 ])), asrt_interval.matches_upper_limit(12)),
         NArrEx('constant False', arg_rend.constant(False),
                asrt_interval.matches_empty()),
         NArrEx('constant False', arg_rend.constant(True),
                asrt_interval.matches_unlimited()),
     ])
예제 #5
0
 def runTest(self):
     _check_single(
         self,
         sut.upper_limit(-5),
         matches_upper_limit(-5),
     )
예제 #6
0
 def runTest(self):
     self._check_cases([
         NArrEx(
             '! >= (within line-num-range)',
             arg_rend.negation(
                 args.LineNum2(im_args.comparison2(comparators.GTE, 4))),
             asrt_interval.matches_upper_limit(4 - 1)),
         NArrEx(
             '! >= (outside line-num-range)',
             arg_rend.negation(
                 args.LineNum2(
                     im_args.comparison2(comparators.LTE,
                                         FIRST_LINE_NUMBER - 1))),
             asrt_interval.matches_unlimited()),
         NArrEx('negation contents',
                arg_rend.negation(args.Contents(sm_args.Empty())),
                asrt_interval.matches_unlimited()),
         NArrEx('negation constant False',
                arg_rend.negation(arg_rend.constant(False)),
                asrt_interval.matches_unlimited()),
         NArrEx('negation constant True',
                arg_rend.negation(arg_rend.constant(True)),
                asrt_interval.matches_empty()),
         NArrEx(
             '> && <= (within line-num-range)',
             arg_rend.within_paren(
                 arg_rend.conjunction([
                     args.LineNum2(im_args.comparison2(comparators.GT, 7)),
                     args.LineNum2(im_args.comparison2(comparators.LTE,
                                                       12)),
                 ])), asrt_interval.matches_finite(7 + 1, 12)),
         NArrEx(
             '> && contents (within line-num-range)',
             arg_rend.within_paren(
                 arg_rend.conjunction([
                     args.LineNum2(im_args.comparison2(comparators.GT, 7)),
                     args.Contents(sm_args.Empty()),
                 ])), asrt_interval.matches_lower_limit(7 + 1)),
         NArrEx(
             'contents && contents',
             arg_rend.within_paren(
                 arg_rend.conjunction([
                     args.Contents(sm_args.Empty()),
                     args.Contents(sm_args.Empty()),
                 ])), asrt_interval.matches_unlimited()),
         NArrEx(
             '> && <= (partly outside line-num-range)',
             arg_rend.within_paren(
                 arg_rend.conjunction([
                     args.LineNum2(im_args.comparison2(comparators.GT, -7)),
                     args.LineNum2(im_args.comparison2(comparators.LTE,
                                                       12)),
                 ])), asrt_interval.matches_upper_limit(12)),
         NArrEx(
             '> && <= (completely outside line-num-range)',
             arg_rend.within_paren(
                 arg_rend.conjunction([
                     args.LineNum2(im_args.comparison2(comparators.GT, -7)),
                     args.LineNum2(im_args.comparison2(comparators.LTE,
                                                       -2)),
                 ])), asrt_interval.matches_empty()),
         NArrEx(
             '> && <= && <= (outside line-num-range)',
             arg_rend.within_paren(
                 arg_rend.conjunction([
                     args.LineNum2(im_args.comparison2(comparators.GT, -7)),
                     args.LineNum2(im_args.comparison2(comparators.LTE,
                                                       12)),
                     args.LineNum2(im_args.comparison2(comparators.LTE,
                                                       15)),
                 ])), asrt_interval.matches_upper_limit(12)),
         NArrEx(
             '== || <= (within line-num-range)',
             arg_rend.within_paren(
                 arg_rend.disjunction([
                     args.LineNum2(im_args.comparison2(comparators.EQ, 17)),
                     args.LineNum2(im_args.comparison2(comparators.LTE,
                                                       10)),
                 ])), asrt_interval.matches_upper_limit(17)),
         NArrEx(
             '== || contents (within line-num-range)',
             arg_rend.within_paren(
                 arg_rend.disjunction([
                     args.LineNum2(im_args.comparison2(comparators.EQ, 17)),
                     args.Contents(sm_args.Empty()),
                 ])), asrt_interval.matches_unlimited()),
         NArrEx(
             'contents || contents',
             arg_rend.within_paren(
                 arg_rend.disjunction([
                     args.Contents(sm_args.Empty()),
                     args.Contents(sm_args.Empty()),
                 ])), asrt_interval.matches_unlimited()),
         NArrEx(
             '> || == (outside line-num-range)',
             arg_rend.within_paren(
                 arg_rend.disjunction([
                     args.LineNum2(im_args.comparison2(comparators.GT, 5)),
                     args.LineNum2(im_args.comparison2(comparators.EQ,
                                                       -12)),
                 ])), asrt_interval.matches_lower_limit(5 + 1)),
         NArrEx(
             '< || <= (completely outside line-num-range)',
             arg_rend.within_paren(
                 arg_rend.disjunction([
                     args.LineNum2(im_args.comparison2(comparators.LT, -5)),
                     args.LineNum2(im_args.comparison2(comparators.LTE,
                                                       -3)),
                 ])), asrt_interval.matches_empty()),
         NArrEx(
             '<= || > || == (outside line-num-range)',
             arg_rend.within_paren(
                 arg_rend.disjunction([
                     args.LineNum2(im_args.comparison2(comparators.LTE, 0)),
                     args.LineNum2(im_args.comparison2(comparators.GT, 5)),
                     args.LineNum2(im_args.comparison2(comparators.EQ, 3)),
                 ])), asrt_interval.matches_lower_limit(3)),
         NArrEx(
             '<= || contents || == (within line-num-range)',
             arg_rend.within_paren(
                 arg_rend.disjunction([
                     args.LineNum2(im_args.comparison2(comparators.LTE,
                                                       12)),
                     args.Contents(sm_args.Empty()),
                     args.LineNum2(im_args.comparison2(comparators.EQ, 15)),
                 ])), asrt_interval.matches_unlimited()),
     ])
예제 #7
0
 def test__unknown_class_is_unlimited_w_unlimited_negation(self):
     _check_adaption_variant_cases(
         self,
         interval_of_unknown_class=unlimited_with_unlimited_inversion(),
         cases=[
             CaseWAdaptionVariants(
                 'two operands',
                 Disjunction([
                     _MatcherWInterval(Finite(-72, 69 + 5)),
                     _MatcherWInterval(Finite(-72 - 9, 69)),
                 ]),
                 [
                     _without_adaption(
                         _equals_interval(Finite(-72 - 9, 69 + 5))),
                     _w_max_upper_adaption(
                         50, asrt_interval.matches_finite(-72 - 9, 50))
                 ],
             ),
             CaseWAdaptionVariants(
                 'two operands, one wo interval',
                 Disjunction([
                     _MatcherWInterval(Finite(-72, 69 + 5)),
                     _matcher_wo_interval(),
                 ]),
                 [
                     _without_adaption(_equals_interval(Unlimited())),
                     _w_max_upper_adaption(
                         50, asrt_interval.matches_upper_limit(50))
                 ],
             ),
             CaseWAdaptionVariants(
                 'two operands, all wo interval',
                 Disjunction([
                     _matcher_wo_interval(),
                     _matcher_wo_interval(),
                 ]),
                 [
                     _without_adaption(_equals_interval(Unlimited())),
                     _w_max_upper_adaption(
                         50, asrt_interval.matches_upper_limit(50))
                 ],
             ),
             CaseWAdaptionVariants(
                 'three operands',
                 Disjunction([
                     _MatcherWInterval(LowerLimit(-3)),
                     _MatcherWInterval(LowerLimit(-11)),
                     _MatcherWInterval(LowerLimit(-7)),
                 ]),
                 [
                     _without_adaption(_equals_interval(LowerLimit(-11))),
                     _w_max_upper_adaption(
                         50, asrt_interval.matches_finite(-11, 50))
                 ],
             ),
             CaseWAdaptionVariants(
                 'three operands, one wo interval',
                 Disjunction([
                     _MatcherWInterval(LowerLimit(-3)),
                     _matcher_wo_interval(),
                     _MatcherWInterval(LowerLimit(-7)),
                 ]),
                 [
                     _without_adaption(_equals_interval(Unlimited())),
                     _w_max_upper_adaption(
                         50, asrt_interval.matches_upper_limit(50))
                 ],
             ),
         ])
예제 #8
0
 def test__unknown_class_is_limited(self):
     _check_adaption_variant_cases(
         self,
         interval_of_unknown_class=UpperLimit(100),
         cases=[
             CaseWAdaptionVariants(
                 'two operands',
                 Conjunction([
                     _MatcherWInterval(Finite(-72, 69 + 5)),
                     _MatcherWInterval(Finite(-72 - 9, 69)),
                 ]),
                 [
                     _without_adaption(_equals_interval(Finite(-72, 69))),
                     _w_max_upper_adaption(
                         50, asrt_interval.matches_finite(-72, 50)),
                 ],
             ),
             CaseWAdaptionVariants(
                 'two operands, one wo interval',
                 Conjunction([
                     _MatcherWInterval(Finite(-70, 200)),
                     _matcher_wo_interval(),
                 ]),
                 [
                     _without_adaption(
                         asrt_interval.matches_finite(-70, 100)),
                     _w_max_upper_adaption(
                         50, asrt_interval.matches_finite(-70, 50)),
                 ],
             ),
             CaseWAdaptionVariants(
                 'two operands, all wo interval',
                 Conjunction([
                     _matcher_wo_interval(),
                     _matcher_wo_interval(),
                 ]),
                 [
                     _without_adaption(
                         asrt_interval.matches_upper_limit(100)),
                     _w_max_upper_adaption(
                         200, asrt_interval.matches_upper_limit(100)),
                 ],
             ),
             CaseWAdaptionVariants(
                 'three operands',
                 Conjunction([
                     _MatcherWInterval(LowerLimit(-3)),
                     _MatcherWInterval(LowerLimit(-11)),
                     _MatcherWInterval(LowerLimit(-7)),
                 ]),
                 [
                     _without_adaption(_equals_interval(LowerLimit(-3))),
                     _w_max_upper_adaption(
                         50, asrt_interval.matches_finite(-3, 50)),
                 ],
             ),
             CaseWAdaptionVariants(
                 'three operands, one wo interval',
                 Conjunction([
                     _MatcherWInterval(LowerLimit(-3)),
                     _matcher_wo_interval(),
                     _MatcherWInterval(LowerLimit(-7)),
                 ]),
                 [
                     _without_adaption(_equals_interval(Finite(-3, 100))),
                     _w_max_upper_adaption(
                         50, asrt_interval.matches_finite(-3, 50)),
                 ],
             ),
         ])