def test_and(self): x, y, z = ints('xyz') fn = gof.DualLinker().accept(FunctionGraph([x,y], [and_(x, y)])).make_function() for a,b in ((0,1), (0,0), (1,0), (1,1)): self.assertTrue(fn(a,b) == (a & b), (a,b)) x, y, z = ints('xyz') fn = gof.DualLinker().accept(FunctionGraph([x,y], [x & y])).make_function() for a,b in ((0,1), (0,0), (1,0), (1,1)): self.assertTrue(fn(a,b) == (a & b), (a,b))
def test_not(self): x, y, z = ints('xyz') fn = gof.DualLinker().accept(FunctionGraph([x,y], [invert(x)])).make_function() for a,b in ((0,1), (0,0), (1,0), (1,1)): self.assertTrue(fn(a,b) == ~a, (a,)) x, y, z = ints('xyz') fn = gof.DualLinker().accept(FunctionGraph([x,y], [~x])).make_function() for a,b in ((0,1), (0,0), (1,0), (1,1)): self.assertTrue(fn(a,b) == ~a, (a,))
def test_not(self): x, y, z = ints("xyz") fn = gof.DualLinker().accept(FunctionGraph([x, y], [invert(x)])).make_function() for a, b in ((0, 1), (0, 0), (1, 0), (1, 1)): assert fn(a, b) == ~a, (a,) x, y, z = ints("xyz") fn = gof.DualLinker().accept(FunctionGraph([x, y], [~x])).make_function() for a, b in ((0, 1), (0, 0), (1, 0), (1, 1)): assert fn(a, b) == ~a, (a,)
def test_and(self): x, y, z = ints('xyz') fn = gof.DualLinker().accept(FunctionGraph([x, y], [and_(x, y)])).make_function() for a, b in ((0, 1), (0, 0), (1, 0), (1, 1)): self.assertTrue(fn(a, b) == (a & b), (a, b)) x, y, z = ints('xyz') fn = gof.DualLinker().accept(FunctionGraph([x, y], [x & y])).make_function() for a, b in ((0, 1), (0, 0), (1, 0), (1, 1)): self.assertTrue(fn(a, b) == (a & b), (a, b))
def test_and(self): x, y, z = ints("xyz") fn = DualLinker().accept(FunctionGraph([x, y], [and_(x, y)])).make_function() for a, b in ((0, 1), (0, 0), (1, 0), (1, 1)): assert fn(a, b) == (a & b), (a, b) x, y, z = ints("xyz") fn = DualLinker().accept(FunctionGraph([x, y], [x & y])).make_function() for a, b in ((0, 1), (0, 0), (1, 0), (1, 1)): assert fn(a, b) == (a & b), (a, b)
def tes_mod(self): # We add this test as not all language and C implementation give the same # sign to the result. This check that the c_code of `Mod` is implemented # as Python. That is what we want. x, y = ints('xy') fn = gof.DualLinker().accept(FunctionGraph([x, y], [x % y])).make_function() for a, b in ((0, 1), (1, 1), (0, -1), (1, -1), (-1, -1), (1, 2), (-1, 2), (1, -2), (-1, -2), (5, 3), (-5, 3), (5, -3), (-5, -3)): self.assertTrue(fn(a, b) == a % b, (a, ))
def tes_mod(self): # We add this test as not all language and C implementation give the same # sign to the result. This check that the c_code of `Mod` is implemented # as Python. That is what we want. x, y = ints('xy') fn = gof.DualLinker().accept(FunctionGraph([x, y], [x % y])).make_function() for a, b in ((0, 1), (1, 1), (0, -1), (1, -1), (-1, -1), (1, 2), (-1, 2), (1, -2), (-1, -2), (5, 3), (-5, 3), (5, -3), (-5, -3) ): self.assertTrue(fn(a, b) == a % b, (a,))
def test_xor(self): x, y, z = ints("xyz") fn = gof.DualLinker().accept(FunctionGraph([x, y], [x ^ y])).make_function() for a, b in ((0, 1), (0, 0), (1, 0), (1, 1)): assert fn(a, b) == (a ^ b), (a, b)
def test_xor(self): x, y, z = ints("xyz") fn = gof.DualLinker().accept(FunctionGraph([x, y], [x ^ y])).make_function() for a, b in ((0, 1), (0, 0), (1, 0), (1, 1)): self.assertTrue(fn(a, b) == (a ^ b), (a, b))