From efbe47b1625422f21bb2f130f916ce040756dbe3 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 6 Jul 2020 12:27:01 -0400 Subject: html/template: add tests from text/template Copy and adapt tests from text/template, to exercise more of html/template's copy. Various differences in behavior are flagged with NOTE comments or t.Skip and documented in #40075. Many of them are probably bugs. One clarifying test case added to both text/template and html/template. No changes to the package itself. Change-Id: Ifefad83d647db846040d24c2741a0244b00ade82 Reviewed-on: https://go-review.googlesource.com/c/go/+/241084 Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot Reviewed-by: Rob Pike --- src/html/template/testdata/file1.tmpl | 2 ++ src/html/template/testdata/file2.tmpl | 2 ++ src/html/template/testdata/tmpl1.tmpl | 3 +++ src/html/template/testdata/tmpl2.tmpl | 3 +++ 4 files changed, 10 insertions(+) create mode 100644 src/html/template/testdata/file1.tmpl create mode 100644 src/html/template/testdata/file2.tmpl create mode 100644 src/html/template/testdata/tmpl1.tmpl create mode 100644 src/html/template/testdata/tmpl2.tmpl (limited to 'src/html/template/testdata') diff --git a/src/html/template/testdata/file1.tmpl b/src/html/template/testdata/file1.tmpl new file mode 100644 index 0000000000..febf9d9f89 --- /dev/null +++ b/src/html/template/testdata/file1.tmpl @@ -0,0 +1,2 @@ +{{define "x"}}TEXT{{end}} +{{define "dotV"}}{{.V}}{{end}} diff --git a/src/html/template/testdata/file2.tmpl b/src/html/template/testdata/file2.tmpl new file mode 100644 index 0000000000..39bf6fb9ee --- /dev/null +++ b/src/html/template/testdata/file2.tmpl @@ -0,0 +1,2 @@ +{{define "dot"}}{{.}}{{end}} +{{define "nested"}}{{template "dot" .}}{{end}} diff --git a/src/html/template/testdata/tmpl1.tmpl b/src/html/template/testdata/tmpl1.tmpl new file mode 100644 index 0000000000..b72b3a340c --- /dev/null +++ b/src/html/template/testdata/tmpl1.tmpl @@ -0,0 +1,3 @@ +template1 +{{define "x"}}x{{end}} +{{template "y"}} diff --git a/src/html/template/testdata/tmpl2.tmpl b/src/html/template/testdata/tmpl2.tmpl new file mode 100644 index 0000000000..16beba6e7d --- /dev/null +++ b/src/html/template/testdata/tmpl2.tmpl @@ -0,0 +1,3 @@ +template2 +{{define "y"}}y{{end}} +{{template "x"}} -- cgit v1.3