Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/pyduchaintest.cpp
Show First 20 Lines • Show All 865 Lines • ▼ Show 20 Line(s) | 848 | #endif | |||
---|---|---|---|---|---|
866 | QTest::newRow("bytes") << "checkme = b\"foo\"" << "bytes"; | 866 | QTest::newRow("bytes") << "checkme = b\"foo\"" << "bytes"; | ||
867 | 867 | | |||
868 | QTest::newRow("function_arg_scope") << "class Foo:\n" | 868 | QTest::newRow("function_arg_scope") << "class Foo:\n" | ||
869 | " a = 3\n" | 869 | " a = 3\n" | ||
870 | " def func(self, x=a):\n" | 870 | " def func(self, x=a):\n" | ||
871 | " return x\n" | 871 | " return x\n" | ||
872 | "f = Foo()\n" | 872 | "f = Foo()\n" | ||
873 | "checkme = f.func()" << "int"; | 873 | "checkme = f.func()" << "int"; | ||
874 | | ||||
874 | QTest::newRow("with") << "with open('foo') as f: checkme = f.read()" << "str"; | 875 | QTest::newRow("with") << "with open('foo') as f: checkme = f.read()" << "str"; | ||
876 | QTest::newRow("with_list_target") << "bar = [1, 2, 3]\n" | ||||
877 | "with open('foo') as bar[1]: checkme = bar[1].read()" << "str"; | ||||
878 | QTest::newRow("with_attr_target") << "bar = object()\n" | ||||
879 | "with open('foo') as bar.zep: checkme = bar.zep.read()" << "str"; | ||||
880 | QTest::newRow("with_nonself_enter") << // From https://bugs.kde.org/show_bug.cgi?id=399534 | ||||
881 | "class Mgr:\n" | ||||
882 | " def __enter__(self): return 42\n" | ||||
883 | " def __exit__(self, *args): pass\n" | ||||
884 | "with Mgr() as asd:\n" | ||||
885 | " checkme = asd" << "int"; | ||||
886 | QTest::newRow("with_tuple_target") << | ||||
887 | "class Mgr:\n" | ||||
888 | " def __enter__(self): return (42, 3.4)\n" | ||||
889 | " def __exit__(self, *args): pass\n" | ||||
890 | "with Mgr() as (aa, bb):\n" | ||||
891 | " checkme = bb" << "float"; | ||||
892 | | ||||
875 | QTest::newRow("arg_after_vararg") << "def func(x, y, *, z:int): return z\ncheckme = func()" << "int"; | 893 | QTest::newRow("arg_after_vararg") << "def func(x, y, *, z:int): return z\ncheckme = func()" << "int"; | ||
876 | QTest::newRow("arg_after_vararg_with_default") << "def func(x=5, y=3, *, z:int): return z\ncheckme = func()" << "int"; | 894 | QTest::newRow("arg_after_vararg_with_default") << "def func(x=5, y=3, *, z:int): return z\ncheckme = func()" << "int"; | ||
877 | 895 | | |||
878 | QTest::newRow("class_scope_end_inside") << "a = str()\nclass M:\n" | 896 | QTest::newRow("class_scope_end_inside") << "a = str()\nclass M:\n" | ||
879 | " a = 2\n foo = a\n" | 897 | " a = 2\n foo = a\n" | ||
880 | "checkme = M().foo" << "int"; | 898 | "checkme = M().foo" << "int"; | ||
881 | QTest::newRow("class_scope_end_outside") << "a = str()\nclass M:\n a = 2\ncheckme = a" << "str"; | 899 | QTest::newRow("class_scope_end_outside") << "a = str()\nclass M:\n a = 2\ncheckme = a" << "str"; | ||
882 | 900 | | |||
▲ Show 20 Lines • Show All 921 Lines • Show Last 20 Lines |