From 2b67566926760c7c2894ae78331a3b43b9d05055 Mon Sep 17 00:00:00 2001 From: tompng Date: Sun, 24 Dec 2023 01:50:13 +0900 Subject: [PATCH] Fix command test --- test/irb/test_cmd.rb | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index d99ac05c5..c192256fd 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -373,17 +373,19 @@ def test_measure_toggle } } out, err = execute_lines( - "measure :foo", - "measure :on, :bar", - "3\n", + "measure :foo\n", + "1\n", + "measure :on, :bar\n", + "2\n", "measure :off, :foo\n", - "measure :off, :bar\n", "3\n", + "measure :off, :bar\n", + "4\n", conf: conf ) assert_empty err - assert_match(/\AFOO is added\.\n=> nil\nfoo\nBAR is added\.\n=> nil\nbar\nfoo\n=> 3\nbar\nfoo\n=> nil\nbar\n=> nil\n=> 3\n/, out) + assert_match(/\AFOO is added\.\n=> nil\nfoo\n=> 1\nBAR is added\.\n=> nil\nbar\nfoo\n=> 2\n=> nil\nbar\n=> 3\n=> nil\n=> 4\n/, out) end def test_measure_with_proc_warning @@ -402,7 +404,6 @@ def test_measure_with_proc_warning out, err = execute_lines( "3\n", "measure do\n", - "end\n", "3\n", conf: conf, main: c @@ -524,7 +525,8 @@ class WorkspacesTest < WorkspaceCommandTestCase def test_workspaces_returns_the_array_of_non_main_workspaces out, err = execute_lines( "pushws #{self.class}::Foo.new\n", - "workspaces.map { |w| w.class.name }", + "workspaces\n", + "_.map { |w| w.class.name }", ) assert_empty err @@ -535,7 +537,8 @@ def test_workspaces_returns_the_array_of_non_main_workspaces def test_workspaces_returns_empty_array_when_no_workspaces_were_added out, err = execute_lines( - "workspaces.map(&:to_s)", + "workspaces\n", + "_.map(&:to_s)", ) assert_empty err @@ -548,7 +551,8 @@ def test_popws_replaces_the_current_workspace_with_the_previous_one out, err = execute_lines( "pushws Foo.new\n", "popws\n", - "cwws.class", + "cwws\n", + "_.class", ) assert_empty err assert_include(out, "=> #{self.class}") @@ -567,7 +571,8 @@ class ChwsTest < WorkspaceCommandTestCase def test_chws_replaces_the_current_workspace out, err = execute_lines( "chws #{self.class}::Foo.new\n", - "cwws.class", + "cwws\n", + "_.class", ) assert_empty err assert_include(out, "=> #{self.class}::Foo") @@ -576,7 +581,8 @@ def test_chws_replaces_the_current_workspace def test_chws_does_nothing_when_receiving_no_argument out, err = execute_lines( "chws\n", - "cwws.class", + "cwws\n", + "_.class", ) assert_empty err assert_include(out, "=> #{self.class}") @@ -747,18 +753,18 @@ def test_ls_grep def test_ls_grep_empty out, err = execute_lines("ls\n") assert_empty err - assert_match(/whereami/, out) - assert_match(/show_source/, out) + assert_match(/assert/, out) + assert_match(/refute/, out) [ - "ls grep: /whereami/\n", - "ls -g whereami\n", - "ls -G whereami\n", + "ls grep: /assert/\n", + "ls -g assert\n", + "ls -G assert\n", ].each do |line| out, err = execute_lines(line) assert_empty err - assert_match(/whereami/, out) - assert_not_match(/show_source/, out) + assert_match(/assert/, out) + assert_not_match(/refute/, out) end end