1from lldbsuite.test.lldbinline import CommandParser
2from lldbsuite.test.lldbtest import Base
3import textwrap
4
5
6class TestCommandParser(Base):
7
8    mydir = Base.compute_mydir(__file__)
9
10    def test_indentation(self):
11        """Test indentation handling"""
12        filename = self.getBuildArtifact("test_file.cpp")
13        with open(filename, "w") as f:
14            f.write(textwrap.dedent("""\
15                    int q;
16                    int w; //% first break
17                    int e;
18                    int r; //% second break
19                    //% continue second
20                    //%   continuing indented
21                      //% not indented
22                    int t; //% third break
23                    """))
24        p = CommandParser()
25        p.parse_source_files([filename])
26
27        def bkpt(line, cmd):
28            return {'file_name': filename, 'line_number': line, 'command': cmd}
29        self.assertEqual(
30            p.breakpoints, [
31                bkpt(2, 'first break'),
32                bkpt(4, 'second break\ncontinue second\n  continuing indented\nnot indented'),
33                bkpt(8, "third break")])
34