[gxml/serialization: 31/33] Ported NodeList to Gee Collections.
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml/serialization: 31/33] Ported NodeList to Gee Collections.
- Date: Fri, 20 Dec 2013 21:33:30 +0000 (UTC)
commit 666976f272b5870943e5ac68084c38ae2a2c9bff
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Dec 18 20:16:18 2013 -0600
Ported NodeList to Gee Collections.
* NodeList requires Gee.Collection interface implementation
* NodeList removed unused API
* Removed GListNodeList implementation
* Replaced GListNodeList with Gee.ArrayList
* ChildNodeList is now a read only Gee.AbstractCollection
* Test ported to new API
gxml/NamedNodeMap.vala | 10 +
gxml/NodeList.vala | 585 ++++++++++++------------------------------------
test/DocumentTest.vala | 5 +-
test/ElementTest.vala | 8 +-
test/NodeTest.vala | 59 ++++--
5 files changed, 203 insertions(+), 464 deletions(-)
---
diff --git a/gxml/NamedNodeMap.vala b/gxml/NamedNodeMap.vala
index 9561695..2f2351d 100644
--- a/gxml/NamedNodeMap.vala
+++ b/gxml/NamedNodeMap.vala
@@ -22,6 +22,7 @@
*/
using GXml;
+using Gee;
namespace GXml {
public interface NamedNodeMap<T> : GLib.Object {
@@ -143,5 +144,14 @@ namespace GXml {
private set {
}
}
+
+ public Gee.Collection<Attr> get_values ()
+ {
+ var c = new Gee.ArrayList<Attr> ();
+ for (int i =0; i < length; i++) {
+ c.add (item (i));
+ }
+ return c;
+ }
}
}
diff --git a/gxml/NodeList.vala b/gxml/NodeList.vala
index 16e0468..f33856a 100644
--- a/gxml/NodeList.vala
+++ b/gxml/NodeList.vala
@@ -1,4 +1,3 @@
-/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* NodeList.vala
*
* Copyright (C) 2011-2013 Richard Schwarting <aquarichy gmail com>
@@ -41,7 +40,8 @@ namespace GXml {
* Version: DOM Level 1 Core<<BR>>
* URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-536297177]]
*/
- public interface NodeList : Gee.Iterable<Node> {
+ public interface NodeList : GLib.Object, Gee.Iterable<Node>, Gee.Collection<Node>
+ {
/* NOTE:
* children should define constructors like:
* internal NodeList (Xml.Node* head, Document owner);
@@ -68,105 +68,11 @@ namespace GXml {
*/
public abstract Node item (ulong idx);
-
- /* ** GNOME List conventions **
- *
- * These methods mimic those available through GList,
- * to make GXmlNodeList more familiar to GLib
- * programmers. Probably don't want to keep all of
- * them since they're not all relevant.
- */
-
- /* TODO: add hints for performance below, perhaps;
- * with GList, you can get the first one, and it's a
- * GList, and then you just ->next through; with
- * GXmlNodeList, you get a GXmlNode which doesn't
- * directly track siblings. We should probably add
- * next_sibling and prev_sibling to GXmlNode, though;
- * libxml2 supports it, and it's convenient. :D */
-
- /**
- * Call the provided func on each item of the list. Like { link GLib.List.foreach}.
- */
- public abstract void foreach (Func<Node> func);
-
- /**
- * Retrieve the first node in the list. Like { link GLib.List.first}.
- */
- public abstract Node first ();
-
- /**
- * Retrieve the last node in the list. Like { link GLib.List.last}.
- */
- public abstract Node last ();
-
- /**
- * Obtain the n'th item in the list. Like { link GLib.List.nth}.
- *
- * @param n The index of the item to access
- */
- public abstract Node? nth (ulong n);
-
- /**
- * Obtain the n'th item in the list. Like { link GLib.List.nth_data}.
- *
- * @param n The index of the item to access
- *
- * @return The n'th item in the list
- */
- public abstract Node? nth_data (ulong n);
-
- /**
- * Obtain the item n places before pivot in the list.
- * Like { link GLib.List.nth_prev}.
- *
- * @param pivot A reference point in the list, from which we'll count back
- * @param n How many nodes to count back from the reference point
- *
- * @return The node that is `n` nodes before `pivot` in the list
- */
- public abstract Node? nth_prev (Node pivot, ulong n);
-
- /**
- * Obtain index for node `target` in the list. Like { link GLib.List.find}.
- *
- * @param target A node in the list
- *
- * @return The index of `target`
- */
- public abstract int find (Node target);
-
- /**
- * Obtain index for node `target` in the list, using
- * CompareFunc to compare. Like { link GLib.List.find_custom}.
- *
- * @param target A node in the list
- * @param cmp A comparison function, useful if `target` is a comparable copy of a node
actually in the list
- *
- * @return The index of the first node in the list matching `target` according to `cmp`
- */
- public abstract int find_custom (Node target, CompareFunc<Node> cmp);
-
- /**
- * Obtain index for node `target` in the list. Like
- * { link GLib.List.position}.
- *
- * @param target A node in the list
- *
- * @return The position of `target` in the list
- */
- public abstract int position (Node target);
-
- /**
- * Obtain index for node target in the list.
- */
- public abstract int index (Node target);
-
/* These exist to support management of a node's children */
- internal abstract unowned Node? insert_before (Node new_child, Node? ref_child);
- internal abstract unowned Node? replace_child (Node new_child, Node old_child);
- internal abstract unowned Node? remove_child (Node old_child);
- internal abstract unowned Node? append_child (Node new_child);
+ public abstract unowned Node? insert_before (Node new_child, Node? ref_child);
+ public abstract unowned Node? replace_child (Node new_child, Node old_child);
+ public abstract unowned Node? remove_child (Node old_child);
+ public abstract unowned Node? append_child (Node new_child);
/**
* Creates an XML string representation of the nodes in the list.
@@ -181,189 +87,31 @@ namespace GXml {
* @todo: write a test
*/
public abstract string to_string (bool in_line);
- }
-
- /**
- * This provides a NodeList that is backed by a GLib.List of
- * Nodes. A root { link GXml.Node} is specified, which
- * is usually the owner/parent of the list's contents
- * (children of the parent).
- */
- internal class GListNodeList : Gee.Traversable<Node>, Gee.Iterable<Node>, NodeList, GLib.Object {
- internal Node root;
- internal GLib.List<Node> nodes;
-
- internal GListNodeList (Node root) {
- this.root = root;
- this.nodes = new GLib.List<Node> ();
- }
/**
- * { inheritDoc}
+ * Retrieve the first node in the list. Like { link GLib.List.first}.
*/
- public ulong length {
- get {
- return nodes.length ();
- }
- private set {
- }
- }
+ public abstract Node first ();
/**
- * { inheritDoc}
- */
- public Node item (ulong idx) {
- return this.nth_data (idx);
- }
- /**
- * { inheritDoc}
- */
- public bool foreach (ForallFunc<Node> func) {
- return iterator ().foreach (func);
- }
- /**
- * { inheritDoc}
- */
- public Node first () {
- return this.nodes.first ().data;
- }
- /**
- * { inheritDoc}
- */
- public Node last () {
- return this.nodes.last ().data;
- }
- /**
- * { inheritDoc}
- */
- public Node? nth (ulong n) {
- return this.nth_data (n);
- }
- /**
- * { inheritDoc}
- */
- public Node? nth_data (ulong n) {
- return this.nodes.nth_data ((uint)n);
- }
- /**
- * { inheritDoc}
- */
- public Node? nth_prev (Node pivot, ulong n) {
- unowned GLib.List<Node> list_pivot = this.nodes.find (pivot);
- return list_pivot.nth_prev ((uint)n).data;
- }
- /**
- * { inheritDoc}
- */
- public int find (Node target) {
- return this.index (target);
- }
- /**
- * { inheritDoc}
- */
- public int find_custom (Node target, CompareFunc<Node> cmp) {
- unowned GLib.List<Node> list_pt = this.nodes.find_custom (target, cmp);
- return this.index (list_pt.data);
- }
- /**
- * { inheritDoc}
- */
- public int position (Node target) {
- return this.index (target);
- }
- /**
- * { inheritDoc}
+ * Retrieve the last node in the list. Like { link GLib.List.last}.
*/
- public int index (Node target) {
- return this.nodes.index (target);
- }
-
- internal unowned Node? insert_before (Node new_child, Node? ref_child) {
- this.nodes.insert_before (this.nodes.find (ref_child), new_child);
- return new_child;
- }
- internal unowned Node? replace_child (Node new_child, Node old_child) {
- int pos = this.index (old_child);
- this.remove_child (old_child);
- this.nodes.insert (new_child, pos);
- return old_child;
- }
- internal unowned Node? remove_child (Node old_child) /*throws DomError*/ {
- this.nodes.remove (old_child);
- return old_child;
- }
- internal unowned Node? append_child (Node new_child) /*throws DomError*/ {
- this.nodes.append (new_child);
- return new_child;
- }
-
- public string to_string (bool in_line) {
- string str = "";
-
- foreach (Node node in this.nodes) {
- str += node.to_string ();
- }
-
- return str;
- }
-
- /* ** Iterable methods ***/
- public GLib.Type element_type {
- get {
- return typeof (Node);
- }
- }
- public Gee.Iterator<Node> iterator () {
- return new NodeListIterator (this);
- }
-
+ public abstract Node last ();
/**
- * Iterator for NodeLists. Allows you to iterate a
- * collection neatly in vala.
+ * Obtain the n'th item in the list. Like { link GLib.List.nth}.
+ *
+ * @param n The index of the item to access
*/
- private class NodeListIterator : GenericNodeListIterator {
- /* When you receive one, initially you cannot get anything.
- * Use has_next () to determine if there is a next one.
- * If the list is not empty, this should always be true.
- * (If it wasn't read-only, it could become empty by removing)
- * Use next () to advance to the first/next one.
- * If not empty, always succeed
- * get () fails before first next and after remove (), always succeeds elsewise.
- * Implies we cycle
- * remove () always fails (does nothing)
- */
-
- private unowned GLib.List<Node> cur;
- private unowned GLib.List<Node> first_node;
- private unowned GLib.List<Node> next_node;
-
- public NodeListIterator (GListNodeList list) {
- this.cur = null;
- this.first_node = list.nodes;
- this.next_node = list.nodes;
- }
-
- protected override Node get_current () {
- return this.cur.data;
- }
-
- protected override bool is_empty () {
- return (this.next_node == null);
- }
-
- // TODO: address ambiguity of libgee documentation that led me to believe that a call
to get needed to be valid in such a way that I had to cycle here.
- protected override void advance () {
- this.cur = this.next_node;
- this.next_node = this.cur.next;
- }
- }
+ public abstract new Node @get (int n);
}
+}
+namespace GXml {
/* TODO: this will somehow need to watch the document and find
* out as new elements are added, and get reconstructed each
* time, or get reconstructed-on-the-go?
*/
- internal class TagNameNodeList : GListNodeList { internal string tag_name;
+ internal class TagNameNodeList : GXml.ArrayList { internal string tag_name;
internal TagNameNodeList (string tag_name, Node root, Document owner) {
base (root);
this.tag_name = tag_name;
@@ -379,7 +127,7 @@ namespace GXml {
// }
// }
- internal class NamespaceAttrNodeList : GListNodeList {
+ internal class NamespaceAttrNodeList : GXml.ArrayList {
internal NamespaceAttrNodeList (BackedNode root, Document owner) {
base (root);
for (Xml.Ns *cur = root.node->ns_def; cur != null; cur = cur->next) {
@@ -479,7 +227,8 @@ namespace GXml {
// TODO: Desperately want to extend List or implement relevant interfaces to make iterable
// TODO: remember that the order of interfaces that you're listing as implemented matters
- internal abstract class ChildNodeList : Gee.Traversable<Node>, Gee.Iterable<Node>, NodeList,
GLib.Object {
+ internal abstract class ChildNodeList : Gee.AbstractCollection<Node>, NodeList
+{
/* TODO: must be live
if this reflects children of a node, then must always be current
same with nodes from GetElementByTagName, made need separate impls for each */
@@ -495,39 +244,37 @@ namespace GXml {
*/
public ulong length {
get {
- int len = 0;
- for (Xml.Node *cur = head; cur != null; cur = cur->next) {
- len++;
- }
- return len;
+ return size;
}
private set { }
}
- /**
- * { inheritDoc}
- */
- public Node item (ulong idx) {
- return this.nth (idx);
- }
-
- /** Iterable methods **/
- public GLib.Type element_type { // TODO: should we need to use the override keyword when
implementing interfaces
- get {
- return typeof(Node);
- }
- }
- public Gee.Iterator<Node> iterator () {
+ public override bool add (Node item)
+ {
+ append_child (item);
+ return true;
+ }
+ public override void clear () {}
+ public override bool contains (Node item) { return false; }
+ public override bool remove (Node item) { return false; }
+ public override bool read_only { get { return true; } }
+ public override int size {
+ get {
+ int len = 0;
+ for (Xml.Node *cur = head; cur != null; cur = cur->next) {
+ len++;
+ }
+ return len;
+ }
+ }
+ public override Gee.Iterator<Node> iterator () {
return new NodeListIterator (this);
}
-
-
- /** GNOME List conventions
- ** Probably don't want to keep all of them since they're not all relevant.
- **/
- public bool foreach (ForallFunc<Node> func) {
+ public override bool @foreach (ForallFunc<Node> func) {
return iterator ().foreach (func);
}
+
+ /** GNOME List conventions */
public Node first () {
return this.owner.lookup_node (head);
}
@@ -538,58 +285,14 @@ namespace GXml {
}
return this.owner.lookup_node (cur); // TODO :check for nulls?
}
- public Node? nth (ulong n) {
+ public new Node @get (int n) {
Xml.Node *cur = head;
for (int i = 0; i < n && cur != null; i++) {
cur = cur->next;
}
return this.owner.lookup_node (cur);
}
- public Node? nth_data (ulong n) {
- return nth (n);
- }
- public Node? nth_prev (Node pivot, ulong n) {
- Xml.Node *cur;
- for (cur = head; cur != null && this.owner.lookup_node (cur) != pivot; cur =
cur->next) {
- }
- if (cur == null) {
- return null;
- }
- for (int i = 0; i < n && cur != null; i++) {
- cur = cur->prev;
- }
- return this.owner.lookup_node (cur);
- }
- public int find (Node target) {
- int pos = 0;
- Xml.Node *cur;
- for (cur = head; cur != null && this.owner.lookup_node (cur) != target; cur =
cur->next) {
- pos++;
- }
- if (cur == null) {
- return -1;
- } else {
- return pos;
- }
- }
- public int find_custom (Node target, CompareFunc<Node> cmp) {
- int pos = 0;
- Xml.Node *cur;
- for (cur = head; cur != null && cmp (this.owner.lookup_node (cur), target) != 0; cur
= cur->next) {
- pos++;
- }
- if (cur == null) {
- return -1;
- } else {
- return pos;
- }
- }
- public int position (Node target) {
- return find (target);
- }
- public int index (Node target) {
- return find (target);
- }
+ public Node item (ulong idx) { return get ((int) idx); }
/** Node's child methods, implemented here **/
internal new unowned Node? insert_before (Node new_child, Node? ref_child) {
@@ -685,123 +388,119 @@ namespace GXml {
/* ** NodeListIterator ***/
- private class NodeListIterator : GenericNodeListIterator {
+ private class NodeListIterator : GLib.Object, Gee.Traversable<Node>, Gee.Iterator<Node>
+ {
private weak Document doc;
private Xml.Node *cur;
private Xml.Node *head;
- private Xml.Node *next_node;
/* TODO: consider rewriting this to work on NodeList instead of the Xml.Node*
list, then perhaps we could reuse it for get_elements_by_tag_name () */
public NodeListIterator (ChildNodeList list) {
this.head = list.head;
- this.next_node = this.head;
this.cur = null;
this.doc = list.owner;
}
-
- /* ** model-specific methods ***/
-
- protected override Node get_current () {
- return this.doc.lookup_node (this.cur);
- }
-
- protected override bool is_empty () {
- return (this.next_node == null);
- }
-
- protected override void advance () {
- this.cur = this.next_node;
- this.next_node = cur->next;
- }
- }
- }
-
- private abstract class GenericNodeListIterator : Gee.Traversable<Node>, Gee.Iterator<Node>,
GLib.Object {
- protected abstract Node get_current ();
- protected abstract bool is_empty ();
- protected abstract void advance ();
-
- public bool foreach (ForallFunc<Node> f) {
- var r = this.get ();
- bool ret = f(r);
- stdout.printf (@"GenericNodeListIterator: Continue = $((ret && this.next
()).to_string ())\n");
- if (ret && this.next ())
- return true;
- else
+ /* Gee.Iterator interface */
+ public new Node @get () { return this.doc.lookup_node (this.cur); }
+ public bool has_next () { return head == null ? false : true; }
+ public bool next () {
+ if (has_next ()) {
+ cur = head;
+ head = head->next;
+ return true;
+ }
return false;
- }
-
- /* ** Iterator methods ***/
-
- /**
- * Obtain the current Node in the iteration.
- * Returns %NULL if there is none, which occurs
- * if the list is empty or if iteration has
- * not started (next () has never been
- * called).
- */
- public new Node get () {
- if (this.valid) {
- return this.get_current ();
- } else {
- /* TODO: file bug, Iterator wants Node, not Node?, but it
- wants us to be able to return null. */
- return null;
}
- }
+ public void remove () {}
+ public bool read_only { get { return true; } }
+ public bool valid { get { return cur != null ? true : false; } }
- /**
- * Advance to the next Node in the list
- */
- public bool next () {
- if (this.is_empty ()) {
- // the list is empty
+ /* Traversable interface */
+ public new bool @foreach (Gee.ForallFunc<Node> f)
+ {
+ if (next ())
+ return f (get ());
return false;
- } else {
- this.advance ();
- return true;
- }
- }
-
- /**
- * Checks whether there is a next Node in the list.
- */
- public bool has_next () {
- return (! this.is_empty ());
- }
-
- /**
- * Lets the user know that the NodeList is
- * read_only so the remove () operation will
- * fail.
- */
- public bool read_only {
- get {
- return true;
- }
- }
-
- /**
- * Indicates whether a call to get () will
- * succeed. This should only be false at the
- * start before the first call to next ().
- */
- public bool valid {
- get {
- return (this.get_current () != null);
}
}
-
- /**
- * NodeLists are read-only. remove () will
- * always fail. To remove a node from a
- * document, it must be done from the parent
- * node using remove_child ().
- */
- public void remove () {
- // TODO: consider making this totally silent
- GLib.warning ("Remove on NodeList not supported: Nodes must be removed from parent or
doc separately.");
- }
}
}
+
+internal class GXml.ArrayList : Gee.ArrayList<Node>, NodeList
+{
+ public GXml.Node root;
+
+ public ulong length {
+ get { return size; }
+ private set {}
+ }
+
+ public ArrayList (GXml.Node root)
+ {
+ this.root = root;
+ }
+
+ public unowned Node? insert_before (Node new_child, Node? ref_child)
+ {
+ int i = -1;
+ if (contains (ref_child)) {
+ i = index_of (ref_child);
+ insert (i, new_child);
+ return new_child;
+ }
+ return null;
+ }
+
+ public unowned Node? replace_child (Node new_child, Node old_child)
+ {
+ if (contains (old_child)) {
+ int i = index_of (old_child);
+ remove_at (i);
+ insert (i, new_child);
+ return new_child;
+ }
+ return null;
+ }
+
+ public unowned Node? remove_child (Node old_child)
+ {
+ if (contains (old_child)) {
+ unowned Node n = old_child;
+ remove_at (index_of (old_child));
+ return n;
+ }
+ return null;
+ }
+
+ public unowned Node? append_child (Node new_child)
+ {
+ add (new_child);
+ return new_child;
+ }
+
+/**
+ * Retrieve the first node in the list. Like { link GLib.List.first}.
+ */
+ public Node first () { return first (); }
+
+ /**
+ * Retrieve the last node in the list. Like { link GLib.List.last}.
+ */
+ public Node last () { return last (); }
+
+ public Node item (ulong idx)
+ {
+ return @get((int) idx);
+ }
+
+ public string to_string (bool in_line)
+ {
+ string str = "";
+ foreach (Node node in this) {
+ str += node.to_string ();
+ }
+
+ return str;
+ }
+}
diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala
index 0c82930..6b4fea6 100644
--- a/test/DocumentTest.vala
+++ b/test/DocumentTest.vala
@@ -265,7 +265,10 @@ class DocumentTest : GXmlTest {
");
authors.append_child (fragment);
- assert (authors.get_elements_by_tag_name ("Author").length == 4);
+ if (authors.get_elements_by_tag_name ("Author").length != 4) {
+ stdout.printf (@"Authors: length error. Expected 4, got
$(authors.get_elements_by_tag_name ("Author").length)\n'");
+ assert_not_reached ();
+ }
string expected = "<?xml version=\"1.0\"?>
<Sentences>
diff --git a/test/ElementTest.vala b/test/ElementTest.vala
index d54a3e2..8795af0 100644
--- a/test/ElementTest.vala
+++ b/test/ElementTest.vala
@@ -237,19 +237,19 @@ class ElementTest : GXmlTest {
emails = elem.get_elements_by_tag_name ("Email");
assert (emails.length == 2);
- email = (Element)emails.nth_data (0);
+ email = (Element)emails get (0);
assert (email.tag_name == "Email");
assert (email.child_nodes.length == 1);
- text = (Text)email.child_nodes.nth_data (0);
+ text = (Text)email child_nodes get (0);
assert (text.node_name == "#text");
assert (text.node_value == "fweasley hogwarts co uk");
- email = (Element)emails.nth_data (1);
+ email = (Element)emails get (1);
assert (email.tag_name == "Email");
assert (email.child_nodes.length == 1);
- text = (Text)email.child_nodes.nth_data (0);
+ text = (Text)email child_nodes get (0);
assert (text.node_name == "#text");
assert (text.node_value == "gweasley hogwarts co uk");
diff --git a/test/NodeTest.vala b/test/NodeTest.vala
index 2b1ad59..06730b0 100644
--- a/test/NodeTest.vala
+++ b/test/NodeTest.vala
@@ -152,17 +152,44 @@ class NodeTest : GXmlTest {
Test.add_func ("/gxml/domnode/child_nodes", () => {
Document doc = get_doc ();
GXml.Node parent = get_elem ("Molly", doc);
+ if (parent == null) {
+ stdout.printf (@"Parent child Molly not found\n");
+ assert_not_reached ();
+ }
GXml.Node child_0 = get_elem ("Percy", doc);
+ if (child_0 == null) {
+ stdout.printf (@"Child_0 Percy not found\n");
+ assert_not_reached ();
+ }
GXml.Node child_1 = get_elem ("Ron", doc);
+ if (child_1 == null) {
+ stdout.printf (@"Child Ron not found\n");
+ assert_not_reached ();
+ }
GXml.Node child_2 = get_elem ("Ginnie", doc);
-
- assert (parent.child_nodes.length == 0);
+ if (child_2 == null) {
+ stdout.printf (@"Child Ginnie not found\n");
+ assert_not_reached ();
+ }
+ if (parent.child_nodes.length != 0) {
+ stdout.printf (@"ChildNode: wrong length. Expected 0 got
$(parent.child_nodes.length)\n");
+ assert_not_reached ();
+ }
parent.append_child (child_0);
parent.append_child (child_1);
parent.append_child (child_2);
- assert (parent.child_nodes.length == 3);
- assert (parent.child_nodes.nth_data (0) == child_0);
- assert (parent.child_nodes.nth_data (2) == child_2);
+ if (parent.child_nodes.length != 3) {
+ stdout.printf (@"ChildNode: wrong length. Expected 0 got
$(parent.child_nodes.length)\n");
+ assert_not_reached ();
+ }
+ if (parent child_nodes get (0) != child_0) {
+ stdout.printf (@"ChildNode: wrong child 0.\n");
+ assert_not_reached ();
+ }
+ if (parent child_nodes get (2) != child_2) {
+ stdout.printf (@"ChildNode: wrong child 2.\n");
+ assert_not_reached ();
+ }
});
Test.add_func ("/gxml/domnode/first_child", () => {
Document doc = get_doc ();
@@ -258,9 +285,9 @@ class NodeTest : GXmlTest {
assert (parent.first_child == child_0);
assert (parent.last_child == child_2);
assert (parent.child_nodes.length == 3);
- assert (parent.child_nodes.nth_data (0) == child_0);
- assert (parent.child_nodes.nth_data (1) == child_1);
- assert (parent.child_nodes.nth_data (2) == child_2);
+ assert (parent child_nodes get (0) == child_0);
+ assert (parent child_nodes get (1) == child_1);
+ assert (parent child_nodes get (2) == child_2);
assert (child_0.previous_sibling == null);
assert (child_1.previous_sibling == child_0);
assert (child_2.previous_sibling == child_1);
@@ -286,8 +313,8 @@ class NodeTest : GXmlTest {
assert (parent.first_child == child_0);
assert (parent.last_child == child_1);
assert (parent.child_nodes.length == 2);
- assert (parent.child_nodes.nth_data (0) == child_0);
- assert (parent.child_nodes.nth_data (1) == child_1);
+ assert (parent child_nodes get (0) == child_0);
+ assert (parent child_nodes get (1) == child_1);
assert (child_0.previous_sibling == null);
assert (child_1.previous_sibling == child_0);
assert (child_0.next_sibling == child_1);
@@ -313,8 +340,8 @@ class NodeTest : GXmlTest {
assert (parent.first_child == child_0);
assert (parent.last_child == child_1);
assert (parent.child_nodes.length == 2);
- assert (parent.child_nodes.nth_data (0) == child_0);
- assert (parent.child_nodes.nth_data (1) == child_1);
+ assert (parent child_nodes get (0) == child_0);
+ assert (parent child_nodes get (1) == child_1);
assert (child_0.previous_sibling == null);
assert (child_1.previous_sibling == child_0);
assert (child_0.next_sibling == child_1);
@@ -325,7 +352,7 @@ class NodeTest : GXmlTest {
assert (parent.first_child == child_1);
assert (parent.last_child == child_1);
assert (parent.child_nodes.length == 1);
- assert (parent.child_nodes.nth_data (0) == child_1);
+ assert (parent child_nodes get (0) == child_1);
assert (child_1.previous_sibling == null);
assert (child_1.next_sibling == null);
@@ -350,9 +377,9 @@ class NodeTest : GXmlTest {
assert (parent.first_child == child_0);
assert (parent.last_child == child_2);
assert (parent.child_nodes.length == 3);
- assert (parent.child_nodes.nth_data (0) == child_0);
- assert (parent.child_nodes.nth_data (1) == child_1);
- assert (parent.child_nodes.nth_data (2) == child_2);
+ assert (parent child_nodes get (0) == child_0);
+ assert (parent child_nodes get (1) == child_1);
+ assert (parent child_nodes get (2) == child_2);
assert (child_0.previous_sibling == null);
assert (child_1.previous_sibling == child_0);
assert (child_2.previous_sibling == child_1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]