Debian Codegraph @

pkg/internal/third_party/go-json-experiment/json/inline_test.go

raw symbols SCIP
1 // Copyright 2020 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 package jsonscip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json`/
6
7 import (
8 "osscip-go gomod github.com/golang/go/src go1.21 os/"
9 "os/execscip-go gomod github.com/golang/go/src go1.21 `os/exec`/"
10 "stringsscip-go gomod github.com/golang/go/src go1.21 strings/"
11 "testingscip-go gomod github.com/golang/go/src go1.21 testing/"
12 )
13
14 // Whether a function is inlineable is dependent on the Go compiler version
15 // and also relies on the presence of the Go toolchain itself being installed.
16 // This test is disabled by default and explicitly enabled with an
17 // environment variable that is specified in our integration tests,
18 // which have fine control over exactly which Go version is being tested.
19 var testInlinescip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json`/testInline. = osscip-go gomod github.com/golang/go/src go1.21 os/.Getenvscip-go gomod github.com/golang/go/src go1.21 os/Getenv().("TEST_INLINE") != ""
20
21 func TestInlinescip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json`/TestInline().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
22 if !testInlinescip-go gomod k8s.io/kube-openapi . `k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json`/testInline. {
23 t.SkipNowscip-go gomod github.com/golang/go/src go1.21 testing/common#SkipNow().()
24 }
25
26 fncs := func() map[string]bool {
27 m := make(map[string]bool)
28 for _, s := range []string{
29 "Encoder.needFlush",
30 "Decoder.ReadValue", // thin wrapper over Decoder.readValue
31 "decodeBuffer.needMore",
32 "consumeWhitespace",
33 "consumeNull",
34 "consumeFalse",
35 "consumeTrue",
36 "consumeSimpleString",
37 "consumeString", // thin wrapper over consumeStringResumable
38 "consumeSimpleNumber",
39 "consumeNumber", // thin wrapper over consumeNumberResumable
40 "unescapeStringMayCopy", // thin wrapper over unescapeString
41 "hasSuffixByte",
42 "trimSuffixByte",
43 "trimSuffixString",
44 "trimSuffixWhitespace",
45 "stateMachine.appendLiteral",
46 "stateMachine.appendNumber",
47 "stateMachine.appendString",
48 "stateMachine.depth",
49 "stateMachine.reset",
50 "stateMachine.mayAppendDelim",
51 "stateMachine.needDelim",
52 "stateMachine.popArray",
53 "stateMachine.popObject",
54 "stateMachine.pushArray",
55 "stateMachine.pushObject",
56 "stateEntry.increment",
57 "stateEntry.decrement",
58 "stateEntry.isArray",
59 "stateEntry.isObject",
60 "stateEntry.length",
61 "stateEntry.needImplicitColon",
62 "stateEntry.needImplicitComma",
63 "stateEntry.needObjectName",
64 "stateEntry.needObjectValue",
65 "objectNameStack.reset",
66 "objectNameStack.length",
67 "objectNameStack.getUnquoted",
68 "objectNameStack.push",
69 "objectNameStack.replaceLastQuotedOffset",
70 "objectNameStack.replaceLastUnquotedName",
71 "objectNameStack.pop",
72 "objectNameStack.ensureCopiedBuffer",
73 "objectNamespace.insertQuoted", // thin wrapper over objectNamespace.insert
74 "objectNamespace.insertUnquoted", // thin wrapper over objectNamespace.insert
75 "Token.String", // thin wrapper over Token.string
76 "foldName", // thin wrapper over appendFoldedName
77 "hash64",
78 } {
79 m[s] = true
80 }
81 return m
82 }()
83
84 cmd := execscip-go gomod github.com/golang/go/src go1.21 `os/exec`/.Commandscip-go gomod github.com/golang/go/src go1.21 `os/exec`/Command().("go", "build", "-gcflags=-m")
85 b, err := cmd.CombinedOutputscip-go gomod github.com/golang/go/src go1.21 `os/exec`/Cmd#CombinedOutput().()
86 if err != nil {
87 t.Fatalfscip-go gomod github.com/golang/go/src go1.21 testing/common#Fatalf().("exec.Command error: %v\n\n%s", err, b)
88 }
89 for _, line := range stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Splitscip-go gomod github.com/golang/go/src go1.21 strings/Split().(string(b), "\n") {
90 const phrase = ": can inline "
91 if i := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Indexscip-go gomod github.com/golang/go/src go1.21 strings/Index().(line, phrase); i >= 0 {
92 fnc := line[i+len(phrase):]
93 fnc = stringsscip-go gomod github.com/golang/go/src go1.21 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.21 strings/ReplaceAll().(fnc, "(", "")
94 fnc = stringsscip-go gomod github.com/golang/go/src go1.21 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.21 strings/ReplaceAll().(fnc, "*", "")
95 fnc = stringsscip-go gomod github.com/golang/go/src go1.21 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.21 strings/ReplaceAll().(fnc, ")", "")
96 delete(fncs, fnc)
97 }
98 }
99 for fnc := range fncs {
100 t.Errorfscip-go gomod github.com/golang/go/src go1.21 testing/common#Errorf().("%v is not inlineable, expected it to be", fnc)
101 }
102 }