mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflection for functions
add channel send type check (thanks austin). fix type mismatch message. R=r DELTA=241 (225 added, 5 deleted, 11 changed) OCL=31370 CL=31375
This commit is contained in:
parent
a68b1da3cc
commit
bba278a43b
8 changed files with 235 additions and 15 deletions
|
|
@ -725,3 +725,22 @@ func TestChan(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Difficult test for function call because of
|
||||
// implicit padding between arguments.
|
||||
func dummy(b byte, c int, d byte) (i byte, j int, k byte){
|
||||
return b, c, d;
|
||||
}
|
||||
|
||||
func TestFunc(t *testing.T) {
|
||||
ret := NewValue(dummy).(*FuncValue).Call([]Value{NewValue(byte(10)), NewValue(20), NewValue(byte(30))});
|
||||
if len(ret) != 3 {
|
||||
t.Fatalf("Call returned %d values, want 3", len(ret));
|
||||
}
|
||||
|
||||
i := ret[0].(*Uint8Value).Get();
|
||||
j := ret[1].(*IntValue).Get();
|
||||
k := ret[2].(*Uint8Value).Get();
|
||||
if i != 10 || j != 20 || k != 30 {
|
||||
t.Errorf("Call returned %d, %d, %d; want 10, 20, 30", i, j, k);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue