Exemplo n.º 1
0
    def test_functions(self):
        import cppyy

        from cppyy.gbl import global_function, Namespace
        assert not(global_function == Namespace.global_function)

        assert round(global_function(1.)-2.718281828459045, 8) == 0.
        assert global_function(1) == 42

        assert Namespace.global_function(1) == 42*2
        assert round(Namespace.global_function(1.)-2.718281828459045*2, 8) == 0.

        assert round(global_function.__overload__('double')(1)-2.718281828459045, 8) == 0.
Exemplo n.º 2
0
    def test_functions(self):
        import cppyy

        from cppyy.gbl import global_function, call_int_int, Namespace
        assert not(global_function == Namespace.global_function)

        assert round(global_function(1.)-2.718281828459045, 8) == 0.
        assert global_function(1) == 42

        assert Namespace.global_function(1) == 42*2
        assert round(Namespace.global_function(1.)-2.718281828459045*2, 8) == 0.

        assert round(global_function.__overload__('double')(1)-2.718281828459045, 8) == 0.

        def add(a, b):
            return a+b
        assert call_int_int(add, 3, 4) == 7
        assert call_int_int(lambda x, y: x*y, 3, 7) == 21
Exemplo n.º 3
0
    def test_functions(self):
        import cppyy

        from cppyy.gbl import global_function, call_int_int, Namespace
        assert not(global_function == Namespace.global_function)

        assert round(global_function(1.)-2.718281828459045, 8) == 0.
        assert global_function(1) == 42

        assert Namespace.global_function(1) == 42*2
        assert round(Namespace.global_function(1.)-2.718281828459045*2, 8) == 0.

        assert round(global_function.__overload__('double')(1)-2.718281828459045, 8) == 0.

        def add(a, b):
            return a+b
        assert call_int_int(add, 3, 4) == 7
        assert call_int_int(lambda x, y: x*y, 3, 7) == 21