chore: import upstream snapshot with attribution
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package graph
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRefContextOf(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
kind EdgeKind
|
||||
from NodeKind
|
||||
meta map[string]any
|
||||
want string
|
||||
}{
|
||||
{"return", EdgeReturns, KindFunction, nil, RefContextReturnType},
|
||||
{"param", EdgeTypedAs, KindParam, nil, RefContextParameterType},
|
||||
{"field", EdgeTypedAs, KindField, nil, RefContextField},
|
||||
{"value_var", EdgeTypedAs, KindVariable, nil, RefContextValue},
|
||||
{"value_local", EdgeTypedAs, KindLocal, nil, RefContextValue},
|
||||
{"typed_other", EdgeTypedAs, KindType, nil, RefContextType},
|
||||
{"attribute", EdgeAnnotated, KindFunction, nil, RefContextAttribute},
|
||||
{"type_ref", EdgeReferences, KindFunction, nil, RefContextType},
|
||||
{"implements", EdgeImplements, KindType, nil, RefContextType},
|
||||
{"read", EdgeReads, KindFunction, nil, RefContextValue},
|
||||
{"call", EdgeCalls, KindFunction, nil, RefContextCall},
|
||||
{"instantiate", EdgeInstantiates, KindFunction, nil, RefContextCall},
|
||||
{"meta_override", EdgeReferences, KindFunction, map[string]any{"ref_context": RefContextGenericArg}, RefContextGenericArg},
|
||||
{"import", EdgeImports, KindFile, nil, RefContextImport},
|
||||
{"re_export", EdgeReExports, KindFile, nil, RefContextImport},
|
||||
{"no_context", EdgeContains, KindFile, nil, ""},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
e := &Edge{Kind: c.kind, Meta: c.meta}
|
||||
if got := RefContextOf(e, c.from); got != c.want {
|
||||
t.Errorf("RefContextOf(%s, from=%s) = %q, want %q", c.kind, c.from, got, c.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
if RefContextOf(nil, KindFunction) != "" {
|
||||
t.Error("nil edge must classify as empty context")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user