Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / cpp / union-static-data-members / TestCppUnionStaticMembers.py
blob1988e997499b222b00307f023deb4885ca53aa2b
1 """
2 Tests that frame variable and expr work for
3 C++ unions and their static data members.
4 """
5 import lldb
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test.decorators import *
8 import lldbsuite.test.lldbutil as lldbutil
10 class CppUnionStaticMembersTestCase(TestBase):
11 def test_print_union(self):
12 """Tests that frame variable and expr work
13 for union with static data members"""
14 self.build()
16 (target, process, main_thread, _) = lldbutil.run_to_source_breakpoint(
17 self, "return 0", lldb.SBFileSpec("main.cpp")
20 self.expect("frame variable foo", substrs=["val = 42"])
21 self.expect("frame variable bar", substrs=["val = 137"])
23 self.expect_expr("foo", result_type="Foo", result_children=[ValueCheck(
24 name="val", value="42"
25 )])
26 self.expect_expr("bar", result_type="Bar", result_children=[ValueCheck(
27 name="val", value="137"
28 )])
30 @expectedFailureWindows
31 def test_expr_union_static_members(self):
32 """Tests that frame variable and expr work
33 for union static data members"""
34 self.build()
36 (target, process, main_thread, _) = lldbutil.run_to_source_breakpoint(
37 self, "return 0", lldb.SBFileSpec("main.cpp")
40 self.expect_expr("Foo::sVal1", result_type="const int", result_value="-42")
41 self.expect_expr("Foo::sVal2", result_type="Foo", result_children=[ValueCheck(
42 name="val", value="42"
43 )])
45 @expectedFailureAll
46 def test_union_in_anon_namespace(self):
47 """Tests that frame variable and expr work
48 for union static data members in anonymous
49 namespaces"""
50 self.build()
52 (target, process, main_thread, _) = lldbutil.run_to_source_breakpoint(
53 self, "return 0", lldb.SBFileSpec("main.cpp")
56 self.expect_expr("Bar::sVal1", result_type="const int", result_value="-137")
57 self.expect_expr("Bar::sVal2", result_type="Bar", result_children=[ValueCheck(
58 name="val", value="137"
59 )])