aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/html/parse_test.go
diff options
context:
space:
mode:
authorNigel Tao <nigeltao@golang.org>2011-11-02 09:42:25 +1100
committerNigel Tao <nigeltao@golang.org>2011-11-02 09:42:25 +1100
commit90b76c0f3e3356e17c03baae3e20a4a11c2a6f10 (patch)
tree26b8cc3d46b54858255624e2024c3adeb08c8f02 /src/pkg/html/parse_test.go
parentf753e3facda2a9845caf7e8aed0e8a122d6b6e48 (diff)
downloadgo-90b76c0f3e3356e17c03baae3e20a4a11c2a6f10.tar.xz
html: refactor the blacklist for the "render and re-parse" test.
R=andybalholm CC=golang-dev, mikesamuel https://golang.org/cl/5331056
Diffstat (limited to 'src/pkg/html/parse_test.go')
-rw-r--r--src/pkg/html/parse_test.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go
index caf3c92bc7..067eb26d04 100644
--- a/src/pkg/html/parse_test.go
+++ b/src/pkg/html/parse_test.go
@@ -160,14 +160,10 @@ func TestParser(t *testing.T) {
t.Errorf("%s test #%d %q, got vs want:\n----\n%s----\n%s----", filename, i, text, got, want)
continue
}
- // Check that rendering and re-parsing results in an identical tree.
- if filename == "tests1.dat" && (i == 30 || i == 77) {
- // Some tests in tests1.dat have such messed-up markup that a correct parse
- // results in a non-conforming tree (one <a> element nested inside another).
- // Therefore when it is rendered and re-parsed, it isn't the same.
- // So we skip rendering on that test.
+ if renderTestBlacklist[text] {
continue
}
+ // Check that rendering and re-parsing results in an identical tree.
pr, pw := io.Pipe()
go func() {
pw.CloseWithError(Render(pw, doc))
@@ -187,3 +183,15 @@ func TestParser(t *testing.T) {
}
}
}
+
+// Some test input result in parse trees are not 'well-formed' despite
+// following the HTML5 recovery algorithms. Rendering and re-parsing such a
+// tree will not result in an exact clone of that tree. We blacklist such
+// inputs from the render test.
+var renderTestBlacklist = map[string]bool{
+ // The second <a> will be reparented to the first <table>'s parent. This
+ // results in an <a> whose parent is an <a>, which is not 'well-formed'.
+ `<a><table><td><a><table></table><a></tr><a></table><b>X</b>C<a>Y`: true,
+ // The second <a> will be reparented, similar to the case above.
+ `<a href="blah">aba<table><a href="foo">br<tr><td></td></tr>x</table>aoe`: true,
+}