1require 'test/unit' 2require 'optparse' 3 4class TestOptionParser < Test::Unit::TestCase 5end 6class TestOptionParser::BashCompletion < Test::Unit::TestCase 7 def setup 8 @opt = OptionParser.new 9 @opt.define("-z", "zzz") {} 10 @opt.define("--foo") {} 11 @opt.define("--bar=BAR") {} 12 @opt.define("--for=TYPE", [:hello, :help, :zot]) {} 13 end 14 15 def test_compsys 16 compsys = @opt.compsys("", "zshcompsys") 17 assert_match(/\"-z\[zzz\]\"/, compsys) 18 assert_match(/\"--foo\[\]\"/, compsys) 19 assert_match(/\"--bar\[\]\"/, compsys) 20 assert_match(/\"--for\[\]\"/, compsys) 21 end 22end 23