Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/pyduchaintest.cpp
Show First 20 Lines • Show All 789 Lines • ▼ Show 20 Line(s) | 782 | { | |||
---|---|---|---|---|---|
790 | 790 | | |||
791 | DUChainReadLocker lock(DUChain::lock()); | 791 | DUChainReadLocker lock(DUChain::lock()); | ||
792 | TypeTestVisitor* visitor = new TypeTestVisitor(); | 792 | TypeTestVisitor* visitor = new TypeTestVisitor(); | ||
793 | visitor->ctx = TopDUContextPointer(ctx.data()); | 793 | visitor->ctx = TopDUContextPointer(ctx.data()); | ||
794 | visitor->searchingForType = expectedType; | 794 | visitor->searchingForType = expectedType; | ||
795 | visitor->visitCode(m_ast.data()); | 795 | visitor->visitCode(m_ast.data()); | ||
796 | QEXPECT_FAIL("lambda", "not implemented: aliasing lambdas", Continue); | 796 | QEXPECT_FAIL("lambda", "not implemented: aliasing lambdas", Continue); | ||
797 | QEXPECT_FAIL("return_builtin_iterator", "fake builtin iter()", Continue); | 797 | QEXPECT_FAIL("return_builtin_iterator", "fake builtin iter()", Continue); | ||
798 | QEXPECT_FAIL("init_class_no_decl", "aliasing info lost", Continue); | ||||
798 | QCOMPARE(visitor->found, true); | 799 | QCOMPARE(visitor->found, true); | ||
799 | } | 800 | } | ||
800 | 801 | | |||
801 | void PyDUChainTest::testTypes_data() | 802 | void PyDUChainTest::testTypes_data() | ||
802 | { | 803 | { | ||
803 | QTest::addColumn<QString>("code"); | 804 | QTest::addColumn<QString>("code"); | ||
804 | QTest::addColumn<QString>("expectedType"); | 805 | QTest::addColumn<QString>("expectedType"); | ||
805 | 806 | | |||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Line(s) | 956 | QTest::newRow("separate_iterator") << "class Foo:\n" | |||
958 | "class Bar:\n" | 959 | "class Bar:\n" | ||
959 | " def __next__(self): return {1}\n" | 960 | " def __next__(self): return {1}\n" | ||
960 | "checkme = [a for a in Foo()]" << "list of set of int"; | 961 | "checkme = [a for a in Foo()]" << "list of set of int"; | ||
961 | QTest::newRow("return_builtin_iterator") << "class Gen2:\n" | 962 | QTest::newRow("return_builtin_iterator") << "class Gen2:\n" | ||
962 | " contents = [1, 2, 3]\n" | 963 | " contents = [1, 2, 3]\n" | ||
963 | " def __iter__(self): return iter(Gen2.contents)\n" | 964 | " def __iter__(self): return iter(Gen2.contents)\n" | ||
964 | "for checkme in Gen2(): pass" << "int"; | 965 | "for checkme in Gen2(): pass" << "int"; | ||
965 | 966 | | |||
967 | QTest::newRow("init_class") << "class Foo:\n" | ||||
968 | " def __init__(self): pass\n" | ||||
969 | " def __call__(self): return 1.5\n" | ||||
970 | "checkme = Foo()\n" << "Foo"; | ||||
971 | QTest::newRow("init_class_no_decl") << "class Foo:\n" | ||||
972 | " def __init__(self): pass\n" | ||||
973 | " def __call__(self): return 1.5\n" | ||||
974 | "a = [Foo]\n" | ||||
975 | "checkme = a[0]()\n" << "Foo"; | ||||
966 | QTest::newRow("call_class") << "class Foo:\n" | 976 | QTest::newRow("call_class") << "class Foo:\n" | ||
967 | " def __call__(self):\n" | 977 | " def __call__(self):\n" | ||
968 | " return 0\n" | 978 | " return 0\n" | ||
969 | "f = Foo()\n" | 979 | "f = Foo()\n" | ||
970 | "checkme = f()\n" << "int"; | 980 | "checkme = f()\n" << "int"; | ||
981 | QTest::newRow("call_class_no_decl") << "class Foo:\n" | ||||
982 | " def __call__(self): return 1.5\n" | ||||
983 | "a = [Foo()]\n" | ||||
984 | "checkme = a[0]()" << "float"; | ||||
971 | QTest::newRow("classmethod") << "class Foo:\n" | 985 | QTest::newRow("classmethod") << "class Foo:\n" | ||
972 | " @classmethod\n" | 986 | " @classmethod\n" | ||
973 | " def foo(cls):\n" | 987 | " def foo(cls):\n" | ||
974 | " k = cls()\n" | 988 | " k = cls()\n" | ||
975 | " return k\n" | 989 | " return k\n" | ||
976 | "f = Foo.foo()\n" | 990 | "f = Foo.foo()\n" | ||
977 | "checkme = f\n" << "Foo"; | 991 | "checkme = f\n" << "Foo"; | ||
978 | 992 | | |||
▲ Show 20 Lines • Show All 560 Lines • Show Last 20 Lines |