[LoopInterchange] Hoist isComputableLoopNest() in the control flow (#124247)
[llvm-project.git] / lldb / test / API / commands / expression / multiline-navigation / TestMultilineNavigation.py
blob810c3949d8d77e25d3713a8b910f97c7dd9dcb58
1 """
2 Tests navigating in the multiline expression editor.
3 """
5 import lldb
6 from lldbsuite.test.decorators import *
7 from lldbsuite.test.lldbtest import *
8 from lldbsuite.test.lldbpexpect import PExpectTest
11 class TestCase(PExpectTest):
12 arrow_up = "\033[A"
13 arrow_down = "\033[B"
15 # PExpect uses many timeouts internally and doesn't play well
16 # under ASAN on a loaded machine..
17 @skipIfAsan
18 @skipIfEditlineSupportMissing
19 @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48316")
20 @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot
21 def test_nav_arrow_up(self):
22 """Tests that we can navigate back to the previous line with the up arrow"""
23 self.launch()
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")
39 self.quit()
41 @skipIfAsan
42 @skipIfEditlineSupportMissing
43 @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48316")
44 @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot
45 def test_nav_arrow_down(self):
46 """Tests that we can navigate to the next line with the down arrow"""
47 self.launch()
49 # Start multiline expression mode by just running 'expr'
50 self.child.sendline("expr")
51 self.child.expect_exact("terminate with an empty line to evaluate")
52 # Create a simple integer expression '111' and press enter.
53 self.child.send("111\n")
54 # We should see the prompt for the second line of our expression.
55 self.child.expect_exact("2: ")
56 # Create another simple integer expression '222'.
57 self.child.send("222")
58 # Go back to the first line and change '111' to '111+' to make
59 # an addition operation that spans two lines. We need to go up to
60 # test that we can go back down again.
61 self.child.send(self.arrow_up + "+")
62 # Go back down to our second line and change '222' to '223'
63 # so that the full expression is now '111+\n223'.
64 # Then press enter twice to evaluate the expression.
65 self.child.send(self.arrow_down + "\b3\n\n")
66 # The result of our expression '111 + 223' should be '334'.
67 # If the expression is '333' then arrow down failed to get
68 # us back to the second line.
69 self.child.expect_exact("(int) $0 = 334")
71 self.quit()
73 @skipIfAsan
74 @skipIfEditlineSupportMissing
75 @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot
76 def test_nav_arrow_up_empty(self):
77 """
78 Tests that navigating with the up arrow doesn't crash and skips
79 empty history entries.
80 """
81 self.launch()
83 # Create a real history entry '456' and then follow up with an
84 # empty entry (that shouldn't be saved).
85 self.child.sendline("expr")
86 self.child.expect_exact("terminate with an empty line to evaluate")
87 self.child.send("456\n\n")
88 self.expect_prompt()
90 self.child.sendline("expr")
91 self.child.expect_exact("terminate with an empty line to evaluate")
92 self.child.send("\n")
93 self.expect_prompt()
95 # The up arrow should recall the actual history entry and not the
96 # the empty entry (as that one shouldn't have been saved).
97 self.child.sendline("expr")
98 self.child.expect_exact("terminate with an empty line to evaluate")
99 self.child.send(self.arrow_up)
100 self.child.expect_exact("456")
101 self.child.send("\n\n")
102 self.expect_prompt()
104 self.quit()