2 Tests navigating in the multiline expression editor.
6 from lldbsuite.test.decorators import *
7 from lldbsuite.test.lldbtest import *
8 from lldbsuite.test.lldbpexpect import PExpectTest
10 class TestCase(PExpectTest):
12 mydir = TestBase.compute_mydir(__file__)
17 # PExpect uses many timeouts internally and doesn't play well
18 # under ASAN on a loaded machine..
20 @skipIfEditlineSupportMissing
21 def test_nav_arrow_up(self):
22 """Tests that we can navigate back to the previous line with the up arrow"""
25 # Start multiline expression mode by just running 'expr'
26 self.child.sendline("expr")
27 self.child.expect_exact("terminate with an empty line to evaluate")
28 # Create a simple integer expression '123' and press enter.
29 self.child.send("123\n")
30 # We should see the prompt for the second line of our expression.
31 self.child.expect_exact("2: ")
32 # Go back to the first line and change 123 to 124.
33 # Then press enter twice to evaluate our expression.
34 self.child.send(self.arrow_up + "\b4\n\n")
35 # The result of our expression should be 124 (our edited expression)
36 # and not 123 (the one we initially typed).
37 self.child.expect_exact("(int) $0 = 124")
42 @skipIfEditlineSupportMissing
43 def test_nav_arrow_down(self):
44 """Tests that we can navigate to the next line with the down arrow"""
47 # Start multiline expression mode by just running 'expr'
48 self.child.sendline("expr")
49 self.child.expect_exact("terminate with an empty line to evaluate")
50 # Create a simple integer expression '111' and press enter.
51 self.child.send("111\n")
52 # We should see the prompt for the second line of our expression.
53 self.child.expect_exact("2: ")
54 # Create another simple integer expression '222'.
55 self.child.send("222")
56 # Go back to the first line and change '111' to '111+' to make
57 # an addition operation that spans two lines. We need to go up to
58 # test that we can go back down again.
59 self.child.send(self.arrow_up + "+")
60 # Go back down to our second line and change '222' to '223'
61 # so that the full expression is now '111+\n223'.
62 # Then press enter twice to evaluate the expression.
63 self.child.send(self.arrow_down + "\b3\n\n")
64 # The result of our expression '111 + 223' should be '334'.
65 # If the expression is '333' then arrow down failed to get
66 # us back to the second line.
67 self.child.expect_exact("(int) $0 = 334")