from match import ThreeWayMatchOperator def tryOrAssert(fn, output, error=False): try: return (fn() == output) except: return error def test1(): r1 = range(0,10) r2 = range(0,10,3) r3 = range(0,10,2) t = ThreeWayMatchOperator((r1,r2,r3)) values = set([v[0] for v in t]) return values def test2(): r1 = range(0,12) r2 = range(0,10,3) r3 = range(0,10,2) t = ThreeWayMatchOperator((r1,r2,r3)) values = set([v[0] for v in t]) return values def test3(): r1 = range(0) r2 = range(0) r3 = range(0) t = ThreeWayMatchOperator((r1,r2,r3)) values = set([v[0] for v in t]) return values def test4(): r1 = range(0,1) r2 = range(0,1) r3 = range(0,1) t = ThreeWayMatchOperator((r1,r2,r3)) values = set([v[0] for v in t]) return values def test5(): r1 = ['a', 'b', 'c','d'] r2 = ['3', '2', '1','d'] r3 = ['p', 'q', 'a','d'] t = ThreeWayMatchOperator((r1,r2,r3)) values = set([v[0] for v in t]) return values print("Basic 1", tryOrAssert(test1, {0, 6})) print("Basic 2", tryOrAssert(test2, {0, 6})) print("Basic 3", tryOrAssert(test5, {'d'})) print("Empty",tryOrAssert(test3, None, True)) print("Singleton", tryOrAssert(test4, {0}))