PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/cli/test_cli_04.e

http://github.com/tybor/Liberty
Specman e | 46 lines | 34 code | 9 blank | 3 comment | 0 complexity | 82c98e1a0c8b6231d26b3adfebf5a046 MD5 | raw file
 1class TEST_CLI_04
 2
 3insert
 4   ARGUMENTS
 5   EIFFELTEST_TOOLS
 6   COMMAND_LINE_ARGUMENT_FACTORY
 7
 8create {}
 9   make
10
11feature {}
12   make
13      local
14         foo_option: COMMAND_LINE_TYPED_ARGUMENT[FIXED_STRING]
15         bar_option: COMMAND_LINE_TYPED_ARGUMENT[INTEGER]
16      do
17         foo_option := option_string("f", "foo", "foo", "The foo string")
18         bar_option := option_integer("b", "bar", "bar", "The bar integer")
19         create args.make(+foo_option and bar_option) -- see TEST_CLI_03; also works written like this
20
21         -- an empty command line is not valid
22         setup
23         assert(not args.parse_command_line)
24
25         -- a bar option alone is not valid
26         setup
27         command_arguments.add_last("--bar=42")
28         assert(not args.parse_command_line)
29
30         -- must have at least foo, bar is optional
31         setup
32         command_arguments.add_last("--foo=the foo z'option")
33         command_arguments.add_last("--bar=42")
34         assert(args.parse_command_line)
35         assert(foo_option.item.is_equal("the foo z'option"))
36         assert(bar_option.item = 42)
37      end
38
39   setup
40      do
41         command_arguments.make(1)
42      end
43
44   args: COMMAND_LINE_ARGUMENTS
45
46end