[Lldb-commits] [lldb] 4bee2af - [lldb][NFC] Modernize TestCPPStaticMethods

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed May 20 03:28:07 PDT 2020


Author: Raphael Isemann
Date: 2020-05-20T12:27:44+02:00
New Revision: 4bee2afcd7ea10c9f58f6172924f822849fed8f9

URL: https://github.com/llvm/llvm-project/commit/4bee2afcd7ea10c9f58f6172924f822849fed8f9
DIFF: https://github.com/llvm/llvm-project/commit/4bee2afcd7ea10c9f58f6172924f822849fed8f9.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
    lldb/test/API/lang/cpp/static_methods/main.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py b/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
index d358757d8837..ee4cc60df97f 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 de1c2ff3e119..332fca62f4be 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 <stdio.h>
-
-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
 }


        


More information about the lldb-commits mailing list