| | |
| | |
| | |
| |
|
| | |
| |
|
| | package json |
| |
|
| | import ( |
| | "os" |
| | "os/exec" |
| | "strings" |
| | "testing" |
| | ) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | var testInline = os.Getenv("TEST_INLINE") != "" |
| |
|
| | func TestInline(t *testing.T) { |
| | if !testInline { |
| | t.SkipNow() |
| | } |
| |
|
| | pkgs := map[string]map[string]bool{ |
| | ".": { |
| | "hash64": true, |
| | "foldName": true, |
| | }, |
| | "./internal/jsonwire": { |
| | "ConsumeWhitespace": true, |
| | "ConsumeNull": true, |
| | "ConsumeFalse": true, |
| | "ConsumeTrue": true, |
| | "ConsumeSimpleString": true, |
| | "ConsumeString": true, |
| | "ConsumeSimpleNumber": true, |
| | "ConsumeNumber": true, |
| | "UnquoteMayCopy": true, |
| | "HasSuffixByte": true, |
| | "TrimSuffixByte": true, |
| | "TrimSuffixString": true, |
| | "TrimSuffixWhitespace": true, |
| | }, |
| | "./jsontext": { |
| | "encoderState.NeedFlush": true, |
| | "Decoder.ReadToken": true, |
| | "Decoder.ReadValue": true, |
| | "Encoder.WriteToken": true, |
| | "Encoder.WriteValue": true, |
| | "decodeBuffer.needMore": true, |
| | "stateMachine.appendLiteral": true, |
| | "stateMachine.appendNumber": true, |
| | "stateMachine.appendString": true, |
| | "stateMachine.Depth": true, |
| | "stateMachine.reset": true, |
| | "stateMachine.MayAppendDelim": true, |
| | "stateMachine.needDelim": true, |
| | "stateMachine.popArray": true, |
| | "stateMachine.popObject": true, |
| | "stateMachine.pushArray": true, |
| | "stateMachine.pushObject": true, |
| | "stateEntry.Increment": true, |
| | "stateEntry.decrement": true, |
| | "stateEntry.isArray": true, |
| | "stateEntry.isObject": true, |
| | "stateEntry.Length": true, |
| | "stateEntry.needImplicitColon": true, |
| | "stateEntry.needImplicitComma": true, |
| | "stateEntry.NeedObjectName": true, |
| | "stateEntry.needObjectValue": true, |
| | "objectNameStack.reset": true, |
| | "objectNameStack.length": true, |
| | "objectNameStack.getUnquoted": true, |
| | "objectNameStack.push": true, |
| | "objectNameStack.ReplaceLastQuotedOffset": true, |
| | "objectNameStack.replaceLastUnquotedName": true, |
| | "objectNameStack.pop": true, |
| | "objectNameStack.ensureCopiedBuffer": true, |
| | "objectNamespace.insertQuoted": true, |
| | "objectNamespace.InsertUnquoted": true, |
| | "Token.String": true, |
| | }, |
| | } |
| |
|
| | for pkg, fncs := range pkgs { |
| | cmd := exec.Command("go", "build", "-gcflags=-m", pkg) |
| | b, err := cmd.CombinedOutput() |
| | if err != nil { |
| | t.Fatalf("exec.Command error: %v\n\n%s", err, b) |
| | } |
| | for _, line := range strings.Split(string(b), "\n") { |
| | const phrase = ": can inline " |
| | if i := strings.Index(line, phrase); i >= 0 { |
| | fnc := line[i+len(phrase):] |
| | fnc = strings.ReplaceAll(fnc, "(", "") |
| | fnc = strings.ReplaceAll(fnc, "*", "") |
| | fnc = strings.ReplaceAll(fnc, ")", "") |
| | delete(fncs, fnc) |
| | } |
| | } |
| | for fnc := range fncs { |
| | t.Errorf("%v is not inlinable, expected it to be", fnc) |
| | } |
| | } |
| | } |
| |
|