MCPcopy
hub / github.com/google/mangle / TestCollectNames

Function TestCollectNames

analysis/validation_test.go:875–904  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

873}
874
875func TestCollectNames(t *testing.T) {
876 extraPredicates := map[ast.PredicateSym]ast.Decl{
877 ast.PredicateSym{"z", 1}: makeSimpleDecl(atom("z(X)"), name("/foo/bar")),
878 }
879 tests := []struct {
880 decls map[ast.PredicateSym]*ast.Decl
881 want symbols.NameTrie
882 }{
883 {
884 decls: makeDesugaredDecls(t,
885 makeSimpleDecl(atom("a(X)"), name("/foo")),
886 makeSimpleDecl(atom("b(X)"), name("/foo")),
887 makeSimpleDecl(atom("c(X)"), name("/foo/bar")),
888 ),
889 want: symbols.NewNameTrie().Add([]string{"foo"}).Add([]string{"foo", "bar"}),
890 },
891 {
892 decls: makeDesugaredDecls(t,
893 makeSimpleDecl(atom("b(X)"), name("/foo/baz")),
894 ),
895 want: symbols.NewNameTrie().Add([]string{"foo", "bar"}).Add([]string{"foo", "baz"}),
896 },
897 }
898 for _, test := range tests {
899 got := collectNames(extraPredicates, test.decls)
900 if !cmp.Equal(got, test.want, cmp.AllowUnexported(symbols.NameTrieNode{})) {
901 t.Errorf("collectNames(%v) = %v, want %v", test.decls, got, test.want)
902 }
903 }
904}
905
906func TestDeferred(t *testing.T) {
907 clauses := []ast.Clause{

Callers

nothing calls this directly

Calls 7

NewNameTrieFunction · 0.92
makeSimpleDeclFunction · 0.85
makeDesugaredDeclsFunction · 0.85
collectNamesFunction · 0.85
atomFunction · 0.70
nameFunction · 0.70
AddMethod · 0.65

Tested by

no test coverage detected