~jasper/type_stack_calc

50cc4323fd276ce388ca9986e46bb9056c49d02a — Jasper den Ouden 1 year, 6 months ago 0df63d4 develop main
Partial fix intersection test. Float needs work
1 files changed, 11 insertions(+), 11 deletions(-)

M test/sets/intersection.py
M test/sets/intersection.py => test/sets/intersection.py +11 -11
@@ 1,23 1,21 @@

# Tests specific values of intersection.

from type_stack_calc.sets.range import SetRange as r, big
from type_stack_calc.sets.stepping import SetStepping as s
from type_stack_calc.sets.intersection import SetIntersection as si
from type_stack_calc.sets.empty import the_empty
from type_stack_calc.sets.empty import the_empty, Empty
from type_stack_calc.sets.bool import SetBool as b
rm = r(0,0).from_members

from type_stack_calc.util.fun_info import fun_info

# Jumps over expect empty.

def is_empty(x):
    assert x.tkey == ('empty',), (x, x.tkey)
# Reduces to single value.

assert si(r(2,6), s(0,5)) == si(r(5,5))

is_empty(si(r(10, 12), s(2,20))[0])
is_empty(si(r(-10, 10), s(-11,30))[0])
assert len(si(r(10, 12), s(2,20))) == 0
assert len(si(r(-10, 10), s(-11,30))) == 0

assert len(si(r(0,20), s(0,1))) == 2



@@ 35,7 33,7 @@ def check(a, b, *what, commute=None):
                else a.get_param_final(name)(b, a))
            assert got == eq, f"\n\n{b} {name} {a}:\n. shouldbe:{eq} vs {got} (commuted)"

is_empty(s(0, 30).set_intersect(r(1,10)))
assert isinstance(s(0, 30).set_intersect(r(1,10)), Empty)

# Range & set versus constant.
check([r(0,10), s(0,1)], [r(3,3)],


@@ 77,9 75,11 @@ check([r(0,10), s(0, 2)], [r(5,20), s(0,3)], # NOTE: second reduces to (5,18 bef
      (':set_union', [s(0,1), r(0,18)]), commute=True)

# There are problems if extra implicit stuff?
check([r(0, 20), s(0,1)], [s(0,1)], (':set_union', [r(-big,big), s(0,1)]),
       commute=True)
check([r(0, 20)], [s(0,1)], (':set_union', [r(-big,big)]),
check([r(0, 20), s(0,1)], [r(-big,big), s(0,1)],
      (':set_union', [r(-big,big), s(0,1)]),
      commute=True)
# TODO test float more.
# check([r(0, 20)], [r(-big,big), s(0,1)], (':set_union', [r(-big,big)]),
#      commute=True)

# TODO add more.