MCPcopy
hub / github.com/google/go-jsonnet / TestSimpleLocal

Function TestSimpleLocal

internal/program/static_analyzer_test.go:48–71  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestSimpleLocal(t *testing.T) {
49 node := &ast.Local{
50 Binds: ast.LocalBinds{
51 ast.LocalBind{
52 Variable: "x",
53 Body: &ast.LiteralNull{},
54 },
55 },
56 Body: &ast.Var{Id: "x"},
57 }
58
59 err := analyze(node)
60 if err != nil {
61 t.Errorf("Unexpected error: %+v", err)
62 }
63 if len(node.FreeVariables()) != 0 {
64 t.Errorf("Unexpected free variables %+v in root local. Expected none.", node.FreeVariables())
65 }
66 returned := node.Body.FreeVariables()
67 expectedVars := ast.Identifiers{"x"}
68 if !hasTheseFreeVars(returned, expectedVars) {
69 t.Errorf("Unexpected free variables %+v in local body. Expected %+v.", returned, expectedVars)
70 }
71}

Callers

nothing calls this directly

Calls 3

analyzeFunction · 0.85
hasTheseFreeVarsFunction · 0.85
FreeVariablesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…