Skip to content

Commit 4821d2a

Browse files
committed
[lldb][NFC] Test going up/down one line in the multiline expression editor
1 parent 01a26fa commit 4821d2a

File tree

1 file changed

+67
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)