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

/test/lib/cli/test_cli_06.e

http://github.com/tybor/Liberty
Specman e | 58 lines | 46 code | 9 blank | 3 comment | 1 complexity | f5b5d412a08fe2f4a0efee4c4355de22 MD5 | raw file
 1class TEST_CLI_06
 2
 3insert
 4   ARGUMENTS
 5   EIFFELTEST_TOOLS
 6   COMMAND_LINE_ARGUMENT_FACTORY
 7
 8create {}
 9   make
10
11feature {}
12   make
13      local
14         verbose_option: COMMAND_LINE_TYPED_ARGUMENT[INTEGER]
15         arg1: COMMAND_LINE_TYPED_ARGUMENT[FIXED_STRING]
16         arg2: COMMAND_LINE_TYPED_ARGUMENT[FIXED_STRING]
17      do
18         verbose_option := option_counter("v", "verbose", "The verbose option, set more than once for increased verbosity")
19         arg1 := positional_string("arg1", "The first positional parameter")
20         arg2 := positional_string("arg2", "The second positional parameter")
21         create args.make(verbose_option and arg1 and arg2)
22
23         -- an empty command line is not valid
24         setup
25         assert(not args.parse_command_line)
26
27         -- an option alone is not valid
28         setup
29         command_arguments.add_last("--verbose")
30         assert(not args.parse_command_line)
31
32         -- check mixed verbosity levels
33         setup
34         command_arguments.add_last("first arg")
35         command_arguments.add_last("-v")
36         command_arguments.add_last("second arg")
37         assert(args.parse_command_line)
38         assert(arg1.item.is_equal("first arg"))
39         assert(arg2.item.is_equal("second arg"))
40         assert(verbose_option.item = 1)
41         setup
42         command_arguments.add_last("first arg")
43         command_arguments.add_last("-vv")
44         command_arguments.add_last("second arg")
45         assert(args.parse_command_line)
46         assert(arg1.item.is_equal("first arg"))
47         assert(arg2.item.is_equal("second arg"))
48         assert(verbose_option.item = 2)
49      end
50
51   setup
52      do
53         command_arguments.make(1)
54      end
55
56   args: COMMAND_LINE_ARGUMENTS
57
58end