(t *testing.T)
| 134 | } |
| 135 | |
| 136 | func TestASTNilSafety(t *testing.T) { |
| 137 | ex, err := ast.ProtoToExpr(nil) |
| 138 | if err != nil { |
| 139 | t.Fatalf("ast.ProtoToExpr() failed: %v", err) |
| 140 | } |
| 141 | info, err := ast.ProtoToSourceInfo(nil) |
| 142 | if err != nil { |
| 143 | t.Fatalf("ast.ProtoToSourceInfo() failed: %v", err) |
| 144 | } |
| 145 | tests := []*ast.AST{ |
| 146 | nil, |
| 147 | ast.NewAST(nil, nil), |
| 148 | ast.NewCheckedAST(nil, nil, nil), |
| 149 | ast.NewCheckedAST(ast.NewAST(nil, nil), nil, nil), |
| 150 | ast.NewAST(ex, info), |
| 151 | ast.NewCheckedAST(ast.NewAST(ex, info), map[int64]*types.Type{}, map[int64]*ast.ReferenceInfo{}), |
| 152 | } |
| 153 | for _, tst := range tests { |
| 154 | a := tst |
| 155 | asts := []*ast.AST{a, ast.Copy(a)} |
| 156 | for _, testAST := range asts { |
| 157 | if testAST.Expr().ID() != 0 { |
| 158 | t.Errorf("Expr().ID() got %v, wanted 0", testAST.Expr().ID()) |
| 159 | } |
| 160 | if testAST.SourceInfo().SyntaxVersion() != "" { |
| 161 | t.Errorf("SourceInfo().SyntaxVersion() got %s, wanted empty string", testAST.SourceInfo().SyntaxVersion()) |
| 162 | } |
| 163 | if testAST.IsChecked() { |
| 164 | t.Error("IsChecked() returned true, wanted false") |
| 165 | } |
| 166 | if testAST.GetType(testAST.Expr().ID()) != types.DynType { |
| 167 | t.Errorf("GetType() got %v, wanted dyn", testAST.GetType(testAST.Expr().ID())) |
| 168 | } |
| 169 | if len(testAST.GetOverloadIDs(testAST.Expr().ID())) != 0 { |
| 170 | t.Errorf("GetOverloadIDs() got %v, wanted empty set", testAST.GetOverloadIDs(testAST.Expr().ID())) |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | func TestSourceInfo(t *testing.T) { |
| 177 | src := common.NewStringSource("a\n? b\n: c", "custom description") |
nothing calls this directly
no test coverage detected