How to use Pop method of main Package

Best Syzkaller code snippet using main.Pop

claim_queue_mock.go

Source:claim_queue_mock.go Github

copy

Full Screen

...25 LengthFunc func() (r int)26 LengthCounter uint6427 LengthPreCounter uint6428 LengthMock mClaimQueueMockLength29 PopFunc func() (r packets.ReferendumClaim)30 PopCounter uint6431 PopPreCounter uint6432 PopMock mClaimQueueMockPop33 PushFunc func(p packets.ReferendumClaim)34 PushCounter uint6435 PushPreCounter uint6436 PushMock mClaimQueueMockPush37}38//NewClaimQueueMock returns a mock for github.com/insolar/insolar/network.ClaimQueue39func NewClaimQueueMock(t minimock.Tester) *ClaimQueueMock {40 m := &ClaimQueueMock{t: t}41 if controller, ok := t.(minimock.MockController); ok {42 controller.RegisterMocker(m)43 }44 m.ClearMock = mClaimQueueMockClear{mock: m}45 m.FrontMock = mClaimQueueMockFront{mock: m}46 m.LengthMock = mClaimQueueMockLength{mock: m}47 m.PopMock = mClaimQueueMockPop{mock: m}48 m.PushMock = mClaimQueueMockPush{mock: m}49 return m50}51type mClaimQueueMockClear struct {52 mock *ClaimQueueMock53 mainExpectation *ClaimQueueMockClearExpectation54 expectationSeries []*ClaimQueueMockClearExpectation55}56type ClaimQueueMockClearExpectation struct {57}58//Expect specifies that invocation of ClaimQueue.Clear is expected from 1 to Infinity times59func (m *mClaimQueueMockClear) Expect() *mClaimQueueMockClear {60 m.mock.ClearFunc = nil61 m.expectationSeries = nil62 if m.mainExpectation == nil {63 m.mainExpectation = &ClaimQueueMockClearExpectation{}64 }65 return m66}67//Return specifies results of invocation of ClaimQueue.Clear68func (m *mClaimQueueMockClear) Return() *ClaimQueueMock {69 m.mock.ClearFunc = nil70 m.expectationSeries = nil71 if m.mainExpectation == nil {72 m.mainExpectation = &ClaimQueueMockClearExpectation{}73 }74 return m.mock75}76//ExpectOnce specifies that invocation of ClaimQueue.Clear is expected once77func (m *mClaimQueueMockClear) ExpectOnce() *ClaimQueueMockClearExpectation {78 m.mock.ClearFunc = nil79 m.mainExpectation = nil80 expectation := &ClaimQueueMockClearExpectation{}81 m.expectationSeries = append(m.expectationSeries, expectation)82 return expectation83}84//Set uses given function f as a mock of ClaimQueue.Clear method85func (m *mClaimQueueMockClear) Set(f func()) *ClaimQueueMock {86 m.mainExpectation = nil87 m.expectationSeries = nil88 m.mock.ClearFunc = f89 return m.mock90}91//Clear implements github.com/insolar/insolar/network.ClaimQueue interface92func (m *ClaimQueueMock) Clear() {93 counter := atomic.AddUint64(&m.ClearPreCounter, 1)94 defer atomic.AddUint64(&m.ClearCounter, 1)95 if len(m.ClearMock.expectationSeries) > 0 {96 if counter > uint64(len(m.ClearMock.expectationSeries)) {97 m.t.Fatalf("Unexpected call to ClaimQueueMock.Clear.")98 return99 }100 return101 }102 if m.ClearMock.mainExpectation != nil {103 return104 }105 if m.ClearFunc == nil {106 m.t.Fatalf("Unexpected call to ClaimQueueMock.Clear.")107 return108 }109 m.ClearFunc()110}111//ClearMinimockCounter returns a count of ClaimQueueMock.ClearFunc invocations112func (m *ClaimQueueMock) ClearMinimockCounter() uint64 {113 return atomic.LoadUint64(&m.ClearCounter)114}115//ClearMinimockPreCounter returns the value of ClaimQueueMock.Clear invocations116func (m *ClaimQueueMock) ClearMinimockPreCounter() uint64 {117 return atomic.LoadUint64(&m.ClearPreCounter)118}119//ClearFinished returns true if mock invocations count is ok120func (m *ClaimQueueMock) ClearFinished() bool {121 // if expectation series were set then invocations count should be equal to expectations count122 if len(m.ClearMock.expectationSeries) > 0 {123 return atomic.LoadUint64(&m.ClearCounter) == uint64(len(m.ClearMock.expectationSeries))124 }125 // if main expectation was set then invocations count should be greater than zero126 if m.ClearMock.mainExpectation != nil {127 return atomic.LoadUint64(&m.ClearCounter) > 0128 }129 // if func was set then invocations count should be greater than zero130 if m.ClearFunc != nil {131 return atomic.LoadUint64(&m.ClearCounter) > 0132 }133 return true134}135type mClaimQueueMockFront struct {136 mock *ClaimQueueMock137 mainExpectation *ClaimQueueMockFrontExpectation138 expectationSeries []*ClaimQueueMockFrontExpectation139}140type ClaimQueueMockFrontExpectation struct {141 result *ClaimQueueMockFrontResult142}143type ClaimQueueMockFrontResult struct {144 r packets.ReferendumClaim145}146//Expect specifies that invocation of ClaimQueue.Front is expected from 1 to Infinity times147func (m *mClaimQueueMockFront) Expect() *mClaimQueueMockFront {148 m.mock.FrontFunc = nil149 m.expectationSeries = nil150 if m.mainExpectation == nil {151 m.mainExpectation = &ClaimQueueMockFrontExpectation{}152 }153 return m154}155//Return specifies results of invocation of ClaimQueue.Front156func (m *mClaimQueueMockFront) Return(r packets.ReferendumClaim) *ClaimQueueMock {157 m.mock.FrontFunc = nil158 m.expectationSeries = nil159 if m.mainExpectation == nil {160 m.mainExpectation = &ClaimQueueMockFrontExpectation{}161 }162 m.mainExpectation.result = &ClaimQueueMockFrontResult{r}163 return m.mock164}165//ExpectOnce specifies that invocation of ClaimQueue.Front is expected once166func (m *mClaimQueueMockFront) ExpectOnce() *ClaimQueueMockFrontExpectation {167 m.mock.FrontFunc = nil168 m.mainExpectation = nil169 expectation := &ClaimQueueMockFrontExpectation{}170 m.expectationSeries = append(m.expectationSeries, expectation)171 return expectation172}173func (e *ClaimQueueMockFrontExpectation) Return(r packets.ReferendumClaim) {174 e.result = &ClaimQueueMockFrontResult{r}175}176//Set uses given function f as a mock of ClaimQueue.Front method177func (m *mClaimQueueMockFront) Set(f func() (r packets.ReferendumClaim)) *ClaimQueueMock {178 m.mainExpectation = nil179 m.expectationSeries = nil180 m.mock.FrontFunc = f181 return m.mock182}183//Front implements github.com/insolar/insolar/network.ClaimQueue interface184func (m *ClaimQueueMock) Front() (r packets.ReferendumClaim) {185 counter := atomic.AddUint64(&m.FrontPreCounter, 1)186 defer atomic.AddUint64(&m.FrontCounter, 1)187 if len(m.FrontMock.expectationSeries) > 0 {188 if counter > uint64(len(m.FrontMock.expectationSeries)) {189 m.t.Fatalf("Unexpected call to ClaimQueueMock.Front.")190 return191 }192 result := m.FrontMock.expectationSeries[counter-1].result193 if result == nil {194 m.t.Fatal("No results are set for the ClaimQueueMock.Front")195 return196 }197 r = result.r198 return199 }200 if m.FrontMock.mainExpectation != nil {201 result := m.FrontMock.mainExpectation.result202 if result == nil {203 m.t.Fatal("No results are set for the ClaimQueueMock.Front")204 }205 r = result.r206 return207 }208 if m.FrontFunc == nil {209 m.t.Fatalf("Unexpected call to ClaimQueueMock.Front.")210 return211 }212 return m.FrontFunc()213}214//FrontMinimockCounter returns a count of ClaimQueueMock.FrontFunc invocations215func (m *ClaimQueueMock) FrontMinimockCounter() uint64 {216 return atomic.LoadUint64(&m.FrontCounter)217}218//FrontMinimockPreCounter returns the value of ClaimQueueMock.Front invocations219func (m *ClaimQueueMock) FrontMinimockPreCounter() uint64 {220 return atomic.LoadUint64(&m.FrontPreCounter)221}222//FrontFinished returns true if mock invocations count is ok223func (m *ClaimQueueMock) FrontFinished() bool {224 // if expectation series were set then invocations count should be equal to expectations count225 if len(m.FrontMock.expectationSeries) > 0 {226 return atomic.LoadUint64(&m.FrontCounter) == uint64(len(m.FrontMock.expectationSeries))227 }228 // if main expectation was set then invocations count should be greater than zero229 if m.FrontMock.mainExpectation != nil {230 return atomic.LoadUint64(&m.FrontCounter) > 0231 }232 // if func was set then invocations count should be greater than zero233 if m.FrontFunc != nil {234 return atomic.LoadUint64(&m.FrontCounter) > 0235 }236 return true237}238type mClaimQueueMockLength struct {239 mock *ClaimQueueMock240 mainExpectation *ClaimQueueMockLengthExpectation241 expectationSeries []*ClaimQueueMockLengthExpectation242}243type ClaimQueueMockLengthExpectation struct {244 result *ClaimQueueMockLengthResult245}246type ClaimQueueMockLengthResult struct {247 r int248}249//Expect specifies that invocation of ClaimQueue.Length is expected from 1 to Infinity times250func (m *mClaimQueueMockLength) Expect() *mClaimQueueMockLength {251 m.mock.LengthFunc = nil252 m.expectationSeries = nil253 if m.mainExpectation == nil {254 m.mainExpectation = &ClaimQueueMockLengthExpectation{}255 }256 return m257}258//Return specifies results of invocation of ClaimQueue.Length259func (m *mClaimQueueMockLength) Return(r int) *ClaimQueueMock {260 m.mock.LengthFunc = nil261 m.expectationSeries = nil262 if m.mainExpectation == nil {263 m.mainExpectation = &ClaimQueueMockLengthExpectation{}264 }265 m.mainExpectation.result = &ClaimQueueMockLengthResult{r}266 return m.mock267}268//ExpectOnce specifies that invocation of ClaimQueue.Length is expected once269func (m *mClaimQueueMockLength) ExpectOnce() *ClaimQueueMockLengthExpectation {270 m.mock.LengthFunc = nil271 m.mainExpectation = nil272 expectation := &ClaimQueueMockLengthExpectation{}273 m.expectationSeries = append(m.expectationSeries, expectation)274 return expectation275}276func (e *ClaimQueueMockLengthExpectation) Return(r int) {277 e.result = &ClaimQueueMockLengthResult{r}278}279//Set uses given function f as a mock of ClaimQueue.Length method280func (m *mClaimQueueMockLength) Set(f func() (r int)) *ClaimQueueMock {281 m.mainExpectation = nil282 m.expectationSeries = nil283 m.mock.LengthFunc = f284 return m.mock285}286//Length implements github.com/insolar/insolar/network.ClaimQueue interface287func (m *ClaimQueueMock) Length() (r int) {288 counter := atomic.AddUint64(&m.LengthPreCounter, 1)289 defer atomic.AddUint64(&m.LengthCounter, 1)290 if len(m.LengthMock.expectationSeries) > 0 {291 if counter > uint64(len(m.LengthMock.expectationSeries)) {292 m.t.Fatalf("Unexpected call to ClaimQueueMock.Length.")293 return294 }295 result := m.LengthMock.expectationSeries[counter-1].result296 if result == nil {297 m.t.Fatal("No results are set for the ClaimQueueMock.Length")298 return299 }300 r = result.r301 return302 }303 if m.LengthMock.mainExpectation != nil {304 result := m.LengthMock.mainExpectation.result305 if result == nil {306 m.t.Fatal("No results are set for the ClaimQueueMock.Length")307 }308 r = result.r309 return310 }311 if m.LengthFunc == nil {312 m.t.Fatalf("Unexpected call to ClaimQueueMock.Length.")313 return314 }315 return m.LengthFunc()316}317//LengthMinimockCounter returns a count of ClaimQueueMock.LengthFunc invocations318func (m *ClaimQueueMock) LengthMinimockCounter() uint64 {319 return atomic.LoadUint64(&m.LengthCounter)320}321//LengthMinimockPreCounter returns the value of ClaimQueueMock.Length invocations322func (m *ClaimQueueMock) LengthMinimockPreCounter() uint64 {323 return atomic.LoadUint64(&m.LengthPreCounter)324}325//LengthFinished returns true if mock invocations count is ok326func (m *ClaimQueueMock) LengthFinished() bool {327 // if expectation series were set then invocations count should be equal to expectations count328 if len(m.LengthMock.expectationSeries) > 0 {329 return atomic.LoadUint64(&m.LengthCounter) == uint64(len(m.LengthMock.expectationSeries))330 }331 // if main expectation was set then invocations count should be greater than zero332 if m.LengthMock.mainExpectation != nil {333 return atomic.LoadUint64(&m.LengthCounter) > 0334 }335 // if func was set then invocations count should be greater than zero336 if m.LengthFunc != nil {337 return atomic.LoadUint64(&m.LengthCounter) > 0338 }339 return true340}341type mClaimQueueMockPop struct {342 mock *ClaimQueueMock343 mainExpectation *ClaimQueueMockPopExpectation344 expectationSeries []*ClaimQueueMockPopExpectation345}346type ClaimQueueMockPopExpectation struct {347 result *ClaimQueueMockPopResult348}349type ClaimQueueMockPopResult struct {350 r packets.ReferendumClaim351}352//Expect specifies that invocation of ClaimQueue.Pop is expected from 1 to Infinity times353func (m *mClaimQueueMockPop) Expect() *mClaimQueueMockPop {354 m.mock.PopFunc = nil355 m.expectationSeries = nil356 if m.mainExpectation == nil {357 m.mainExpectation = &ClaimQueueMockPopExpectation{}358 }359 return m360}361//Return specifies results of invocation of ClaimQueue.Pop362func (m *mClaimQueueMockPop) Return(r packets.ReferendumClaim) *ClaimQueueMock {363 m.mock.PopFunc = nil364 m.expectationSeries = nil365 if m.mainExpectation == nil {366 m.mainExpectation = &ClaimQueueMockPopExpectation{}367 }368 m.mainExpectation.result = &ClaimQueueMockPopResult{r}369 return m.mock370}371//ExpectOnce specifies that invocation of ClaimQueue.Pop is expected once372func (m *mClaimQueueMockPop) ExpectOnce() *ClaimQueueMockPopExpectation {373 m.mock.PopFunc = nil374 m.mainExpectation = nil375 expectation := &ClaimQueueMockPopExpectation{}376 m.expectationSeries = append(m.expectationSeries, expectation)377 return expectation378}379func (e *ClaimQueueMockPopExpectation) Return(r packets.ReferendumClaim) {380 e.result = &ClaimQueueMockPopResult{r}381}382//Set uses given function f as a mock of ClaimQueue.Pop method383func (m *mClaimQueueMockPop) Set(f func() (r packets.ReferendumClaim)) *ClaimQueueMock {384 m.mainExpectation = nil385 m.expectationSeries = nil386 m.mock.PopFunc = f387 return m.mock388}389//Pop implements github.com/insolar/insolar/network.ClaimQueue interface390func (m *ClaimQueueMock) Pop() (r packets.ReferendumClaim) {391 counter := atomic.AddUint64(&m.PopPreCounter, 1)392 defer atomic.AddUint64(&m.PopCounter, 1)393 if len(m.PopMock.expectationSeries) > 0 {394 if counter > uint64(len(m.PopMock.expectationSeries)) {395 m.t.Fatalf("Unexpected call to ClaimQueueMock.Pop.")396 return397 }398 result := m.PopMock.expectationSeries[counter-1].result399 if result == nil {400 m.t.Fatal("No results are set for the ClaimQueueMock.Pop")401 return402 }403 r = result.r404 return405 }406 if m.PopMock.mainExpectation != nil {407 result := m.PopMock.mainExpectation.result408 if result == nil {409 m.t.Fatal("No results are set for the ClaimQueueMock.Pop")410 }411 r = result.r412 return413 }414 if m.PopFunc == nil {415 m.t.Fatalf("Unexpected call to ClaimQueueMock.Pop.")416 return417 }418 return m.PopFunc()419}420//PopMinimockCounter returns a count of ClaimQueueMock.PopFunc invocations421func (m *ClaimQueueMock) PopMinimockCounter() uint64 {422 return atomic.LoadUint64(&m.PopCounter)423}424//PopMinimockPreCounter returns the value of ClaimQueueMock.Pop invocations425func (m *ClaimQueueMock) PopMinimockPreCounter() uint64 {426 return atomic.LoadUint64(&m.PopPreCounter)427}428//PopFinished returns true if mock invocations count is ok429func (m *ClaimQueueMock) PopFinished() bool {430 // if expectation series were set then invocations count should be equal to expectations count431 if len(m.PopMock.expectationSeries) > 0 {432 return atomic.LoadUint64(&m.PopCounter) == uint64(len(m.PopMock.expectationSeries))433 }434 // if main expectation was set then invocations count should be greater than zero435 if m.PopMock.mainExpectation != nil {436 return atomic.LoadUint64(&m.PopCounter) > 0437 }438 // if func was set then invocations count should be greater than zero439 if m.PopFunc != nil {440 return atomic.LoadUint64(&m.PopCounter) > 0441 }442 return true443}444type mClaimQueueMockPush struct {445 mock *ClaimQueueMock446 mainExpectation *ClaimQueueMockPushExpectation447 expectationSeries []*ClaimQueueMockPushExpectation448}449type ClaimQueueMockPushExpectation struct {450 input *ClaimQueueMockPushInput451}452type ClaimQueueMockPushInput struct {453 p packets.ReferendumClaim454}455//Expect specifies that invocation of ClaimQueue.Push is expected from 1 to Infinity times456func (m *mClaimQueueMockPush) Expect(p packets.ReferendumClaim) *mClaimQueueMockPush {457 m.mock.PushFunc = nil458 m.expectationSeries = nil459 if m.mainExpectation == nil {460 m.mainExpectation = &ClaimQueueMockPushExpectation{}461 }462 m.mainExpectation.input = &ClaimQueueMockPushInput{p}463 return m464}465//Return specifies results of invocation of ClaimQueue.Push466func (m *mClaimQueueMockPush) Return() *ClaimQueueMock {467 m.mock.PushFunc = nil468 m.expectationSeries = nil469 if m.mainExpectation == nil {470 m.mainExpectation = &ClaimQueueMockPushExpectation{}471 }472 return m.mock473}474//ExpectOnce specifies that invocation of ClaimQueue.Push is expected once475func (m *mClaimQueueMockPush) ExpectOnce(p packets.ReferendumClaim) *ClaimQueueMockPushExpectation {476 m.mock.PushFunc = nil477 m.mainExpectation = nil478 expectation := &ClaimQueueMockPushExpectation{}479 expectation.input = &ClaimQueueMockPushInput{p}480 m.expectationSeries = append(m.expectationSeries, expectation)481 return expectation482}483//Set uses given function f as a mock of ClaimQueue.Push method484func (m *mClaimQueueMockPush) Set(f func(p packets.ReferendumClaim)) *ClaimQueueMock {485 m.mainExpectation = nil486 m.expectationSeries = nil487 m.mock.PushFunc = f488 return m.mock489}490//Push implements github.com/insolar/insolar/network.ClaimQueue interface491func (m *ClaimQueueMock) Push(p packets.ReferendumClaim) {492 counter := atomic.AddUint64(&m.PushPreCounter, 1)493 defer atomic.AddUint64(&m.PushCounter, 1)494 if len(m.PushMock.expectationSeries) > 0 {495 if counter > uint64(len(m.PushMock.expectationSeries)) {496 m.t.Fatalf("Unexpected call to ClaimQueueMock.Push. %v", p)497 return498 }499 input := m.PushMock.expectationSeries[counter-1].input500 testify_assert.Equal(m.t, *input, ClaimQueueMockPushInput{p}, "ClaimQueue.Push got unexpected parameters")501 return502 }503 if m.PushMock.mainExpectation != nil {504 input := m.PushMock.mainExpectation.input505 if input != nil {506 testify_assert.Equal(m.t, *input, ClaimQueueMockPushInput{p}, "ClaimQueue.Push got unexpected parameters")507 }508 return509 }510 if m.PushFunc == nil {511 m.t.Fatalf("Unexpected call to ClaimQueueMock.Push. %v", p)512 return513 }514 m.PushFunc(p)515}516//PushMinimockCounter returns a count of ClaimQueueMock.PushFunc invocations517func (m *ClaimQueueMock) PushMinimockCounter() uint64 {518 return atomic.LoadUint64(&m.PushCounter)519}520//PushMinimockPreCounter returns the value of ClaimQueueMock.Push invocations521func (m *ClaimQueueMock) PushMinimockPreCounter() uint64 {522 return atomic.LoadUint64(&m.PushPreCounter)523}524//PushFinished returns true if mock invocations count is ok525func (m *ClaimQueueMock) PushFinished() bool {526 // if expectation series were set then invocations count should be equal to expectations count527 if len(m.PushMock.expectationSeries) > 0 {528 return atomic.LoadUint64(&m.PushCounter) == uint64(len(m.PushMock.expectationSeries))529 }530 // if main expectation was set then invocations count should be greater than zero531 if m.PushMock.mainExpectation != nil {532 return atomic.LoadUint64(&m.PushCounter) > 0533 }534 // if func was set then invocations count should be greater than zero535 if m.PushFunc != nil {536 return atomic.LoadUint64(&m.PushCounter) > 0537 }538 return true539}540//ValidateCallCounters checks that all mocked methods of the interface have been called at least once541//Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller542func (m *ClaimQueueMock) ValidateCallCounters() {543 if !m.ClearFinished() {544 m.t.Fatal("Expected call to ClaimQueueMock.Clear")545 }546 if !m.FrontFinished() {547 m.t.Fatal("Expected call to ClaimQueueMock.Front")548 }549 if !m.LengthFinished() {550 m.t.Fatal("Expected call to ClaimQueueMock.Length")551 }552 if !m.PopFinished() {553 m.t.Fatal("Expected call to ClaimQueueMock.Pop")554 }555 if !m.PushFinished() {556 m.t.Fatal("Expected call to ClaimQueueMock.Push")557 }558}559//CheckMocksCalled checks that all mocked methods of the interface have been called at least once560//Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller561func (m *ClaimQueueMock) CheckMocksCalled() {562 m.Finish()563}564//Finish checks that all mocked methods of the interface have been called at least once565//Deprecated: please use MinimockFinish or use Finish method of minimock.Controller566func (m *ClaimQueueMock) Finish() {567 m.MinimockFinish()568}569//MinimockFinish checks that all mocked methods of the interface have been called at least once570func (m *ClaimQueueMock) MinimockFinish() {571 if !m.ClearFinished() {572 m.t.Fatal("Expected call to ClaimQueueMock.Clear")573 }574 if !m.FrontFinished() {575 m.t.Fatal("Expected call to ClaimQueueMock.Front")576 }577 if !m.LengthFinished() {578 m.t.Fatal("Expected call to ClaimQueueMock.Length")579 }580 if !m.PopFinished() {581 m.t.Fatal("Expected call to ClaimQueueMock.Pop")582 }583 if !m.PushFinished() {584 m.t.Fatal("Expected call to ClaimQueueMock.Push")585 }586}587//Wait waits for all mocked methods to be called at least once588//Deprecated: please use MinimockWait or use Wait method of minimock.Controller589func (m *ClaimQueueMock) Wait(timeout time.Duration) {590 m.MinimockWait(timeout)591}592//MinimockWait waits for all mocked methods to be called at least once593//this method is called by minimock.Controller594func (m *ClaimQueueMock) MinimockWait(timeout time.Duration) {595 timeoutCh := time.After(timeout)596 for {597 ok := true598 ok = ok && m.ClearFinished()599 ok = ok && m.FrontFinished()600 ok = ok && m.LengthFinished()601 ok = ok && m.PopFinished()602 ok = ok && m.PushFinished()603 if ok {604 return605 }606 select {607 case <-timeoutCh:608 if !m.ClearFinished() {609 m.t.Error("Expected call to ClaimQueueMock.Clear")610 }611 if !m.FrontFinished() {612 m.t.Error("Expected call to ClaimQueueMock.Front")613 }614 if !m.LengthFinished() {615 m.t.Error("Expected call to ClaimQueueMock.Length")616 }617 if !m.PopFinished() {618 m.t.Error("Expected call to ClaimQueueMock.Pop")619 }620 if !m.PushFinished() {621 m.t.Error("Expected call to ClaimQueueMock.Push")622 }623 m.t.Fatalf("Some mocks were not called on time: %s", timeout)624 return625 default:626 time.Sleep(time.Millisecond)627 }628 }629}630//AllMocksCalled returns true if all mocked methods were called before the execution of AllMocksCalled,631//it can be used with assert/require, i.e. assert.True(mock.AllMocksCalled())632func (m *ClaimQueueMock) AllMocksCalled() bool {633 if !m.ClearFinished() {634 return false635 }636 if !m.FrontFinished() {637 return false638 }639 if !m.LengthFinished() {640 return false641 }642 if !m.PopFinished() {643 return false644 }645 if !m.PushFinished() {646 return false647 }648 return true649}...

