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

Function TestAddVars

ast/ast_test.go:501–535  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

499}
500
501func TestAddVars(t *testing.T) {
502 tests := []struct {
503 term Term
504 want []string
505 }{
506 {
507 term: Variable{"X"},
508 want: []string{"X"},
509 },
510 {
511 term: Variable{"_"},
512 want: []string{"_"},
513 },
514 {
515 term: NewAtom("foo", Variable{"X"}),
516 want: []string{"X"},
517 },
518 {
519 term: Eq{Variable{"Y"}, ApplyFn{FunctionSym{"fn:foo", 1}, []BaseTerm{Variable{"X"}}}},
520 want: []string{"X", "Y"},
521 },
522 }
523 for _, test := range tests {
524 vars := make(map[Variable]bool)
525 AddVars(test.term, vars)
526 if len(vars) != len(test.want) {
527 t.Errorf("AddVars(%v, {})=%v want %v", test.term, vars, test.want)
528 }
529 for _, v := range test.want {
530 if !vars[Variable{v}] {
531 t.Errorf("AddVars(%v, {})=%v does not contain %v", test.term, vars, v)
532 }
533 }
534 }
535}
536
537func TestReplaceWildcards(t *testing.T) {
538 tests := []struct {

Callers

nothing calls this directly

Calls 2

NewAtomFunction · 0.85
AddVarsFunction · 0.85

Tested by

no test coverage detected