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_json_commands
is test
18 intrude import doc
::commands
::commands_main
21 class TestCommandsJson
25 fun print_json
(json
: nullable Serializable) do
26 if json
== null then return
27 print json
.serialize_to_json
(pretty
= true, plain
= true)
32 fun test_cmd_entity
is test
do
33 var cmd
= new CmdEntity(test_model
, mentity_name
= "test_prog::Character")
35 print_json cmd
.to_json
38 fun test_cmd_comment
is test
do
39 var cmd
= new CmdComment(test_model
, mentity_name
= "test_prog::Character")
41 print_json cmd
.to_json
44 fun test_cmd_link
is test
do
45 var cmd
= new CmdEntityLink(test_model
, mentity_name
= "test_prog::Character")
47 print_json cmd
.to_json
52 fun test_cmd_parents
is test
do
53 var cmd
= new CmdParents(test_model
, test_main
, mentity_name
= "test_prog::Warrior")
55 print_json cmd
.to_json
58 fun test_cmd_ancestors
is test
do
59 var cmd
= new CmdAncestors(test_model
, test_main
, mentity_name
= "test_prog::Warrior", parents
= false)
61 print_json cmd
.to_json
64 fun test_cmd_children
is test
do
65 var cmd
= new CmdChildren(test_model
, test_main
, mentity_name
= "test_prog::Career")
67 print_json cmd
.to_json
70 fun test_cmd_descendants
is test
do
71 var cmd
= new CmdDescendants(test_model
, test_main
, mentity_name
= "test_prog::Career")
73 print_json cmd
.to_json
78 fun test_cmd_search
is test
do
79 var cmd
= new CmdSearch(test_model
, query
= "Carer", limit
= 10)
81 print_json cmd
.to_json
86 fun test_cmd_features
is test
do
87 var cmd
= new CmdFeatures(test_model
, mentity_name
= "test_prog::Career")
89 print_json cmd
.to_json
94 fun test_cmd_lin
is test
do
95 var cmd
= new CmdLinearization(test_model
, test_main
, mentity_name
= "init")
97 print_json cmd
.to_json
102 fun test_cmd_mentities
is test
do
103 var cmd
= new CmdModelEntities(test_model
, kind
= "modules")
105 print_json cmd
.to_json
110 fun test_cmd_new
is test
do
111 var cmd
= new CmdNew(test_model
, test_builder
, mentity_name
= "test_prog::Character")
113 print_json cmd
.to_json
116 fun test_cmd_call
is test
do
117 var cmd
= new CmdCall(test_model
, test_builder
, mentity_name
= "strength_bonus")
119 print_json cmd
.to_json
122 fun test_cmd_return
is test
do
123 var cmd
= new CmdReturn(test_model
, mentity_name
= "test_prog::Character")
125 print_json cmd
.to_json
128 fun test_cmd_param
is test
do
129 var cmd
= new CmdParam(test_model
, mentity_name
= "test_prog::Character")
131 print_json cmd
.to_json
136 fun test_cmd_ini_desc
is test
do
137 var cmd
= new CmdIniDescription(test_model
, mentity_name
= "test_prog")
139 print_json cmd
.to_json
142 fun test_cmd_ini_git
is test
do
143 var cmd
= new CmdIniGitUrl(test_model
, mentity_name
= "test_prog")
145 print_json cmd
.to_json
148 fun test_cmd_ini_clone
is test
do
149 var cmd
= new CmdIniCloneCommand(test_model
, mentity_name
= "test_prog")
151 print_json cmd
.to_json
154 fun test_cmd_ini_issues
is test
do
155 var cmd
= new CmdIniIssuesUrl(test_model
, mentity_name
= "test_prog")
157 print_json cmd
.to_json
160 fun test_cmd_ini_maintainer
is test
do
161 var cmd
= new CmdIniMaintainer(test_model
, mentity_name
= "test_prog")
163 print_json cmd
.to_json
166 fun test_cmd_ini_contributors
is test
do
167 var cmd
= new CmdIniContributors(test_model
, mentity_name
= "test_prog")
169 print_json cmd
.to_json
172 fun test_cmd_ini_license
is test
do
173 var cmd
= new CmdIniLicense(test_model
, mentity_name
= "test_prog")
175 print_json cmd
.to_json
178 fun test_cmd_ini_license_file
is test
do
179 var cmd
= new CmdLicenseFile(test_model
, mentity_name
= "test_prog")
181 cmd
.file
= cmd
.file
.as(not null).basename
# for testing path
182 print_json cmd
.to_json
185 fun test_cmd_ini_license_file_content
is test
do
186 var cmd
= new CmdLicenseFileContent(test_model
, mentity_name
= "test_prog")
188 cmd
.file
= cmd
.file
.as(not null).basename
# for testing path
189 print_json cmd
.to_json
192 fun test_cmd_ini_contrib_file
is test
do
193 var cmd
= new CmdContribFile(test_model
, mentity_name
= "test_prog")
195 cmd
.file
= cmd
.file
.as(not null).basename
# for testing path
196 print_json cmd
.to_json
199 fun test_cmd_ini_contrib_file_content
is test
do
200 var cmd
= new CmdContribFileContent(test_model
, mentity_name
= "test_prog")
202 cmd
.file
= cmd
.file
.as(not null).basename
# for testing path
203 print_json cmd
.to_json
208 fun test_cmd_mains
is test
do
209 var cmd
= new CmdMains(test_model
, mentity_name
= "test_prog")
211 print_json cmd
.to_json
214 fun test_cmd_main_compile
is test
do
215 var cmd
= new CmdMainCompile(test_model
, mentity_name
= "test_prog::test_prog")
217 print_json cmd
.to_json
220 fun test_cmd_testing
is test
do
221 var cmd
= new CmdTesting(test_model
, mentity_name
= "test_prog")
223 print_json cmd
.to_json
226 fun test_cmd_man_synopsis
is test
do
227 var cmd
= new CmdManSynopsis(test_model
, mentity_name
= "test_prog")
229 print_json cmd
.to_json
232 fun test_cmd_man_options
is test
do
233 var cmd
= new CmdManOptions(test_model
, mentity_name
= "test_prog")
235 print_json cmd
.to_json
239 redef class nitc
::Location
242 # Avoid diff on location absolute path
243 redef fun core_serialize_to
(v
) do
244 v
.serialize_attribute
("column_end", column_end
)
245 v
.serialize_attribute
("column_start", column_start
)
246 v
.serialize_attribute
("line_end", line_end
)
247 v
.serialize_attribute
("line_start", line_start
)
250 v
.serialize_attribute
("file", "test_location")
256 redef class CmdMainCompile
257 redef fun test_path
(file
) do
258 if file
== null then return null
259 return file
.filename
.basename
264 redef class CmdTesting
265 redef fun test_path
(mentity
) do
266 var file
= mentity
.location
.file
267 if file
== null then return null
268 return file
.filename
.basename