Full Screen

Full Screen

lextable.go

Source:lextable.go Github

copy

Full Screen

1// Copyright (C) 2017, 2018, 2019 EGAAS S.A.2//3// This program is free software; you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation; either version 2 of the License, or (at6// your option) any later version.7//8// This program is distributed in the hope that it will be useful, but9// WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11// General Public License for more details.12//13// You should have received a copy of the GNU General Public License14// along with this program; if not, write to the Free Software15// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.16package main17import (18 "encoding/json"19 "fmt"20 "io/ioutil"21 "strings"22)23// The program creates packages/script/lex_table.go files.24// Action is a map of actions25type Action map[string][]string26// States is a map of states27type States map[string]Action28const (29 // AlphaSize is the length of alphabet30 AlphaSize = 3431)32/* Здесь мы определяем алфавит, с которым будет работать наш язык и описываем конечный автомат, который33 переходит из одного состояния в другое в зависимости от очередного полученного символа.34 Данная программа переводит список состояний в числовой массив и сохраняет его как35 packages/script/lex_table.go36*/37var (38 table [][AlphaSize]uint3239 lexem = map[string]uint32{``: 0, `sys`: 1, `oper`: 2, `number`: 3, `ident`: 4, `newline`: 5, `string`: 6,40 `comment`: 7}41 flags = map[string]uint32{`next`: 1, `push`: 2, `pop`: 4, `skip`: 8}42 alphabet = []byte{0x01, 0x0a, ' ', '`', '"', ';', '(', ')', '[', ']', '{', '}', '&',43 // default n s q Q44 '|', '#', '.', ',', '<', '>', '=', '!', '*', '$', '@', ':',45 '+', '-', '/', '\\', '0', '1', 'a', '_', 128}46 // r47 // В states мы обозначили за d - все символы, которые не указаны в состоянии48 // n - 0x0a, s - пробел, q - обратные кавычки `, Q - двойные кавычки, r - символы >= 12849 // a - A-Z и a-z, 1 - 1-950 // В качестве ключей выступаю имена состояний, a в объекте-значении перечислены возможные наборы символов51 // и затем для каждого такого набора идет новое состояние, куда следует сделать переход, далее имя лексемы,52 // если нам нужно вернуться в начальное состояние и третьим параметром идут служебные флаги,53 // которые указывают, что делать с текущим символом.54 // Например, у нас сотояние main и входящий символ /. push говорит запомнить его в отедльном стеке и55 // next - перейти к следующему символу, при этом мы меняе состояние на solidus.56 // Берем следующий символ и смотрим на состоние solidus57 // Если у нас / или * - то мы переходим в состояние комментарий, так они начинаются с // или /*.58 // При этом видно, что для каждого комментария разные последующие состояния, так как заканчиваются59 // они разными символами. А если у нас следующий символ не / и не *, то мы все что у нас положено60 // в стэк (/) записываем как лексему с типом oper, очищаем стэк и возвращаемся в состояние main.61 states = `{62 "main": {63 "n;": ["main", "newline", "next"],64 "()#[],{}:": ["main", "sys", "next"],65 "s": ["main", "", "next"],66 "q": ["string", "", "push next"],67 "Q": ["dstring", "", "push next"],68 "&": ["and", "", "push next"],69 "|": ["or", "", "push next"],70 "=": ["eq", "", "push next"],71 "/": ["solidus", "", "push next"],72 "<>!": ["oneq", "", "push next"],73 "*+-": ["main", "oper", "next"],74 "01": ["number", "", "push next"],75 "a_r": ["ident", "", "push next"],76 "@$": ["mustident", "", "push next"],77 ".": ["dot", "", "push next"],78 "d": ["error", "", ""]79 },80 "string": {81 "q": ["main", "string", "pop next"],82 "d": ["string", "", "next"]83 },84 "dstring": {85 "Q": ["main", "string", "pop next"],86 "\\": ["dslash", "", "skip"], 87 "d": ["dstring", "", "next"]88 },89 "dslash": {90 "d": ["dstring", "", "next"]91 }, 92 "dot": {93 ".": ["ddot", "", "next"],94 "01": ["number", "", "next"],95 "d": ["main", "sys", "pop"]96 },97 "ddot": {98 ".": ["main", "ident", "pop next"],99 "d": ["error", "", ""]100 },101 "and": {102 "&": ["main", "oper", "pop next"],103 "d": ["error", "", ""]104 },105 "or": {106 "|": ["main", "oper", "pop next"],107 "d": ["error", "", ""]108 },109 "eq": {110 "=": ["main", "oper", "pop next"],111 "d": ["main", "sys", "pop"]112 },113 "solidus": {114 "/": ["comline", "", "pop next"],115 "*": ["comment", "", "next"],116 "d": ["main", "oper", "pop"]117 },118 "oneq": {119 "=": ["main", "oper", "pop next"],120 "d": ["main", "oper", "pop"]121 },122 "number": {123 "01.": ["number", "", "next"],124 "a_r": ["error", "", ""],125 "d": ["main", "number", "pop"]126 },127 "ident": {128 "01a_r": ["ident", "", "next"],129 "d": ["main", "ident", "pop"]130 },131 "mustident": {132 "01a_r": ["ident", "", "next"],133 "d": ["error", "", ""]134 },135 "comment": {136 "*": ["comstop", "", "next"],137 "d": ["comment", "", "next"]138 },139 "comstop": {140 "/": ["main", "comment", "pop next"],141 "d": ["comment", "", "next"]142 },143 "comline": {144 "n": ["main", "", ""],145 "d": ["comline", "", "next"]146 }147}`148)149func main() {150 var alpha [129]byte151 for ind, ch := range alphabet {152 i := byte(ind)153 switch ch {154 case ' ':155 alpha[0x09] = i156 alpha[0x0d] = i157 alpha[' '] = i158 case '1':159 for k := '1'; k <= '9'; k++ {160 alpha[k] = i161 }162 case 'a':163 for k := 'A'; k <= 'Z'; k++ {164 alpha[k] = i165 }166 for k := 'a'; k <= 'z'; k++ {167 alpha[k] = i168 }169 case 128:170 alpha[128] = i171 default:172 alpha[ch] = i173 }174 }175 out := `package script176 // This file was generated with lextable.go177 178var (179 alphabet = []byte{`180 for i, ch := range alpha {181 out += fmt.Sprintf(`%d,`, ch)182 if i > 0 && i%24 == 0 {183 out += "\r\n\t\t\t"184 }185 }186 out += "\r\n\t\t}\r\n"187 var (188 data States189 )190 state2int := map[string]uint{`main`: 0}191 if err := json.Unmarshal([]byte(states), &data); err == nil {192 for key := range data {193 if key != `main` {194 state2int[key] = uint(len(state2int))195 }196 }197 table = make([][AlphaSize]uint32, len(state2int))198 for key, istate := range data {199 curstate := state2int[key]200 for i := range table[curstate] {201 table[curstate][i] = 0xFE0000202 }203 for skey, sval := range istate {204 var val uint32205 if sval[0] == `error` {206 val = 0xff0000207 } else {208 val = uint32(state2int[sval[0]] << 16) // new state209 }210 val |= uint32(lexem[sval[1]] << 8) // lexem211 cmds := strings.Split(sval[2], ` `)212 var flag uint32213 for _, icmd := range cmds {214 flag |= flags[icmd]215 }216 val |= flag217 for _, ch := range []byte(skey) {218 var ind int219 switch ch {220 case 'd':221 ind = 0222 case 'n':223 ind = 1224 case 's':225 ind = 2226 case 'q':227 ind = 3228 case 'Q':229 ind = 4230 case 'r':231 ind = AlphaSize - 1232 default:233 for k, ach := range alphabet {234 if ach == ch {235 ind = k236 break237 }238 }239 }240 table[curstate][ind] = val241 if ind == 0 { // default value242 for i := range table[curstate] {243 if table[curstate][i] == 0xFE0000 {244 table[curstate][i] = val245 }246 }247 }248 }249 }250 }251 out += "\t\tlexTable = [][" + fmt.Sprint(AlphaSize) + "]uint32{\r\n"252 for _, line := range table {253 out += "\t\t\t{"254 for _, ival := range line {255 out += fmt.Sprintf(" 0x%x,", ival)256 }257 out += "\r\n\t\t\t},\r\n"258 }259 out += "\t\t\t}\r\n)\r\n"260 err = ioutil.WriteFile("../lex_table.go", []byte(out), 0644)261 if err != nil {262 fmt.Println(err.Error())263 }264 } else {265 fmt.Println(err.Error())266 }267}...

Full Screen

Full Screen

myqueue.go

Source:myqueue.go Github

copy

Full Screen

...11 q.mainStack.Display()12 q.temporaryStack.Display()13}14func (q *Queue) Dequeue() (value *int) {15 for value := q.mainStack.Pop(); value != nil; value = q.mainStack.Pop() {16 q.temporaryStack.Push(*value)17 }18 dequeuedValue := q.temporaryStack.Pop()19 for value := q.temporaryStack.Pop(); value != nil; value = q.temporaryStack.Pop() {20 q.mainStack.Push(*value)21 }22 return dequeuedValue23}24func (q *Queue) Dequeue1() (value *int) {25 return q.mainStack.Pop()26}27func (q *Queue) Enqueue1(queuedValue int) {28 for value := q.mainStack.Pop(); value != nil; value = q.mainStack.Pop() {29 q.temporaryStack.Push(*value)30 }31 q.temporaryStack.Push(queuedValue)32 for value := q.temporaryStack.Pop(); value != nil; value = q.temporaryStack.Pop() {33 q.mainStack.Push(*value)34 }35}...

Full Screen

Full Screen

Pop

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 stack.Push(1)4 stack.Push(2)5 stack.Push(3)6 stack.Push(4)7 stack.Push(5)8 fmt.Println(stack.Pop())9 fmt.Println(stack.Pop())

