MCPcopy
hub / github.com/hashicorp/hcl / TestPeeker

Function TestPeeker

hclsyntax/peeker_test.go:16–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14}
15
16func TestPeeker(t *testing.T) {
17 tokens := Tokens{
18 {
19 Type: TokenIdent,
20 },
21 {
22 Type: TokenComment,
23 },
24 {
25 Type: TokenIdent,
26 },
27 {
28 Type: TokenComment,
29 },
30 {
31 Type: TokenIdent,
32 },
33 {
34 Type: TokenNewline,
35 },
36 {
37 Type: TokenIdent,
38 },
39 {
40 Type: TokenNewline,
41 },
42 {
43 Type: TokenIdent,
44 },
45 {
46 Type: TokenNewline,
47 },
48 {
49 Type: TokenEOF,
50 },
51 }
52
53 {
54 peeker := newPeeker(tokens, true)
55
56 wantTypes := []TokenType{
57 TokenIdent,
58 TokenComment,
59 TokenIdent,
60 TokenComment,
61 TokenIdent,
62 TokenNewline,
63 TokenIdent,
64 TokenNewline,
65 TokenIdent,
66 TokenNewline,
67 TokenEOF,
68 }
69 var gotTypes []TokenType
70
71 for {
72 peeked := peeker.Peek()
73 read := peeker.Read()

Callers

nothing calls this directly

Calls 5

PushIncludeNewlinesMethod · 0.80
PopIncludeNewlinesMethod · 0.80
newPeekerFunction · 0.70
PeekMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected