~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to test/optparse/test_optparse.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'test/unit'
 
2
require 'optparse'
 
3
 
 
4
class TestOptionParser < Test::Unit::TestCase
 
5
  def setup
 
6
    @opt = OptionParser.new
 
7
    @flag = self.class          # cannot set by option
 
8
  end
 
9
  def no_error(*args)
 
10
    assert_nothing_raised(*args) {return yield}
 
11
  end
 
12
 
 
13
  def test_permute
 
14
    assert_equal(%w"", no_error {@opt.permute!(%w"")})
 
15
    assert_equal(self.class, @flag)
 
16
    assert_equal(%w"foo bar", no_error {@opt.permute!(%w"foo bar")})
 
17
    assert_equal(self.class, @flag)
 
18
    assert_equal(%w"- foo bar", no_error {@opt.permute!(%w"- foo bar")})
 
19
    assert_equal(self.class, @flag)
 
20
    assert_equal(%w"foo bar", no_error {@opt.permute!(%w"-- foo bar")})
 
21
    assert_equal(self.class, @flag)
 
22
    assert_equal(%w"foo - bar", no_error {@opt.permute!(%w"foo - bar")})
 
23
    assert_equal(self.class, @flag)
 
24
    assert_equal(%w"foo bar", no_error {@opt.permute!(%w"foo -- bar")})
 
25
    assert_equal(self.class, @flag)
 
26
    assert_equal(%w"foo --help bar", no_error {@opt.permute!(%w"foo -- --help bar")})
 
27
    assert_equal(self.class, @flag)
 
28
  end
 
29
 
 
30
  def test_order
 
31
    assert_equal(%w"", no_error {@opt.order!(%w"")})
 
32
    assert_equal(self.class, @flag)
 
33
    assert_equal(%w"foo bar", no_error {@opt.order!(%w"foo bar")})
 
34
    assert_equal(self.class, @flag)
 
35
    assert_equal(%w"- foo bar", no_error {@opt.order!(%w"- foo bar")})
 
36
    assert_equal(self.class, @flag)
 
37
    assert_equal(%w"foo bar", no_error {@opt.permute!(%w"-- foo bar")})
 
38
    assert_equal(self.class, @flag)
 
39
    assert_equal(%w"foo - bar", no_error {@opt.order!(%w"foo - bar")})
 
40
    assert_equal(self.class, @flag)
 
41
    assert_equal(%w"foo -- bar", no_error {@opt.order!(%w"foo -- bar")})
 
42
    assert_equal(self.class, @flag)
 
43
    assert_equal(%w"foo -- --help bar", no_error {@opt.order!(%w"foo -- --help bar")})
 
44
    assert_equal(self.class, @flag)
 
45
  end
 
46
end