Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(799)

Delta Between Two Patch Sets: src/pkg/json/decode_test.go

Issue 4423043: code review 4423043: changes for more restricted reflect.SetValue (Closed)
Left Patch Set: Created 14 years ago
Right Patch Set: diff -r 47bd15b15056 https://go.googlecode.com/hg Created 13 years, 12 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/json/decode.go ('k') | src/pkg/netchan/export.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package json 5 package json
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "os" 9 "os"
10 "reflect" 10 "reflect"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if err := checkValid(in, &scan); err != nil { 131 if err := checkValid(in, &scan); err != nil {
132 if !reflect.DeepEqual(err, tt.err) { 132 if !reflect.DeepEqual(err, tt.err) {
133 t.Errorf("#%d: checkValid: %#v", i, err) 133 t.Errorf("#%d: checkValid: %#v", i, err)
134 continue 134 continue
135 } 135 }
136 } 136 }
137 if tt.ptr == nil { 137 if tt.ptr == nil {
138 continue 138 continue
139 } 139 }
140 // v = new(right-type) 140 // v = new(right-type)
141 » » v := reflect.NewValue(tt.ptr) 141 » » v := reflect.New(reflect.Typeof(tt.ptr).Elem())
142 » » v.Set(reflect.Zero(v.Type().Elem()).Addr())
143 if err := Unmarshal([]byte(in), v.Interface()); !reflect.DeepEqu al(err, tt.err) { 142 if err := Unmarshal([]byte(in), v.Interface()); !reflect.DeepEqu al(err, tt.err) {
144 t.Errorf("#%d: %v want %v", i, err, tt.err) 143 t.Errorf("#%d: %v want %v", i, err, tt.err)
145 continue 144 continue
146 } 145 }
147 if !reflect.DeepEqual(v.Elem().Interface(), tt.out) { 146 if !reflect.DeepEqual(v.Elem().Interface(), tt.out) {
148 t.Errorf("#%d: mismatch\nhave: %#+v\nwant: %#+v", i, v.E lem().Interface(), tt.out) 147 t.Errorf("#%d: mismatch\nhave: %#+v\nwant: %#+v", i, v.E lem().Interface(), tt.out)
149 data, _ := Marshal(v.Elem().Interface()) 148 data, _ := Marshal(v.Elem().Interface())
150 println(string(data)) 149 println(string(data))
151 data, _ = Marshal(tt.out) 150 data, _ = Marshal(tt.out)
152 println(string(data)) 151 println(string(data))
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 }, 531 },
533 "PSmall": null, 532 "PSmall": null,
534 "PPSmall": { 533 "PPSmall": {
535 "Tag": "tag31" 534 "Tag": "tag31"
536 }, 535 },
537 "Interface": null, 536 "Interface": null,
538 "PInterface": 5.2 537 "PInterface": 5.2
539 }` 538 }`
540 539
541 var pallValueCompact = strings.Map(noSpace, pallValueIndent) 540 var pallValueCompact = strings.Map(noSpace, pallValueIndent)
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b