// expect consumes the next token and guarantees it has the required type.
336938
func (t *tree) expect(expected itemType, context string) item {
	token := t.next()
	if token.typ != expected {
		t.unexpected(token, fmt.Sprintf("%v (expected %v)", context, expected.String()))
	}
	return token
}
617777
func (p *Parser) expect(llk *LLk, st *semantic.Statement, s semantic.Symbol, cls *Clause) (bool, error) {
	if cls.ProcessStart != nil {
		if _, err := cls.ProcessStart(st, s); err != nil {
			return false, err
		}
	}
	for _, elem := range cls.Elements {
		tkn := llk.Current()
		if elem.isSymbol {
			if b, err := p.consume(llk, st, elem.Symbol()); !b || err != nil {
				return false, fmt.Errorf("Parser.parse: Failed to consume symbol %v, with error %v", elem.Symbol(), err)
			}
		} else {
			if !llk.Consume(elem.Token()) {
				return false, fmt.Errorf("Parser.parse: Failed to consume %s, got %s instead", elem.Token(), llk.Current().Type)
			}
		}
		if cls.ProcessedElement != nil {
			var ce semantic.ConsumedElement
			if elem.isSymbol {
				ce = semantic.NewConsumedSymbol(elem.Symbol())
			} else {
				ce = semantic.NewConsumedToken(tkn)
			}
			if _, err := cls.ProcessedElement(st, ce); err != nil {
				return false, err
			}
		}
	}
	if cls.ProcessEnd != nil {
		if _, err := cls.ProcessEnd(st, s); err != nil {
			return false, err
		}
	}
	return true, nil
}
1308892
func peek(parser *Parser, Kind lexer.TokenKind) bool {
	return parser.Token.Kind == Kind
}
209394
func (r *Lexer) consume() {
	r.token.kind = tokenUndef
	r.token.delimValue = 0
}
1121559
func expectThat(
	x interface{},
	m oglematchers.Matcher,
	depth int,
	errorParts []interface{}) (passed bool) {
	// Check whether the value matches. If it does, we are finished.
	matcherErr := m.Matches(x)
	if matcherErr == nil {
		passed = true
		return
	}

	var r FailureRecord

	// Get information about the call site.
	var ok bool
	if _, r.FileName, r.LineNumber, ok = runtime.Caller(depth + 1); !ok {
		panic("expectThat: runtime.Caller")
	}

	r.FileName = path.Base(r.FileName)

	// Create an appropriate failure message. Make sure that the expected and
	// actual values align properly.
	relativeClause := ""
	if matcherErr.Error() != "" {
		relativeClause = fmt.Sprintf(", %s", matcherErr.Error())
	}

	r.Error = fmt.Sprintf(
		"Expected: %s\nActual:   %v%s",
		m.Description(),
		x,
		relativeClause)

	// Add the user error, if any.
	if len(errorParts) != 0 {
		v := reflect.ValueOf(errorParts[0])
		if v.Kind() != reflect.String {
			panic(fmt.Sprintf("ExpectThat: invalid format string type %v", v.Kind()))
		}

		r.Error = fmt.Sprintf(
			"%s\n%s",
			r.Error,
			fmt.Sprintf(v.String(), errorParts[1:]...))
	}

	// Report the failure.
	AddFailureRecord(r)

	return
}
327276
func (err BadParameterError) Expected(expexcted interface{}) BadParameterError {
	err.expectedValue = expexcted
	err.hasExpectedValue = true
	return err
}
152805
func (e *Expect) OPTIONS(path string, pathargs ...interface{}) *Request {
	return e.Request("OPTIONS", path, pathargs...)
}
25878
func Promise(f func() error) chan error {
	ch := make(chan error, 1)
	go func() {
		ch <- f()
	}()
	return ch
}
272211
func (this *import_data_parser) expect_special(special string) {
	i := 0
	for i < len(special) {
		if this.toktype != rune(special[i]) {
			break
		}

		this.next()
		i++
	}

	if i < len(special) {
		this.errorf("expected: \"%s\", got something else", special)
	}
}
1311100
func (r *Lexer) Skip() {
	if r.token.kind == tokenUndef && r.Ok() {
		r.FetchToken()
	}
	r.consume()
}
81860
func (l *Lexer) Next() (TokenType, []byte) {
	l.text = nil
	var c byte
	if l.inTag {
		l.attrVal = nil
		for { // before attribute name state
			if c = l.r.Peek(0); c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' {
				l.r.Move(1)
				continue
			}
			break
		}
		if c == 0 && l.r.Err() != nil {
			return ErrorToken, nil
		} else if c != '>' && (c != '/' || l.r.Peek(1) != '>') {
			return AttributeToken, l.shiftAttribute()
		}
		start := l.r.Pos()
		l.inTag = false
		if c == '/' {
			l.r.Move(2)
			l.text = l.r.Lexeme()[start:]
			return StartTagVoidToken, l.r.Shift()
		}
		l.r.Move(1)
		l.text = l.r.Lexeme()[start:]
		return StartTagCloseToken, l.r.Shift()
	}

	if l.rawTag != 0 {
		if rawText := l.shiftRawText(); len(rawText) > 0 {
			l.rawTag = 0
			return TextToken, rawText
		}
		l.rawTag = 0
	}

	for {
		c = l.r.Peek(0)
		if c == '<' {
			c = l.r.Peek(1)
			isEndTag := c == '/' && l.r.Peek(2) != '>' && (l.r.Peek(2) != 0 || l.r.PeekErr(2) == nil)
			if l.r.Pos() > 0 {
				if isEndTag || 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '!' || c == '?' {
					// return currently buffered texttoken so that we can return tag next iteration
					return TextToken, l.r.Shift()
				}
			} else if isEndTag {
				l.r.Move(2)
				// only endtags that are not followed by > or EOF arrive here
				if c = l.r.Peek(0); !('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') {
					return CommentToken, l.shiftBogusComment()
				}
				return EndTagToken, l.shiftEndTag()
			} else if 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' {
				l.r.Move(1)
				l.inTag = true
				return l.shiftStartTag()
			} else if c == '!' {
				l.r.Move(2)
				return l.readMarkup()
			} else if c == '?' {
				l.r.Move(1)
				return CommentToken, l.shiftBogusComment()
			}
		} else if c == 0 && l.r.Err() != nil {
			if l.r.Pos() > 0 {
				return TextToken, l.r.Shift()
			}
			return ErrorToken, nil
		}
		l.r.Move(1)
	}
}
504823
func (l *LLk) Consume(tt lexer.TokenType) bool {
	if l.tkns[0].Type != tt {
		return false
	}
	l.tkns = l.tkns[1:]
	appendNextToken(l)
	return true
}
551813
func (dc *MockDBClient) ExpectRequestRE(queryRE string, result *sqltypes.Result, err error) {
	select {
	case <-dc.done:
		dc.done = make(chan struct{})
	default:
	}
	dc.expect = append(dc.expect, &mockExpect{
		query:  queryRE,
		re:     regexp.MustCompile(queryRE),
		result: result,
		err:    err,
	})
}
1307692
func (c *Websocket) Expect() *WebsocketMessage {
	switch {
	case c.chain.failed():
		return makeWebsocketMessage(c.chain)
	case c.conn == nil:
		c.chain.fail("\nunexpected read from failed WebSocket connection")
		return makeWebsocketMessage(c.chain)
	case c.isClosed:
		c.chain.fail("\nunexpected read from closed WebSocket connection")
		return makeWebsocketMessage(c.chain)
	case !c.setReadDeadline():
		return makeWebsocketMessage(c.chain)
	}
	var err error
	m := makeWebsocketMessage(c.chain)
	m.typ, m.content, err = c.conn.ReadMessage()
	if err != nil {
		if cls, ok := err.(*websocket.CloseError); ok {
			m.typ = websocket.CloseMessage
			m.closeCode = cls.Code
			m.content = []byte(cls.Text)
			c.printRead(m.typ, m.content, m.closeCode)
		} else {
			c.chain.fail(
				"\nexpected read WebSocket connection, "+
					"but got failure: %s", err.Error())
			return makeWebsocketMessage(c.chain)
		}
	} else {
		c.printRead(m.typ, m.content, m.closeCode)
	}
	return m
}
1219881
func (s *Service) execThenExpect(commandArgs []string, expectation string) error {
	out, err := s.runCommand(commandArgs...)
	if err != nil {
		return errors.Trace(err)
	}
	if !strings.Contains(out, expectation) {
		return errors.Annotatef(err, `expected "%s", got "%s"`, expectation, out)
	}
	return nil
}
539096
func (e *Expect) Object(value map[string]interface{}) *Object {
	return NewObject(e.config.Reporter, value)
}
18215
func (e *Expect) PUT(path string, pathargs ...interface{}) *Request {
	return e.Request("PUT", path, pathargs...)
}