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