(t *testing.T)
| 51 | ) |
| 52 | |
| 53 | func TestUnification1(t *testing.T) { |
| 54 | type test struct { // an individual test |
| 55 | name string |
| 56 | ast interfaces.Stmt // raw AST |
| 57 | fail bool |
| 58 | expect map[interfaces.Expr]*types.Type |
| 59 | experr error // expected error if fail == true (nil ignores it) |
| 60 | experrstr string // expected error prefix |
| 61 | } |
| 62 | testCases := []test{} |
| 63 | |
| 64 | // this causes a panic, so it can't be used |
| 65 | //{ |
| 66 | // testCases = append(testCases, test{ |
| 67 | // "nil", |
| 68 | // nil, |
| 69 | // true, // expect error |
| 70 | // nil, // no AST |
| 71 | // }) |
| 72 | //} |
| 73 | { |
| 74 | expr := &ast.ExprStr{V: "hello"} |
| 75 | stmt := &ast.StmtProg{ |
| 76 | Body: []interfaces.Stmt{ |
| 77 | &ast.StmtRes{ |
| 78 | Kind: "test", |
| 79 | Name: &ast.ExprStr{V: "t1"}, |
| 80 | Contents: []ast.StmtResContents{ |
| 81 | &ast.StmtResField{ |
| 82 | Field: "str", |
| 83 | Value: expr, |
| 84 | }, |
| 85 | }, |
| 86 | }, |
| 87 | }, |
| 88 | } |
| 89 | testCases = append(testCases, test{ |
| 90 | name: "one res", |
| 91 | ast: stmt, |
| 92 | fail: false, |
| 93 | expect: map[interfaces.Expr]*types.Type{ |
| 94 | expr: types.TypeStr, |
| 95 | }, |
| 96 | }) |
| 97 | } |
| 98 | { |
| 99 | v1 := &ast.ExprStr{} |
| 100 | v2 := &ast.ExprStr{} |
| 101 | v3 := &ast.ExprStr{} |
| 102 | expr := &ast.ExprList{ |
| 103 | Elements: []interfaces.Expr{ |
| 104 | v1, |
| 105 | v2, |
| 106 | v3, |
| 107 | }, |
| 108 | } |
| 109 | stmt := &ast.StmtProg{ |
| 110 | Body: []interfaces.Stmt{ |
nothing calls this directly
no test coverage detected