OSDN Git Service

libgo: Update to weekly.2012-01-15.
[pf3gnuchains/gcc-fork.git] / libgo / go / html / parse_test.go
index 015b583..c929c25 100644 (file)
@@ -103,10 +103,21 @@ func dumpLevel(w io.Writer, n *Node, level int) error {
                } else {
                        fmt.Fprintf(w, "<%s>", n.Data)
                }
-               for _, a := range n.Attr {
+               attr := n.Attr
+               if len(attr) == 2 && attr[0].Namespace == "xml" && attr[1].Namespace == "xlink" {
+                       // Some of the test cases in tests10.dat change the order of adjusted
+                       // foreign attributes, but that behavior is not in the spec, and could
+                       // simply be an implementation detail of html5lib's python map ordering.
+                       attr[0], attr[1] = attr[1], attr[0]
+               }
+               for _, a := range attr {
                        io.WriteString(w, "\n")
                        dumpIndent(w, level+1)
-                       fmt.Fprintf(w, `%s="%s"`, a.Key, a.Val)
+                       if a.Namespace != "" {
+                               fmt.Fprintf(w, `%s %s="%s"`, a.Namespace, a.Key, a.Val)
+                       } else {
+                               fmt.Fprintf(w, `%s="%s"`, a.Key, a.Val)
+                       }
                }
        case TextNode:
                fmt.Fprintf(w, `"%s"`, n.Data)
@@ -172,8 +183,8 @@ func TestParser(t *testing.T) {
                {"tests3.dat", -1},
                {"tests4.dat", -1},
                {"tests5.dat", -1},
-               {"tests6.dat", 47},
-               {"tests10.dat", 16},
+               {"tests6.dat", -1},
+               {"tests10.dat", 33},
        }
        for _, tf := range testFiles {
                f, err := os.Open("testdata/webkit/" + tf.filename)