(t *testing.T)
| 550 | } |
| 551 | |
| 552 | func TestEvalStructFieldAccess(t *testing.T) { |
| 553 | s := struct { |
| 554 | Exported int |
| 555 | unexported int |
| 556 | }{ |
| 557 | Exported: 123, |
| 558 | unexported: 234, |
| 559 | } |
| 560 | |
| 561 | var data = make(VarMap) |
| 562 | data.Set("struct", s) |
| 563 | |
| 564 | RunJetTest(t, data, nil, "StructFieldAccess", `{{ struct.Exported }}`, "123") |
| 565 | |
| 566 | var set = NewSet(NewInMemLoader(), WithSafeWriter(nil)) |
| 567 | tt, err := set.parse("StructFieldAccess_unexported", `{{ struct.unexported }}`, false) |
| 568 | if err != nil { |
| 569 | t.Error(err) |
| 570 | } |
| 571 | buff := bytes.NewBuffer(nil) |
| 572 | err = tt.Execute(buff, data, nil) |
| 573 | if err == nil { |
| 574 | t.Error("expected evaluating unexported field of struct to fail with a runtime error but got nil") |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | func TestEvalStructFieldPointerExpressions(t *testing.T) { |
| 579 | var data = make(VarMap) |
nothing calls this directly
no test coverage detected
searching dependent graphs…