def test_primo(): x = var() assert set(run(0, x, membero(x, (1,2,3,4,5,6,7,8,9,10,11)), (primo, x))) == set((2, 3, 5, 7, 11)) assert all(isprime(i) for i in run(5, x, primo(x))) assert set(run(0, x, membero(x, (1,2,3,4,5,6,7,8,9,10)), primo(x))) == \ set((2, 3, 5, 7))
def test_membero(): x = var("x") assert set(run(5, x, membero(x, (1, 2, 3)), membero(x, (2, 3, 4)))) == set((2, 3)) assert run(5, x, membero(2, (1, x, 3))) == (2,)
def test_uneval_membero(): x, y = var('x'), var('y') assert set(run(100, x, membero(y, ((1,2,3),(4,5,6))), (membero, x, y))) == \ set((1,2,3,4,5,6))
def test_typo(): x = var('x') assert results(typo(3, int)) assert not results(typo(3.3, int)) assert run(0, x, membero(x, (1, 'cat', 2.2, 'hat')), (typo, x, str)) ==\ ('cat', 'hat')
def test_membero(): x = var('x') assert set(run(5, x, membero(x, (1, 2, 3)), membero(x, (2, 3, 4)))) == set( (2, 3)) assert run(5, x, membero(2, (1, x, 3))) == (2, )
def test_membero_can_be_reused(): x = var('x') g = membero(x, (0, 1, 2)) assert list(goaleval(g)({})) == [{x: 0}, {x: 1}, {x: 2}] assert list(goaleval(g)({})) == [{x: 0}, {x: 1}, {x: 2}]