1""" 2Tests std::stack functionality. 3""" 4 5from lldbsuite.test.decorators import * 6from lldbsuite.test.lldbtest import * 7from lldbsuite.test import lldbutil 8 9class TestStack(TestBase): 10 11 mydir = TestBase.compute_mydir(__file__) 12 13 @add_test_categories(["libc++"]) 14 @skipIf(compiler=no_match("clang")) 15 @skipIfLinux # Declaration in some Linux headers causes LLDB to crash. 16 def test(self): 17 self.build() 18 19 lldbutil.run_to_source_breakpoint(self, 20 "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) 21 22 self.runCmd("settings set target.import-std-module true") 23 24 # Test std::stack functionality with a std::deque. 25 stack_type = "std::stack<C>" 26 size_type = stack_type + "::size_type" 27 28 self.expect_expr("s_deque", result_type=stack_type) 29 self.expect("expr s_deque.pop()") 30 self.expect("expr s_deque.push({4})") 31 self.expect_expr("s_deque.size()", 32 result_type=size_type, 33 result_value="3") 34 self.expect_expr("s_deque.top().i", 35 result_type="int", 36 result_value="4") 37 self.expect("expr s_deque.emplace(5)") 38 self.expect_expr("s_deque.top().i", 39 result_type="int", 40 result_value="5") 41 42 # Test std::stack functionality with a std::vector. 43 stack_type = "std::stack<C, std::vector<C> >" 44 size_type = stack_type + "::size_type" 45 46 self.expect_expr("s_vector", result_type=stack_type) 47 self.expect("expr s_vector.pop()") 48 self.expect("expr s_vector.push({4})") 49 self.expect_expr("s_vector.size()", 50 result_type=size_type, 51 result_value="3") 52 self.expect_expr("s_vector.top().i", 53 result_type="int", 54 result_value="4") 55 self.expect("expr s_vector.emplace(5)") 56 self.expect_expr("s_vector.top().i", 57 result_type="int", 58 result_value="5") 59 60 # Test std::stack functionality with a std::list. 61 stack_type = "std::stack<C, std::list<C> >" 62 size_type = stack_type + "::size_type" 63 self.expect_expr("s_list", result_type=stack_type) 64 self.expect("expr s_list.pop()") 65 self.expect("expr s_list.push({4})") 66 self.expect_expr("s_list.size()", 67 result_type=size_type, 68 result_value="3") 69 self.expect_expr("s_list.top().i", result_type="int", result_value="4") 70 self.expect("expr s_list.emplace(5)") 71 self.expect_expr("s_list.top().i", result_type="int", result_value="5") 72