testify icon indicating copy to clipboard operation
testify copied to clipboard

docs(assert/require): clarify allowed rx values for Regexp/NotRegexp (#268, #1793)

Open kdt523 opened this issue 2 months ago • 0 comments

docs(assert/require): clarify allowed rx values for Regexp/NotRegexp (#268, #1793) Summary Clarify the allowed types and runtime behavior of the rx argument for assert.Regexp, assert.NotRegexp and their require and *f variants. This is a documentation-only change. Changes Updated function comments in: assert/assertions.go assert/assertion_format.go assert/assertion_forward.go require/require.go require/require_forward.go The comments now: State that the preferred rx value is a *regexp.Regexp. Explain that non-*regexp.Regexp values are stringified and compiled (historical behavior preserved). Motivation Users were unclear about which types are accepted for the rx parameter and whether passing a plain string or other value was supported. The code historically accepts interface{} and falls back to stringifying and compiling the value; documenting this explicitly reduces confusion and helps callers choose the safest/most efficient usage (passing a compiled *regexp.Regexp when possible). Related issues #1793 Behavior / Tests Behavior: No runtime or API behavior changes were made. The implementation still stringifies non-*regexp.Regexp values and compiles them with regexp.MustCompile (same as before). This PR is documentation-only. Tests: I ran package tests for the changed packages locally: go test ./assert ./require — passed. Note: Running go test d:. on Windows may show failures in suite due to environment-specific tests (panic/restart tests and -race subprocess builds needing a C toolchain). Those failures are unrelated to this docs-only change.

kdt523 avatar Oct 25 '25 14:10 kdt523