diff options
| author | Emmanuel Odeke <emm.odeke@gmail.com> | 2017-05-22 15:17:38 -0600 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2017-08-12 00:21:16 +0000 |
| commit | 590c5b08070dfb2ddeb2b2583acc3a2b0fcb03bb (patch) | |
| tree | 2f43c907050ff5017a5c5117f4d1c660cf146e05 /src/text/template/exec_test.go | |
| parent | 057a34a281a52b474184614ac63b808974e22549 (diff) | |
| download | go-590c5b08070dfb2ddeb2b2583acc3a2b0fcb03bb.tar.xz | |
text/template: support indexing into *int* maps
Ensure that we can index maps whose key types are:
* int
* uint
* int32
* uint32
* int64
* uint64
* uintptr
Fixes #20439
Change-Id: I8fa96b14073c8af72786482ff4ffc3508064ea86
Reviewed-on: https://go-review.googlesource.com/43850
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/text/template/exec_test.go')
| -rw-r--r-- | src/text/template/exec_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go index 9f7e637c19..d0cda6bd62 100644 --- a/src/text/template/exec_test.go +++ b/src/text/template/exec_test.go @@ -44,6 +44,12 @@ type T struct { MSIEmpty map[string]int MXI map[interface{}]int MII map[int]int + MI32S map[int32]string + MI64S map[int64]string + MUI32S map[uint32]string + MUI64S map[uint64]string + MI8S map[int8]string + MUI8S map[uint8]string SMSI []map[string]int // Empty interfaces; used to see if we can dig inside one. Empty0 interface{} // nil @@ -124,6 +130,12 @@ var tVal = &T{ MSIone: map[string]int{"one": 1}, MXI: map[interface{}]int{"one": 1}, MII: map[int]int{1: 1}, + MI32S: map[int32]string{1: "one", 2: "two"}, + MI64S: map[int64]string{2: "i642", 3: "i643"}, + MUI32S: map[uint32]string{2: "u322", 3: "u323"}, + MUI64S: map[uint64]string{2: "ui642", 3: "ui643"}, + MI8S: map[int8]string{2: "i82", 3: "i83"}, + MUI8S: map[uint8]string{2: "u82", 3: "u83"}, SMSI: []map[string]int{ {"one": 1, "two": 2}, {"eleven": 11, "twelve": 12}, @@ -448,6 +460,11 @@ var execTests = []execTest{ {"map[WRONG]", "{{index .MSI 10}}", "", tVal, false}, {"double index", "{{index .SMSI 1 `eleven`}}", "11", tVal, true}, {"nil[1]", "{{index nil 1}}", "", tVal, false}, + {"map MI64S", "{{index .MI64S 2}}", "i642", tVal, true}, + {"map MI32S", "{{index .MI32S 2}}", "two", tVal, true}, + {"map MUI64S", "{{index .MUI64S 3}}", "ui643", tVal, true}, + {"map MI8S", "{{index .MI8S 3}}", "i83", tVal, true}, + {"map MUI8S", "{{index .MUI8S 2}}", "u82", tVal, true}, // Len. {"slice", "{{len .SI}}", "3", tVal, true}, |
