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

Delta Between Two Patch Sets: src/pkg/encoding/gob/type_test.go

Issue 6637047: code review 6637047: encoding/gob: fix data race in Register (Closed)
Left Patch Set: Created 11 years, 5 months ago
Right Patch Set: diff -r 5a8c4552dd85 https://code.google.com/p/go/ Created 11 years, 5 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/encoding/gob/type.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 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 gob 5 package gob
6 6
7 import ( 7 import (
8 "reflect" 8 "reflect"
9 "testing" 9 "testing"
10 ) 10 )
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 name string 170 name string
171 }{ 171 }{
172 {&N1{}, "*gob.N1"}, 172 {&N1{}, "*gob.N1"},
173 {N2{}, "encoding/gob.N2"}, 173 {N2{}, "encoding/gob.N2"},
174 } 174 }
175 175
176 for _, tc := range testCases { 176 for _, tc := range testCases {
177 Register(tc.t) 177 Register(tc.t)
178 178
179 tct := reflect.TypeOf(tc.t) 179 tct := reflect.TypeOf(tc.t)
180 » » registerLock.Lock() 180 » » registerLock.RLock()
181 ct := nameToConcreteType[tc.name] 181 ct := nameToConcreteType[tc.name]
182 » » registerLock.Unlock() 182 » » registerLock.RUnlock()
183 if ct != tct { 183 if ct != tct {
184 t.Errorf("nameToConcreteType[%q] = %v, want %v", tc.name , ct, tct) 184 t.Errorf("nameToConcreteType[%q] = %v, want %v", tc.name , ct, tct)
185 } 185 }
186 // concreteTypeToName is keyed off the base type. 186 // concreteTypeToName is keyed off the base type.
187 if tct.Kind() == reflect.Ptr { 187 if tct.Kind() == reflect.Ptr {
188 tct = tct.Elem() 188 tct = tct.Elem()
189 } 189 }
190 if n := concreteTypeToName[tct]; n != tc.name { 190 if n := concreteTypeToName[tct]; n != tc.name {
191 t.Errorf("concreteTypeToName[%v] got %v, want %v", tct, n, tc.name) 191 t.Errorf("concreteTypeToName[%v] got %v, want %v", tct, n, tc.name)
192 } 192 }
193 } 193 }
194 } 194 }
LEFTRIGHT

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