MCPcopy Index your code
hub / github.com/google/mtail / TestCodeGenFromSource

Function TestCodeGenFromSource

internal/runtime/compiler/codegen/codegen_test.go:1048–1067  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1046}
1047
1048func TestCodeGenFromSource(t *testing.T) {
1049 for _, tc := range testCodeGenPrograms {
1050 tc := tc
1051 t.Run(tc.name, func(t *testing.T) {
1052 ast, err := parser.Parse(tc.name, strings.NewReader(tc.source))
1053 testutil.FatalIfErr(t, err)
1054 ast, err = checker.Check(ast, 0, 0)
1055 if *codegenTestDebug {
1056 s := parser.Sexp{}
1057 s.EmitTypes = true
1058 t.Log("Typed AST:\n" + s.Dump(ast))
1059 }
1060 testutil.FatalIfErr(t, err)
1061 obj, err := codegen.CodeGen(tc.name, ast)
1062 testutil.FatalIfErr(t, err)
1063
1064 testutil.ExpectNoDiff(t, tc.prog, obj.Program, testutil.AllowUnexported(code.Instr{}))
1065 })
1066 }
1067}
1068
1069var testCodeGenASTs = []struct {
1070 name string

Callers

nothing calls this directly

Calls 8

DumpMethod · 0.95
ParseFunction · 0.92
FatalIfErrFunction · 0.92
CheckFunction · 0.92
CodeGenFunction · 0.92
ExpectNoDiffFunction · 0.92
AllowUnexportedFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected