2 Test that objective-c constant strings are generated correctly by the expression
6 from __future__ import print_function
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
17 class ConstStringTestCase(TestBase):
19 mydir = TestBase.compute_mydir(__file__)
20 d = {'OBJC_SOURCES': 'const-strings.m'}
23 # Call super's setUp().
25 # Find the line number to break inside main().
26 self.main_source = "const-strings.m"
27 self.line = line_number(self.main_source, '// Set breakpoint here.')
31 """Test constant string generation amd comparison by the expression parser."""
32 self.build(dictionary=self.d)
33 self.setTearDownCleanup(self.d)
35 exe = os.path.join(os.getcwd(), "a.out")
36 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
38 lldbutil.run_break_set_by_file_and_line(
42 num_expected_locations=1,
45 self.runCmd("run", RUN_SUCCEEDED)
46 self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
47 substrs=[" at %s:%d" % (self.main_source, self.line),
48 "stop reason = breakpoint"])
50 self.expect('expression (int)[str compare:@"hello"]',
51 startstr="(int) $0 = 0")
52 self.expect('expression (int)[str compare:@"world"]',
53 startstr="(int) $1 = -1")
55 # Test empty strings, too.
56 self.expect('expression (int)[@"" length]',
57 startstr="(int) $2 = 0")
59 self.expect('expression (int)[@"123" length]',
60 startstr="(int) $3 = 3")