diff --git a/src/pkg/exp/template/html/escape_test.go b/src/pkg/exp/template/html/escape_test.go
index da3c011961..ea7d3bdb04 100644
--- a/src/pkg/exp/template/html/escape_test.go
+++ b/src/pkg/exp/template/html/escape_test.go
@@ -7,6 +7,7 @@ package html
import (
"bytes"
"fmt"
+ "json"
"os"
"strings"
"template"
@@ -14,11 +15,25 @@ import (
"testing"
)
+type badMarshaler struct{}
+
+func (x *badMarshaler) MarshalJSON() ([]byte, os.Error) {
+ // Keys in valid JSON must be double quoted as must all strings.
+ return []byte("{ foo: 'not quite valid JSON' }"), nil
+}
+
+type goodMarshaler struct{}
+
+func (x *goodMarshaler) MarshalJSON() ([]byte, os.Error) {
+ return []byte(`{ "": "O'Reilly" }`), nil
+}
+
func TestEscape(t *testing.T) {
var data = struct {
F, T bool
C, G, H string
A, E []string
+ B, M json.Marshaler
N int
Z *int
W HTML
@@ -31,6 +46,8 @@ func TestEscape(t *testing.T) {
A: []string{"", ""},
E: []string{},
N: 42,
+ B: &badMarshaler{},
+ M: &goodMarshaler{},
Z: nil,
W: HTML(`¡Hello, !`),
}
@@ -195,6 +212,16 @@ func TestEscape(t *testing.T) {
"