MCPcopy Create free account
hub / github.com/expr-lang/expr / addFuncFormatterTests

Function addFuncFormatterTests

internal/spew/format_test.go:1179–1256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1177}
1178
1179func addFuncFormatterTests() {
1180 // Function with no params and no returns.
1181 v := addIntFormatterTests
1182 nv := (*func())(nil)
1183 pv := &v
1184 vAddr := fmt.Sprintf("%p", pv)
1185 pvAddr := fmt.Sprintf("%p", &pv)
1186 vt := "func()"
1187 vs := fmt.Sprintf("%p", v)
1188 addFormatterTest("%v", v, vs)
1189 addFormatterTest("%v", pv, "<*>"+vs)
1190 addFormatterTest("%v", &pv, "<**>"+vs)
1191 addFormatterTest("%+v", nv, "<nil>")
1192 addFormatterTest("%+v", v, vs)
1193 addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
1194 addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
1195 addFormatterTest("%+v", nv, "<nil>")
1196 addFormatterTest("%#v", v, "("+vt+")"+vs)
1197 addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
1198 addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
1199 addFormatterTest("%#v", nv, "(*"+vt+")"+"<nil>")
1200 addFormatterTest("%#+v", v, "("+vt+")"+vs)
1201 addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
1202 addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
1203 addFormatterTest("%#+v", nv, "(*"+vt+")"+"<nil>")
1204
1205 // Function with param and no returns.
1206 v2 := TestFormatter
1207 nv2 := (*func(*testing.T))(nil)
1208 pv2 := &v2
1209 v2Addr := fmt.Sprintf("%p", pv2)
1210 pv2Addr := fmt.Sprintf("%p", &pv2)
1211 v2t := "func(*testing.T)"
1212 v2s := fmt.Sprintf("%p", v2)
1213 addFormatterTest("%v", v2, v2s)
1214 addFormatterTest("%v", pv2, "<*>"+v2s)
1215 addFormatterTest("%v", &pv2, "<**>"+v2s)
1216 addFormatterTest("%+v", nv2, "<nil>")
1217 addFormatterTest("%+v", v2, v2s)
1218 addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
1219 addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
1220 addFormatterTest("%+v", nv2, "<nil>")
1221 addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
1222 addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
1223 addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
1224 addFormatterTest("%#v", nv2, "(*"+v2t+")"+"<nil>")
1225 addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
1226 addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
1227 addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
1228 addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"<nil>")
1229
1230 // Function with multiple params and multiple returns.
1231 var v3 = func(i int, s string) (b bool, err error) {
1232 return true, nil
1233 }
1234 nv3 := (*func(int, string) (bool, error))(nil)
1235 pv3 := &v3
1236 v3Addr := fmt.Sprintf("%p", pv3)

Callers 1

TestFormatterFunction · 0.85

Calls 2

addFormatterTestFunction · 0.85
SprintfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…