aboutsummaryrefslogtreecommitdiff
path: root/src/text/template/exec_test.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2015-04-30 12:11:35 -0700
committerRob Pike <r@golang.org>2015-05-01 01:07:43 +0000
commit042200145fbf994e3fcbfa87e75b10d042867b3a (patch)
treea915f6a65dabe237262f3ce77d4186c96cb84322 /src/text/template/exec_test.go
parentcf3ac26a4c79ec53a8a5161f15cc91ab75b3ac46 (diff)
downloadgo-042200145fbf994e3fcbfa87e75b10d042867b3a.tar.xz
text/template: allow newlines in raw quotes
This was disallowed for error-checking reasons but people ask for it, it's easy, and it's clear what it all means. Fixes #7323. Change-Id: I26542f5ac6519e45b335ad789713a4d9e356279b Reviewed-on: https://go-review.googlesource.com/9537 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/text/template/exec_test.go')
-rw-r--r--src/text/template/exec_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go
index 8c4e165f2f..27c74eb44d 100644
--- a/src/text/template/exec_test.go
+++ b/src/text/template/exec_test.go
@@ -1095,3 +1095,16 @@ func TestMissingMapKey(t *testing.T) {
t.Errorf("expected error; got none")
}
}
+
+// Test that the error message for multiline unterminated string
+// refers to the line number of the opening quote.
+func TestUnterminatedStringError(t *testing.T) {
+ _, err := New("X").Parse("hello\n\n{{`unterminated\n\n\n\n}}\n some more\n\n")
+ if err == nil {
+ t.Fatal("expected error")
+ }
+ str := err.Error()
+ if !strings.Contains(str, "X:3: unexpected unterminated raw quoted strin") {
+ t.Fatalf("unexpected error: %s", str)
+ }
+}