Merge: Faster ASCII-only strings
authorJean Privat <jean@pryen.org>
Thu, 28 Apr 2016 23:04:49 +0000 (19:04 -0400)
committerJean Privat <jean@pryen.org>
Thu, 28 Apr 2016 23:04:49 +0000 (19:04 -0400)
This simple PR re-introduces the concept of ASCII strings for faster no-overhead accesses to random characters in a string.

The class is private as it is to be used only internally, no client should care for the specific type of a String and all performance improvements will be automatic, should the optimization be possible.

Since we are dealing with UTF-8, the only case where O(1) access can efficiently and without much overhead (one `if` statement at creation) be determined, is when a string only contains ASCII characters.
Note that since the Buffer can change access semantics depending on what is appended during its lifetime, no ASCII-only FlatBuffer has been added.

This is implemented here by introducing two subclasses of FlatString, one for ASCII only strings, and one for regular Unicode strings (the old FlatString).

In terms of performance, in the compiler, there is a ~0.5% improvement, but in specific cases like JSON parsing for the `big_gov_data.json` (where not a single unicode character is present) bench, the difference amounts to ~35%.

Pull-Request: #2040
Reviewed-by: Jean Privat <jean@pryen.org>

46 files changed:
lib/json/serialization.nit
lib/nitcorn/examples/www/hello_world/dir/binary_file.png [new file with mode: 0644]
lib/nitcorn/file_server.nit
lib/nitcorn/reactor.nit
lib/nitcorn/server_config.nit
lib/pthreads/pthreads.nit
src/compiler/abstract_compiler.nit
src/interpreter/dynamic_loading_ffi/on_demand_compiler.nit
src/interpreter/naive_interpreter.nit
src/modelbuilder_base.nit
src/modelize/modelize_property.nit
tests/base_new_factory.nit [new file with mode: 0644]
tests/error_unk_class.nit
tests/error_unk_class2.nit [new file with mode: 0644]
tests/sav/base_new_factory.res [new file with mode: 0644]
tests/sav/error_unk_class.res
tests/sav/error_unk_class2.res [new file with mode: 0644]
tests/sav/nitce/test_json_deserialization_alt1.res
tests/sav/nitce/test_json_deserialization_alt3.res [new file with mode: 0644]
tests/sav/nitce/test_serialization.res
tests/sav/nitce/test_serialization_alt2.res
tests/sav/nitce/test_serialization_alt3.res
tests/sav/nitce/test_serialization_alt4.res
tests/sav/nitce/test_serialization_alt5.res
tests/sav/nitce/test_serialization_redef.res
tests/sav/nitce/test_serialization_redef_alt0.res
tests/sav/nitce/test_serialization_redef_alt1.res
tests/sav/nitce/test_serialization_redef_alt2.res
tests/sav/test_json_deserialization.res
tests/sav/test_json_deserialization_alt1.res
tests/sav/test_json_deserialization_alt2.res
tests/sav/test_json_deserialization_alt3.res [new file with mode: 0644]
tests/sav/test_json_deserialization_alt4.res [new file with mode: 0644]
tests/sav/test_nitcorn.res [new file with mode: 0644]
tests/sav/test_serialization.res
tests/sav/test_serialization_alt1.res
tests/sav/test_serialization_alt2.res
tests/sav/test_serialization_alt3.res
tests/sav/test_serialization_alt4.res
tests/sav/test_serialization_alt5.res
tests/sav/test_serialization_redef.res
tests/sav/test_serialization_redef_alt0.res
tests/sav/test_serialization_redef_alt1.res
tests/sav/test_serialization_redef_alt2.res
tests/test_json_deserialization.nit
tests/test_nitcorn.nit [new file with mode: 0644]

index 5da6289..4d00782 100644 (file)
@@ -99,7 +99,7 @@ class JsonSerializer
        # Target writing stream
        var stream: Writer
 
-       # Write plain JSON? easier to read but does not support Nit deserialization
+       # Write plain JSON? Standard JSON without metadata for deserialization
        #
        # If `false`, the default, serialize to support deserialization:
        #
@@ -121,9 +121,18 @@ class JsonSerializer
        # * Does not support cycles, will replace the problematic references by `null`.
        # * Does not serialize the meta-data needed to deserialize the objects
        #   back to regular Nit objects.
-       # * Keys of Nit `HashMap` are converted to their string reprensentation using `to_s`.
+       # * Keys of Nit `HashMap` are converted to their string representation using `to_s`.
        var plain_json = false is writable
 
+       # Write pretty JSON for human eyes?
+       #
+       # Toggles skipping lines between attributes of an object and
+       # properly indent the written JSON.
+       var pretty_json = false is writable
+
+       # Current indentation level used for writing `pretty_json`
+       private var indent_level = 0
+
        # List of the current open objects, the first is the main target of the serialization
        #
        # Used only when `plain_json == true` to detect cycles in serialization.
@@ -142,7 +151,8 @@ class JsonSerializer
                        if plain_json then
                                for o in open_objects do
                                        if object.is_same_serialized(o) then
-                                               # Cycle detected
+                                               # Cycle, can't be managed in plain json
+                                               warn "Cycle detected in serialized object, replacing reference with 'null'."
                                                stream.write "null"
                                                return
                                        end
@@ -162,10 +172,11 @@ class JsonSerializer
        redef fun serialize_attribute(name, value)
        do
                if not plain_json or not first_attribute then
-                       stream.write ", "
+                       stream.write ","
                        first_attribute = false
                end
 
+               new_line_and_indent
                stream.write "\""
                stream.write name
                stream.write "\": "
@@ -177,14 +188,28 @@ class JsonSerializer
                if not plain_json and cache.has_object(object) then
                        # if already serialized, add local reference
                        var id = cache.id_for(object)
-                       stream.write "\{\"__kind\": \"ref\", \"__id\": "
+                       stream.write "\{"
+                       indent_level += 1
+                       new_line_and_indent
+                       stream.write "\"__kind\": \"ref\", \"__id\": "
                        stream.write id.to_s
+                       indent_level -= 1
+                       new_line_and_indent
                        stream.write "\}"
                else
                        # serialize here
                        serialize object
                end
        end
+
+       # Write a new line and indent it, only if `pretty_json`
+       private fun new_line_and_indent
+       do
+               if pretty_json then
+                       stream.write "\n"
+                       for i in indent_level.times do stream.write "\t"
+               end
+       end
 end
 
 # Deserializer from a Json string.
@@ -475,7 +500,9 @@ redef class Serializable
        do
                var id = v.cache.new_id_for(self)
                v.stream.write "\{"
+               v.indent_level += 1
                if not v.plain_json then
+                       v.new_line_and_indent
                        v.stream.write "\"__kind\": \"obj\", \"__id\": "
                        v.stream.write id.to_s
                        v.stream.write ", \"__class\": \""
@@ -483,6 +510,9 @@ redef class Serializable
                        v.stream.write "\""
                end
                core_serialize_to(v)
+
+               v.indent_level -= 1
+               v.new_line_and_indent
                v.stream.write "\}"
        end
 
@@ -545,16 +575,21 @@ redef class Collection[E]
        private fun serialize_to_pure_json(v: JsonSerializer)
        do
                        v.stream.write "["
+                       v.indent_level += 1
                        var is_first = true
                        for e in self do
                                if is_first then
                                        is_first = false
-                               else v.stream.write ", "
+                               else v.stream.write ","
+                               v.new_line_and_indent
 
                                if not v.try_to_serialize(e) then
+                                       assert e != null # null would have been serialized
                                        v.warn("element of type {e.class_name} is not serializable.")
                                end
                        end
+                       v.indent_level -= 1
+                       v.new_line_and_indent
                        v.stream.write "]"
        end
 end
@@ -565,16 +600,23 @@ redef class SimpleCollection[E]
                # Register as pseudo object
                if not v.plain_json then
                        var id = v.cache.new_id_for(self)
-                       v.stream.write """{"__kind": "obj", "__id": """
+                       v.stream.write """{"""
+                       v.indent_level += 1
+                       v.new_line_and_indent
+                       v.stream.write """"__kind": "obj", "__id": """
                        v.stream.write id.to_s
                        v.stream.write """, "__class": """"
                        v.stream.write class_name
