MCPcopy
hub / github.com/hashicorp/hcl / TestExprAsKeyword

Function TestExprAsKeyword

traversal_for_expr_test.go:173–221  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

171}
172
173func TestExprAsKeyword(t *testing.T) {
174 tests := []struct {
175 Expr Expression
176 Want string
177 }{
178 {
179 asTraversalSupported{RootName: "foo"},
180 "foo",
181 },
182 {
183 asTraversalSupportedAttr{
184 RootName: "foo",
185 AttrName: "bar",
186 },
187 "",
188 },
189 {
190 asTraversalNotSupported{},
191 "",
192 },
193 {
194 asTraversalDeclined{},
195 "",
196 },
197 {
198 asTraversalWrappedDelegated{
199 original: asTraversalSupported{RootName: "foo"},
200 },
201 "foo",
202 },
203 {
204 asTraversalWrappedDelegated{
205 original: asTraversalWrappedDelegated{
206 original: asTraversalSupported{RootName: "foo"},
207 },
208 },
209 "foo",
210 },
211 }
212
213 for _, test := range tests {
214 t.Run("", func(t *testing.T) {
215 got := ExprAsKeyword(test.Expr)
216 if got != test.Want {
217 t.Errorf("wrong result %q; want %q\ninput: %T", got, test.Want, test.Expr)
218 }
219 })
220 }
221}

Callers

nothing calls this directly

Calls 2

ExprAsKeywordFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected