summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
diff options
context:
space:
mode:
authorLawrence D'Anna <lawrence_danna@apple.com>2019-11-04 12:48:49 -0800
committerLawrence D'Anna <lawrence_danna@apple.com>2019-11-04 12:48:49 -0800
commitadbf64ccc9e18278600ebaeadd8f0117eb8e64b1 (patch)
tree4dd857d012749bea97dd4ddbbaeb0d28ff006621 /lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
parent4312c4afd43209400df53ca541b4b19919f797af (diff)
downloadbcm5719-llvm-adbf64ccc9e18278600ebaeadd8f0117eb8e64b1.tar.gz
bcm5719-llvm-adbf64ccc9e18278600ebaeadd8f0117eb8e64b1.zip
[LLDB][Python] remove ArgInfo::count
Summary: This patch updates the last user of ArgInfo::count and deletes it. I also delete `GetNumInitArguments()` and `GetInitArgInfo()`. Classess are callables and `GetArgInfo()` should work on them. On python 3 it already works, of course. `inspect` is good. On python 2 we have to add yet another special case. But hey if python 2 wasn't crufty we wouln't need python 3. I also delete `is_bound_method` becuase it is unused. This path is tested in `TestStepScripted.py` Reviewers: labath, mgorny, JDevlieghere Reviewed By: labath, JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D69742
Diffstat (limited to 'lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp')
-rw-r--r--lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
index 7481482fd8f..ec5d02ee04d 100644
--- a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
+++ b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
@@ -640,9 +640,7 @@ TEST_F(PythonDataObjectsTest, TestCallable) {
auto lambda = Take<PythonCallable>(o);
auto arginfo = lambda.GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
- EXPECT_EQ(arginfo.get().count, 1);
EXPECT_EQ(arginfo.get().max_positional_args, 1u);
- EXPECT_EQ(arginfo.get().has_varargs, false);
}
{
@@ -652,9 +650,7 @@ TEST_F(PythonDataObjectsTest, TestCallable) {
auto lambda = Take<PythonCallable>(o);
auto arginfo = lambda.GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
- EXPECT_EQ(arginfo.get().count, 2);
EXPECT_EQ(arginfo.get().max_positional_args, 2u);
- EXPECT_EQ(arginfo.get().has_varargs, false);
}
{
@@ -664,9 +660,7 @@ TEST_F(PythonDataObjectsTest, TestCallable) {
auto lambda = Take<PythonCallable>(o);
auto arginfo = lambda.GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
- EXPECT_EQ(arginfo.get().count, 2);
EXPECT_EQ(arginfo.get().max_positional_args, 2u);
- EXPECT_EQ(arginfo.get().has_varargs, false);
}
{
@@ -676,10 +670,8 @@ TEST_F(PythonDataObjectsTest, TestCallable) {
auto lambda = Take<PythonCallable>(o);
auto arginfo = lambda.GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
- EXPECT_EQ(arginfo.get().count, 2);
EXPECT_EQ(arginfo.get().max_positional_args,
PythonCallable::ArgInfo::UNBOUNDED);
- EXPECT_EQ(arginfo.get().has_varargs, true);
}
{
@@ -689,10 +681,8 @@ TEST_F(PythonDataObjectsTest, TestCallable) {
auto lambda = Take<PythonCallable>(o);
auto arginfo = lambda.GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
- EXPECT_EQ(arginfo.get().count, 2);
EXPECT_EQ(arginfo.get().max_positional_args,
PythonCallable::ArgInfo::UNBOUNDED);
- EXPECT_EQ(arginfo.get().has_varargs, true);
}
{
@@ -713,6 +703,16 @@ bar_bound = Foo().bar
bar_class = Foo().classbar
bar_static = Foo().staticbar
bar_unbound = Foo.bar
+
+
+class OldStyle:
+ def __init__(self, one, two, three):
+ pass
+
+class NewStyle(object):
+ def __init__(self, one, two, three):
+ pass
+
)";
PyObject *o =
PyRun_String(script, Py_file_input, globals.get(), globals.get());
@@ -723,38 +723,43 @@ bar_unbound = Foo.bar
ASSERT_THAT_EXPECTED(bar_bound, llvm::Succeeded());
auto arginfo = bar_bound.get().GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
- EXPECT_EQ(arginfo.get().count, 2); // FIXME, wrong
EXPECT_EQ(arginfo.get().max_positional_args, 1u);
- EXPECT_EQ(arginfo.get().has_varargs, false);
auto bar_unbound = As<PythonCallable>(globals.GetItem("bar_unbound"));
ASSERT_THAT_EXPECTED(bar_unbound, llvm::Succeeded());
arginfo = bar_unbound.get().GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
- EXPECT_EQ(arginfo.get().count, 2);
EXPECT_EQ(arginfo.get().max_positional_args, 2u);
- EXPECT_EQ(arginfo.get().has_varargs, false);
auto bar_class = As<PythonCallable>(globals.GetItem("bar_class"));
ASSERT_THAT_EXPECTED(bar_class, llvm::Succeeded());
arginfo = bar_class.get().GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
EXPECT_EQ(arginfo.get().max_positional_args, 1u);
- EXPECT_EQ(arginfo.get().has_varargs, false);
auto bar_static = As<PythonCallable>(globals.GetItem("bar_static"));
ASSERT_THAT_EXPECTED(bar_static, llvm::Succeeded());
arginfo = bar_static.get().GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
EXPECT_EQ(arginfo.get().max_positional_args, 1u);
- EXPECT_EQ(arginfo.get().has_varargs, false);
auto obj = As<PythonCallable>(globals.GetItem("obj"));
ASSERT_THAT_EXPECTED(obj, llvm::Succeeded());
arginfo = obj.get().GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
EXPECT_EQ(arginfo.get().max_positional_args, 1u);
- EXPECT_EQ(arginfo.get().has_varargs, false);
+
+ auto oldstyle = As<PythonCallable>(globals.GetItem("OldStyle"));
+ ASSERT_THAT_EXPECTED(oldstyle, llvm::Succeeded());
+ arginfo = oldstyle.get().GetArgInfo();
+ ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
+ EXPECT_EQ(arginfo.get().max_positional_args, 3u);
+
+ auto newstyle = As<PythonCallable>(globals.GetItem("NewStyle"));
+ ASSERT_THAT_EXPECTED(newstyle, llvm::Succeeded());
+ arginfo = newstyle.get().GetArgInfo();
+ ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
+ EXPECT_EQ(arginfo.get().max_positional_args, 3u);
}
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3
@@ -767,9 +772,7 @@ bar_unbound = Foo.bar
ASSERT_THAT_EXPECTED(hex, llvm::Succeeded());
auto arginfo = hex.get().GetArgInfo();
ASSERT_THAT_EXPECTED(arginfo, llvm::Succeeded());
- EXPECT_EQ(arginfo.get().count, 1);
EXPECT_EQ(arginfo.get().max_positional_args, 1u);
- EXPECT_EQ(arginfo.get().has_varargs, false);
}
#endif
OpenPOWER on IntegriCloud