Пример #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))
Пример #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,))
Пример #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,)
Пример #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))
Пример #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)
Пример #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, ))
Пример #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,))
Пример #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)
Пример #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))