1"""
2Test std::unique_ptr functionality with a decl from debug info as content.
3"""
4
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9
10class TestUniquePtrDbgInfoContent(TestBase):
11
12    @add_test_categories(["libc++"])
13    @skipIf(compiler=no_match("clang"))
14    @skipIf(compiler="clang", compiler_version=['<', '9.0'])
15    @skipIfLinux # s.reset() causes link errors on ubuntu 18.04/Clang 9
16    def test(self):
17        self.build()
18
19        lldbutil.run_to_source_breakpoint(self,
20                                          "// Set break point at this line.",
21                                          lldb.SBFileSpec("main.cpp"))
22
23        self.runCmd("settings set target.import-std-module true")
24
25        self.expect_expr(
26            "s",
27            result_type="std::unique_ptr<Foo>",
28            result_children=[ValueCheck(children=[ValueCheck(value="3")])])
29        self.expect_expr("s->a", result_type="int", result_value="3")
30        self.expect_expr("s->a = 5", result_type="int", result_value="5")
31        self.expect_expr("(int)s->a", result_type="int", result_value="5")
32        self.expect_expr("(bool)s", result_type="bool", result_value="true")
33        self.expect("expr s.reset()")
34        self.expect_expr("(bool)s", result_type="bool", result_value="false")
35