(t *testing.T)
| 404 | } |
| 405 | |
| 406 | func TestHeights(t *testing.T) { |
| 407 | tests := []struct { |
| 408 | expr string |
| 409 | height int |
| 410 | }{ |
| 411 | {`'a' == 'b'`, 1}, |
| 412 | {`'a'.size()`, 1}, |
| 413 | {`[1, 2].size()`, 2}, |
| 414 | {`size('a')`, 1}, |
| 415 | {`has({'a': 1}.a)`, 2}, |
| 416 | {`{'a': 1}`, 1}, |
| 417 | {`{'a': 1}['a']`, 2}, |
| 418 | {`[1, 2, 3].exists(i, i % 2 == 1)`, 4}, |
| 419 | {`google.expr.proto3.test.TestAllTypes{}`, 1}, |
| 420 | {`google.expr.proto3.test.TestAllTypes{repeated_int32: [1, 2]}`, 2}, |
| 421 | } |
| 422 | for _, tst := range tests { |
| 423 | checked := mustTypeCheck(t, tst.expr) |
| 424 | maxHeight := ast.Heights(checked)[checked.Expr().ID()] |
| 425 | if maxHeight != tst.height { |
| 426 | t.Errorf("ast.Heights(%q) got max height %d, wanted %d", tst.expr, maxHeight, tst.height) |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | func TestHasExtension(t *testing.T) { |
| 432 | info := ast.NewSourceInfo(common.NewStringSource("true", "test-only")) |
nothing calls this directly
no test coverage detected