diff options
author | Stan Lo <[email protected]> | 2023-01-11 21:26:12 +0000 |
---|---|---|
committer | git <[email protected]> | 2023-01-11 21:26:18 +0000 |
commit | c693dfd7ef686ccda9db18340bc426e1227e5b53 (patch) | |
tree | 05995cca971bd9f8db0b6211d6238125cb351494 | |
parent | 36420068725e5b4b86b3481fa1f82b249a60d928 (diff) |
[ruby/irb] Drop unused arguments in `RubyLex`
(https://github.com/ruby/irb/pull/504)
* Simplify `RubyLex#set_prompt`
It's optional argument is never used by any caller.
* Remove the optional `p` argument from `RubyLex#set_input`
The argument is only used in a test case, which can be easily replaced by
a block argument.
-rw-r--r-- | lib/irb/ruby-lex.rb | 15 | ||||
-rw-r--r-- | test/irb/test_ruby_lex.rb | 4 |
2 files changed, 7 insertions, 12 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index c3171f486c..40c194efeb 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -48,7 +48,7 @@ class RubyLex end # io functions - def set_input(io, p = nil, context:, &block) + def set_input(io, context:, &block) @io = io if @io.respond_to?(:check_termination) @io.check_termination do |code| @@ -116,22 +116,15 @@ class RubyLex end end - if p.respond_to?(:call) - @input = p - elsif block_given? + if block_given? @input = block else @input = Proc.new{@io.gets} end end - def set_prompt(p = nil, &block) - p = block if block_given? - if p.respond_to?(:call) - @prompt = p - else - @prompt = Proc.new{print p} - end + def set_prompt(&block) + @prompt = block end ERROR_TOKENS = [ diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb index 1c1ce92e6a..8c8aa74079 100644 --- a/test/irb/test_ruby_lex.rb +++ b/test/irb/test_ruby_lex.rb @@ -62,7 +62,9 @@ module TestIRB context = build_context(local_variables) io = proc{ lines.join("\n") } - ruby_lex.set_input(io, io, context: context) + ruby_lex.set_input(io, context: context) do + lines.join("\n") + end ruby_lex.lex(context) ruby_lex end |