-                       v.stream.write """", "__items": """
+                       v.stream.write """","""
+                       v.new_line_and_indent
+                       v.stream.write """"__items": """
                end
 
                serialize_to_pure_json v
 
                if not v.plain_json then
+                       v.indent_level -= 1
+                       v.new_line_and_indent
                        v.stream.write "\}"
                end
        end
@@ -603,35 +645,49 @@ redef class Map[K, V]
 
                if v.plain_json then
                        v.stream.write "\{"
+                       v.indent_level += 1
                        var first = true
                        for key, val in self do
                                if not first then
-                                       v.stream.write ", "
+                                       v.stream.write ","
                                else first = false
+                               v.new_line_and_indent
 
                                var k = key or else "null"
                                v.stream.write k.to_s.to_json
                                v.stream.write ": "
                                if not v.try_to_serialize(val) then
+                                       assert val != null # null would have been serialized
                                        v.warn("element of type {val.class_name} is not serializable.")
                                        v.stream.write "null"
                                end
                        end
+                       v.indent_level -= 1
+                       v.new_line_and_indent
                        v.stream.write "\}"
                else
-                       v.stream.write """{"__kind": "obj", "__id": """
+                       v.stream.write "\{"
+                       v.indent_level += 1
+                       v.new_line_and_indent
+                       v.stream.write """"__kind": "obj", "__id": """
                        v.stream.write id.to_s
                        v.stream.write """, "__class": """"
                        v.stream.write class_name
                        v.stream.write """", "__length": """
                        v.stream.write length.to_s
 
-                       v.stream.write """, "__keys": """
+                       v.stream.write ","
+                       v.new_line_and_indent
+                       v.stream.write """"__keys": """
                        keys.serialize_to_pure_json v
 
-                       v.stream.write """, "__values": """
+                       v.stream.write ","
+                       v.new_line_and_indent
+                       v.stream.write """"__values": """
                        values.serialize_to_pure_json v
 
+                       v.indent_level -= 1
+                       v.new_line_and_indent
                        v.stream.write "\}"
                end
        end
diff --git a/lib/nitcorn/examples/www/hello_world/dir/binary_file.png b/lib/nitcorn/examples/www/hello_world/dir/binary_file.png
new file mode 100644 (file)
index 0000000..d522fcc
Binary files /dev/null and b/lib/nitcorn/examples/www/hello_world/dir/binary_file.png differ
index 80f64d2..ea3212d 100644 (file)
@@ -111,6 +111,8 @@ class FileServer
                                        var title = turi
                                        var files = local_file.files
 
+                                       alpha_comparator.sort files
+
                                        var links = new Array[String]
                                        if turi.length > 1 then
                                                var path = (request.uri + "/..").simplify_path
index d475444..de9ddc0 100644 (file)
@@ -81,8 +81,8 @@ class HttpServer
                                # Delegate the responsibility to respond to the `Action`
                                handler.prepare_respond_and_close(request, turi, self)
                                return
-                       else response = new HttpResponse(405)
-               else response = new HttpResponse(405)
+                       else response = new HttpResponse(404)
+               else response = new HttpResponse(404)
 
                respond response
                close
index c2bd614..e61caad 100644 (file)
@@ -61,6 +61,12 @@ class Route
        # Path to this action present in the URI
        var path: nullable String
 
+       init
+       do
+               var path = path
+               if path != null then self.path = "/" / path
+       end
+
        # `Action` to activate when this route is traveled
        var handler: Action
 end
index a1c43a2..1db10b2 100644 (file)
@@ -16,7 +16,7 @@
 
 # Main POSIX threads support and intro the classes `Thread`, `Mutex` and `Barrier`
 module pthreads is
-       cflags "-pthread"
+       cflags "-pthread -Wno-unknown-attributes"
        ldflags "-pthread"
        pkgconfig "bdw-gc"
        new_annotation threaded
