199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTests std::stack functionality. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 599451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 699451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 799451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 899451b44SJordan Rupprecht 999451b44SJordan Rupprecht 10*2238dcc3SJonas Devlieghereclass TestStack(TestBase): 1199451b44SJordan Rupprecht @add_test_categories(["libc++"]) 1299451b44SJordan Rupprecht @skipIf(compiler=no_match("clang")) 13a703998eSRaphael Isemann @skipIfLinux # Declaration in some Linux headers causes LLDB to crash. 145ee910feSAugusto Noronha @skipIf(bugnumber="rdar://97622854") 1599451b44SJordan Rupprecht def test(self): 1699451b44SJordan Rupprecht self.build() 1799451b44SJordan Rupprecht 18*2238dcc3SJonas Devlieghere lldbutil.run_to_source_breakpoint( 19*2238dcc3SJonas Devlieghere self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp") 20*2238dcc3SJonas Devlieghere ) 2199451b44SJordan Rupprecht 2299451b44SJordan Rupprecht self.runCmd("settings set target.import-std-module true") 2399451b44SJordan Rupprecht 2499451b44SJordan Rupprecht # Test std::stack functionality with a std::deque. 253f6c856bSRaphael Isemann stack_type = "std::stack<C>" 26a703998eSRaphael Isemann size_type = stack_type + "::size_type" 27a703998eSRaphael Isemann 28a703998eSRaphael Isemann self.expect_expr("s_deque", result_type=stack_type) 2999451b44SJordan Rupprecht self.expect("expr s_deque.pop()") 3099451b44SJordan Rupprecht self.expect("expr s_deque.push({4})") 31*2238dcc3SJonas Devlieghere self.expect_expr("s_deque.size()", result_type=size_type, result_value="3") 32*2238dcc3SJonas Devlieghere self.expect_expr("s_deque.top().i", result_type="int", result_value="4") 3399451b44SJordan Rupprecht self.expect("expr s_deque.emplace(5)") 34*2238dcc3SJonas Devlieghere self.expect_expr("s_deque.top().i", result_type="int", result_value="5") 3599451b44SJordan Rupprecht 3699451b44SJordan Rupprecht # Test std::stack functionality with a std::vector. 373f6c856bSRaphael Isemann stack_type = "std::stack<C, std::vector<C> >" 38a703998eSRaphael Isemann size_type = stack_type + "::size_type" 39a703998eSRaphael Isemann 40a703998eSRaphael Isemann self.expect_expr("s_vector", result_type=stack_type) 4199451b44SJordan Rupprecht self.expect("expr s_vector.pop()") 4299451b44SJordan Rupprecht self.expect("expr s_vector.push({4})") 43*2238dcc3SJonas Devlieghere self.expect_expr("s_vector.size()", result_type=size_type, result_value="3") 44*2238dcc3SJonas Devlieghere self.expect_expr("s_vector.top().i", result_type="int", result_value="4") 4599451b44SJordan Rupprecht self.expect("expr s_vector.emplace(5)") 46*2238dcc3SJonas Devlieghere self.expect_expr("s_vector.top().i", result_type="int", result_value="5") 4799451b44SJordan Rupprecht 4899451b44SJordan Rupprecht # Test std::stack functionality with a std::list. 493f6c856bSRaphael Isemann stack_type = "std::stack<C, std::list<C> >" 50a703998eSRaphael Isemann size_type = stack_type + "::size_type" 51a703998eSRaphael Isemann self.expect_expr("s_list", result_type=stack_type) 5299451b44SJordan Rupprecht self.expect("expr s_list.pop()") 5399451b44SJordan Rupprecht self.expect("expr s_list.push({4})") 54*2238dcc3SJonas Devlieghere self.expect_expr("s_list.size()", result_type=size_type, result_value="3") 55a703998eSRaphael Isemann self.expect_expr("s_list.top().i", result_type="int", result_value="4") 5699451b44SJordan Rupprecht self.expect("expr s_list.emplace(5)") 57a703998eSRaphael Isemann self.expect_expr("s_list.top().i", result_type="int", result_value="5") 58