(t *testing.T)
| 506 | } |
| 507 | |
| 508 | func TestTypeCheck(t *testing.T) { |
| 509 | fooDecl, err := ast.NewDecl( |
| 510 | ast.NewAtom("foo", ast.Variable{"SomeNum"}, ast.Variable{"SomeStr"}, ast.Variable{"SomeName"}), |
| 511 | nil, |
| 512 | []ast.BoundDecl{ |
| 513 | ast.NewBoundDecl(ast.NumberBound, symbols.NewStructType(name("/bar"), symbols.NewListType(ast.StringBound)), ast.NameBound)}, nil) |
| 514 | if err != nil { |
| 515 | t.Fatal(err) |
| 516 | } |
| 517 | decls := map[ast.PredicateSym]ast.Decl{ |
| 518 | ast.PredicateSym{"foo", 3}: fooDecl, |
| 519 | } |
| 520 | checker, err := NewTypeChecker(decls) |
| 521 | if err != nil { |
| 522 | t.Fatalf("bad test setup, cannot construct type checker: %v", err) |
| 523 | } |
| 524 | okFact := evAtom("foo(12, {/bar: ['aaa']}, /bar)") |
| 525 | if err := checker.CheckTypeBounds(okFact); err != nil { |
| 526 | t.Errorf("CheckTypeBounds(%v) failed %v", okFact, err) |
| 527 | } |
| 528 | badFact := evAtom("foo('aaa', {/bar: ['b12']}, /bar)") |
| 529 | if err := checker.CheckTypeBounds(badFact); err == nil { // if NO error |
| 530 | t.Errorf("CheckTypeBounds(%v) succeeded expected error", badFact) |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | func TestCheckTypeExpressionStructured(t *testing.T) { |
| 535 | tests := []struct { |
nothing calls this directly
no test coverage detected