summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-11-10 14:55:11 -0800
committergit <svn-admin@ruby-lang.org>2022-11-10 22:55:15 +0000
commit8fa83fa0b2031ad17f01b5a12b39599398dc6da6 (patch)
tree99b01439ea80f7b3c3a2d2425def6d53e8bdb747 /test
parentd5513da01d24fbc4de71975b6a49f0ba3b3be401 (diff)
[ruby/irb] Transform ls's --grep/-G option to keyword args
(https://github.com/ruby/irb/pull/437) * Transform ls's --grep/-G option to keyword args * Make --grep less flexible * Support -g instead of --grep * Suppress warnings from symbol aliases
Diffstat (limited to 'test')
-rw-r--r--test/irb/test_cmd.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb
index d233cbb9b5..eafa8be382 100644
--- a/test/irb/test_cmd.rb
+++ b/test/irb/test_cmd.rb
@@ -480,6 +480,44 @@ module TestIRB
assert_match(/C.methods:\s+m5\n/m, out)
end
+ def test_ls_grep
+ pend if RUBY_ENGINE == 'truffleruby'
+ out, err = execute_lines("ls 42\n")
+ assert_empty err
+ assert_match(/times/, out)
+ assert_match(/polar/, out)
+
+ [
+ "ls 42, grep: /times/\n",
+ "ls 42 -g times\n",
+ "ls 42 -G times\n",
+ ].each do |line|
+ out, err = execute_lines(line)
+ assert_empty err
+ assert_match(/times/, out)
+ assert_not_match(/polar/, out)
+ end
+ end
+
+ def test_ls_grep_empty
+ pend if RUBY_ENGINE == 'truffleruby'
+ out, err = execute_lines("ls\n")
+ assert_empty err
+ assert_match(/whereami/, out)
+ assert_match(/show_source/, out)
+
+ [
+ "ls grep: /whereami/\n",
+ "ls -g whereami\n",
+ "ls -G whereami\n",
+ ].each do |line|
+ out, err = execute_lines(line)
+ assert_empty err
+ assert_match(/whereami/, out)
+ assert_not_match(/show_source/, out)
+ end
+ end
+
def test_ls_with_no_singleton_class
out, err = execute_lines(
"ls 42",