@@ -33,6 +33,8 @@ in "C Header" `{
 `}
 
 in "C" `{
+       #include <string.h>
+
        // TODO protect with: #ifdef WITH_LIBGC
        // We might have to add the next line to gc_chooser.c too, especially
        // if we get an error like "thread not registered with GC".
index 31dfcc4..9982dd1 100644 (file)
@@ -577,7 +577,7 @@ abstract class AbstractCompiler
 
        # The list of all associated files
        # Used to generate .c files
-       var files = new List[CodeFile]
+       var files = new Array[CodeFile]
 
        # Initialize a visitor specific for a compiler engine
        fun new_visitor: VISITOR is abstract
@@ -1127,8 +1127,8 @@ end
 # Where to store generated lines
 class CodeWriter
        var file: CodeFile
-       var lines: List[String] = new List[String]
-       var decl_lines: List[String] = new List[String]
+       var lines = new Array[String]
+       var decl_lines = new Array[String]
 
        # Add a line in the main part of the generated C
        fun add(s: String) do self.lines.add(s)
@@ -3945,12 +3945,36 @@ redef class ANewExpr
                        return v.native_array_instance(elttype, l)
                end
 
-               var recv = v.init_instance_or_extern(mtype)
-
                var callsite = self.callsite
-               if callsite == null then return recv
+               if callsite == null then return v.init_instance_or_extern(mtype)
                if callsite.is_broken then return null
 
+               var recv
+               # new factories are badly implemented.
+               # They assume a stub temporary receiver exists.
+               # This temporary receiver is required because it
+               # currently holds the method and the formal types.
+               #
+               # However, this object could be reused if the formal types are the same.
+               # Therefore, the following code will `once` it in these case
+               if callsite.mproperty.is_new and not mtype.need_anchor then
+                       var name = v.get_name("varoncenew")
+                       var guard = v.get_name(name + "_guard")
+                       v.add_decl("static {mtype.ctype} {name};")
+                       v.add_decl("static int {guard};")
+                       recv = v.new_var(mtype)
+                       v.add("if (likely({guard})) \{")
+                       v.add("{recv} = {name};")
+                       v.add("\} else \{")
+                       var i = v.init_instance_or_extern(mtype)
+                       v.add("{recv} = {i};")
+                       v.add("{name} = {recv};")
+                       v.add("{guard} = 1;")
+                       v.add("\}")
+               else
+                       recv = v.init_instance_or_extern(mtype)
+               end
+
                var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.n_args.n_exprs)
                var res2 = v.compile_callsite(callsite, args)
                if res2 != null then
index 5593f87..4207a01 100644 (file)
@@ -93,7 +93,7 @@ redef class NaiveInterpreter
        end
 
        # External compiler used to generate the foreign code library
-       private var c_compiler = "gcc"
+       private var c_compiler = "cc"
 end
 
 redef class AModule
@@ -132,7 +132,7 @@ redef class AModule
 
                # Protect pkg-config
                var pkgconfigs = mmodule.pkgconfigs
-               var pkg_command = ""
+               var pkg_cflags = ""
                if not pkgconfigs.is_empty then
                        var cmd = "which pkg-config >/dev/null"
                        if system(cmd) != 0 then
@@ -148,17 +148,18 @@ redef class AModule
                                end
                        end
 
-                       pkg_command = "`pkg-config --cflags --libs {pkgconfigs.join(" ")}`"
+                       pkg_cflags = "`pkg-config --cflags {pkgconfigs.join(" ")}`"
+                       ldflags += " `pkg-config --libs {pkgconfigs.join(" ")}`"
                end
 
                # Compile each source file to an object file (or equivalent)
                var object_files = new Array[String]
                for f in srcs do
-                       f.compile(v, mmodule, object_files)
+                       f.compile(v, mmodule, object_files, pkg_cflags)
                end
 
                # Link everything in a shared library
-               var cmd = "{v.c_compiler} -Wall -shared -o {foreign_code_lib_path} {object_files.join(" ")} {ldflags} {pkg_command}"
+               var cmd = "{v.c_compiler} -Wall -shared -o {foreign_code_lib_path} {object_files.join(" ")} {ldflags}"
                if system(cmd) != 0 then
                        v.fatal "FFI Error: Failed to link native code using `{cmd}`"
                        return false
@@ -398,14 +399,14 @@ end
 redef class ExternFile
        # Compile this source file
        private fun compile(v: NaiveInterpreter, mmodule: MModule,
-               object_files: Array[String]): Bool is abstract
+               object_files: Array[String], pkg_cflags: String): Bool is abstract
 end
 
 redef class ExternCFile
-       redef fun compile(v, mmodule, object_files)
+       redef fun compile(v, mmodule, object_files, pkg_cflags)
        do
                var compile_dir = v.compile_dir
-               var cflags = mmodule.cflags[""].join(" ")
+               var cflags = mmodule.cflags[""].join(" ") + " " + pkg_cflags
                var obj = compile_dir / filename.basename(".c") + ".o"
 
                var cmd = "{v.c_compiler} -Wall -c -fPIC -I {compile_dir} -g -o {obj} {filename} {cflags}"
index 0028df4..99f2356 100644 (file)
@@ -117,10 +117,6 @@ class NaiveInterpreter
        # Set this mark to skip the evaluation until a labeled statement catch it with `is_escape`
        var escapemark: nullable EscapeMark = null
 
-       # Is an abort being executed ?
-       # Set this mark to return to the last `catch` bloc or effectively aborting if there isn't any
-       var catch_mark = new EscapeMark
-
        # The count of `catch` blocs that have been encountered and can catch an abort
        var catch_count = 0
 
@@ -1701,8 +1697,7 @@ redef class AAbortExpr
                        fatal(v, "Aborted")
                        exit(1)
                else
-                       # Abort mode, skipping everything until a `catch` bloc is reached
-                       v.escapemark = v.catch_mark
+                       abort
                end
        end
 end
@@ -1747,14 +1742,23 @@ end
 redef class ADoExpr
        redef fun stmt(v)
        do
-               # If this bloc has a catch, register it in the counter
-               if self.n_catch != null then v.catch_count += 1
-               v.stmt(self.n_block)
-               v.is_escape(self.break_mark) # Clear the break (if any)
+               # If this bloc has a catch, handle it with a do ... catch ... end
                if self.n_catch != null then
-                       v.catch_count -= 1
-                       # Are we in abort mode? then this catch is executing
-                       if v.is_escape(v.catch_mark) then v.stmt(self.n_catch)
+                       var frame = v.frame
+                       v.catch_count += 1
+                       do
+                               v.stmt(self.n_block)
+                               v.is_escape(self.break_mark) # Clear the break (if any)
+                               v.catch_count -= 1
+                       catch
+                               # Restore the current frame if needed
+                               while v.frame != frame do v.frames.shift
+                               v.catch_count -= 1
+                               v.stmt(self.n_catch)
+                       end
+               else
+                       v.stmt(self.n_block)
+                       v.is_escape(self.break_mark)
                end
        end
 end
index 06f2396..5c64d23 100644 (file)
@@ -301,7 +301,51 @@ class ModelBuilder
                        end
                end
 
-               # If everything fail, then give up :(
+               # If everything fail, then give up with class by proposing things.
+               #
+               # TODO Give hints on formal types (param and virtual)
+               # TODO How to move this in a libified autonomous code?
+
+               var all_classes = model.get_mclasses_by_name(name)
+
+               # Look for imported but invisible classes.
+               if all_classes != null then for c in all_classes do
+                       if not mmodule.in_importation <= c.intro_mmodule then continue
+                       error(ntype, "Error: class `{c.full_name}` not visible in module `{mmodule}`.")
+                       return null
+               end
+
+               # Look for not imported but known classes from importable modules
+               var hints = new Array[String]
+               if all_classes != null then for c in all_classes do
+                       if c.intro_mmodule.in_importation <= mmodule then continue
+                       if c.visibility <= private_visibility then continue
+                       hints.add "`{c.intro_mmodule.full_name}`"
+               end
+               if hints.not_empty then
+                       error(ntype, "Error: class `{name}` not found in module `{mmodule}`. Maybe import {hints.join(",", " or ")}?")
+                       return null
+               end
+
+               # Look for classes with an approximative name.
+               var bestd = name.length / 2 # limit up to 50% name change
+               for c in model.mclasses do
+                       if not mmodule.in_importation <= c.intro_mmodule then continue
+                       if not mmodule.is_visible(c.intro_mmodule, c.visibility) then continue
+                       var d = name.levenshtein_distance(c.name)
+                       if d <= bestd then
+                               if d < bestd then
+                                       hints.clear
+                                       bestd = d
+                               end
+                               hints.add "`{c.name}`"
+                       end
+               end
+               if hints.not_empty then
+                       error(ntype, "Error: class `{name}` not found in module `{mmodule}`. Did you mean {hints.join(",", " or ")}?")
+                       return null
+               end
+
                error(ntype, "Error: class `{name}` not found in module `{mmodule}`.")
                return null
        end
index df8f8bd..141ed81 100644 (file)
@@ -1463,7 +1463,7 @@ redef class AAttrPropdef
 
                var mlazypropdef = self.mlazypropdef
                if mlazypropdef != null then
-                       mlazypropdef.static_mtype = modelbuilder.model.get_mclasses_by_name("Bool").first.mclass_type
+                       mlazypropdef.static_mtype = mmodule.bool_type
                end
                check_repeated_types(modelbuilder)
        end
diff --git a/tests/base_new_factory.nit b/tests/base_new_factory.nit
new file mode 100644 (file)
index 0000000..d8b704c
--- /dev/null
@@ -0,0 +1,71 @@
+# 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.
+
+import core::kernel
+
+interface A
+       new do return new B(5)
+end
+
+class B
+       super A
+       var i: Int
+       redef fun output do
+               'B'.output
+               i.output
+       end
+end
+
+interface G[E: Object]
+       new(a: E) do return new H[E](a)
+       fun dup:G[E] is abstract
+end
+
+class H[F: Object]
+       super G[F]
+       var o: F
+
+       redef fun output do
+               'H'.output
+               o.output
+       end
+
+       redef fun dup do return new G[F](self.o)
+end
+
+var b = new B(1)
+b.output
+var a = new A
+a.output
+
+var ha = new H[A](a)
+ha.output
+var hb = new H[B](b)
+hb.output
+
+var ga = new G[A](a)
+ga.output
+var gb = new G[B](b)
+gb.output
+
+ga.dup.output
+gb.dup.output
+
+var gga = new G[G[A]](ga)
+gga.output
+var ggb = new G[G[B]](gb)
+ggb.output
+
+gga.dup.output
+ggb.dup.output
index 4d9517f..76ec29d 100644 (file)
@@ -1,7 +1,5 @@
 # This file is part of NIT ( http://www.nitlanguage.org ).
 #
-# Copyright 2004-2008 Jean Privat <jean@pryen.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
@@ -14,5 +12,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-var i = new Canard
+var i
+i = new Fail
+i = new Boolean
+i = new ListNode
+i = new POSet
 i.output
diff --git a/tests/error_unk_class2.nit b/tests/error_unk_class2.nit
new file mode 100644 (file)
index 0000000..c452bda
--- /dev/null
@@ -0,0 +1,16 @@
+# 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.
+
+import poset
+import error_unk_class
diff --git a/tests/sav/base_new_factory.res b/tests/sav/base_new_factory.res
new file mode 100644 (file)
index 0000000..238446a
--- /dev/null
@@ -0,0 +1,12 @@
+B1
+B5
+HB5
+HB1
+HB5
+HB1
+HB5
+HB1
+HHB5
+HHB1
+HHB5
+HHB1
index 7ae3800..13326c8 100644 (file)
@@ -1 +1,4 @@
-error_unk_class.nit:17,13--18: Error: class `Canard` not found in module `error_unk_class`.
+error_unk_class.nit:16,9--12: Error: class `Fail` not found in module `error_unk_class`.
+error_unk_class.nit:17,9--15: Error: class `Boolean` not found in module `error_unk_class`. Did you mean `Bool`?
+error_unk_class.nit:18,9--16: Error: class `core::list::ListNode` not visible in module `error_unk_class`.
+error_unk_class.nit:19,9--13: Error: class `POSet` not found in module `error_unk_class`. Did you mean `Set`?
diff --git a/tests/sav/error_unk_class2.res b/tests/sav/error_unk_class2.res
new file mode 100644 (file)
index 0000000..6b89188
--- /dev/null
@@ -0,0 +1,4 @@
+error_unk_class.nit:16,9--12: Error: class `Fail` not found in module `error_unk_class`.
+error_unk_class.nit:17,9--15: Error: class `Boolean` not found in module `error_unk_class`. Did you mean `Bool`?
+error_unk_class.nit:18,9--16: Error: class `core::list::ListNode` not visible in module `error_unk_class`.
+error_unk_class.nit:19,9--13: Error: class `POSet` not found in module `error_unk_class`. Maybe import `poset`?
index 8e58cac..dd26cc0 100644 (file)
@@ -2,7 +2,7 @@
 <A: true a 0.123 1234 asdf false p4ssw0rd>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "A", "b": true, "c": {"__kind": "char", "__val": "a"}, "f": 0.123, "i": 1234, "serialization_specific_name": "asdf", "n": null}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"serialization_specific_name": "asdf","n": null}
 
 # Back in Nit:
 <A: true a 0.123 1234 asdf false p4ssw0rd>
@@ -11,7 +11,7 @@
 <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "serialization_specific_name": "hjkl", "n": 12, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"serialization_specific_name": "hjkl","n": 12,"ii": 1111,"ss": "qwer"}
 
 # Back in Nit:
 <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
@@ -20,7 +20,7 @@
 <C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 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, "serialization_specific_name": "asdf", "n": null}, "b": {"__kind": "obj", "__id": 2, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "serialization_specific_name": "hjkl", "n": 12, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"serialization_specific_name": "asdf","n": null},"b": {"__kind": "obj", "__id": 2, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"serialization_specific_name": "hjkl","n": 12,"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # Back in Nit:
 <C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
@@ -30,7 +30,7 @@
 <- false p4ssw0rd> 1111        f"\r\/> true>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "D", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "serialization_specific_name": "new line ->\n<-", "n": null, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"serialization_specific_name": "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 ->
@@ -40,7 +40,7 @@
 <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", "__items": ["hello", 1234, 123.4]}, "b": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": ["hella", 2345, 234.5]}}
+{"__kind": "obj", "__id": 0, "__class": "E","a": {"__kind": "obj", "__id": 1, "__class": "Array","__items": ["hello",1234,123.4]},"b": {"__kind": "obj", "__id": 2, "__class": "Array","__items": ["hella",2345,234.5]}}
 
 # Back in Nit:
 <E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>
@@ -49,7 +49,7 @@
 <E: 2222>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "F", "n": 2222}
+{"__kind": "obj", "__id": 0, "__class": "F","n": 2222}
 
 # Back in Nit:
 null
@@ -58,7 +58,7 @@ null
 <E: 33.33>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "F", "n": 33.33}
+{"__kind": "obj", "__id": 0, "__class": "F","n": 33.33}
 
 # Back in Nit:
 null
@@ -67,7 +67,7 @@ null
 <G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "G", "hs": {"__kind": "obj", "__id": 1, "__class": "HashSet", "__items": [-1, 0]}, "s": {"__kind": "obj", "__id": 2, "__class": "ArraySet", "__items": ["one", "two"]}, "hm": {"__kind": "obj", "__id": 3, "__class": "HashMap", "__length": 2, "__keys": ["one", "two"], "__values": [1, 2]}, "am": {"__kind": "obj", "__id": 4, "__class": "ArrayMap", "__length": 2, "__keys": ["three", "four"], "__values": ["3", "4"]}}
+{"__kind": "obj", "__id": 0, "__class": "G","hs": {"__kind": "obj", "__id": 1, "__class": "HashSet","__items": [-1,0]},"s": {"__kind": "obj", "__id": 2, "__class": "ArraySet","__items": ["one","two"]},"hm": {"__kind": "obj", "__id": 3, "__class": "HashMap", "__length": 2,"__keys": ["one","two"],"__values": [1,2]},"am": {"__kind": "obj", "__id": 4, "__class": "ArrayMap", "__length": 2,"__keys": ["three","four"],"__values": ["3","4"]}}
 
 # Back in Nit:
 <G: hs: ; s: ; hm: ; am: >
diff --git a/tests/sav/nitce/test_json_deserialization_alt3.res b/tests/sav/nitce/test_json_deserialization_alt3.res
new file mode 100644 (file)
index 0000000..b269caf
--- /dev/null
@@ -0,0 +1,192 @@
+# Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "A",
+       "b": true,
+       "c": {"__kind": "char", "__val": "a"},
+       "f": 0.123,
+       "i": 1234,
+       "serialization_specific_name": "asdf",
+       "n": null
+}
+
+# Back in Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "B",
+       "b": false,
+       "c": {"__kind": "char", "__val": "b"},
+       "f": 123.123,
+       "i": 2345,
+       "serialization_specific_name": "hjkl",
+       "n": 12,
+       "ii": 1111,
+       "ss": "qwer"
+}
+
+# Back in Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 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,
+               "serialization_specific_name": "asdf",
+               "n": null
+       },
+       "b": {
+               "__kind": "obj", "__id": 2, "__class": "B",
+               "b": false,
+               "c": {"__kind": "char", "__val": "b"},
+               "f": 123.123,
+               "i": 2345,
+               "serialization_specific_name": "hjkl",
+               "n": 12,
+               "ii": 1111,
+               "ss": "qwer"
+       },
+       "aa": {
+               "__kind": "ref", "__id": 1
+       }
+}
+
+# Back in Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
+
+# Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false p4ssw0rd> 1111        f"\r\/> true>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "D",
+       "b": false,
+       "c": {"__kind": "char", "__val": "b"},
+       "f": 123.123,
+       "i": 2345,
+       "serialization_specific_name": "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 p4ssw0rd> 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",
+               "__items": [
+                       "hello",
+                       1234,
+                       123.4
+               ]
+       },
+       "b": {
+               "__kind": "obj", "__id": 2, "__class": "Array",
+               "__items": [
+                       "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",
+       "n": 2222
+}
+
+# Back in Nit:
+null
+
+# Nit:
+<E: 33.33>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "F",
+       "n": 33.33
+}
+
+# Back in Nit:
+null
+
+# Nit:
+<G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "G",
+       "hs": {
+               "__kind": "obj", "__id": 1, "__class": "HashSet",
+               "__items": [
+                       -1,
+                       0
+               ]
+       },
+       "s": {
+               "__kind": "obj", "__id": 2, "__class": "ArraySet",
+               "__items": [
+                       "one",
+                       "two"
+               ]
+       },
+       "hm": {
+               "__kind": "obj", "__id": 3, "__class": "HashMap", "__length": 2,
+               "__keys": [
+                       "one",
+                       "two"
+               ],
+               "__values": [
+                       1,
+                       2
+               ]
+       },
+       "am": {
+               "__kind": "obj", "__id": 4, "__class": "ArrayMap", "__length": 2,
+               "__keys": [
+                       "three",
+                       "four"
+               ],
+               "__values": [
+                       "3",
+                       "4"
+               ]
+       }
+}
+
+# Back in Nit:
+<G: hs: ; s: ; hm: ; am: >
+
index 38a1cb2..67a1674 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index 37fe5b4..d3fb349 100644 (file)
@@ -5,24 +5,24 @@ alt/test_serialization_alt2.nit:64,1--72,3: Warning: superfluous use of `auto_se
 <A: true a 0.123 1234 asdf false>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "A", "b": true, "f": 0.123, "i": 1234, "s": "asdf", "n": null, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]}}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "C", "a": {"__kind": "obj", "__id": 1, "__class": "A", "b": true, "f": 0.123, "i": 1234, "s": "asdf", "n": null, "array": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array", "__items": [88, "hello", null]}}, "aa": {"__kind": "ref", "__id": 1}}
+{"__kind": "obj", "__id": 0, "__class": "C","a": {"__kind": "obj", "__id": 1, "__class": "A","b": true,"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 2, "__class": "Array","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array","__items": [88,"hello",null]}},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "f": 123.123, "i": 2345, "s": "new line ->\n<-", "n": null, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"d": {"__kind": "ref", "__id": 0}}
 
index be2dadd..3b72eda 100644 (file)
@@ -3,24 +3,24 @@ alt/test_serialization_alt3.nit:40,1--51,3: Warning: superfluous use of `noseria
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]}}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array", "__items": [88, "hello", null]}}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array","__items": [88,"hello",null]}},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"d": {"__kind": "ref", "__id": 0}}
 
index 26a805a..5f40834 100644 (file)
@@ -3,24 +3,24 @@ alt/test_serialization_alt4.nit:29,2--31,26: Warning: superfluous use of `serial
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index ba3196e..cc17087 100644 (file)
@@ -3,24 +3,24 @@ alt/test_serialization_alt5.nit:22,1--38,3: Warning: duplicated annotation `seri
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index 38a1cb2..67a1674 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index d380e42..a6a77fd 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef"}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef"}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef"}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef"},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index 4e37506..ec4a7d9 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer", "ffff": 6.789, "bbbb": false}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer","ffff": 6.789,"bbbb": false}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer", "ffff": 6.789, "bbbb": false}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer","ffff": 6.789,"bbbb": false},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "ffff": 6.789, "bbbb": false, "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","ffff": 6.789,"bbbb": false,"d": {"__kind": "ref", "__id": 0}}
 
index 106a664..48b21cc 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef"}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef"}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "qwer", "ffff": 6.789, "bbbb": false}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "qwer","ffff": 6.789,"bbbb": false}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef"}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "qwer", "ffff": 6.789, "bbbb": false}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef"},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "qwer","ffff": 6.789,"bbbb": false},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "\tf\"\r\\/", "ffff": 6.789, "bbbb": false, "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "\tf\"\r\\/","ffff": 6.789,"bbbb": false,"d": {"__kind": "ref", "__id": 0}}
 
index 95a4dc1..5ab004a 100644 (file)
@@ -2,7 +2,7 @@
 <A: true a 0.123 1234 asdf false p4ssw0rd>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "A", "b": true, "c": {"__kind": "char", "__val": "a"}, "f": 0.123, "i": 1234, "serialization_specific_name": "asdf", "n": null}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"serialization_specific_name": "asdf","n": null}
 
 # Back in Nit:
 <A: true a 0.123 1234 asdf false p4ssw0rd>
@@ -11,7 +11,7 @@
 <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "serialization_specific_name": "hjkl", "n": 12, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"serialization_specific_name": "hjkl","n": 12,"ii": 1111,"ss": "qwer"}
 
 # Back in Nit:
 <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
@@ -20,7 +20,7 @@
 <C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 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, "serialization_specific_name": "asdf", "n": null}, "b": {"__kind": "obj", "__id": 2, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "serialization_specific_name": "hjkl", "n": 12, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"serialization_specific_name": "asdf","n": null},"b": {"__kind": "obj", "__id": 2, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"serialization_specific_name": "hjkl","n": 12,"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # Back in Nit:
 <C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
@@ -30,7 +30,7 @@
 <- false p4ssw0rd> 1111        f"\r\/> true>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "D", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "serialization_specific_name": "new line ->\n<-", "n": null, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"serialization_specific_name": "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 ->
index 84e2d3d..161fb58 100644 (file)
@@ -2,7 +2,7 @@
 <A: true a 0.123 1234 asdf false p4ssw0rd>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "A", "b": true, "c": {"__kind": "char", "__val": "a"}, "f": 0.123, "i": 1234, "serialization_specific_name": "asdf", "n": null}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"serialization_specific_name": "asdf","n": null}
 
 # Back in Nit:
 <A: true a 0.123 1234 asdf false p4ssw0rd>
@@ -11,7 +11,7 @@
 <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "serialization_specific_name": "hjkl", "n": 12, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"serialization_specific_name": "hjkl","n": 12,"ii": 1111,"ss": "qwer"}
 
 # Back in Nit:
 <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
@@ -20,7 +20,7 @@
 <C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 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, "serialization_specific_name": "asdf", "n": null}, "b": {"__kind": "obj", "__id": 2, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "serialization_specific_name": "hjkl", "n": 12, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"serialization_specific_name": "asdf","n": null},"b": {"__kind": "obj", "__id": 2, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"serialization_specific_name": "hjkl","n": 12,"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # Back in Nit:
 <C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
@@ -30,7 +30,7 @@
 <- false p4ssw0rd> 1111        f"\r\/> true>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "D", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "serialization_specific_name": "new line ->\n<-", "n": null, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"serialization_specific_name": "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 ->
@@ -40,7 +40,7 @@
 <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]", "__items": ["hello", 1234, 123.4]}, "b": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Serializable]", "__items": ["hella", 2345, 234.5]}}
+{"__kind": "obj", "__id": 0, "__class": "E","a": {"__kind": "obj", "__id": 1, "__class": "Array[Object]","__items": ["hello",1234,123.4]},"b": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Serializable]","__items": ["hella",2345,234.5]}}
 
 # Back in Nit:
 <E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>
@@ -49,7 +49,7 @@
 <E: 2222>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "F[Int]", "n": 2222}
+{"__kind": "obj", "__id": 0, "__class": "F[Int]","n": 2222}
 
 # Back in Nit:
 <E: 2222>
@@ -58,7 +58,7 @@
 <E: 33.33>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "F[Float]", "n": 33.33}
+{"__kind": "obj", "__id": 0, "__class": "F[Float]","n": 33.33}
 
 # Back in Nit:
 <E: 33.33>
@@ -67,7 +67,7 @@
 <G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "G", "hs": {"__kind": "obj", "__id": 1, "__class": "HashSet[Int]", "__items": [-1, 0]}, "s": {"__kind": "obj", "__id": 2, "__class": "ArraySet[String]", "__items": ["one", "two"]}, "hm": {"__kind": "obj", "__id": 3, "__class": "HashMap[String, Int]", "__length": 2, "__keys": ["one", "two"], "__values": [1, 2]}, "am": {"__kind": "obj", "__id": 4, "__class": "ArrayMap[String, String]", "__length": 2, "__keys": ["three", "four"], "__values": ["3", "4"]}}
+{"__kind": "obj", "__id": 0, "__class": "G","hs": {"__kind": "obj", "__id": 1, "__class": "HashSet[Int]","__items": [-1,0]},"s": {"__kind": "obj", "__id": 2, "__class": "ArraySet[String]","__items": ["one","two"]},"hm": {"__kind": "obj", "__id": 3, "__class": "HashMap[String, Int]", "__length": 2,"__keys": ["one","two"],"__values": [1,2]},"am": {"__kind": "obj", "__id": 4, "__class": "ArrayMap[String, String]", "__length": 2,"__keys": ["three","four"],"__values": ["3","4"]}}
 
 # Back in Nit:
 <G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
index 86c613b..48005ec 100644 (file)
@@ -2,32 +2,33 @@
 <A: true a 0.123 1234 asdf false p4ssw0rd>
 
 # Json:
-{"b": true, "c": "a", "f": 0.123, "i": 1234, "serialization_specific_name": "asdf", "n": null}
+{"b": true,"c": "a","f": 0.123,"i": 1234,"serialization_specific_name": "asdf","n": null}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
 
 # Json:
-{"b": false, "c": "b", "f": 123.123, "i": 2345, "serialization_specific_name": "hjkl", "n": 12, "ii": 1111, "ss": "qwer"}
+{"b": false,"c": "b","f": 123.123,"i": 2345,"serialization_specific_name": "hjkl","n": 12,"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
 
 # Json:
-{"a": {"b": true, "c": "a", "f": 0.123, "i": 1234, "serialization_specific_name": "asdf", "n": null}, "b": {"b": false, "c": "b", "f": 123.123, "i": 2345, "serialization_specific_name": "hjkl", "n": 12, "ii": 1111, "ss": "qwer"}, "aa": {"b": true, "c": "a", "f": 0.123, "i": 1234, "serialization_specific_name": "asdf", "n": null}}
+{"a": {"b": true,"c": "a","f": 0.123,"i": 1234,"serialization_specific_name": "asdf","n": null},"b": {"b": false,"c": "b","f": 123.123,"i": 2345,"serialization_specific_name": "hjkl","n": 12,"ii": 1111,"ss": "qwer"},"aa": {"b": true,"c": "a","f": 0.123,"i": 1234,"serialization_specific_name": "asdf","n": null}}
 
+Serialization warning: Cycle detected in serialized object, replacing reference with 'null'.
 # Nit:
 <D: <B: <A: false b 123.123 2345 new line ->
 <- false p4ssw0rd> 1111        f"\r\/> true>
 
 # Json:
-{"b": false, "c": "b", "f": 123.123, "i": 2345, "serialization_specific_name": "new line ->\n<-", "n": null, "ii": 1111, "ss": "\tf\"\r\\/", "d": null}
+{"b": false,"c": "b","f": 123.123,"i": 2345,"serialization_specific_name": "new line ->\n<-","n": null,"ii": 1111,"ss": "\tf\"\r\\/","d": null}
 
 # Nit:
 <E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>
 
 # Json:
-{"a": ["hello", 1234, 123.4], "b": ["hella", 2345, 234.5]}
+{"a": ["hello",1234,123.4],"b": ["hella",2345,234.5]}
 
 # Nit:
 <E: 2222>
@@ -45,5 +46,5 @@
 <G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
 
 # Json:
-{"hs": [-1, 0], "s": ["one", "two"], "hm": {"one": 1, "two": 2}, "am": {"three": "3", "four": "4"}}
+{"hs": [-1,0],"s": ["one","two"],"hm": {"one": 1,"two": 2},"am": {"three": "3","four": "4"}}
 
diff --git a/tests/sav/test_json_deserialization_alt3.res b/tests/sav/test_json_deserialization_alt3.res
new file mode 100644 (file)
index 0000000..c49a52a
--- /dev/null
@@ -0,0 +1,192 @@
+# Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "A",
+       "b": true,
+       "c": {"__kind": "char", "__val": "a"},
+       "f": 0.123,
+       "i": 1234,
+       "serialization_specific_name": "asdf",
+       "n": null
+}
+
+# Back in Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "B",
+       "b": false,
+       "c": {"__kind": "char", "__val": "b"},
+       "f": 123.123,
+       "i": 2345,
+       "serialization_specific_name": "hjkl",
+       "n": 12,
+       "ii": 1111,
+       "ss": "qwer"
+}
+
+# Back in Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 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,
+               "serialization_specific_name": "asdf",
+               "n": null
+       },
+       "b": {
+               "__kind": "obj", "__id": 2, "__class": "B",
+               "b": false,
+               "c": {"__kind": "char", "__val": "b"},
+               "f": 123.123,
+               "i": 2345,
+               "serialization_specific_name": "hjkl",
+               "n": 12,
+               "ii": 1111,
+               "ss": "qwer"
+       },
+       "aa": {
+               "__kind": "ref", "__id": 1
+       }
+}
+
+# Back in Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
+
+# Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false p4ssw0rd> 1111        f"\r\/> true>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "D",
+       "b": false,
+       "c": {"__kind": "char", "__val": "b"},
+       "f": 123.123,
+       "i": 2345,
+       "serialization_specific_name": "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 p4ssw0rd> 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]",
+               "__items": [
+                       "hello",
+                       1234,
+                       123.4
+               ]
+       },
+       "b": {
+               "__kind": "obj", "__id": 2, "__class": "Array[nullable Serializable]",
+               "__items": [
+                       "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:
+null
+
+# Nit:
+<E: 33.33>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "F[Float]",
+       "n": 33.33
+}
+
+# Back in Nit:
+null
+
+# Nit:
+<G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
+
+# Json:
+{
+       "__kind": "obj", "__id": 0, "__class": "G",
+       "hs": {
+               "__kind": "obj", "__id": 1, "__class": "HashSet[Int]",
+               "__items": [
+                       -1,
+                       0
+               ]
+       },
+       "s": {
+               "__kind": "obj", "__id": 2, "__class": "ArraySet[String]",
+               "__items": [
+                       "one",
+                       "two"
+               ]
+       },
+       "hm": {
+               "__kind": "obj", "__id": 3, "__class": "HashMap[String, Int]", "__length": 2,
+               "__keys": [
+                       "one",
+                       "two"
+               ],
+               "__values": [
+                       1,
+                       2
+               ]
+       },
+       "am": {
+               "__kind": "obj", "__id": 4, "__class": "ArrayMap[String, String]", "__length": 2,
+               "__keys": [
+                       "three",
+                       "four"
+               ],
+               "__values": [
+                       "3",
+                       "4"
+               ]
+       }
+}
+
+# Back in Nit:
+<G: hs: ; s: ; hm: ; am: >
+
diff --git a/tests/sav/test_json_deserialization_alt4.res b/tests/sav/test_json_deserialization_alt4.res
new file mode 100644 (file)
index 0000000..5527174
--- /dev/null
@@ -0,0 +1,135 @@
+# Nit:
+<A: true a 0.123 1234 asdf false p4ssw0rd>
+
+# Json:
+{
+       "b": true,
+       "c": "a",
+       "f": 0.123,
+       "i": 1234,
+       "serialization_specific_name": "asdf",
+       "n": null
+}
+
+# Nit:
+<B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>
+
+# Json:
+{
+       "b": false,
+       "c": "b",
+       "f": 123.123,
+       "i": 2345,
+       "serialization_specific_name": "hjkl",
+       "n": 12,
+       "ii": 1111,
+       "ss": "qwer"
+}
+
+# Nit:
+<C: <A: true a 0.123 1234 asdf false p4ssw0rd> <B: <A: false b 123.123 2345 hjkl true p4ssw0rd> 1111 qwer>>
+
+# Json:
+{
+       "a": {
+               "b": true,
+               "c": "a",
+               "f": 0.123,
+               "i": 1234,
+               "serialization_specific_name": "asdf",
+               "n": null
+       },
+       "b": {
+               "b": false,
+               "c": "b",
+               "f": 123.123,
+               "i": 2345,
+               "serialization_specific_name": "hjkl",
+               "n": 12,
+               "ii": 1111,
+               "ss": "qwer"
+       },
+       "aa": {
+               "b": true,
+               "c": "a",
+               "f": 0.123,
+               "i": 1234,
+               "serialization_specific_name": "asdf",
+               "n": null
+       }
+}
+
+Serialization warning: Cycle detected in serialized object, replacing reference with 'null'.
+# Nit:
+<D: <B: <A: false b 123.123 2345 new line ->
+<- false p4ssw0rd> 1111        f"\r\/> true>
+
+# Json:
+{
+       "b": false,
+       "c": "b",
+       "f": 123.123,
+       "i": 2345,
+       "serialization_specific_name": "new line ->\n<-",
+       "n": null,
+       "ii": 1111,
+       "ss": "\tf\"\r\\/",
+       "d": null
+}
+
+# Nit:
+<E: a: hello, 1234, 123.4; b: hella, 2345, 234.5>
+
+# Json:
+{
+       "a": [
+               "hello",
+               1234,
+               123.4
+       ],
+       "b": [
+               "hella",
+               2345,
+               234.5
+       ]
+}
+
+# Nit:
+<E: 2222>
+
+# Json:
+{
+       "n": 2222
+}
+
+# Nit:
+<E: 33.33>
+
+# Json:
+{
+       "n": 33.33
+}
+
+# Nit:
+<G: hs: -1, 0; s: one, two; hm: one. 1, two. 2; am: three. 3, four. 4>
+
+# Json:
+{
+       "hs": [
+               -1,
+               0
+       ],
+       "s": [
+               "one",
+               "two"
+       ],
+       "hm": {
+               "one": 1,
+               "two": 2
+       },
+       "am": {
+               "three": "3",
+               "four": "4"
+       }
+}
+
diff --git a/tests/sav/test_nitcorn.res b/tests/sav/test_nitcorn.res
new file mode 100644 (file)
index 0000000..6e77d2e
--- /dev/null
@@ -0,0 +1,125 @@
+
+[Client] curl -s localhost:*****/simple_answer
+[Response] Simple answer
+Method: GET, URI: /simple_answer, trailing: /
+
+[Client] curl -s localhost:*****/simple_answer/
+[Response] Simple answer
+Method: GET, URI: /simple_answer/, trailing: /
+
+[Client] curl -s localhost:*****/simple_answer/trailing/path
+[Response] Simple answer
+Method: GET, URI: /simple_answer/trailing/path, trailing: /trailing/path
+
+[Client] curl -s 'localhost:*****/simple_answer?i=0123&s=asdf'
+[Response] Simple answer
+Method: GET, URI: /simple_answer, trailing: /
+GET args: i:0123, s:asdf
+
+[Client] curl -s localhost:*****/simple_answer --data 'i=0123&s=asdf'
+[Response] Simple answer
+Method: POST, URI: /simple_answer, trailing: /
+POST args: i:0123, s:asdf
+
+[Client] curl -s localhost:*****/simple_answer --cookie 'i=0123; s=asdf'
+[Response] Simple answer
+Method: GET, URI: /simple_answer, trailing: /
+Cookie: i:0123, s:asdf
+
+[Client] curl -s localhost:*****/params_answer/0123/asdf
+[Response] Simple answer
+Method: GET, URI: /params_answer/0123/asdf, trailing: /
+Params args: i:0123, s:asdf
+
+[Client] curl -s localhost:*****/params_answer/0123/
+[Response] Simple answer
+Method: GET, URI: /params_answer/0123/, trailing: /
+Params args: i:0123, s:
+
+[Client] curl -s localhost:*****/params_answer/0123/asdf/trailing/path
+[Response] Simple answer
+Method: GET, URI: /params_answer/0123/asdf/trailing/path, trailing: /trailing/path
+Params args: i:0123, s:asdf
+
+[Client] curl -s localhost:*****/params_answer/0123 --head
+HTTP/1.0 404 Not Found\r
+Content-Length: 0\r
+Server: nitcorn\r
+Set-Cookie: nitcorn_session=; HttpOnly; expires=Thu, 01 Jan 1970 00:00:00 GMT\r
+\r
+
+[Client] curl -s localhost:*****/file_server/
+<!DOCTYPE html>
+<head>
+       <meta charset="utf-8">
+       <meta http-equiv="X-UA-Compatible" content="IE=edge">
+       <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
+       <script>
+               
+       </script>
+       <title>/</title>
+</head>
+<body>
+       
+       <div class="container">
+               <h1>/</h1>
+               <ul>
+                       <li><a href="a.txt">a.txt</a></li>
+                       <li><a href="b.txt">b.txt</a></li>
+                       <li><a href="binary_file.png">binary_file.png</a></li>
+               </ul>
+       </div>
+</body>
+</html>
+[Client] curl -s localhost:*****/file_server/ --head
+HTTP/1.0 200 OK\r
+Content-Type: text/html\r
+Content-Length: 467\r
+Server: nitcorn\r
+Set-Cookie: nitcorn_session=; HttpOnly; expires=Thu, 01 Jan 1970 00:00:00 GMT\r
+\r
+
+[Client] curl -s localhost:*****/file_server --head
+HTTP/1.0 303 See Other\r
+Location: /file_server/\r
+Content-Length: 0\r
+Server: nitcorn\r
+Set-Cookie: nitcorn_session=; HttpOnly; expires=Thu, 01 Jan 1970 00:00:00 GMT\r
+\r
+
+[Client] curl -s localhost:*****/file_server/a.txt
+aaaAAAAAaaaa
+
+[Client] curl -s localhost:*****/file_server/a.txt --head
+HTTP/1.0 200 OK\r
+Content-Type: text/plain\r
+cache-control: public, max-age=360\r
+Content-Length: 13\r
+Server: nitcorn\r
+Set-Cookie: nitcorn_session=; HttpOnly; expires=Thu, 01 Jan 1970 00:00:00 GMT\r
+\r
+
+[Client] curl -s localhost:*****/file_server/binary_file.png --head
+HTTP/1.0 200 OK\r
+Content-Type: image/png\r
+cache-control: public, max-age=360\r
+Content-Length: 2503\r
+Server: nitcorn\r
+Set-Cookie: nitcorn_session=; HttpOnly; expires=Thu, 01 Jan 1970 00:00:00 GMT\r
+\r
+
+[Client] curl -s localhost:*****/file_server/binary_file.png | diff - .../binary_file.png
+
+[Client] curl -s localhost:*****/file_server/unknown_file.txt --head
+HTTP/1.0 404 Not Found\r
+Content-Length: 329\r
+Server: nitcorn\r
+Set-Cookie: nitcorn_session=; HttpOnly; expires=Thu, 01 Jan 1970 00:00:00 GMT\r
+\r
+
+[Client] curl -s localhost:*****/invalid_route --head
+HTTP/1.0 404 Not Found\r
+Content-Length: 0\r
+Server: nitcorn\r
+Set-Cookie: nitcorn_session=; HttpOnly; expires=Thu, 01 Jan 1970 00:00:00 GMT\r
+\r
index 29b474e..e3b56a7 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index 4fa0577..f275932 100644 (file)
@@ -2,24 +2,25 @@
 <A: true a 0.123 1234 asdf false>
 
 # Json:
-{"b": true, "c": "a", "f": 0.123, "i": 1234, "s": "asdf", "n": null, "array": [88, "hello", null]}
+{"b": true,"c": "a","f": 0.123,"i": 1234,"s": "asdf","n": null,"array": [88,"hello",null]}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"b": false, "c": "b", "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": [88, "hello", null], "ii": 1111, "ss": "qwer"}
+{"b": false,"c": "b","f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": [88,"hello",null],"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>>
 
 # Json:
-{"a": {"b": true, "c": "a", "f": 0.123, "i": 1234, "s": "asdf", "n": null, "array": [88, "hello", null]}, "b": {"b": false, "c": "b", "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": [88, "hello", null], "ii": 1111, "ss": "qwer"}, "aa": {"b": true, "c": "a", "f": 0.123, "i": 1234, "s": "asdf", "n": null, "array": [88, "hello", null]}}
+{"a": {"b": true,"c": "a","f": 0.123,"i": 1234,"s": "asdf","n": null,"array": [88,"hello",null]},"b": {"b": false,"c": "b","f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": [88,"hello",null],"ii": 1111,"ss": "qwer"},"aa": {"b": true,"c": "a","f": 0.123,"i": 1234,"s": "asdf","n": null,"array": [88,"hello",null]}}
 
+Serialization warning: Cycle detected in serialized object, replacing reference with 'null'.
 # Nit:
 <D: <B: <A: false b 123.123 2345 new line ->
 <- false> 1111         f"\r\/> true>
 
 # Json:
-{"b": false, "c": "b", "f": 123.123, "i": 2345, "s": "new line ->\n<-", "n": null, "array": [88, "hello", null], "ii": 1111, "ss": "\tf\"\r\\/", "d": null}
+{"b": false,"c": "b","f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": [88,"hello",null],"ii": 1111,"ss": "\tf\"\r\\/","d": null}
 
index aa15c5f..42ad47b 100644 (file)
@@ -5,24 +5,24 @@ alt/test_serialization_alt2.nit:64,1--72,3: Warning: superfluous use of `auto_se
 <A: true a 0.123 1234 asdf false>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "A", "b": true, "f": 0.123, "i": 1234, "s": "asdf", "n": null, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]}}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "C", "a": {"__kind": "obj", "__id": 1, "__class": "A", "b": true, "f": 0.123, "i": 1234, "s": "asdf", "n": null, "array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}, "aa": {"__kind": "ref", "__id": 1}}
+{"__kind": "obj", "__id": 0, "__class": "C","a": {"__kind": "obj", "__id": 1, "__class": "A","b": true,"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]","__items": [88,"hello",null]}},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "f": 123.123, "i": 2345, "s": "new line ->\n<-", "n": null, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"d": {"__kind": "ref", "__id": 0}}
 
