Beispiel #1
0
def test_return_type(metaclass):
    for t, v in types_and_values:

        class T(object):
            __metaclass__ = metaclass
            _clrnamespace = get_unique_namespace()

            @accepts()
            @returns(t)
            def Foo(self):
                return v

        foo = GetClrType(T).GetMethod("Foo")

        AreEqual(foo.ReturnType, GetClrType(t))

        if metaclass is ClrClass:
            AreEqual(v, foo.Invoke(T(), None))
Beispiel #2
0
def test_argument_types(metaclass):
    for t, v in types_and_values:

        class T(object):
            __metaclass__ = metaclass
            _clrnamespace = get_unique_namespace()

            @accepts(t)
            @returns()
            def Foo(self, a):
                AreEqual(a, v)

        foo = GetClrType(T).GetMethod("Foo")

        p0 = foo.GetParameters()[0]
        AreEqual(p0.ParameterType, GetClrType(t))

        if metaclass is ClrClass:
            foo.Invoke(T(), System.Array[object]([v]))