Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/pyduchaintest.cpp
Show First 20 Lines • Show All 1378 Lines • ▼ Show 20 Line(s) | 1354 | { | |||
---|---|---|---|---|---|
1379 | QTest::newRow("for_loop_tuple_1") << "d = [(3, 3.5)]\nfor a, b in d:\n checkme = a" << "int" << true; | 1379 | QTest::newRow("for_loop_tuple_1") << "d = [(3, 3.5)]\nfor a, b in d:\n checkme = a" << "int" << true; | ||
1380 | QTest::newRow("for_loop_tuple_2") << "d = [(3, 3.5)]\nfor a, b in d:\n checkme = b" << "float" << true; | 1380 | QTest::newRow("for_loop_tuple_2") << "d = [(3, 3.5)]\nfor a, b in d:\n checkme = b" << "float" << true; | ||
1381 | QTest::newRow("for_loop_tuple_unsure") << "d = [(3, 3.5), (3.5, 3)]\nfor a, b in d:\n checkme = b" | 1381 | QTest::newRow("for_loop_tuple_unsure") << "d = [(3, 3.5), (3.5, 3)]\nfor a, b in d:\n checkme = b" | ||
1382 | << "unsure (float, int)" << true; | 1382 | << "unsure (float, int)" << true; | ||
1383 | // Proposed by Nicolás Alvarez; why not? https://bugs.kde.org/show_bug.cgi?id=359915 | 1383 | // Proposed by Nicolás Alvarez; why not? https://bugs.kde.org/show_bug.cgi?id=359915 | ||
1384 | QTest::newRow("comprehension_messy") << "users = {'a':19, 'b':42, 'c':35}\n" | 1384 | QTest::newRow("comprehension_messy") << "users = {'a':19, 'b':42, 'c':35}\n" | ||
1385 | "sorted_list = sorted(users.items(), key=lambda kv: (-kv[1], kv[0]))\n" | 1385 | "sorted_list = sorted(users.items(), key=lambda kv: (-kv[1], kv[0]))\n" | ||
1386 | "checkme = [k for r,(k,v) in enumerate(sorted_list, 1)]" << "list of str" << true; | 1386 | "checkme = [k for r,(k,v) in enumerate(sorted_list, 1)]" << "list of str" << true; | ||
1387 | // From https://bugs.kde.org/show_bug.cgi?id=359912 | ||||
1388 | QTest::newRow("subscript_multi") << | ||||
1389 | "class Middle:\n def __getitem__(self, key):\n return str()\n" | ||||
1390 | "class Outer:\n def __getitem__(self, key):\n return Middle()\n" | ||||
1391 | "aaa = Outer()\ncheckme = aaa[0][0]" << "str" << true; | ||||
1392 | QTest::newRow("subscript_func_call") << | ||||
1393 | "class Foo:\n def __getitem__(self, key):\n return str()\n" | ||||
1394 | "def bar():\n return Foo()\n" | ||||
1395 | "checkme = bar()[0]" << "str" << true; | ||||
1387 | } | 1396 | } | ||
1388 | 1397 | | |||
1389 | void PyDUChainTest::testVariableCreation() | 1398 | void PyDUChainTest::testVariableCreation() | ||
1390 | { | 1399 | { | ||
1391 | QFETCH(QString, code); | 1400 | QFETCH(QString, code); | ||
1392 | QFETCH(QStringList, expected_local_declarations); | 1401 | QFETCH(QStringList, expected_local_declarations); | ||
1393 | QFETCH(QStringList, expected_types); | 1402 | QFETCH(QStringList, expected_types); | ||
1394 | 1403 | | |||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |