MCPcopy
hub / github.com/purpleidea/mgmt / TestUnification1

Function TestUnification1

lang/unification/solvers/unification_test.go:53–1004  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51)
52
53func 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{

Callers

nothing calls this directly

Calls 15

SetTypeMethod · 0.95
SetTypeMethod · 0.95
UnifyMethod · 0.95
TypeMethod · 0.95
NewTypeFunction · 0.92
StrInListFunction · 0.92
MergeExprMapsFunction · 0.92
LookupDefaultFunction · 0.92
NewUnifiedStateFunction · 0.92
LogfMethod · 0.80

Tested by

no test coverage detected