MCPcopy Index your code
hub / github.com/expr-lang/expr / TestCreateDoc_FromMap

Function TestCreateDoc_FromMap

docgen/docgen_test.go:208–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

206}
207
208func TestCreateDoc_FromMap(t *testing.T) {
209 env := map[string]any{
210 "Tweets": []*Tweet{},
211 "Config": struct {
212 MaxSize int
213 }{},
214 "Max": math.Max,
215 }
216 Operators = nil
217 Builtins = nil
218 doc := CreateDoc(env)
219 expected := &Context{
220 Variables: map[Identifier]*Type{
221 "Tweets": {
222 Kind: "array",
223 Type: &Type{
224 Kind: "struct",
225 Name: "docgen_test.Tweet",
226 },
227 },
228 "Config": {
229 Kind: "struct",
230 Fields: map[Identifier]*Type{
231 "MaxSize": {Kind: "int"},
232 },
233 },
234 "Max": {
235 Kind: "func",
236 Arguments: []*Type{
237 {Kind: "float"},
238 {Kind: "float"},
239 },
240 Return: &Type{Kind: "float"},
241 },
242 },
243 Types: map[TypeName]*Type{
244 "docgen_test.Tweet": {
245 Kind: "struct",
246 Fields: map[Identifier]*Type{
247 "Size": {Kind: "int"},
248 "Message": {Kind: "string"},
249 },
250 },
251 },
252 }
253
254 require.EqualValues(t, expected.Markdown(), doc.Markdown())
255}
256
257func TestContext_Markdown(t *testing.T) {
258 doc := CreateDoc(&Env{})

Callers

nothing calls this directly

Calls 3

MarkdownMethod · 0.95
EqualValuesFunction · 0.92
CreateDocFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…