diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-05 10:09:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-05 10:09:58 +0000 |
commit | 4dada1c8a20c0fab0e058d7cd934c1c011617049 (patch) | |
tree | bf5ed7bc0310d7d113d3bf57d6e01eb92ba3413e /test/optparse/test_optparse.rb | |
parent | 9983e4645ec127d90d402af42cb36e446cfaafe3 (diff) | |
download | ruby-4dada1c8a20c0fab0e058d7cd934c1c011617049.tar.gz |
* lib/optparse.rb (OptionParser::Switch::PlacedArgument::parse):
do not remove next argument if empty value is placed.
* test/optparse: added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/optparse/test_optparse.rb')
-rw-r--r-- | test/optparse/test_optparse.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/optparse/test_optparse.rb b/test/optparse/test_optparse.rb new file mode 100644 index 0000000000..9c73399f5b --- /dev/null +++ b/test/optparse/test_optparse.rb @@ -0,0 +1,46 @@ +require 'test/unit' +require 'optparse' + +class TestOptionParser < Test::Unit::TestCase + def setup + @opt = OptionParser.new + @flag = self.class # cannot set by option + end + def no_error(*args) + assert_nothing_raised(*args) {return yield} + end + + def test_permute + assert_equal(%w"", no_error {@opt.permute!(%w"")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo bar", no_error {@opt.permute!(%w"foo bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"- foo bar", no_error {@opt.permute!(%w"- foo bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo bar", no_error {@opt.permute!(%w"-- foo bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo - bar", no_error {@opt.permute!(%w"foo - bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo bar", no_error {@opt.permute!(%w"foo -- bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo --help bar", no_error {@opt.permute!(%w"foo -- --help bar")}) + assert_equal(self.class, @flag) + end + + def test_order + assert_equal(%w"", no_error {@opt.order!(%w"")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo bar", no_error {@opt.order!(%w"foo bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"- foo bar", no_error {@opt.order!(%w"- foo bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo bar", no_error {@opt.permute!(%w"-- foo bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo - bar", no_error {@opt.order!(%w"foo - bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo -- bar", no_error {@opt.order!(%w"foo -- bar")}) + assert_equal(self.class, @flag) + assert_equal(%w"foo -- --help bar", no_error {@opt.order!(%w"foo -- --help bar")}) + assert_equal(self.class, @flag) + end +end |