199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest basic std::unique_ptr 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 9cabee89bSRaphael Isemann 1099451b44SJordan Rupprechtclass TestUniquePtr(TestBase): 1199451b44SJordan Rupprecht @add_test_categories(["libc++"]) 1299451b44SJordan Rupprecht @skipIf(compiler=no_match("clang")) 13*2238dcc3SJonas Devlieghere @skipIf(compiler="clang", compiler_version=["<", "9.0"]) 1415ea45f1SRaphael Isemann @skipIfLinux # s.reset() causes link errors on ubuntu 18.04/Clang 9 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 24*2238dcc3SJonas Devlieghere if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( 25*2238dcc3SJonas Devlieghere [">", "16.0"] 26*2238dcc3SJonas Devlieghere ): 273c667298SMichael Buch ptr_type = "std::unique_ptr<int>" 283c667298SMichael Buch else: 293c667298SMichael Buch ptr_type = "std::unique_ptr<int, std::default_delete<int> >" 303c667298SMichael Buch 31cabee89bSRaphael Isemann self.expect_expr( 32cabee89bSRaphael Isemann "s", 333c667298SMichael Buch result_type=ptr_type, 34cabee89bSRaphael Isemann result_summary="3", 35*2238dcc3SJonas Devlieghere result_children=[ValueCheck(name="pointer")], 36*2238dcc3SJonas Devlieghere ) 37cabee89bSRaphael Isemann self.expect_expr("*s", result_type="int", result_value="3") 38cabee89bSRaphael Isemann self.expect_expr("*s = 5", result_type="int", result_value="5") 39cabee89bSRaphael Isemann self.expect_expr("*s", result_type="int", result_value="5") 40cabee89bSRaphael Isemann self.expect_expr("(bool)s", result_type="bool", result_value="true") 4199451b44SJordan Rupprecht self.expect("expr s.reset()") 42cabee89bSRaphael Isemann self.expect_expr("(bool)s", result_type="bool", result_value="false") 43