MCPcopy
hub / github.com/expr-lang/expr / TestSpew

Function TestSpew

internal/spew/spew_test.go:210–320  ·  view source on GitHub ↗

TestSpew executes all of the tests described by spewTests.

(t *testing.T)

Source from the content-addressed store, hash-verified

208
209// TestSpew executes all of the tests described by spewTests.
210func TestSpew(t *testing.T) {
211 initSpewTests()
212
213 t.Logf("Running %d tests", len(spewTests))
214 for i, test := range spewTests {
215 buf := new(bytes.Buffer)
216 switch test.f {
217 case fCSFdump:
218 test.cs.Fdump(buf, test.in)
219
220 case fCSFprint:
221 test.cs.Fprint(buf, test.in)
222
223 case fCSFprintf:
224 test.cs.Fprintf(buf, test.format, test.in)
225
226 case fCSFprintln:
227 test.cs.Fprintln(buf, test.in)
228
229 case fCSPrint:
230 b, err := redirStdout(func() { test.cs.Print(test.in) })
231 if err != nil {
232 t.Errorf("%v #%d %v", test.f, i, err)
233 continue
234 }
235 buf.Write(b)
236
237 case fCSPrintln:
238 b, err := redirStdout(func() { test.cs.Println(test.in) })
239 if err != nil {
240 t.Errorf("%v #%d %v", test.f, i, err)
241 continue
242 }
243 buf.Write(b)
244
245 case fCSSdump:
246 str := test.cs.Sdump(test.in)
247 buf.WriteString(str)
248
249 case fCSSprint:
250 str := test.cs.Sprint(test.in)
251 buf.WriteString(str)
252
253 case fCSSprintf:
254 str := test.cs.Sprintf(test.format, test.in)
255 buf.WriteString(str)
256
257 case fCSSprintln:
258 str := test.cs.Sprintln(test.in)
259 buf.WriteString(str)
260
261 case fCSErrorf:
262 err := test.cs.Errorf(test.format, test.in)
263 buf.WriteString(err.Error())
264
265 case fCSNewFormatter:
266 fmt.Fprintf(buf, test.format, test.cs.NewFormatter(test.in))
267

Callers

nothing calls this directly

Calls 15

ErrorfFunction · 0.92
FprintFunction · 0.92
FprintlnFunction · 0.92
PrintFunction · 0.92
PrintlnFunction · 0.92
SdumpFunction · 0.92
SprintFunction · 0.92
SprintfFunction · 0.92
SprintlnFunction · 0.92
initSpewTestsFunction · 0.85
redirStdoutFunction · 0.85
FdumpMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…