summaryrefslogtreecommitdiff
path: root/src/pkg/json/decode_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/json/decode_test.go')
-rw-r--r--src/pkg/json/decode_test.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/pkg/json/decode_test.go b/src/pkg/json/decode_test.go
index 49135c4bf..bf8bf10bf 100644
--- a/src/pkg/json/decode_test.go
+++ b/src/pkg/json/decode_test.go
@@ -21,7 +21,7 @@ type tx struct {
x int
}
-var txType = reflect.Typeof((*tx)(nil)).Elem()
+var txType = reflect.TypeOf((*tx)(nil)).Elem()
// A type that can unmarshal itself.
@@ -64,14 +64,14 @@ var unmarshalTests = []unmarshalTest{
{`"g-clef: \uD834\uDD1E"`, new(string), "g-clef: \U0001D11E", nil},
{`"invalid: \uD834x\uDD1E"`, new(string), "invalid: \uFFFDx\uFFFD", nil},
{"null", new(interface{}), nil, nil},
- {`{"X": [1,2,3], "Y": 4}`, new(T), T{Y: 4}, &UnmarshalTypeError{"array", reflect.Typeof("")}},
+ {`{"X": [1,2,3], "Y": 4}`, new(T), T{Y: 4}, &UnmarshalTypeError{"array", reflect.TypeOf("")}},
{`{"x": 1}`, new(tx), tx{}, &UnmarshalFieldError{"x", txType, txType.Field(0)}},
// skip invalid tags
{`{"X":"a", "y":"b", "Z":"c"}`, new(badTag), badTag{"a", "b", "c"}, nil},
// syntax errors
- {`{"X": "foo", "Y"}`, nil, nil, SyntaxError("invalid character '}' after object key")},
+ {`{"X": "foo", "Y"}`, nil, nil, &SyntaxError{"invalid character '}' after object key", 17}},
// composite tests
{allValueIndent, new(All), allValue, nil},
@@ -125,12 +125,12 @@ func TestMarshalBadUTF8(t *testing.T) {
}
func TestUnmarshal(t *testing.T) {
- var scan scanner
for i, tt := range unmarshalTests {
+ var scan scanner
in := []byte(tt.in)
if err := checkValid(in, &scan); err != nil {
if !reflect.DeepEqual(err, tt.err) {
- t.Errorf("#%d: checkValid: %v", i, err)
+ t.Errorf("#%d: checkValid: %#v", i, err)
continue
}
}
@@ -138,8 +138,7 @@ func TestUnmarshal(t *testing.T) {
continue
}
// v = new(right-type)
- v := reflect.NewValue(tt.ptr)
- v.Set(reflect.Zero(v.Type().Elem()).Addr())
+ v := reflect.New(reflect.TypeOf(tt.ptr).Elem())
if err := Unmarshal([]byte(in), v.Interface()); !reflect.DeepEqual(err, tt.err) {
t.Errorf("#%d: %v want %v", i, err, tt.err)
continue