1# encoding: utf-8
2
3import lldb
4from lldbsuite.test.decorators import *
5from lldbsuite.test.lldbtest import *
6from lldbsuite.test import lldbutil
7
8
9class CMTimeDataFormatterTestCase(TestBase):
10    @skipUnlessDarwin
11    def test_nsindexpath_with_run_command(self):
12        """Test formatters for CMTime."""
13        self.build()
14        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
15
16        line = line_number("main.m", "// break here")
17        lldbutil.run_break_set_by_file_and_line(
18            self, "main.m", line, num_expected_locations=1, loc_exact=True
19        )
20
21        self.runCmd("run", RUN_SUCCEEDED)
22
23        self.expect(
24            "thread list",
25            STOPPED_DUE_TO_BREAKPOINT,
26            substrs=["stopped", "stop reason = breakpoint"],
27        )
28
29        self.expect(
30            "frame variable t1",
31            substrs=["1 half seconds", "value = 1", "timescale = 2", "epoch = 0"],
32        )
33        self.expect(
34            "frame variable t2",
35            substrs=["1 third of a second", "value = 1", "timescale = 3", "epoch = 0"],
36        )
37        self.expect(
38            "frame variable t3",
39            substrs=["1 10th of a second", "value = 1", "timescale = 10", "epoch = 0"],
40        )
41        self.expect(
42            "frame variable t4",
43            substrs=["10 seconds", "value = 10", "timescale = 1", "epoch = 0"],
44        )
45        self.expect("frame variable t5", substrs=["+oo"])
46        self.expect("frame variable t6", substrs=["-oo"])
47        self.expect("frame variable t7", substrs=["indefinite"])
48