GoodPrompts
Main navigation
Prompt library

Fix a bug with a regression test

Reproduce the failure, patch the function and verify relevant boundary cases.

Category
Coding
Author
GoodPrompts
Original language
Español (España)

Fill and copy

Variables

Final prompt

Fix {{code}} to match {{contract}}. Return a complete function with the same name and signature, then a failing case for the previous implementation and the expected result. Keep the change scoped to this function.

Fill in all variables to copy the completed prompt.

View original template

Original prompt

Corrige el fallo de {{código}} según {{contrato}}. Devuelve primero una función completa que mantenga el nombre y la firma; después, indica un caso que falle con la versión anterior y el resultado esperado. Limita el cambio a esta función.

Translation

Fix {{code}} to match {{contract}}. Return a complete function with the same name and signature, then a failing case for the previous implementation and the expected result. Keep the change scoped to this function.

Run samples

Codex · · One run. Exact model version unrecorded.

Input

Código: function clampMin(value, min) { return value <= min ? min : min; }
Contrato: devolver value si es mayor que min; en otro caso, devolver min.

Output

function clampMin(value, min) { return Math.max(value, min); }

The old implementation returns 4 for (8, 4). The fix returns 8 and preserves equality and below-minimum behavior. The model produced the code plus the case (8, 4) → 8.