| 1 | package interp_testscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/ |
| 2 | |
| 3 | import ( |
| 4 | "reflectscip-go gomod github.com/golang/go/src go1.21 reflect/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.21 testing/" |
| 6 | |
| 7 | "github.com/traefik/yaegi/interpscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/" |
| 8 | ) |
| 9 | |
| 10 | // IntChan is a channel type alias for testing. |
| 11 | type IntChanscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/IntChan# chan int |
| 12 | |
| 13 | // NewIntChan creates a new IntChan. |
| 14 | func NewIntChanscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/NewIntChan().() IntChanscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/IntChan# { |
| 15 | return make(IntChanscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/IntChan#, 1) |
| 16 | } |
| 17 | |
| 18 | func TestSendToBinaryChannelTypeAliasscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/TestSendToBinaryChannelTypeAlias().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 19 | i := interpscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/.Newscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/New().(interpscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/.Optionsscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/Options#{}) |
| 20 | |
| 21 | err := i.Usescip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/Interpreter#Use().(interpscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/.Exportsscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/Exports#{ |
| 22 | "mypkg/mypkg": { |
| 23 | "IntChan": reflectscip-go gomod github.com/golang/go/src go1.21 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.21 reflect/ValueOf().((*IntChanscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/IntChan#)(nil)), |
| 24 | "NewIntChan": reflectscip-go gomod github.com/golang/go/src go1.21 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.21 reflect/ValueOf().(NewIntChanscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/NewIntChan().), |
| 25 | }, |
| 26 | }) |
| 27 | if err != nil { |
| 28 | t.Fatalscip-go gomod github.com/golang/go/src go1.21 testing/common#Fatal().(err) |
| 29 | } |
| 30 | |
| 31 | _, err = i.Evalscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/Interpreter#Eval().(` |
| 32 | package main |
| 33 | |
| 34 | import "mypkg" |
| 35 | |
| 36 | func main() { |
| 37 | ch := mypkg.NewIntChan() |
| 38 | ch <- 42 |
| 39 | val := <-ch |
| 40 | if val != 42 { |
| 41 | panic("unexpected value") |
| 42 | } |
| 43 | } |
| 44 | `) |
| 45 | if err != nil { |
| 46 | t.Fatalscip-go gomod github.com/golang/go/src go1.21 testing/common#Fatal().(err) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | func TestSendToSourceDefinedChannelscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/TestSendToSourceDefinedChannel().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 51 | i := interpscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/.Newscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/New().(interpscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/.Optionsscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/Options#{}) |
| 52 | |
| 53 | // Test with a channel defined purely in interpreted code |
| 54 | _, err := i.Evalscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/Interpreter#Eval().(` |
| 55 | package main |
| 56 | |
| 57 | func main() { |
| 58 | ch := make(chan int, 1) |
| 59 | ch <- 42 |
| 60 | val := <-ch |
| 61 | if val != 42 { |
| 62 | panic("unexpected value") |
| 63 | } |
| 64 | } |
| 65 | `) |
| 66 | if err != nil { |
| 67 | t.Fatalscip-go gomod github.com/golang/go/src go1.21 testing/common#Fatal().(err) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | func TestSendToSourceDefinedChannelTypeAliasscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp_test`/TestSendToSourceDefinedChannelTypeAlias().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 72 | i := interpscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/.Newscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/New().(interpscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/.Optionsscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/Options#{}) |
| 73 | |
| 74 | // Test with a channel type alias defined in interpreted code |
| 75 | _, err := i.Evalscip-go gomod github.com/traefik/yaegi . `github.com/traefik/yaegi/interp`/Interpreter#Eval().(` |
| 76 | package main |
| 77 | |
| 78 | type MyChan chan int |
| 79 | |
| 80 | func main() { |
| 81 | ch := make(MyChan, 1) |
| 82 | ch <- 42 |
| 83 | val := <-ch |
| 84 | if val != 42 { |
| 85 | panic("unexpected value") |
| 86 | } |
| 87 | } |
| 88 | `) |
| 89 | if err != nil { |
| 90 | t.Fatalscip-go gomod github.com/golang/go/src go1.21 testing/common#Fatal().(err) |
| 91 | } |
| 92 | } |