tpl: Sync go_templates for Go 1.18

Using Go tag go1.18 4aa1efed4853ea067d665a952eee77c52faac774

Updates #9677
This commit is contained in:
Bjørn Erik Pedersen
2022-03-16 08:48:16 +01:00
parent 4d6d1d08da
commit 65a78cae1e
48 changed files with 697 additions and 223 deletions

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.13 && !windows
// +build go1.13,!windows
package template
@@ -105,7 +106,7 @@ func TestNextJsCtx(t *testing.T) {
func TestJSValEscaper(t *testing.T) {
tests := []struct {
x interface{}
x any
js string
}{
{int(42), " 42 "},
@@ -142,8 +143,8 @@ func TestJSValEscaper(t *testing.T) {
// "\v" == "v" on IE 6 so use "\u000b" instead.
{"\t\x0b", `"\t\u000b"`},
{struct{ X, Y int }{1, 2}, `{"X":1,"Y":2}`},
{[]interface{}{}, "[]"},
{[]interface{}{42, "foo", nil}, `[42,"foo",null]`},
{[]any{}, "[]"},
{[]any{42, "foo", nil}, `[42,"foo",null]`},
{[]string{"<!--", "</script>", "-->"}, `["\u003c!--","\u003c/script\u003e","--\u003e"]`},
{"<!--", `"\u003c!--"`},
{"-->", `"--\u003e"`},
@@ -160,7 +161,7 @@ func TestJSValEscaper(t *testing.T) {
}
// Make sure that escaping corner cases are not broken
// by nesting.
a := []interface{}{test.x}
a := []any{test.x}
want := "[" + strings.TrimSpace(test.js) + "]"
if js := jsValEscaper(a); js != want {
t.Errorf("%+v: want\n\t%q\ngot\n\t%q", a, want, js)
@@ -170,7 +171,7 @@ func TestJSValEscaper(t *testing.T) {
func TestJSStrEscaper(t *testing.T) {
tests := []struct {
x interface{}
x any
esc string
}{
{"", ``},
@@ -225,7 +226,7 @@ func TestJSStrEscaper(t *testing.T) {
func TestJSRegexpEscaper(t *testing.T) {
tests := []struct {
x interface{}
x any
esc string
}{
{"", `(?:)`},
@@ -280,7 +281,7 @@ func TestEscapersOnLower7AndSelectHighCodepoints(t *testing.T) {
tests := []struct {
name string
escaper func(...interface{}) string
escaper func(...any) string
escaped string
}{
{