Skip to content

fix: validate final values in numeric change assertions - #1881

Open
xiehuanyi wants to merge 1 commit into
chaijs:mainfrom
xiehuanyi:fix/final-numeric-delta-types-r2-20261013
Open

xiehuanyi wants to merge 1 commit into
chaijs:mainfrom
xiehuanyi:fix/final-numeric-delta-types-r2-20261013

Conversation

@xiehuanyi

Copy link
Copy Markdown

Numeric change assertions validate the initial subject but do not validate the value observed after invoking the target function. A counter changing from numeric 1 to string "2" incorrectly passes .increase(), and changing to string "0" incorrectly passes .decrease(). A final undefined value silently passes their negated forms because arithmetic produces NaN.

Check the final observed value using the same numeric prerequisite as the initial value, before calculating the delta. This covers object properties and getter callbacks, including negated assertions and custom error messages. Existing valid numeric changes retain their behavior.

Validation:

  • Three new public regression cases fail on unchanged main, covering object/getter subjects and invalid final values under negation.
  • npm run build and npm run lint pass.
  • npm run test-node: 515 passing; Chromium suite with the local Chrome executable: 514 passing.
  • git diff --check passes.

Discovery and implementation: automated OpenAI gpt-6.1-sol source review, xhigh reasoning.

@xiehuanyi
xiehuanyi requested a review from a team as a code owner October 13, 2026 09:45
Copilot AI balanced review requested due to automatic review settings October 13, 2026 09:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants