Exemplo n.º 1
0
    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))
Exemplo n.º 2
0
    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,))
Exemplo n.º 3
0
    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,)
Exemplo n.º 4
0
    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))
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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, ))
Exemplo n.º 7
0
    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,))
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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))