mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/optparse.rb (OptionParser#to_a): String#to_a is no longer
defined. [ruby-dev:45568][Bug #6348] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
770ddcdfe0
commit
a9917efd5d
3 changed files with 24 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Apr 24 14:54:03 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/optparse.rb (OptionParser#to_a): String#to_a is no longer
|
||||||
|
defined. [ruby-dev:45568][Bug #6348]
|
||||||
|
|
||||||
Tue Apr 24 12:46:50 2012 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
Tue Apr 24 12:46:50 2012 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
* hash.c, object.c, struct.c, lib/ostruct.rb: add to_h methods.
|
* hash.c, object.c, struct.c, lib/ostruct.rb: add to_h methods.
|
||||||
|
|
|
@ -1065,13 +1065,13 @@ XXX
|
||||||
#
|
#
|
||||||
# Returns option summary string.
|
# Returns option summary string.
|
||||||
#
|
#
|
||||||
def help; summarize(banner.to_s.sub(/\n?\z/, "\n")) end
|
def help; summarize("#{banner}".sub(/\n?\z/, "\n")) end
|
||||||
alias to_s help
|
alias to_s help
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns option summary list.
|
# Returns option summary list.
|
||||||
#
|
#
|
||||||
def to_a; summarize(banner.to_a.dup) end
|
def to_a; summarize([*banner]) end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Checks if an argument is given twice, in which case an ArgumentError is
|
# Checks if an argument is given twice, in which case an ArgumentError is
|
||||||
|
|
|
@ -18,4 +18,21 @@ class TestOptionParser::SummaryTest < TestOptionParser
|
||||||
assert_match(/description 2/, s[1])
|
assert_match(/description 2/, s[1])
|
||||||
assert_match(/last-option/, s[-1])
|
assert_match(/last-option/, s[-1])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_banner
|
||||||
|
o = OptionParser.new("foo bar")
|
||||||
|
assert_equal("foo bar", o.banner)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_banner_from_progname
|
||||||
|
o = OptionParser.new
|
||||||
|
o.program_name = "foobar"
|
||||||
|
assert_equal("Usage: foobar [options]\n", o.help)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_summary
|
||||||
|
o = OptionParser.new("foo bar")
|
||||||
|
assert_equal("foo bar\n", o.to_s)
|
||||||
|
assert_equal(["foo bar"], o.to_a)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue