199451b44SJordan Rupprecht"""
299451b44SJordan RupprechtTest that importing the std module on a compile unit
399451b44SJordan Rupprechtthat doesn't use the std module will not break LLDB.
499451b44SJordan Rupprecht
599451b44SJordan RupprechtIt's not really specified at the moment what kind of
699451b44SJordan Rupprechterror we should report back to the user in this
799451b44SJordan Rupprechtsituation. Currently Clang will just complain that
899451b44SJordan Rupprechtthe std module doesn't exist or can't be loaded.
999451b44SJordan Rupprecht"""
1099451b44SJordan Rupprecht
1199451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
1299451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
1399451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
1499451b44SJordan Rupprecht
1599451b44SJordan Rupprecht
1699451b44SJordan Rupprechtclass STLTestCase(TestBase):
1799451b44SJordan Rupprecht    @add_test_categories(["libc++"])
1899451b44SJordan Rupprecht    @skipIf(compiler=no_match("clang"))
1999451b44SJordan Rupprecht    def test(self):
2099451b44SJordan Rupprecht        self.build()
2199451b44SJordan Rupprecht
22*2238dcc3SJonas Devlieghere        lldbutil.run_to_source_breakpoint(
23*2238dcc3SJonas Devlieghere            self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")
24*2238dcc3SJonas Devlieghere        )
2599451b44SJordan Rupprecht
2699451b44SJordan Rupprecht        # Activate importing of std module.
2799451b44SJordan Rupprecht        self.runCmd("settings set target.import-std-module true")
2899451b44SJordan Rupprecht
2999451b44SJordan Rupprecht        # Run some commands that should all fail without our std module.
3099451b44SJordan Rupprecht        self.expect("expr std::abs(-42)", error=True)
3199451b44SJordan Rupprecht        self.expect("expr std::div(2, 1).quot", error=True)
3299451b44SJordan Rupprecht        self.expect("expr (std::size_t)33U", error=True)
33*2238dcc3SJonas Devlieghere        self.expect("expr char a = 'b'; char b = 'a'; std::swap(a, b); a", error=True)
34