index 1e8de79..9ad4073 100644 (file)
@@ -3,24 +3,24 @@ alt/test_serialization_alt3.nit:40,1--51,3: Warning: superfluous use of `noseria
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]}}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]","__items": [88,"hello",null]}},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"d": {"__kind": "ref", "__id": 0}}
 
index 1d9be55..039170f 100644 (file)
@@ -3,24 +3,24 @@ alt/test_serialization_alt4.nit:29,2--31,26: Warning: superfluous use of `serial
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index be11dba..6f763c2 100644 (file)
@@ -3,24 +3,24 @@ alt/test_serialization_alt5.nit:22,1--38,3: Warning: duplicated annotation `seri
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index 29b474e..e3b56a7 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index 4c298df..337cdaa 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef"}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef"}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "qwer"}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "qwer"}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef"}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "qwer"}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef"},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "qwer"},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "\tf\"\r\\/", "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "\tf\"\r\\/","d": {"__kind": "ref", "__id": 0}}
 
index 6e79e63..2deb5ce 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]}}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer", "ffff": 6.789, "bbbb": false}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer","ffff": 6.789,"bbbb": false}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "qwer", "ffff": 6.789, "bbbb": false}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]","__items": [88,"hello",null]}},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "qwer","ffff": 6.789,"bbbb": false},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "ii": 1111, "ss": "\tf\"\r\\/", "ffff": 6.789, "bbbb": false, "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"ii": 1111,"ss": "\tf\"\r\\/","ffff": 6.789,"bbbb": false,"d": {"__kind": "ref", "__id": 0}}
 
index e52136f..1c1850c 100644 (file)
@@ -2,24 +2,24 @@
 <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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef"}
+{"__kind": "obj", "__id": 0, "__class": "A","b": true,"c": {"__kind": "char", "__val": "a"},"f": 0.123,"i": 1234,"s": "asdf","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef"}
 
 # Nit:
 <B: <A: false b 123.123 2345 hjkl true> 1111 qwer>
 
 # Json:
-{"__kind": "obj", "__id": 0, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "qwer", "ffff": 6.789, "bbbb": false}
+{"__kind": "obj", "__id": 0, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "qwer","ffff": 6.789,"bbbb": false}
 
 # Nit:
 <C: <A: true a 0.123 1234 asdf false> <B: <A: false b 123.123 2345 hjkl true> 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, "array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef"}, "b": {"__kind": "obj", "__id": 3, "__class": "B", "b": false, "c": {"__kind": "char", "__val": "b"}, "f": 123.123, "i": 2345, "s": "hjkl", "n": 12, "array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "qwer", "ffff": 6.789, "bbbb": false}, "aa": {"__kind": "ref", "__id": 1}}
+{"__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,"array": {"__kind": "obj", "__id": 2, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef"},"b": {"__kind": "obj", "__id": 3, "__class": "B","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "hjkl","n": 12,"array": {"__kind": "obj", "__id": 4, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "qwer","ffff": 6.789,"bbbb": false},"aa": {"__kind": "ref", "__id": 1}}
 
 # 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, "array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]", "__items": [88, "hello", null]}, "iii": 6789, "sss": "redef", "ii": 1111, "ss": "\tf\"\r\\/", "ffff": 6.789, "bbbb": false, "d": {"__kind": "ref", "__id": 0}}
+{"__kind": "obj", "__id": 0, "__class": "D","b": false,"c": {"__kind": "char", "__val": "b"},"f": 123.123,"i": 2345,"s": "new line ->\n<-","n": null,"array": {"__kind": "obj", "__id": 1, "__class": "Array[nullable Object]","__items": [88,"hello",null]},"iii": 6789,"sss": "redef","ii": 1111,"ss": "\tf\"\r\\/","ffff": 6.789,"bbbb": false,"d": {"__kind": "ref", "__id": 0}}
 
index 8baadb1..155a39c 100644 (file)
@@ -18,20 +18,25 @@ import json::serialization
 
 var entities = new TestEntities
 
-var tests = entities.without_generics#alt1##alt2#
+var tests = entities.without_generics#alt1##alt2##alt3##alt4#
 #alt1#var tests = entities.with_generics
 #alt2#var tests = entities.with_generics
+#alt3#var tests = entities.with_generics
+#alt4#var tests = entities.with_generics
 
 for o in tests do
        var stream = new StringWriter
        var serializer = new JsonSerializer(stream)
        #alt2#serializer.plain_json = true
+       #alt3#serializer.pretty_json = true
+       #alt4#serializer.plain_json = true
+       #alt4#serializer.pretty_json = true
        serializer.serialize(o)
 
-       var deserializer = new JsonDeserializer(stream.to_s)#alt2#
-       var deserialized = deserializer.deserialize#alt2#
+       var deserializer = new JsonDeserializer(stream.to_s)#alt2##alt4#
+       var deserialized = deserializer.deserialize#alt2##alt4#
 
        print "# Nit:\n{o}\n"
        print "# Json:\n{stream}\n"
-       print "# Back in Nit:\n{deserialized or else "null"}\n"#alt2#
+       print "# Back in Nit:\n{deserialized or else "null"}\n"#alt2##alt4#
 end
diff --git a/tests/test_nitcorn.nit b/tests/test_nitcorn.nit
new file mode 100644 (file)
index 0000000..e4088a2
--- /dev/null
@@ -0,0 +1,133 @@
+# 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.
+
+import nitcorn
+import pthreads
+
+redef class Sys
+       var iface: String is lazy do
+               srand
+               return "localhost:{10000+20000.rand}"
+       end
+
+       var fs_path: String = getcwd / "../lib/nitcorn/examples/www/hello_world/dir" is lazy
+end
+
+class MyAction
+       super Action
+
+       redef fun answer(request, turi)
+       do
+               var rep = new HttpResponse(200)
+               rep.body = """
+[Response] Simple answer
+Method: {{{request.method}}}, URI: {{{request.uri}}}, trailing: {{{turi}}}"""
+
+               if request.get_args.not_empty
+               then rep.body += "\nGET args: {request.get_args.join(", ", ":")}"
+
+               if request.post_args.not_empty
+               then rep.body += "\nPOST args: {request.post_args.join(", ", ":")}"
+
+               if request.uri_params.not_empty
+               then rep.body += "\nParams args: {request.uri_params.join(", ", ":")}"
+
+               if request.cookie.not_empty
+               then rep.body += "\nCookie: {request.cookie.join(", ", ":")}"
+
+               rep.body += "\n"
+               return rep
+       end
+end
+
+class ServerThread
+       super Thread
+
+       redef fun main
+       do
+               # Hide testing concept to force nitcorn to actually run
+               "NIT_TESTING".setenv("false")
+
+               # Setup
+               var vh = new VirtualHost(iface)
+               vh.routes.add new Route("file_server", new FileServer(fs_path.simplify_path))
+               vh.routes.add new Route("simple_answer", new MyAction)
+               vh.routes.add new Route("params_answer/:i/:s", new MyAction)
+
+               # Launch
+               var factory = new HttpFactory.and_libevent
+               factory.config.virtual_hosts.add vh
+               factory.run
+
+               return null
+       end
+end
+
+class ClientThread
+       super Thread
+
+       redef fun main
+       do
+               system "curl -s {iface}/simple_answer"
+               system "curl -s {iface}/simple_answer/"
+               system "curl -s {iface}/simple_answer/trailing/path"
+
+               system "curl -s '{iface}/simple_answer?i=0123&s=asdf'"
+               system "curl -s {iface}/simple_answer --data 'i=0123&s=asdf'"
+               system "curl -s {iface}/simple_answer --cookie 'i=0123; s=asdf'"
+
+               system "curl -s {iface}/params_answer/0123/asdf"
+               system "curl -s {iface}/params_answer/0123/"
+               system "curl -s {iface}/params_answer/0123/asdf/trailing/path"
+               system "curl -s {iface}/params_answer/0123 --head"
+
+               system "curl -s {iface}/file_server/"
+               system "curl -s {iface}/file_server/ --head"
+               system "curl -s {iface}/file_server --head"
+               system "curl -s {iface}/file_server/a.txt"
+               system "curl -s {iface}/file_server/a.txt --head"
+               system "curl -s {iface}/file_server/binary_file.png --head"
+               system("curl -s {iface}/file_server/binary_file.png | diff - {fs_path.escape_to_sh}/binary_file.png",
+                      "curl -s {iface}/file_server/binary_file.png | diff - .../binary_file.png")
+               system "curl -s {iface}/file_server/unknown_file.txt --head"
+
+               system "curl -s {iface}/invalid_route --head"
+               return null
+       end
+
+       # Regex to catch and hide the port from the output to get consistent results
+       var host_re: Regex = "localhost:\[0-9\]+".to_re
+
+       fun system(cmd: String, title: nullable String)
+       do
+               title = title or else cmd
+               title = title.replace(host_re, "localhost:*****")
+               print "\n[Client] {title}"
+               sys.system cmd
+       end
+end
+
+# First, launch a server in the background
+var server = new ServerThread
+server.start
+0.1.sleep
+
+# Then, launch a client running test requests
+var client = new ClientThread
+client.start
+client.join
+0.1.sleep
+
+# Force quit the server
+exit 0