1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
30 init(b
: Bool, c
: Char, f
: Float, i
: Int, s
: String, n
: nullable Int)
39 redef fun to_s
do return "<A: {b} {c} {f} {i} {s} {n != null}>"
50 init(b
: Bool, c
: Char, f
: Float, i
: Int, s
: String, n
: nullable Int, ii
: Int, ss
: String)
52 super(b
, c
, f
, i
, s
, n
)
58 redef fun to_s
do return "<B: {super} {ii} {ss}>"
61 # Composed of an A and a B
66 var b
= new B
(false, 'b', 123.123, 2345, "hjkl", 12, 1111, "qwer")
76 redef fun to_s
do return "<C: {a} {b}>"
79 # Class with cyclic reference
84 var d
: nullable D
= null
86 redef fun to_s
do return "<D: {super} {d != null}>"
93 var a
= new Array[Object].with_items
("hello", 1234, 123.4)
94 var b
= new Array[nullable Serializable].with_items
("hella", 2345, 234.5)
96 redef fun to_s
do return "<E: a: {a.join(", ")}; b: {b.join(", ")}>"
105 redef fun to_s
do return "<E: {n}>"
112 var hs
= new HashSet[Int]
113 var s
: Set[String] = new ArraySet[String]
114 var hm
= new HashMap[String, Int]
115 var am
= new ArrayMap[String, String]
129 redef fun to_s
do return "<G: hs: {hs.join(", ")}; s: {s.join(", ")}; "+
130 "hm: {hm.join(", ", ". ")}; am: {am.join(", ", ". ")}>"
134 var a
= new A
(true, 'a', 0.1234, 1234, "asdf", null)
135 var b
= new B
(false, 'b', 123.123, 2345, "hjkl", 12, 1111, "qwer")
137 var d
= new D
(false, 'b', 123.123, 2345, "new line ->\n<-", null, 1111, "\t\f\"\r\\
/")
140 var fi = new F[Int](2222)
141 var ff = new F[Float](33.33)
144 # should work without nitserial
145 var without_generics: Array[Serializable] = [a, b, c, d: Serializable]
147 # Default works only with Nit serial
148 var with_generics: Array[Serializable] = [a, b, c, d, e, fi, ff, g: Serializable]
151 # We instanciate it here so that `nitserial` detects generic types as being alive
152 var entities = new TestEntities