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

Function addCircularFormatterTests

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

Source from the content-addressed store, hash-verified

1256}
1257
1258func addCircularFormatterTests() {
1259 // Struct that is circular through self referencing.
1260 type circular struct {
1261 c *circular
1262 }
1263 v := circular{nil}
1264 v.c = &v
1265 pv := &v
1266 vAddr := fmt.Sprintf("%p", pv)
1267 pvAddr := fmt.Sprintf("%p", &pv)
1268 vt := "spew_test.circular"
1269 vs := "{<*>{<*><shown>}}"
1270 vs2 := "{<*><shown>}"
1271 vs3 := "{c:<*>(" + vAddr + "){c:<*>(" + vAddr + ")<shown>}}"
1272 vs4 := "{c:<*>(" + vAddr + ")<shown>}"
1273 vs5 := "{c:(*" + vt + "){c:(*" + vt + ")<shown>}}"
1274 vs6 := "{c:(*" + vt + ")<shown>}"
1275 vs7 := "{c:(*" + vt + ")(" + vAddr + "){c:(*" + vt + ")(" + vAddr +
1276 ")<shown>}}"
1277 vs8 := "{c:(*" + vt + ")(" + vAddr + ")<shown>}"
1278 addFormatterTest("%v", v, vs)
1279 addFormatterTest("%v", pv, "<*>"+vs2)
1280 addFormatterTest("%v", &pv, "<**>"+vs2)
1281 addFormatterTest("%+v", v, vs3)
1282 addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs4)
1283 addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs4)
1284 addFormatterTest("%#v", v, "("+vt+")"+vs5)
1285 addFormatterTest("%#v", pv, "(*"+vt+")"+vs6)
1286 addFormatterTest("%#v", &pv, "(**"+vt+")"+vs6)
1287 addFormatterTest("%#+v", v, "("+vt+")"+vs7)
1288 addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs8)
1289 addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs8)
1290
1291 // Structs that are circular through cross referencing.
1292 v2 := xref1{nil}
1293 ts2 := xref2{&v2}
1294 v2.ps2 = &ts2
1295 pv2 := &v2
1296 ts2Addr := fmt.Sprintf("%p", &ts2)
1297 v2Addr := fmt.Sprintf("%p", pv2)
1298 pv2Addr := fmt.Sprintf("%p", &pv2)
1299 v2t := "spew_test.xref1"
1300 v2t2 := "spew_test.xref2"
1301 v2s := "{<*>{<*>{<*><shown>}}}"
1302 v2s2 := "{<*>{<*><shown>}}"
1303 v2s3 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + "){ps2:<*>(" +
1304 ts2Addr + ")<shown>}}}"
1305 v2s4 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + ")<shown>}}"
1306 v2s5 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + "){ps2:(*" + v2t2 +
1307 ")<shown>}}}"
1308 v2s6 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + ")<shown>}}"
1309 v2s7 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t +
1310 ")(" + v2Addr + "){ps2:(*" + v2t2 + ")(" + ts2Addr +
1311 ")<shown>}}}"
1312 v2s8 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t +
1313 ")(" + v2Addr + ")<shown>}}"
1314 addFormatterTest("%v", v2, v2s)
1315 addFormatterTest("%v", pv2, "<*>"+v2s2)

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…