id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c21900 | mock.recorder = &MockMathMockRecorder{mock}
return mock
} | |
c21901 | "Sum", arg0, arg1)
ret0, _ := ret[0].(int)
return ret0
} | |
c21902 | mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sum", reflect.TypeOf((*MockMath)(nil).Sum), arg0, arg1)
} | |
c21903 | nil {
return nil, err
}
// Process output.
var pkg model.Package
if err := gob.NewDecoder(f).Decode(&pkg); err != nil {
return nil, err
}
if err := f.Close(); err != nil {
return nil, err
}
return &pkg, nil
} | |
c21904 | // Windows won't execute a program unless it has a ".exe" suffix.
progBinary += ".exe"
}
if err := ioutil.WriteFile(filepath.Join(tmpDir, progSource), program, 0600); err != nil {
return nil, err
}
cmdArgs := []string{}
cmdArgs = append(cmdArgs, "build")
if *buildFlags != "" {
cmdArgs = append(cmdArgs, ... | |
c21905 | && keys[0] == "a" {
index.Ellip("%d", 0, 1, 1, 2, 3)
index.Ellip("%d", 1, 3, 6, 10, 15)
index.EllipOnly("arg")
}
} | |
c21906 | c.maxCalls = 1e8
}
return c
} | |
c21907 | = n
if c.minCalls == 1 {
c.minCalls = 0
}
return c
} | |
c21908 | // can return the values with a type assertion.
v := reflect.New(want).Elem()
v.Set(reflect.ValueOf(ret))
rets[i] = v.Interface()
} else {
c.t.Fatalf("wrong type of argument %d to Return for %T.%v: %v is not assignable to %v [%s]",
i, c.receiver, c.method, got, want, c.origin)
}
}
c.addAction(fu... | |
c21909 | {
c.minCalls, c.maxCalls = n, n
return c
} | |
c21910 | reflect.Ptr:
dt := at.Elem()
if vt := reflect.TypeOf(value); !vt.AssignableTo(dt) {
c.t.Fatalf("SetArg(%d, ...) argument is a %v, not assignable to %v [%s]",
n, vt, dt, c.origin)
}
case reflect.Interface:
// nothing to do
case reflect.Slice:
// nothing to do
default:
c.t.Fatalf("SetArg(%d, ...) r... | |
c21911 | preReq.isPreReq(other) {
return true
}
}
return false
} | |
c21912 | }
if preReq.isPreReq(c) {
c.t.Fatalf("Loop in call order: %v is a prerequisite to %v (possibly indirectly).", c, preReq)
}
c.preReqs = append(c.preReqs, preReq)
return c
} | |
c21913 | c.preReqs
c.preReqs = nil
return
} | |
c21914 | 1; i < len(calls); i++ {
calls[i].After(calls[i-1])
}
} | |
c21915 | unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' {
t += string(r)
continue
}
}
t += "_"
}
if t == "_" {
t = "x"
}
return t
} | |
c21916 | ok := g.mockNames[typeName]; ok {
return mockName
}
return "Mock" + typeName
} | |
c21917 |
g.out()
g.p("}")
callArgs = ", " + idVarArgs + "..."
}
if len(m.Out) == 0 {
g.p(`%v.ctrl.Call(%v, %q%v)`, idRecv, idRecv, m.Name, callArgs)
} else {
idRet := ia.allocateIdentifier("ret")
g.p(`%v := %v.ctrl.Call(%v, %q%v)`, idRet, idRecv, idRecv, m.Name, callArgs)
// Go does not allow "naked" type ass... | |
c21918 | to format generated source code: %s\n%s", err, g.buf.String())
}
return src
} | |
c21919 | m = cs.exhausted
}
m[key] = append(m[key], call)
} | |
c21920 |
cs.expected[key] = append(calls[:i], calls[i+1:]...)
cs.exhausted[key] = append(cs.exhausted[key], call)
break
}
}
} | |
c21921 | // get useful error messages.
exhausted := cs.exhausted[key]
for _, call := range exhausted {
if err := call.matches(args); err != nil {
fmt.Fprintf(&callsErrors, "\n%v", err)
}
}
if len(expected)+len(exhausted) == 0 {
fmt.Fprintf(&callsErrors, "there are no expected calls of the method %q for that recei... | |
c21922 | range cs.expected {
for _, call := range calls {
if !call.satisfied() {
failures = append(failures, call)
}
}
}
return failures
} | |
c21923 | mock.recorder = &MockIndexMockRecorder{mock}
return mock
} | |
c21924 | m.ctrl.Call(m, "Anon", arg0)
} | |
c21925 | mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Anon", reflect.TypeOf((*MockIndex)(nil).Anon), arg0)
} | |
c21926 |
m.ctrl.Call(m, "Chan", arg0, arg1)
} | |
c21927 | "ConcreteRet")
ret0, _ := ret[0].(chan<- bool)
return ret0
} | |
c21928 |
varargs := append([]interface{}{arg0}, arg1...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ellip", reflect.TypeOf((*MockIndex)(nil).Ellip), varargs...)
} | |
c21929 |
varargs = append(varargs, a)
}
m.ctrl.Call(m, "EllipOnly", varargs...)
} | |
c21930 | m.ctrl.Call(m, "ForeignFour", arg0)
} | |
c21931 | m.ctrl.Call(m, "ForeignOne", arg0)
} | |
c21932 | m.ctrl.Call(m, "ForeignThree", arg0)
} | |
c21933 | m.ctrl.Call(m, "ForeignTwo", arg0)
} | |
c21934 | m.ctrl.T.Helper()
m.ctrl.Call(m, "Func", arg0)
} | |
c21935 | _ := ret[0].(interface{})
ret1, _ := ret[1].(interface{})
return ret0, ret1
} | |
c21936 | m.ctrl.Call(m, "Map", arg0)
} | |
c21937 | "NillableRet")
ret0, _ := ret[0].(error)
return ret0
} | |
c21938 | "Other")
ret0, _ := ret[0].(hash.Hash)
return ret0
} | |
c21939 | m.ctrl.Call(m, "Ptr", arg0)
} | |
c21940 | "Slice", arg0, arg1)
ret0, _ := ret[0].([3]int)
return ret0
} | |
c21941 | m.ctrl.Call(m, "Struct", arg0)
} | |
c21942 | m.ctrl.Call(m, "StructChan", arg0)
} | |
c21943 |
m.ctrl.Call(m, "Summary", arg0, arg1)
} | |
c21944 | m.ctrl.Call(m, "Templates", arg0, arg1)
} | |
c21945 | mock.recorder = &MockEmbedMockRecorder{mock}
return mock
} | |
c21946 | "ForeignEmbeddedMethod")
ret0, _ := ret[0].(*bufio.Reader)
return ret0
} | |
c21947 |
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForeignEmbeddedMethod", reflect.TypeOf((*MockEmbed)(nil).ForeignEmbeddedMethod))
} | |
c21948 | *imp1.ImpT, arg4 chan imp1.ImpT) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "ImplicitPackage", arg0, arg1, arg2, arg3, arg4)
} | |
c21949 |
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImplicitPackage", reflect.TypeOf((*MockEmbed)(nil).ImplicitPackage), arg0, arg1, arg2, arg3, arg4)
} | |
c21950 |
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegularMethod")
} | |
c21951 | mock.recorder = &MockEmbeddedMockRecorder{mock}
return mock
} | |
c21952 |
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EmbeddedMethod", reflect.TypeOf((*MockEmbedded)(nil).EmbeddedMethod))
} | |
c21953 | mock.recorder = &MockMatcherMockRecorder{mock}
return mock
} | |
c21954 | "Matches", arg0)
ret0, _ := ret[0].(bool)
return ret0
} | |
c21955 | mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Matches", reflect.TypeOf((*MockMatcher)(nil).Matches), arg0)
} | |
c21956 | "String")
ret0, _ := ret[0].(string)
return ret0
} | |
c21957 |
// Don't stomp any other imports.
for _, f := range p.auxFiles {
auxImports, _ := importsOfFile(f)
for pkg, path := range auxImports {
if _, ok := p.imports[pkg]; !ok {
p.imports[pkg] = path
}
}
}
var is []*model.Interface
for ni := range iterInterfaces(file) {
i, err := p.parseInterface(ni.nam... | |
c21958 | }
for ni := range iterInterfaces(file) {
p.importedInterfaces[path][ni.name.Name] = ni.it
}
imports, _ := importsOfFile(file)
for pkgName, pkgPath := range imports {
if _, ok := p.imports[pkgName]; !ok {
p.imports[pkgName] = pkgPath
}
}
}
return nil
} | |
c21959 | pkgName = strings.SplitN(last, ".", 2)[0]
} else {
pkgName = pkg.Name
}
}
if pkgName == "." {
dotImports = append(dotImports, importPath)
} else {
if _, ok := normalImports[pkgName]; ok {
log.Fatalf("imported package collision: %q imported twice", pkgName)
}
normalImports[pkgName] =... | |
c21960 | {
continue
}
it, ok := ts.Type.(*ast.InterfaceType)
if !ok {
continue
}
ch <- namedInterface{ts.Name, it}
}
}
close(ch)
}()
return ch
} | |
c21961 | if nargs == 0 {
return false
}
_, ok := f.Params.List[nargs-1].Type.(*ast.Ellipsis)
return ok
} | |
c21962 | }
return &Controller{
T: h,
expectedCalls: newCallSet(),
}
} | |
c21963 | if !ok {
h = nopTestHelper{t}
}
ctx, cancel := context.WithCancel(ctx)
return NewController(&cancelReporter{h, cancel}), ctx
} | |
c21964 | {
if recv.Type().Method(i).Name == method {
return ctrl.RecordCallWithMethodType(receiver, method, recv.Method(i).Type(), args...)
}
}
ctrl.T.Fatalf("gomock: failed finding method %s on %T", method, receiver)
panic("unreachable")
} | |
c21965 | receiver, method, methodType, args...)
ctrl.mu.Lock()
defer ctrl.mu.Unlock()
ctrl.expectedCalls.Add(call)
return call
} | |
c21966 | calls,
// * and the prerequite calls are no longer expected, so remove them.
preReqCalls := expected.dropPrereqs()
for _, preReqCall := range preReqCalls {
ctrl.expectedCalls.Remove(preReqCall)
}
actions := expected.call(args)
if expected.exhausted() {
ctrl.expectedCalls.Remove(expected)
}
retur... | |
c21967 | are satisfied.
failures := ctrl.expectedCalls.Failures()
for _, call := range failures {
ctrl.T.Errorf("missing call(s) to %v", call)
}
if len(failures) != 0 {
ctrl.T.Fatalf("aborting test due to missing call(s)")
}
} | |
c21968 | := range pkg.Interfaces {
intf.addImports(im)
}
return im
} | |
c21969 | != nil {
return
}
variadic = p
}
for i := 0; i < t.NumOut(); i++ {
p, err = parameterFromType(t.Out(i))
if err != nil {
return
}
out = append(out, p)
}
return
} | |
c21970 | decode = hex.Decode
case 32:
decode = base32.StdEncoding.Decode
}
if decode == nil {
err = fmt.Errorf("unhandled xt parameter encoding: encoded length %d", len(infoHash))
return
}
n, err := decode(m.InfoHash[:], []byte(infoHash))
if err != nil {
err = fmt.Errorf("error decoding xt: %s", err)
return
}... | |
c21971 | bencode.NewDecoder(r)
err := d.Decode(&mi)
if err != nil {
return nil, err
}
return &mi, nil
} | |
c21972 | return nil, err
}
defer f.Close()
return Load(f)
} | |
c21973 | bencode.NewEncoder(w).Encode(mi)
} | |
c21974 | = time.Now().Unix()
// mi.Info.PieceLength = 256 * 1024
} | |
c21975 | = append(m.Trackers, t)
}
m.DisplayName = displayName
m.InfoHash = infoHash
return
} | |
c21976 | mi.Announce != "" {
return [][]string{[]string{mi.Announce}}
}
return nil
} | |
c21977 | noInfo++
continue
}
ret += info.TotalLength()
hadInfo++
}
if hadInfo != 0 {
// Treat each torrent without info as the average of those with,
// rounded up.
ret += (noInfo*ret + hadInfo - 1) / hadInfo
}
return
} | |
c21978 | false
}
return len(ip) == net.IPv6len
} | |
c21979 | ml.NextBool(!l.utp(), !r.utp())
ml.NextBool(l.ipv6(), r.ipv6())
return ml.FinalOk()
} | |
c21980 | {
if cn.t.haveInfo() {
return cn.t.numPieces()
}
return cn.peerMinPieces
} | |
c21981 | bitmap.ToEnd)
cn.peerPiecesChanged()
return nil
} | |
c21982 | writer flushing it out.).
cn.writeBuffer.Write(msg.MustMarshalBinary())
// Last I checked only Piece messages affect stats, and we don't post
// those.
cn.wroteMsg(&msg)
cn.tickleWriter()
} | |
c21983 | // dupliateRequestTimeout window. We are trying to avoid having to
// duplicate requests.
cn.chunksReceivedWhileExpecting*int64(cn.t.duplicateRequestTimeout)/expectingTime,
),
))
}
return int(clamp(
1,
int64(cn.PeerMaxRequests),
max(64,
cn.stats.ChunksReadUseful.Int64()-(cn.stats.ChunksRead.... | |
c21984 | cn.requests[r] = struct{}{}
if cn.validReceiveChunks == nil {
cn.validReceiveChunks = make(map[request]struct{})
}
cn.validReceiveChunks[r] = struct{}{}
cn.t.pendingRequests[r]++
cn.t.lastRequested[r] = time.AfterFunc(cn.t.duplicateRequestTimeout, func() {
torrent.Add("duplicate request timeouts", 1)
cn.mu(... | |
c21985 | cn.wroteMsg(&msg)
cn.writeBuffer.Write(msg.MustMarshalBinary())
torrent.Add(fmt.Sprintf("messages filled of type %s", msg.Type.String()), 1)
return cn.writeBuffer.Len() < 1<<16 // 64KiB
})
}
if cn.writeBuffer.Len() == 0 && time.Since(lastWrite) >= keepAliveTimeout {
cn.writeBuffer.Write(pp.Mes... | |
c21986 | skip.Add(i.(int))
return cb(i)
}, bitmap.Sub(bm, *skip).Iter) {
return
}
}
}
} | |
c21987 | {
return true
}
if cn == cn.t.fastestConn {
return true
}
return false
} | |
c21988 | cn.pieceRequestOrder.Remove(bitmap.BitIndex(piece))
} | |
c21989 | cn.t.requestStrategy {
case 1:
switch tpp {
case PiecePriorityNormal:
case PiecePriorityReadahead:
prio -= int(cn.t.numPieces())
case PiecePriorityNext, PiecePriorityNow:
prio -= 2 * int(cn.t.numPieces())
default:
panic(tpp)
}
prio += int(piece / 3)
default:
}
return cn.pieceRequestOrder.Set... | |
c21990 | := cn.t
f(&t.stats)
f(&t.cl.stats)
} | |
c21991 | cn.reconciledHandshakeStats {
cn.postHandshakeStats(f)
}
} | |
c21992 | c.PeerInterested {
return true
}
if c.peerHasWantedPieces() {
return true
}
return false
} | |
c21993 | io.ReadWriter) {
cn.r = rw
cn.w = rw
} | |
c21994 | {
return struct {
io.Reader
io.Writer
}{cn.r, cn.w}
} | |
c21995 | We had the piece, but not anymore.
break another
}
}
log.Str("error sending chunk to peer").AddValues(c, r, err).Log(c.t.logger)
// If we failed to send a chunk, choke the peer to ensure they
// flush all their requests. We've probably dropped a piece,
// but there's no way to communicat... | |
c21996 | return
}
}
v6 := ip.To16()
if v6 != nil {
return ipl.lookup(v6)
}
if v4 == nil && v6 == nil {
r = Range{
Description: "bad IP",
}
ok = true
}
return
} | |
c21997 | // it.
i := sort.Search(n, func(i int) bool {
if i+1 >= n {
return true
}
return bytes.Compare(ip, first(i+1)) < 0
})
if i == n {
return
}
r = full(i)
ok = bytes.Compare(r.First, ip) <= 0 && bytes.Compare(ip, r.Last) <= 0
return
} | |
c21998 | int) Range {
return ipl.ranges[i]
}, len(ipl.ranges), ip)
} | |
c21999 | lineNum++
if !ok {
continue
}
if s, ok := uniqStrs[r.Description]; ok {
r.Description = s
} else {
uniqStrs[r.Description] = r.Description
}
ranges = append(ranges, r)
}
err = scanner.Err()
if err != nil {
return
}
ret = New(ranges)
return
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.