1""" 2Test that importing the std module on a compile unit 3that doesn't use the std module will not break LLDB. 4 5It's not really specified at the moment what kind of 6error we should report back to the user in this 7situation. Currently Clang will just complain that 8the std module doesn't exist or can't be loaded. 9""" 10 11from lldbsuite.test.decorators import * 12from lldbsuite.test.lldbtest import * 13from lldbsuite.test import lldbutil 14 15 16class STLTestCase(TestBase): 17 @add_test_categories(["libc++"]) 18 @skipIf(compiler=no_match("clang")) 19 def test(self): 20 self.build() 21 22 lldbutil.run_to_source_breakpoint( 23 self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp") 24 ) 25 26 # Activate importing of std module. 27 self.runCmd("settings set target.import-std-module true") 28 29 # Run some commands that should all fail without our std module. 30 self.expect("expr std::abs(-42)", error=True) 31 self.expect("expr std::div(2, 1).quot", error=True) 32 self.expect("expr (std::size_t)33U", error=True) 33 self.expect("expr char a = 'b'; char b = 'a'; std::swap(a, b); a", error=True) 34