Skip to content

Add a test JSON encoder for Codable tests - #55

Merged
dfabulich merged 1 commit into
mainfrom
codable-test-encoder-2
Dec 4, 2026
Merged

dfabulich merged 1 commit into
mainfrom
codable-test-encoder-2

Conversation

@dfabulich

Copy link
Copy Markdown
Member

skip-lib has no concrete Encoder, so its Kotlin Codable dispatch could only be tested downstream in skip-foundation. TestJSONEncoder is a minimal Kotlin TopLevelEncoder in the test module that writes compact JSON with sorted keys, and throws on values that are neither scalars nor Encodable.

CodableTests encodes with Foundation's JSONEncoder natively and with TestJSONEncoder on Android, so each expected JSON string is checked against Swift's own output. Tests for optional and nested dictionary encoding are compiled out on Android until #54 is fixed.

Skip Pull Request Checklist:

  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

I've reviewed the tests and they pass on my machine. Passing against macOS validates that the tests are correct.

skip-lib has no concrete Encoder, so its Kotlin Codable dispatch could only be tested downstream in skip-foundation. TestJSONEncoder is a minimal Kotlin TopLevelEncoder in the test module that writes compact JSON with sorted keys, and throws on values that are neither scalars nor Encodable.

CodableTests encodes with Foundation's JSONEncoder natively and with TestJSONEncoder on Android, so each expected JSON string is checked against Swift's own output. Tests for optional and nested dictionary encoding are compiled out on Android until #54 is fixed.
@dfabulich
dfabulich merged commit 871457f into main Dec 4, 2026
2 checks passed
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.

1 participant