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

Delta Between Two Patch Sets: src/pkg/testing/script/script.go

Issue 4301043: update tree for reflect changes (Closed)
Left Patch Set: Created 13 years ago
Right Patch Set: diff -r f692a5e90f6f https://go.googlecode.com/hg/ Created 13 years 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/testing/quick/quick.go ('k') | src/pkg/try/try.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 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 // This package aids in the testing of code that uses channels. 5 // This package aids in the testing of code that uses channels.
6 package script 6 package script
7 7
8 import ( 8 import (
9 "fmt" 9 "fmt"
10 "os" 10 "os"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 func newEmptyInterface(e empty) reflect.Value { 136 func newEmptyInterface(e empty) reflect.Value {
137 return reflect.NewValue(e).(*reflect.StructValue).Field(0) 137 return reflect.NewValue(e).(*reflect.StructValue).Field(0)
138 } 138 }
139 139
140 func (s Send) send() { 140 func (s Send) send() {
141 // With reflect.ChanValue.Send, we must match the types exactly. So, if 141 // With reflect.ChanValue.Send, we must match the types exactly. So, if
142 // s.Channel is a chan interface{} we convert s.Value to an interface{} 142 // s.Channel is a chan interface{} we convert s.Value to an interface{}
143 // first. 143 // first.
144 c := reflect.NewValue(s.Channel).(*reflect.ChanValue) 144 c := reflect.NewValue(s.Channel).(*reflect.ChanValue)
145 var v reflect.Value 145 var v reflect.Value
146 » if iface, ok := c.Type().(*reflect.ChanType).Elem().(*reflect.InterfaceT ype); ok && iface.NumMethod() == 0 { 146 » if iface := c.Type().Elem(); iface.Kind() == reflect.Interface && iface. NumMethod() == 0 {
147 v = newEmptyInterface(empty{s.Value}) 147 v = newEmptyInterface(empty{s.Value})
148 } else { 148 } else {
149 v = reflect.NewValue(s.Value) 149 v = reflect.NewValue(s.Value)
150 } 150 }
151 c.Send(v) 151 c.Send(v)
152 } 152 }
153 153
154 // A Close action closes the given channel. 154 // A Close action closes the given channel.
155 type Close struct { 155 type Close struct {
156 Channel interface{} 156 Channel interface{}
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 continue 350 continue
351 } 351 }
352 names[j] = event.name 352 names[j] = event.name
353 } 353 }
354 354
355 return nil, SetupError("dependency cycle in events. These events are waiting to run but cannot: " + strings.Join(names, ", ")) 355 return nil, SetupError("dependency cycle in events. These events are waiting to run but cannot: " + strings.Join(names, ", "))
356 } 356 }
357 357
358 return ready[0:j], nil 358 return ready[0:j], nil
359 } 359 }
LEFTRIGHT

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