Child class at the same level as parent namespace
- create a new context
- add a simple vala file (here, toto.vala)
- parse current context
- provided file has two nodes : the namespace and his class child.
why ?
There should only be one node at the top level in this case (the namespace)
toto.vala
namespace Toto {
public class Tutu : Object {
public string tata { get; set; }
}
}
main.vala
public static void main (string[] args) {
var context = new Vala.CodeContext();
Vala.CodeContext.push (context);
var source = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, "toto.vala");
context.add_source_file (source);
context.add_external_package ("gobject-2.0");
context.add_external_package ("glib-2.0");
new Vala.Parser().parse (context);
context.check();
assert (source.get_nodes().size == 2); // always true
assert (source.get_nodes()[0].type_name == "ValaClass"); // always true;
assert (source.get_nodes()[1].type_name == "ValaNamespace"); // always true;
assert ((source.get_nodes()[1] as Vala.Namespace).get_classes()[0] == source.get_nodes()[0]); // always true;
Vala.CodeContext.pop();
}
Edited by Yannick Inizan