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_json
is test
18 import doc
::commands
::commands_json
20 class TestCommandsJson
24 fun print_json
(json
: nullable Serializable) do
25 if json
== null then return
26 print json
.serialize_to_json
(pretty
= true, plain
= true)
31 fun test_cmd_entity
is test
do
32 var cmd
= new CmdEntity(test_view
, mentity_name
= "test_prog::Character")
34 print_json cmd
.to_json
37 fun test_cmd_comment
is test
do
38 var cmd
= new CmdComment(test_view
, mentity_name
= "test_prog::Character")
40 print_json cmd
.to_json
43 fun test_cmd_link
is test
do
44 var cmd
= new CmdEntityLink(test_view
, mentity_name
= "test_prog::Character")
46 print_json cmd
.to_json
51 fun test_cmd_parents
is test
do
52 var cmd
= new CmdParents(test_view
, mentity_name
= "test_prog::Warrior")
54 print_json cmd
.to_json
57 fun test_cmd_ancestors
is test
do
58 var cmd
= new CmdAncestors(test_view
, mentity_name
= "test_prog::Warrior", parents
= false)
60 print_json cmd
.to_json
63 fun test_cmd_children
is test
do
64 var cmd
= new CmdChildren(test_view
, mentity_name
= "test_prog::Career")
66 print_json cmd
.to_json
69 fun test_cmd_descendants
is test
do
70 var cmd
= new CmdDescendants(test_view
, mentity_name
= "test_prog::Career")
72 print_json cmd
.to_json
77 fun test_cmd_search
is test
do
78 var cmd
= new CmdSearch(test_view
, query
= "Carer", limit
= 10)
80 print_json cmd
.to_json
85 fun test_cmd_features
is test
do
86 var cmd
= new CmdFeatures(test_view
, mentity_name
= "test_prog::Career")
88 print_json cmd
.to_json
93 fun test_cmd_lin
is test
do
94 var cmd
= new CmdLinearization(test_view
, mentity_name
= "init")
96 print_json cmd
.to_json
101 fun test_cmd_mentities
is test
do
102 var cmd
= new CmdModelEntities(test_view
, kind
= "modules")
104 print_json cmd
.to_json
109 fun test_cmd_new
is test
do
110 var cmd
= new CmdNew(test_view
, test_builder
, mentity_name
= "test_prog::Character")
112 print_json cmd
.to_json
115 fun test_cmd_call
is test
do
116 var cmd
= new CmdCall(test_view
, test_builder
, mentity_name
= "strength_bonus")
118 print_json cmd
.to_json
121 fun test_cmd_return
is test
do
122 var cmd
= new CmdReturn(test_view
, mentity_name
= "test_prog::Character")
124 print_json cmd
.to_json
127 fun test_cmd_param
is test
do
128 var cmd
= new CmdParam(test_view
, mentity_name
= "test_prog::Character")
130 print_json cmd
.to_json
134 redef class nitc
::Location
137 # Avoid diff on location absolute path
138 redef fun core_serialize_to
(v
) do
139 v
.serialize_attribute
("column_end", column_end
)
140 v
.serialize_attribute
("column_start", column_start
)
141 v
.serialize_attribute
("line_end", line_end
)
142 v
.serialize_attribute
("line_start", line_start
)
145 v
.serialize_attribute
("file", "test_location")