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_model
is test
20 class TestModelSerialization
24 fun test_refs_to_full_json
is test
do
25 var mentities
= new Array[MEntity]
26 mentities
.add test_model
.mpackages
.first
27 mentities
.add test_model
.mmodules
.first
28 mentities
.add test_model
.mclasses
.first
29 for mentity
in mentities
do
30 print
((new MEntityRef(mentity
)).serialize_to_json
(pretty
= true, plain
= true))
34 fun test_packages_to_full_json
is test
do
35 for mentity
in test_model
.mpackages
do
36 print mentity
.serialize_to_json
(pretty
= true, plain
= true)
40 fun test_groups_to_full_json
is test
do
41 for mpackage
in test_model
.mpackages
do
42 for mentity
in mpackage
.mgroups
do
43 print mentity
.serialize_to_json
(pretty
= true, plain
= true)
48 fun test_modules_to_full_json
is test
do
49 for mentity
in test_model
.mmodules
do
50 print mentity
.serialize_to_json
(pretty
= true, plain
= true)
54 fun test_classes_to_full_json
is test
do
55 for mentity
in test_model
.mclasses
do
56 print mentity
.serialize_to_json
(pretty
= true, plain
= true)
60 fun test_classdefs_to_full_json
is test
do
61 for mclass
in test_model
.mclasses
do
62 for mentity
in mclass
.mclassdefs
do
63 print mentity
.serialize_to_json
(pretty
= true, plain
= true)
68 fun test_props_to_full_json
is test
do
69 for mentity
in test_model
.mproperties
do
70 print mentity
.serialize_to_json
(pretty
= true, plain
= true)
74 fun test_propdefs_to_full_json
is test
do
75 for mprop
in test_model
.mproperties
do
76 for mentity
in mprop
.mpropdefs
do
77 print mentity
.serialize_to_json
(pretty
= true, plain
= true)
83 redef class nitc
::Location
86 # Avoid diff on location absolute path
87 redef fun core_serialize_to
(v
) do
88 v
.serialize_attribute
("column_end", column_end
)
89 v
.serialize_attribute
("column_start", column_start
)
90 v
.serialize_attribute
("line_end", line_end
)
91 v
.serialize_attribute
("line_start", line_start
)
94 v
.serialize_attribute
("file", "test_location")