Skip to content

Conversation

Copy link

Copilot AI commented Jan 20, 2026

The add operator now supports arrays, objects, and throws errors on incompatible types, but lacked test coverage for these branches.

Changes

  • String handling tests: Non-numeric string concatenation and numeric string addition
  • Array concatenation tests: Basic and empty array cases
  • Object merge tests: Property merging and overlapping key behavior
  • Type coercion tests: Boolean to number conversion (true + 1 = 2)
  • Error handling tests: Incompatible type combinations throw descriptive errors
  • Edge case tests: null + null behavior

Example

parser.evaluate('[1, 2] + [3, 4]')           // [1, 2, 3, 4]
parser.evaluate('{a: 1} + {b: 2}')           // {a: 1, b: 2}
parser.evaluate('"hello" + "world"')         // "helloworld"
parser.evaluate('"5" + "3"')                 // 8
parser.evaluate('5 + [1, 2]')                // Error: Cannot add values of incompatible types

All branches of the add function now have test coverage.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Sander-Toonen <5106372+Sander-Toonen@users.noreply.github.com>
Copilot AI changed the title [WIP] Allow + operator to work with more types and handle errors Add comprehensive test coverage for add operator's type handling Jan 20, 2026
Copilot AI requested a review from Sander-Toonen January 20, 2026 15:06
@Sander-Toonen Sander-Toonen marked this pull request as ready for review January 20, 2026 15:14
Copilot AI review requested due to automatic review settings January 20, 2026 15:14
@Sander-Toonen Sander-Toonen merged commit cedeafd into feature/add-support-for-multiple-types Jan 20, 2026
4 checks passed
Copy link

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 test coverage for the add operator's type handling capabilities, ensuring all code branches are tested including string concatenation, array concatenation, object merging, type coercion, and error handling.

Changes:

  • Added 7 new test cases covering string handling, array operations, object merging, type coercion, null handling, and error scenarios
  • All previously untested branches of the add operator now have test coverage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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