| 345 | } |
| 346 | |
| 347 | func (s *state) callTTBFunc(f, x, y reflect.Value) bool { |
| 348 | if !s.dynChecker.Next() { |
| 349 | return f.Call([]reflect.Value{x, y})[0].Bool() |
| 350 | } |
| 351 | |
| 352 | // Swapping the input arguments is sufficient to check that |
| 353 | // f is symmetric and deterministic. |
| 354 | // We run in goroutines so that the race detector (if enabled) can detect |
| 355 | // unsafe mutations to the input. |
| 356 | c := make(chan reflect.Value) |
| 357 | go detectRaces(c, f, y, x) |
| 358 | got := <-c |
| 359 | want := f.Call([]reflect.Value{x, y})[0].Bool() |
| 360 | if !got.IsValid() || got.Bool() != want { |
| 361 | panic(fmt.Sprintf("non-deterministic or non-symmetric function detected: %s", function.NameOf(f))) |
| 362 | } |
| 363 | return want |
| 364 | } |
| 365 | |
| 366 | func detectRaces(c chan<- reflect.Value, f reflect.Value, vs ...reflect.Value) { |
| 367 | var ret reflect.Value |