From 3665d4a25a9d7e73d7f0f6d1f1020fd59f29c2d6 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Mon, 17 Jul 2023 21:35:20 +0100 Subject: [PATCH] Add test for `show_cmds` pager's termination --- test/irb/yamatanooroti/test_rendering.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/irb/yamatanooroti/test_rendering.rb b/test/irb/yamatanooroti/test_rendering.rb index d2342d6a2..1c4bb2341 100644 --- a/test/irb/yamatanooroti/test_rendering.rb +++ b/test/irb/yamatanooroti/test_rendering.rb @@ -252,6 +252,24 @@ def test_assignment_expression_truncate EOC end + def test_show_cmds_with_pager_can_quit_with_ctrl_c + write_irbrc <<~'LINES' + puts 'start IRB' + LINES + start_terminal(40, 80, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB') + write("show_cmds\n") + write("G") # move to the end of the screen + write("\C-c") # quit pager + close + + screen = result.join("\n").sub(/\n*\z/, "\n") + # IRB::Abort should be rescued + assert_not_match(/IRB::Abort/, screen) + # IRB should resume + assert_not_match(/END/, screen) + assert_match(/=> nil/, screen) + end + private def write_irbrc(content)