From 4bee2afcd7ea10c9f58f6172924f822849fed8f9 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Wed, 20 May 2020 11:57:52 +0200 Subject: [PATCH] [lldb][NFC] Modernize TestCPPStaticMethods Now with LLVM code style and expect_expr for checking. Also some minor changes to be more similar to the structure we use in other tests. --- .../cpp/static_methods/TestCPPStaticMethods.py | 9 +++---- lldb/test/API/lang/cpp/static_methods/main.cpp | 28 +++++----------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py b/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py index d358757d883..ee4cc60df97 100644 --- a/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py +++ b/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py @@ -15,10 +15,7 @@ class CPPStaticMethodsTestCase(TestBase): def test_with_run_command(self): """Test that static methods are properly distinguished from regular methods""" self.build() - lldbutil.run_to_source_breakpoint(self, "// Break at this line", lldb.SBFileSpec("main.cpp")) + lldbutil.run_to_source_breakpoint(self, "// Break here", lldb.SBFileSpec("main.cpp")) - self.expect("expression -- A::getStaticValue()", - startstr="(int) $0 = 5") - - self.expect("expression -- my_a.getMemberValue()", - startstr="(int) $1 = 3") + self.expect_expr("A::getStaticValue()", result_type="int", result_value="5") + self.expect_expr("a.getMemberValue()", result_type="int", result_value="3") diff --git a/lldb/test/API/lang/cpp/static_methods/main.cpp b/lldb/test/API/lang/cpp/static_methods/main.cpp index de1c2ff3e11..332fca62f4b 100644 --- a/lldb/test/API/lang/cpp/static_methods/main.cpp +++ b/lldb/test/API/lang/cpp/static_methods/main.cpp @@ -1,29 +1,13 @@ -#include - -class A -{ +struct A { public: - static int getStaticValue(); - int getMemberValue(); + static int getStaticValue() { return 5; } + int getMemberValue() { return a; } int a; }; -int A::getStaticValue() -{ - return 5; -} - -int A::getMemberValue() -{ - return a; -} - int main() { - A my_a; - - my_a.a = 3; - - printf("%d\n", A::getStaticValue()); // Break at this line - printf("%d\n", my_a.getMemberValue()); + A a; + a.a = 3; + return A::getStaticValue() + a.getMemberValue(); // Break here } -- 2.11.0