ruby-changes:49929
From: nobu <ko1@a...>
Date: Fri, 26 Jan 2018 12:41:08 +0900 (JST)
Subject: [ruby-changes:49929] nobu:r62047 (trunk): optparse.rb: froze string literals
nobu 2018-01-26 12:41:04 +0900 (Fri, 26 Jan 2018) New Revision: 62047 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62047 Log: optparse.rb: froze string literals Modified files: trunk/lib/optparse.rb trunk/test/optparse/test_summary.rb Index: lib/optparse.rb =================================================================== --- lib/optparse.rb (revision 62046) +++ lib/optparse.rb (revision 62047) @@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L1 -# frozen_string_literal: false +# frozen_string_literal: true # # optparse.rb - command-line option analysis with the OptionParser class. # @@ -577,7 +577,7 @@ class OptionParser https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L577 while s = lopts.shift l = left[-1].length + s.length l += arg.length if left.size == 1 && arg - l < max or sopts.empty? or left << '' + l < max or sopts.empty? or left << +'' left[-1] << (left[-1].empty? ? ' ' * 4 : ', ') << s end @@ -1136,7 +1136,7 @@ XXX https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L1136 # def banner unless @banner - @banner = "Usage: #{program_name} [options]" + @banner = +"Usage: #{program_name} [options]" visit(:add_banner, @banner) end @banner @@ -1180,7 +1180,7 @@ XXX https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L1180 # def ver if v = version - str = "#{program_name} #{[v].join('.')}" + str = +"#{program_name} #{[v].join('.')}" str << " (#{v})" if v = release str end Index: test/optparse/test_summary.rb =================================================================== --- test/optparse/test_summary.rb (revision 62046) +++ test/optparse/test_summary.rb (revision 62047) @@ -44,4 +44,13 @@ class TestOptionParser::SummaryTest < Te https://github.com/ruby/ruby/blob/trunk/test/optparse/test_summary.rb#L44 assert_equal("foo bar\n", o.to_s, bug6348) assert_equal(["foo bar"], o.to_a, bug6348) end + + def test_ver + o = OptionParser.new("foo bar") + o.program_name = "foo" + o.version = [0, 1] + assert_equal "foo 0.1", o.ver + o.release = "rel" + assert_equal "foo 0.1 (rel)", o.ver + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/