Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds configurable numeric normalization strategies to TOONEncoder, providing JSONEncoder-style control over how negative zero and non-conforming floating-point values (NaN, Infinity, -Infinity) are encoded. It implements two separate strategies: NegativeZeroEncodingStrategy (normalize or preserve) and NonConformingFloatEncodingStrategy (null, throw, or convertToString). The changes maintain backward compatibility by keeping the default behaviors that match the TOON specification 3.0.
Changes:
- Added
NegativeZeroEncodingStrategyandNonConformingFloatEncodingStrategypublic enums with associated encoding logic - Implemented validation function that recursively checks for non-conforming floats when
.throwstrategy is selected - Added tests for default behavior, negative zero preservation, and throw strategy
- Updated README documentation with usage examples and updated feature description
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| Sources/ToonFormat/Encoder.swift | Adds two strategy enums, validation function, and encoding logic for numeric normalization |
| Tests/ToonFormatTests/EncoderTests.swift | Adds tests for new numeric encoding strategies including default behavior and error throwing |
| README.md | Updates canonical number formatting note and adds new section documenting numeric normalization configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Linked Issue
Alternative to #23
Description
This PR implements JSONEncoder-style numeric strategies on
TOONEncoder, adds validation for.throw, updates tests for defaults and custom behavior, and documents the configuration in the README.Type of Change
Changes Made
^ See description
SPEC Compliance
Testing
Pre-submission Checklist
Breaking Changes
Additional Context