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 import test_deserialization
16 import binary
::serialization
17 #alt1# import test_deserialization_serial
19 class NoSerializeClass
22 var some_attribute
: String
25 var entities
= new TestEntities
27 var tests
= entities
.without_generics
#alt1##alt2#
28 #alt1#var tests = entities.with_generics
29 #alt2#var tests = [new NoSerializeClass("will not deserialize")]
31 var dir
= "out/test_binary_deserialization"
32 if not dir
.file_exists
then dir
.mkdir
34 var path
= dir
/ "alt0"#alt1##alt2#
35 #alt1#var path = dir / "alt1"
36 #alt2#var path = dir / "alt2"
38 var writer
= new FileWriter.open
(path
)
39 var serializer
= new BinarySerializer(writer
)
41 serializer
.serialize o
45 var reader
= new FileReader.open
(path
)
46 var deserializer
= new BinaryDeserializer(reader
)
48 var dst
= deserializer
.deserialize
50 if deserializer
.errors
.not_empty
then
51 print deserializer
.errors
.join
(", ")
55 assert o
.is_same_type
(dst
)
58 print
"# Dst:\n{dst}\n"