Author: atsushi
Date: 2005-12-12 06:49:32 -0500 (Mon, 12 Dec 2005)
New Revision: 54231
Modified:
trunk/mcs/class/System.XML/System.Xml/ChangeLog
trunk/mcs/class/System.XML/System.Xml/XmlReader.cs
trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
trunk/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs
Log:
2005-12-12 Atsushi Enomoto <[EMAIL PROTECTED]>
* XmlReader.cs : fixed several misconception in MoveToNextSibling().
It should check its ReadState to avoid infinite loop.
* XmlReaderCommonTests.cs : enabled MoveToNextSibling() tests.
Modified: trunk/mcs/class/System.XML/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/ChangeLog 2005-12-12 11:26:27 UTC
(rev 54230)
+++ trunk/mcs/class/System.XML/System.Xml/ChangeLog 2005-12-12 11:49:32 UTC
(rev 54231)
@@ -1,5 +1,10 @@
2005-12-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * XmlReader.cs : fixed several misconception in MoveToNextSibling().
+ It should check its ReadState to avoid infinite loop.
+
+2005-12-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* XmlException.cs : added another .ctor() overload that takes both
IXmlLineInfo and innerException.
* XmlQualifiedName.cs : added Parse() overload that takes XmlReader
Modified: trunk/mcs/class/System.XML/System.Xml/XmlReader.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlReader.cs 2005-12-12 11:26:27 UTC
(rev 54230)
+++ trunk/mcs/class/System.XML/System.Xml/XmlReader.cs 2005-12-12 11:49:32 UTC
(rev 54231)
@@ -863,10 +863,10 @@
public virtual bool ReadToNextSibling (string name)
{
- if (NodeType != XmlNodeType.Element || IsEmptyElement)
+ if (ReadState != ReadState.Interactive)
return false;
int depth = Depth;
- for (Skip (); depth < Depth; Skip ())
+ for (Skip (); depth >= Depth; Skip ())
if (NodeType == XmlNodeType.Element && name ==
Name)
return true;
return false;
@@ -874,10 +874,10 @@
public virtual bool ReadToNextSibling (string localName, string
namespaceURI)
{
- if (NodeType != XmlNodeType.Element || IsEmptyElement)
+ if (ReadState != ReadState.Interactive)
return false;
int depth = Depth;
- for (Skip (); depth < Depth; Skip ())
+ for (Skip (); depth >= Depth; Skip ())
if (NodeType == XmlNodeType.Element &&
localName == LocalName && namespaceURI == NamespaceURI)
return true;
return false;
Modified: trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog 2005-12-12
11:26:27 UTC (rev 54230)
+++ trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog 2005-12-12
11:49:32 UTC (rev 54231)
@@ -1,5 +1,9 @@
2005-12-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * XmlReaderCommonTests.cs : enabled MoveToNextSibling() tests.
+
+2005-12-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* XmlReaderCommonTests.cs : added several tests for 2.0 methods.
2005-12-09 Atsushi Enomoto <[EMAIL PROTECTED]>
Modified: trunk/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs
2005-12-12 11:26:27 UTC (rev 54230)
+++ trunk/mcs/class/System.XML/Test/System.Xml/XmlReaderCommonTests.cs
2005-12-12 11:49:32 UTC (rev 54231)
@@ -1554,44 +1554,57 @@
Assert ("#4", !xmlReader.ReadToFollowing ("bar"));
}
-/*
[Test]
+ [Category ("NotDotNet")]
+ public void ReadToNextSiblingAtInitialState ()
+ {
+ string xml = @"<root></root>";
+ RunTest (xml, new TestMethod
(ReadToNextSiblingAtInitialState ));
+ }
+
+ void ReadToNextSiblingAtInitialState (XmlReader xmlReader)
+ {
+ Assert ("#1", !xmlReader.ReadToNextSibling ("bar"));
+ Assert ("#2", !xmlReader.ReadToNextSibling ("root"));
+ }
+
+ [Test]
public void ReadToNextSibling ()
{
- string xml = @"<root><foo/><bar
attr='value'/><foo><bar><bar></bar><foo></foo><bar/></bar></foo></root>";
+ string xml = @"<root><foo/><bar
attr='value'/><foo><pooh/><bar></bar><foo></foo><bar/></foo></root>";
RunTest (xml, new TestMethod (ReadToNextSibling));
}
void ReadToNextSibling (XmlReader xmlReader)
{
- Assert ("#1", !xmlReader.ReadToNextSibling ("bar"));
- Assert ("#2", !xmlReader.ReadToNextSibling ("root"));
+ // It is funky, but without it MS.NET results in an
infinite loop.
xmlReader.Read (); // root
+
xmlReader.Read (); // foo
Assert ("#3", xmlReader.ReadToNextSibling ("bar"));
+
AssertEquals ("#3-2", "value", xmlReader.GetAttribute
("attr"));
xmlReader.Read (); // foo
- xmlReader.Read (); // bar
+ xmlReader.Read (); // pooh
Assert ("#4", xmlReader.ReadToNextSibling ("bar"));
Assert ("#4-2", !xmlReader.IsEmptyElement);
Assert ("#5", xmlReader.ReadToNextSibling ("bar"));
Assert ("#5-2", xmlReader.IsEmptyElement);
- Assert ("#6", xmlReader.Read ()); // /bar
+ Assert ("#6", xmlReader.Read ()); // /foo
AssertNodeValues ("#7", xmlReader,
XmlNodeType.EndElement,
- 2, // Depth
+ 1, // Depth
false, // IsEmptyElement
- "bar", // Name
+ "foo", // Name
String.Empty, // Prefix
- "bar", // LocalName
+ "foo", // LocalName
String.Empty, // NamespaceURI
String.Empty, // Value
false, // HasValue
0, // AttributeCount
false); // HasAttributes
}
-*/
[Test]
public void ReadSubtree ()
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches