GoPLS Viewer

Home|gopls/godoc/godoc17_test.go
1// Copyright 2017 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5//go:build go1.7
6// +build go1.7
7
8package godoc
9
10import (
11    "bytes"
12    "fmt"
13    "testing"
14)
15
16// Verify that scanIdentifier isn't quadratic.
17// This doesn't actually measure and fail on its own, but it was previously
18// very obvious when running by hand.
19//
20// TODO: if there's a reliable and non-flaky way to test this, do so.
21// Maybe count user CPU time instead of wall time? But that's not easy
22// to do portably in Go.
23func TestStructField(t *testing.T) {
24    for _n := range []int{10100100010000} {
25        n := n
26        t.Run(fmt.Sprint(n), func(t *testing.T) {
27            var buf bytes.Buffer
28            fmt.Fprintf(&buf"package foo\n\ntype T struct {\n")
29            for i := 0i < ni++ {
30                fmt.Fprintf(&buf"\t// Field%d is foo.\n\tField%d int\n\n"ii)
31            }
32            fmt.Fprintf(&buf"}\n")
33            linkifySource(tbuf.Bytes())
34        })
35    }
36}
37
MembersX
TestStructField.RangeStmt_617.BlockStmt.BlockStmt.i
TestStructField
TestStructField.t
TestStructField.RangeStmt_617.n
TestStructField.RangeStmt_617.BlockStmt.n
TestStructField.RangeStmt_617.BlockStmt.BlockStmt.buf
Members
X