Skip to content

feat: Toon SpecGenerator for building unit tests to verify against spec#6

Merged
239573049 merged 15 commits intomainfrom
toon-revision-2
Nov 22, 2025
Merged

feat: Toon SpecGenerator for building unit tests to verify against spec#6
239573049 merged 15 commits intomainfrom
toon-revision-2

Conversation

@ghost1face
Copy link
Copy Markdown
Contributor

@ghost1face ghost1face commented Nov 17, 2025

Description

This PR creates tests to quickly validate if code is aligned with a specific spec version.

  • Created SpecGenerator tool to automatically generate xUnit tests from TOON spec fixtures
  • Added comprehensive test coverage for V2 spec including primitives, arrays, objects, delimiters, and whitespace handling
  • Implemented .specignore file to explicitly skip tests incompatible with .NET constraints
  • Added convenience scripts (specgen.sh and specgen.ps1) for easy test regeneration

Unit tests have been generated all pass except for:

  • Key Folding tests
  • Path Expansion tests
  • Several tests for decimal parsing and representation of them

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Related Issues

Closes #

Changes Made

  • Adds test generator for generating tests according to the spec
  • Adds unit tests to cover V2 spec

SPEC Compliance

  • This PR implements/fixes spec compliance
  • Spec section(s) affected:
  • Spec version:

Testing

  • All existing tests pass
  • Added new tests for changes
  • Tested on .NET 8.0
  • Tested on .NET 9.0

Checklist

  • My code follows the project's coding standards
  • I have run dotnet format
  • I have added tests that prove my fix/feature works
  • New and existing tests pass locally
  • I have updated documentation (if needed)
  • My changes do not introduce new dependencies

Additional Context

239573049 and others added 12 commits November 6, 2025 16:12
- Implement StringUtils for string manipulation, including escaping and unescaping.
- Create ValidationShared for key validation and safety checks.
- Introduce ToonDecodeOptions and ToonEncodeOptions for customizable encoding/decoding settings.
- Develop ToonDecoder for parsing TOON format strings into JsonNode objects.
- Implement ToonEncoder for converting data structures into TOON format strings.
- Add ToonFormatException for error handling during parsing and encoding.
- Create unit tests for ToonDecoder and ToonEncoder to ensure functionality and data integrity.
- Remove outdated UnitTest1.cs file.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ghost1face ghost1face added the enhancement New feature or request label Nov 17, 2025
@ghost1face ghost1face changed the title WIP: Toon revision 2 feat: Toon SpecGenerator for building unit tests to verify against spec Nov 18, 2025
@ghost1face ghost1face marked this pull request as ready for review November 18, 2025 02:24
@ghost1face ghost1face requested review from a team and johannschopplich as code owners November 18, 2025 02:24
@ghost1face
Copy link
Copy Markdown
Contributor Author

Now we have better visibility on which tests are not passing and can start to address them in upcoming PRs

@ghost1face ghost1face requested a review from Copilot November 18, 2025 02:34
Copy link
Copy Markdown
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 introduces a test generation tool that automatically creates unit tests from the TOON specification repository, enabling systematic validation of encoder and decoder implementations against the spec. The generated tests cover the V2 spec with noted exceptions for key folding, path expansion, and certain decimal parsing behaviors.

Key Changes

  • Created SpecGenerator tool to automatically generate xUnit tests from TOON spec fixtures
  • Added comprehensive test coverage for V2 spec including primitives, arrays, objects, delimiters, and whitespace handling
  • Implemented .specignore file to explicitly skip tests incompatible with .NET constraints
  • Added convenience scripts (specgen.sh and specgen.ps1) for easy test regeneration

Reviewed Changes

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

Show a summary per file
File Description
tests/ToonFormat.SpecGenerator/* New test generator tool that reads TOON spec fixtures and generates C# unit tests
tests/ToonFormat.Tests/Encode/* Auto-generated encode tests validating TOON encoder output
tests/ToonFormat.Tests/Decode/* Auto-generated decode tests validating TOON decoder behavior
.specignore Configuration file listing tests to skip due to .NET language constraints
specgen.sh / specgen.ps1 Shell scripts for regenerating tests from spec
src/ToonFormat/Internal/Decode/* Fixed Chinese comment translations to English

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@johannschopplich johannschopplich left a comment

Choose a reason for hiding this comment

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

@ghost1face Thanks for the PR (and generally reviewing the other PRs!). I was only tagged due to changes to the Contributing file – LGTM.

@ghost1face
Copy link
Copy Markdown
Contributor Author

@ghost1face Thanks for the PR (and generally reviewing the other PRs!). I was only tagged due to changes to the Contributing file – LGTM.

Looks like I'll be needing another maintainer to review myself here. If we can get this in, we can set a good foundation of tests to validate against

@johannschopplich
Copy link
Copy Markdown
Contributor

I agree. Hopefully more members of the community besides @0xZunia are willing to contribute. Happy to add members to the team that you recommend.

@0xZunia
Copy link
Copy Markdown

0xZunia commented Nov 18, 2025

Sorry I'm running out of time right now @ghost1face.
Might need to add a maintainer ASAP during my low activity period...

@ghost1face
Copy link
Copy Markdown
Contributor Author

Sorry I'm running out of time right now @ghost1face. Might need to add a maintainer ASAP during my low activity period...

No problem, I understand we're all busy.

I've been moving a little slow only because I want to make sure this is community and not just my preference alone. We'll take things to the discussions for any other passionate maintainers

@ghost1face
Copy link
Copy Markdown
Contributor Author

@239573049 this is our first order of business. Can you review here? Once we have this in place we have a test suite to validate against

@239573049
Copy link
Copy Markdown
Contributor

这是我们的首要任务。你能在这里复习一下吗?一旦我们有了这个测试套件,就可以进行验证

Could you please take a look at these checks and see why they are incorrect?

@239573049
Copy link
Copy Markdown
Contributor

Could you please check for me why I don't have the merge permission? @johannschopplich
image

@ghost1face
Copy link
Copy Markdown
Contributor Author

这是我们的首要任务。你能在这里复习一下吗?一旦我们有了这个测试套件,就可以进行验证

These checks run a new generated suite of unit tests to validate full compliance to the V2 spec. The code-base isn't yet v2 compliant. Subsequent pull requests will be getting us closer.

As far as not having the merge permission, you'll have to approve first as a maintainer. Merging is blocked without a maintainer approval

@239573049
Copy link
Copy Markdown
Contributor

这是我们的首要任务。你能在这里复习一下吗?一旦我们有了这个测试套件,就可以进行验证

These checks run a new generated suite of unit tests to validate full compliance to the V2 spec. The code-base isn't yet v2 compliant. Subsequent pull requests will be getting us closer.

As far as not having the merge permission, you'll have to approve first as a maintainer. Merging is blocked without a maintainer approval

image

Sorry, it seems that I haven't found a place to approve this PR.

Copy link
Copy Markdown
Contributor

@239573049 239573049 left a comment

Choose a reason for hiding this comment

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

approve

@johannschopplich
Copy link
Copy Markdown
Contributor

@239573049 You have to click on the Files changed tab and then the green "Review" button to leave your review:

Bildschirmfoto 2025-11-22 um 08 44 47

Copy link
Copy Markdown
Contributor

@239573049 239573049 left a comment

Choose a reason for hiding this comment

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

Approve

@239573049 239573049 merged commit fce9b0a into main Nov 22, 2025
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants