diff --git a/src/test/scala/scala/xml/AttributeTest.scala b/src/test/scala/scala/xml/AttributeTest.scala
index 13aa7bfc6..67b289748 100644
--- a/src/test/scala/scala/xml/AttributeTest.scala
+++ b/src/test/scala/scala/xml/AttributeTest.scala
@@ -65,4 +65,97 @@ class AttributeTest {
assertEquals("apple", xml \@ "bar")
}
-}
\ No newline at end of file
+ @Test
+ def attributePathRootNoAttribute: Unit = {
+ val xml =
+ assertEquals(NodeSeq.Empty, xml \ "@bar")
+ }
+
+ @Test(expected=classOf[IllegalArgumentException])
+ def attributePathIllegalEmptyAttribute: Unit = {
+ val xml =
+ xml \ "@"
+ }
+
+ @Test
+ def attributePathRootWithOneAttribute: Unit = {
+ val xml =
+ assertEquals(Group(Text("apple")), xml \ "@bar")
+ // assertEquals(NodeSeq.fromSeq(Seq(Text("apple"))), xml \ "@bar")
+ }
+
+ @Test
+ def attributePathRootWithMissingAttributes: Unit = {
+ val xml =
+ assertEquals(NodeSeq.Empty, xml \ "@oops")
+ }
+
+ @Test
+ def attributePathDuplicateAttribute: Unit = {
+ val xml = Elem(null, "foo",
+ Attribute("bar", Text("apple"),
+ Attribute("bar", Text("orange"), Null)), TopScope)
+ assertEquals(Group(Text("apple")), xml \ "@bar")
+ }
+
+ @Test
+ def attributePathDescendantAttributes: Unit = {
+ val xml =
+ assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \\ "@bar"))
+ }
+
+ @Test
+ def attributeDescendantPathChildAttributes: Unit = {
+ val xml =
+ assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \ "b" \\ "@bar"))
+ }
+
+ @Test
+ def attributeDescendantPathDescendantAttributes: Unit = {
+ val xml =
+ assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \\ "b" \\ "@bar"))
+ }
+
+ @Test
+ def attributeChildDescendantPathDescendantAttributes: Unit = {
+ val xml =
+ assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \ "a" \\ "@bar"))
+ }
+
+ @Test
+ def attributeDescendantDescendantPathDescendantAttributes: Unit = {
+ val xml =
+ assertEquals(NodeSeq.fromSeq(Seq(Text("1"), Text("2"))), (xml \\ "b" \\ "@bar"))
+ }
+
+ @Test(expected=classOf[IllegalArgumentException])
+ def attributePathDescendantIllegalEmptyAttribute: Unit = {
+ val xml =
+ xml \\ "@"
+ }
+
+ @Test
+ def attributePathNoDescendantAttributes: Unit = {
+ val xml =
+ assertEquals(NodeSeq.Empty, (xml \\ "@oops"))
+ }
+
+ @Test
+ def attributePathOneChildWithAttributes: Unit = {
+ val xml = >
+ assertEquals(Group(Seq(Text("1"))), (xml \ "b" \ "@bar"))
+ }
+
+ @Test
+ def attributePathTwoChildrenWithAttributes: Unit = {
+ val xml =
+ val b = xml \ "b"
+ assertEquals(2, b.length)
+ assertEquals(NodeSeq.fromSeq(Seq(, )), b)
+ val barFail = b \ "@bar"
+ val barList = b.map(_ \ "@bar")
+ assertEquals(NodeSeq.Empty, barFail)
+ assertEquals(List(Group(Seq(Text("1"))), Group(Seq(Text("2")))), barList)
+ }
+
+}