~ubuntu-branches/ubuntu/raring/jruby/raring

« back to all changes in this revision

Viewing changes to test/externals/ruby1.8/optparse/test_summary.rb

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Delafond
  • Date: 2010-05-12 15:56:25 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 maverick)
  • Revision ID: james.westby@ubuntu.com-20100512155625-sgdfaj1hn8k84090
Tags: 1.5.0~rc3-1
New upstream release (Closes: #581360).

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; end
 
5
class TestOptionParser::SummaryTest < Test::Unit::TestCase
 
6
  def test_short_clash
 
7
    r = nil
 
8
    o = OptionParser.new do |opts|
 
9
      opts.on("-f", "--first-option", "description 1", "description 2"){r = "first-option"}
 
10
      opts.on("-t", "--test-option"){r = "test-option"}
 
11
      opts.on("-t", "--another-test-option"){r = "another-test-option"}
 
12
      opts.separator "this is\nseparator"
 
13
      opts.on("-l", "--last-option"){r = "last-option"}
 
14
    end
 
15
    s = o.summarize
 
16
    o.parse("-t")
 
17
    assert_match(/--#{r}/, s.grep(/^\s*-t,/)[0])
 
18
    assert_match(/first-option/, s[0])
 
19
    assert_match(/description 1/, s[0])
 
20
    assert_match(/description 2/, s[1])
 
21
    assert_match(/last-option/, s[-1])
 
22
  end
 
23
end