(t *testing.T)
| 414 | } |
| 415 | |
| 416 | func TestStruct(t *testing.T) { |
| 417 | fac := ast.NewExprFactory() |
| 418 | expr := fac.NewStruct(1, |
| 419 | "custom.StructType", |
| 420 | []ast.EntryExpr{ |
| 421 | fac.NewStructField(2, "a", fac.NewLiteral(3, types.True), true), |
| 422 | fac.NewStructField(4, "b", fac.NewLiteral(5, types.False), false), |
| 423 | }) |
| 424 | s := expr.AsStruct() |
| 425 | if s.TypeName() != "custom.StructType" { |
| 426 | t.Errorf("s.TypeName() got %q, wanted 'custom.StructType'", s.TypeName()) |
| 427 | } |
| 428 | if len(s.Fields()) != 2 { |
| 429 | t.Errorf("s.Fields() got %d, wanted 2", len(s.Fields())) |
| 430 | } |
| 431 | expr.RenumberIDs(testIDGen(50)) |
| 432 | if expr.ID() != 51 { |
| 433 | t.Errorf("expr.ID() got %d, wanted 51", expr.ID()) |
| 434 | } |
| 435 | if s.Fields()[0].ID() != 52 { |
| 436 | t.Errorf("s.Fields()[0].ID() got %d, wanted 52", s.Fields()[0].ID()) |
| 437 | } |
| 438 | field := s.Fields()[0].AsStructField() |
| 439 | if val := field.Value(); val.ID() != 53 { |
| 440 | t.Errorf("val.ID() got %d, wanted 53", val.ID()) |
| 441 | } |
| 442 | if field.Name() != "a" { |
| 443 | t.Errorf("field.Name() got %s, wanted 'a'", field.Name()) |
| 444 | } |
| 445 | if !field.IsOptional() { |
| 446 | t.Error("field.IsOptional() got false, wanted true") |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | func TestStructNil(t *testing.T) { |
| 451 | expr := nilTestExpr(t) |
nothing calls this directly
no test coverage detected