tests: test a module generated by `nitserial`
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 6 Aug 2014 17:19:54 +0000 (13:19 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 13 Aug 2014 15:56:26 +0000 (11:56 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

tests/sav/test_deserialization_serial.res [new file with mode: 0644]
tests/test_deserialization_serial.nit [new file with mode: 0644]

diff --git a/tests/sav/test_deserialization_serial.res b/tests/sav/test_deserialization_serial.res
new file mode 100644 (file)
index 0000000..189c39d
--- /dev/null
@@ -0,0 +1,65 @@
+# Nit:
+<A: true a 0.123 1234 asdf false>
+
+# Json:
+{"__kind": "obj", "__id": 0, "__class": "A", "b": true, "c": {"__kind": "char", "__val": "a"}, "f": 0.123, "i": 1234, "s": "asdf", "n": null}
+
+# Back in Nit:
+<A: true a 0.123 1234 asdf false>
+
+# Nit:
+<B: <A: false b 123.123 2345 hjkl false> 1111 qwer>
+
+# Json:
+{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": null, "ii": 1111, "ss": "qwer"}
+
+# Back in Nit:
+<B: <A: false b 123.123 2345 hjkl false> 1111 qwer>
+
+# Nit:
+<C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl false> 1111 qwer>>
+
+# Json:
+{"__kind": "obj", "__id": 0, "__class": "C", "a": {"__kind": "obj", "__id": 1, "__class": "A", "b": true, "c": {"__kind": "char", "__val": "a"}, "f": 0.123, "i": 1234, "s": "asdf", "n": null}, "b": {"__kind": "obj", "__id": 2, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": null, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+
+# Back in Nit:
+<C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl false> 1111 qwer>>
+
+# Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false> 1111         f"\r\/> true>
+
+# Json:
+{"__kind": "obj", "__id": 0, "__class": "D", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "new line ->\n<-", "n": null, "ii": 1111, "ss": "\tf\"\r\\\/", "d": {"__kind": "ref", "__id": 0}}
+
+# Back in Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false> 1111         f"\r\/> true>
+
+# Nit:
+<E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>
+
+# Json:
+{"__kind": "obj", "__id": 0, "__class": "E", "a": {"__kind": "obj", "__id": 1, "__class": "Array[Object]", "__length": 3, "__items": ["hello", 1234, 123.4]}, "b": ["hella", 2345, 234.5]}
+
+# Back in Nit:
+<E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>
+
+# Nit:
+<E: 2222>
+
+# Json:
+{"__kind": "obj", "__id": 0, "__class": "F[Int]", "n": 2222}
+
+# Back in Nit:
+<E: 2222>
+
+# Nit:
+<E: 33.33>
+
+# Json:
+{"__kind": "obj", "__id": 0, "__class": "F[Float]", "n": 33.33}
+
+# Back in Nit:
+<E: 33.33>
+
diff --git a/tests/test_deserialization_serial.nit b/tests/test_deserialization_serial.nit
new file mode 100644 (file)
index 0000000..1279538
--- /dev/null
@@ -0,0 +1,37 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This file is generated by nitserial
+# Saved here for testing
+module test_deserialization_serial
+
+import test_deserialization
+import serialization
+
+redef class Deserializer
+       redef fun deserialize_class(name)
+       do
+                       if name == "Array[Object]" then return new Array[Object].from_deserializer(self)
+                       if name == "Array[nullable Serializable]" then return new Array[nullable Serializable].from_deserializer(self)
+                       if name == "F[Int]" then return new F[Int].from_deserializer(self)
+                       if name == "F[Float]" then return new F[Float].from_deserializer(self)
+                       if name == "Array[Serializable]" then return new Array[Serializable].from_deserializer(self)
+                       if name == "Array[String]" then return new Array[String].from_deserializer(self)
+                       if name == "Array[HashMap[String, nullable Object]]" then return new Array[HashMap[String, nullable Object]].from_deserializer(self)
+                       if name == "Array[Match]" then return new Array[Match].from_deserializer(self)
+                       if name == "Array[nullable Object]" then return new Array[nullable Object].from_deserializer(self)
+                       if name == "Array[FlatBuffer]" then return new Array[FlatBuffer].from_deserializer(self)
+               return super
+       end
+end