From 50cc4323fd276ce388ca9986e46bb9056c49d02a Mon Sep 17 00:00:00 2001 From: Jasper den Ouden Date: Sun, 13 Mar 2022 15:12:22 +0100 Subject: [PATCH] Partial fix intersection test. Float needs work --- test/sets/intersection.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/sets/intersection.py b/test/sets/intersection.py index 0aa2e20..bfe3c3b 100644 --- a/test/sets/intersection.py +++ b/test/sets/intersection.py @@ -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. -- 2.38.5