Merge: src/model/model_index: model index uses BKTree
[nit.git] / src / doc / commands / tests / test_commands_main.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 module test_commands_main is test
16
17 import test_commands
18 import doc::commands::commands_main
19
20 class TestCommandsMain
21 super TestCommands
22 test
23
24 fun test_cmd_mains is test do
25 var cmd = new CmdMains(test_model, mentity_name = "test_prog")
26 var res = cmd.init_command
27 assert res isa CmdSuccess
28 var results = cmd.results
29 assert results != null
30 assert results.length == 1
31 assert results.first.full_name == "test_prog::test_prog"
32 end
33
34 fun test_cmd_main_compile is test do
35 var cmd = new CmdMainCompile(test_model, mentity_name = "test_prog::test_prog")
36 var res = cmd.init_command
37 assert res isa CmdSuccess
38
39 var command = cmd.command
40 assert command != null
41 assert command.has_prefix("nitc ")
42 assert command.has_suffix("test_prog.nit")
43 end
44
45 fun test_cmd_testing is test do
46 var cmd = new CmdTesting(test_model, mentity_name = "test_prog")
47 var res = cmd.init_command
48 assert res isa CmdSuccess
49
50 var command = cmd.command
51 assert command != null
52 assert command.has_prefix("nitunit ")
53 assert command.has_suffix("/tests")
54 end
55
56 fun test_cmd_man_synopsis is test do
57 var cmd = new CmdManSynopsis(test_model, mentity_name = "test_prog")
58 var res = cmd.init_command
59 assert res isa CmdSuccess
60 assert cmd.synopsis == "test_prog [*options*] ARGS..."
61 end
62
63 fun test_cmd_man_options is test do
64 var cmd = new CmdManOptions(test_model, mentity_name = "test_prog")
65 var res = cmd.init_command
66 assert res isa CmdSuccess
67
68 var options = cmd.options
69 assert options != null
70 assert options["--opt1"] == "Option 1."
71 assert options["--opt2"] == "Option 2."
72 end
73 end