1""" 2Tests navigating in the multiline expression editor. 3""" 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test.lldbpexpect import PExpectTest 9 10class 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 @skipIfEditlineSupportMissing 21 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr48316') 22 def test_nav_arrow_up(self): 23 """Tests that we can navigate back to the previous line with the up arrow""" 24 self.launch() 25 26 # Start multiline expression mode by just running 'expr' 27 self.child.sendline("expr") 28 self.child.expect_exact("terminate with an empty line to evaluate") 29 # Create a simple integer expression '123' and press enter. 30 self.child.send("123\n") 31 # We should see the prompt for the second line of our expression. 32 self.child.expect_exact("2: ") 33 # Go back to the first line and change 123 to 124. 34 # Then press enter twice to evaluate our expression. 35 self.child.send(self.arrow_up + "\b4\n\n") 36 # The result of our expression should be 124 (our edited expression) 37 # and not 123 (the one we initially typed). 38 self.child.expect_exact("(int) $0 = 124") 39 40 self.quit() 41 42 @skipIfAsan 43 @skipIfEditlineSupportMissing 44 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr48316') 45 def test_nav_arrow_down(self): 46 """Tests that we can navigate to the next line with the down arrow""" 47 self.launch() 48 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") 70 71 self.quit() 72