1 # This file is part of NIT ( http://www.nitlanguage.org ).
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 module test_commands_main
is test
18 import doc
::commands
::commands_main
20 class TestCommandsMain
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"
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
39 var command
= cmd
.command
40 assert command
!= null
41 assert command
.has_prefix
("nitc ")
42 assert command
.has_suffix
("test_prog.nit")
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
50 var command
= cmd
.command
51 assert command
!= null
52 assert command
.has_prefix
("nitunit ")
53 assert command
.has_suffix
("/tests")
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..."
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
68 var options
= cmd
.options
69 assert options
!= null
70 assert options
["--opt1"] == "Option 1."
71 assert options
["--opt2"] == "Option 2."