MCPcopy Create free account
hub / github.com/CloudyKit/jet / TestEvalStructFieldAccess

Function TestEvalStructFieldAccess

eval_test.go:552–576  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

550}
551
552func 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
578func TestEvalStructFieldPointerExpressions(t *testing.T) {
579 var data = make(VarMap)

Callers

nothing calls this directly

Calls 7

RunJetTestFunction · 0.85
NewSetFunction · 0.85
NewInMemLoaderFunction · 0.85
WithSafeWriterFunction · 0.85
parseMethod · 0.80
ExecuteMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…