xref: /llvm-project/lldb/test/API/test_utils/TestInlineTest.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1349295fcSPavel Labathfrom lldbsuite.test.lldbinline import CommandParser
2349295fcSPavel Labathfrom lldbsuite.test.lldbtest import Base
3349295fcSPavel Labathimport textwrap
4349295fcSPavel Labath
5349295fcSPavel Labath
6349295fcSPavel Labathclass TestCommandParser(Base):
7349295fcSPavel Labath    def test_indentation(self):
8349295fcSPavel Labath        """Test indentation handling"""
9349295fcSPavel Labath        filename = self.getBuildArtifact("test_file.cpp")
10349295fcSPavel Labath        with open(filename, "w") as f:
11*2238dcc3SJonas Devlieghere            f.write(
12*2238dcc3SJonas Devlieghere                textwrap.dedent(
13*2238dcc3SJonas Devlieghere                    """\
14349295fcSPavel Labath                    int q;
15349295fcSPavel Labath                    int w; //% first break
16349295fcSPavel Labath                    int e;
17349295fcSPavel Labath                    int r; //% second break
18349295fcSPavel Labath                    //% continue second
19349295fcSPavel Labath                    //%   continuing indented
20349295fcSPavel Labath                      //% not indented
21349295fcSPavel Labath                    int t; //% third break
22*2238dcc3SJonas Devlieghere                    """
23*2238dcc3SJonas Devlieghere                )
24*2238dcc3SJonas Devlieghere            )
25349295fcSPavel Labath        p = CommandParser()
26349295fcSPavel Labath        p.parse_source_files([filename])
27349295fcSPavel Labath
28349295fcSPavel Labath        def bkpt(line, cmd):
29*2238dcc3SJonas Devlieghere            return {"file_name": filename, "line_number": line, "command": cmd}
30*2238dcc3SJonas Devlieghere
31349295fcSPavel Labath        self.assertEqual(
32*2238dcc3SJonas Devlieghere            p.breakpoints,
33*2238dcc3SJonas Devlieghere            [
34*2238dcc3SJonas Devlieghere                bkpt(2, "first break"),
35*2238dcc3SJonas Devlieghere                bkpt(
36*2238dcc3SJonas Devlieghere                    4,
37*2238dcc3SJonas Devlieghere                    "second break\ncontinue second\n  continuing indented\nnot indented",
38*2238dcc3SJonas Devlieghere                ),
39*2238dcc3SJonas Devlieghere                bkpt(8, "third break"),
40*2238dcc3SJonas Devlieghere            ],
41*2238dcc3SJonas Devlieghere        )
42