aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/html/parse_test.go
diff options
context:
space:
mode:
authorAndrew Balholm <andybalholm@gmail.com>2011-11-24 09:28:58 +1100
committerNigel Tao <nigeltao@golang.org>2011-11-24 09:28:58 +1100
commit77b0ad1e806580e47e4f682dfb912c55e1411b73 (patch)
treeee5f208102be1f8295b68215ffe2861ca619fa99 /src/pkg/html/parse_test.go
parentb3923a27dd80592ec4cd21ca04ea2a736578c9ad (diff)
downloadgo-77b0ad1e806580e47e4f682dfb912c55e1411b73.tar.xz
html: parse DOCTYPE into name and public and system identifiers
Pass tests2.dat, test 59: <!DOCTYPE <!DOCTYPE HTML>><!--<!--x-->--> | <!DOCTYPE <!doctype> | <html> | <head> | <body> | ">" | <!-- <!--x --> | "-->" Pass all the tests in doctype01.dat. Also pass tests2.dat, test 60: <!doctype html><div><form></form><div></div></div> R=nigeltao CC=golang-dev https://golang.org/cl/5437045
Diffstat (limited to 'src/pkg/html/parse_test.go')
-rw-r--r--src/pkg/html/parse_test.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go
index c1347c9dc1..90d3f46c61 100644
--- a/src/pkg/html/parse_test.go
+++ b/src/pkg/html/parse_test.go
@@ -97,7 +97,23 @@ func dumpLevel(w io.Writer, n *Node, level int) error {
case CommentNode:
fmt.Fprintf(w, "<!-- %s -->", n.Data)
case DoctypeNode:
- fmt.Fprintf(w, "<!DOCTYPE %s>", n.Data)
+ fmt.Fprintf(w, "<!DOCTYPE %s", n.Data)
+ if n.Attr != nil {
+ var p, s string
+ for _, a := range n.Attr {
+ switch a.Key {
+ case "public":
+ p = a.Val
+ case "system":
+ s = a.Val
+ }
+ }
+ if p != "" || s != "" {
+ fmt.Fprintf(w, ` "%s"`, p)
+ fmt.Fprintf(w, ` "%s"`, s)
+ }
+ }
+ io.WriteString(w, ">")
case scopeMarkerNode:
return errors.New("unexpected scopeMarkerNode")
default:
@@ -133,8 +149,9 @@ func TestParser(t *testing.T) {
n int
}{
// TODO(nigeltao): Process all the test cases from all the .dat files.
+ {"doctype01.dat", -1},
{"tests1.dat", -1},
- {"tests2.dat", 59},
+ {"tests2.dat", -1},
{"tests3.dat", 0},
}
for _, tf := range testFiles {