4 class TestOptionParser < Test::Unit::TestCase
6 @opt = OptionParser.new
7 @flag = self.class # cannot set by option
10 assert_nothing_raised(*args) {return yield}
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)
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)