Full Screen

Full Screen

Pop

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 stack.Push(1)4 stack.Push(2)5 stack.Push(3)6 stack.Push(4)7 stack.Push(5)8 fmt.Println(stack.Pop())9 fmt.Println(stack.Pop())10}11import "fmt"12type Stack struct {13}14func (s *Stack) Push(i int) {15 if s.top == 5 {16 }17}18func (s *Stack) Pop() int {19 if s.top == 0 {20 }21}22func main() {23 stack.Push(1)24 stack.Push(2)25 stack.Push(3)26 stack.Push(4)27 stack.Push(5)28 fmt.Println(stack.Pop())29 fmt.Println(stack.Pop())30}31import "fmt"32type Stack struct {33}34func (s *Stack) Push(i int) {35 s.items = append(s.items, i)36}37func (s *Stack) Pop() int {38 toRemove := s.items[len(s.items)-1]39 s.items = s.items[:len(s.items)-1]40}41func main() {42 stack.Push(1)43 stack.Push(2)44 stack.Push(3)45 stack.Push(4)46 stack.Push(5)47 fmt.Println(stack.Pop())48 fmt.Println(stack.Pop())49}50import "fmt"51type Node struct {52}53type Stack struct {54}55func (s *Stack) Push(i int

Full Screen

Full Screen

Pop

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 s.Push(1)4 s.Push(2)5 s.Push(3)6 s.Push(4)7 s.Push(5)8 fmt.Println(s.Pop())9 fmt.Println(s.Pop())10 fmt.Println(s.Pop())11 fmt.Println(s.Pop())12 fmt.Println(s.Pop())13 fmt.Println(s.Pop())14}15import (16func main() {17 s.Push(1)18 s.Push(2)19 s.Push(3)20 s.Push(4)21 s.Push(5)22 fmt.Println(s.Peek())23 fmt.Println(s.Peek())24 fmt.Println(s.Peek())25 fmt.Println(s.Peek())26 fmt.Println(s.Peek())27 fmt.Println(s.Peek())28}29import (30func main() {31 fmt.Println(s.IsEmpty())32 s.Push(1)33 fmt.Println(s.IsEmpty())34 s.Push(2)35 fmt.Println(s.IsEmpty())36 s.Push(3)37 fmt.Println(s.IsEmpty())38 s.Push(4)39 fmt.Println(s.IsEmpty())40 s.Push(5)41 fmt.Println(s.IsEmpty())42}43import (44func main() {45 fmt.Println(s.IsFull())46 s.Push(1)47 fmt.Println(s.IsFull())48 s.Push(2)49 fmt.Println(s.IsFull())50 s.Push(3)51 fmt.Println(s.IsFull())52 s.Push(4)53 fmt.Println(s.IsFull())54 s.Push(5)55 fmt.Println(s.IsFull())56}57import (58func main() {59 fmt.Println(s.Size())60 s.Push(1)61 fmt.Println(s.Size())62 s.Push(2)63 fmt.Println(s.Size())64 s.Push(3)65 fmt.Println(s.Size())66 s.Push(4)67 fmt.Println(s.Size())68 s.Push(5)69 fmt.Println(s.Size())70}71import (72func main() {73 s.Push(1)74 s.Push(2)75 s.Push(3)76 s.Push(4)77 s.Push(

Full Screen

Full Screen

Pop

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 s := stack.NewStack()4 s.Push(10)5 s.Push(20)6 s.Push(30)7 s.Push(40)8 s.Push(50)9 fmt.Println(s.Pop())10 fmt.Println(s.Pop())11 fmt.Println(s.Pop())12 fmt.Println(s.Pop())13 fmt.Println(s.Pop())14 fmt.Println(s.Pop())15}

Full Screen

Full Screen

Pop

Using AI Code Generation

copy

Full Screen

1func main() {2 s.Push(1)3 s.Push(2)4 s.Push(3)5 fmt.Println(s.Pop())6 fmt.Println(s.Pop())7 fmt.Println(s.Pop())8}9func main() {10 s.Push(1)11 s.Push(2)12 s.Push(3)13 fmt.Println(s.Pop())14 fmt.Println(s.Pop())15 fmt.Println(s.Pop())16}17func main() {18 s.Push(1)19 s.Push(2)20 s.Push(3)21 fmt.Println(s.Pop())22 fmt.Println(s.Pop())23 fmt.Println(s.Pop())24}25func main() {26 s.Push(1)27 s.Push(2)28 s.Push(3)29 fmt.Println(s.Pop())30 fmt.Println(s.Pop())31 fmt.Println(s.Pop())32}33func main() {34 s.Push(1)35 s.Push(2)36 s.Push(3)37 fmt.Println(s.Pop())38 fmt.Println(s.Pop())39 fmt.Println(s.Pop())40}41func main() {42 s.Push(1)43 s.Push(2)44 s.Push(3)45 fmt.Println(s.Pop())46 fmt.Println(s.Pop())47 fmt.Println(s.Pop())48}49func main() {50 s.Push(1)51 s.Push(2)52 s.Push(3)

Full Screen

Full Screen

Pop

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, playground")4 s.Push(10)5 s.Push(20)6 s.Push(30)7 s.Push(40)8 s.Push(50)9 fmt.Println(s.Pop())10 fmt.Println(s.Pop())11 fmt.Println(s.Pop())12 fmt.Println(s.Pop())13 fmt.Println(s.Pop())14 fmt.Println(s.Pop())15}

Full Screen

Full Screen

Pop

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 s := stack.New()4 s.Push(1)5 s.Push(2)6 s.Push(3)7 s.Push(4)8 s.Push(5)9 s.Push(6)10 s.Push(7)11 s.Push(8)12 s.Push(9)13 s.Push(10)14 fmt.Println(s.Pop())15 fmt.Println(s.Pop())16 fmt.Println(s.Pop())

Full Screen

Full Screen

Pop

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Pop method")4 fmt.Println(Pop())5}6import (7func main() {8 fmt.Println("Push method")9 fmt.Println(Push(10))10}11import (12func main() {13 fmt.Println("Peek method")14 fmt.Println(Peek())15}16import (17func main() {18 fmt.Println("IsEmpty method")19 fmt.Println(IsEmpty())20}21import (22func main() {23 fmt.Println("IsFull method")24 fmt.Println(IsFull())25}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful