Skip to content

Conversation

@nev21
Copy link
Contributor

@nev21 nev21 commented Jan 21, 2026

Add comprehensive change tracking assertions for monitoring value mutations during function execution. Supports both getter functions and object properties with optional delta validation via .by() chaining.

New Assertion Types:

  • change/changes: Track any value change (direction-agnostic)
  • increase/increases: Track positive value changes
  • decrease/decreases: Track negative value changes
  • changeBy/changesBy: Direct delta validation (sign-agnostic)
  • increaseBy/increasesBy: Positive delta validation
  • decreaseBy/decreasesBy: Negative delta validation

Implementation:

  • Added ChangeFn and ChangeByFn function interfaces for type safety
  • Created IChangeResultOp interface for .by() chaining support
  • Added IChangeResultValue interface for change metadata
  • Created changeResultOp helper for .by() chain functionality

Integration:

  • Updated IToOp interface with all 12 change assertion methods
  • Updated IAssertInst interface with matching methods
  • Updated IAssertClass with 24 assert.* methods (all variants)
  • Added all methods to coreFunctions and toOp registrations
  • Updated scopeContext with symbol-based _$details getter for easier debugging

Documentation:

  • Added comprehensive TypeDoc with @param, @example, and @alias tags
  • Documented both getter function and object property usage patterns
  • Clarified sign-agnostic behavior for changeBy/changesBy
  • Emphasized positive delta requirement for increase/decrease variants

Testing:

  • Added exprAdapter tests for scope function isolation
  • Updated property tests with better assertions
  • Fixed oneOf test for Map entries

Chai Compatibility:

  • Updated chaiAssert with all change/increase/decrease methods
  • Enabled previously commented Chai compatibility tests
  • All Chai shim tests now passing

This enables powerful assertions like:
expect(fn).to.change(obj, 'val').by(5) expect(fn).to.increase(getValue) assert.decreases(fn, obj, 'count')

@nev21 nev21 added this to the 0.1.5 milestone Jan 21, 2026
Copilot AI review requested due to automatic review settings January 21, 2026 06:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive change tracking assertions for monitoring value mutations during function execution. It introduces three main assertion types (change/increase/decrease) with support for delta validation via .by() chaining, covering both getter functions and object properties.

Changes:

  • Added 12 new assertion methods (change/changes, increase/increases, decrease/decreases and their variants with By suffix)
  • Created new interfaces and type definitions for change tracking (IChangeResultOp, IChangeResultValue, ChangeFn, ChangeByFn)
  • Updated Chai compatibility shim with all change assertions and enabled previously commented tests
  • Added comprehensive test coverage across multiple test files
  • Enhanced scopeContext with symbol-based _$details getter for debugging

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
core/src/assert/funcs/changes.ts New implementation for change/increase/decrease assertions
core/src/assert/funcs/changesBy.ts New implementation for changeBy/increaseBy/decreaseBy assertions
core/src/assert/ops/changeResultOp.ts New operation for .by() chaining support
core/src/assert/interface/ops/IChangeResultOp.ts Interface for change result with .by() chaining
core/src/assert/interface/ops/IChangeResultValue.ts Interface for change metadata
core/src/assert/interface/funcs/ChangeFn.ts Function signature for change assertions
core/src/assert/interface/funcs/ChangeByFn.ts Function signature for changeBy assertions
core/src/assert/interface/ops/IToOp.ts Updated with 12 new assertion methods and documentation
core/src/assert/interface/IAssertInst.ts Updated with 12 new assertion methods
core/src/assert/interface/IAssertClass.ts Updated with 24 assert.* methods, fixed typo in comment
core/src/assert/interface/IAssertClassDef.ts Fixed typo: "accert" to "assert"
core/src/assert/internal/_isMsgSource.ts New helper to validate MsgSource type
core/src/assert/internal/_baseFunctions.ts Added change assertions to core functions
core/src/assert/ops/toOp.ts Registered all new change assertions
core/src/assert/assertClass.ts Added 12 assert.* method definitions with nArgs
core/src/assert/assertScope.ts Updated debug logging prefix
core/src/assert/scopeContext.ts Added symbol-based _$details getter for debugging
core/src/assert/adapters/exprAdapter.ts CRITICAL: Contains commented-out code
core/src/assert/adapters/evalAdapter.ts Updated debug logging prefix
core/src/index.ts Exported new interfaces and types
shim/chai/src/assert/chaiAssert.ts Implemented all change assertions for Chai compatibility
shim/chai/test/src/chaiAssert.test.ts Enabled and updated previously commented tests
core/test/src/assert/expect.change.test.ts New comprehensive test file for expect-style assertions
core/test/src/assert/assert.changes.test.ts New comprehensive test file for assert-style assertions
core/test/src/assert/assert.property.test.ts Enhanced property assertion tests
core/test/src/assert/assert.oneOf.test.ts Added missing test assertion for Map entry
core/test/src/assert/adapters/exprAdapter.test.ts New comprehensive adapter tests for scope function isolation

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

@nev21 nev21 force-pushed the nev21/changeOps branch 2 times, most recently from e2a3310 to a988566 Compare January 21, 2026 07:06
@nev21 nev21 requested a review from Copilot January 21, 2026 07:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

Add comprehensive change tracking assertions for monitoring value mutations
during function execution. Supports both getter functions and object properties
with optional delta validation via .by() chaining.

New Assertion Types:
- change/changes: Track any value change (direction-agnostic)
- increase/increases: Track positive value changes
- decrease/decreases: Track negative value changes
- changeBy/changesBy: Direct delta validation (sign-agnostic)
- increaseBy/increasesBy: Positive delta validation
- decreaseBy/decreasesBy: Negative delta validation

Implementation:
- Added ChangeFn and ChangeByFn function interfaces for type safety
- Created IChangeResultOp interface for .by() chaining support
- Added IChangeResultValue interface for change metadata
- Created changeResultOp helper for .by() chain functionality

Integration:
- Updated IToOp interface with all 12 change assertion methods
- Updated IAssertInst interface with matching methods
- Updated IAssertClass with 24 assert.* methods (all variants)
- Added all methods to coreFunctions and toOp registrations
- Updated scopeContext with symbol-based _$details getter for easier debugging

Documentation:
- Added comprehensive TypeDoc with @param, @example, and @alias tags
- Documented both getter function and object property usage patterns
- Clarified sign-agnostic behavior for changeBy/changesBy
- Emphasized positive delta requirement for increase/decrease variants

Testing:
- Added exprAdapter tests for scope function isolation
- Updated property tests with better assertions
- Fixed oneOf test for Map entries

Chai Compatibility:
- Updated chaiAssert with all change/increase/decrease methods
- Enabled previously commented Chai compatibility tests
- All Chai shim tests now passing

This enables powerful assertions like:
  expect(fn).to.change(obj, 'val').by(5)
  expect(fn).to.increase(getValue)
  assert.decreases(fn, obj, 'count')
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated no new comments.

@nev21 nev21 enabled auto-merge (squash) January 22, 2026 04:13
@nev21 nev21 merged commit bebb318 into main Jan 22, 2026
16 checks passed
@nev21 nev21 deleted the nev21/changeOps branch January 22, 2026 04:23
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