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:
Russ Cox 2009-07-08 18:16:09 -07:00
parent a68b1da3cc
commit bba278a43b
8 changed files with 235 additions and 15 deletions

View file

@ -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);
}
}