Exemple
Distinguish JSON.dump Marshal-compatible default options and argument dispatch from JSON.generate strict limits
sha256:4c386a5b763c3a3e2bbc668a77a917939638feb691e08cb081805758360988ae
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Cas
- Objectif
- Distinguish JSON.dump Marshal-compatible default options and argument dispatch from JSON.generate strict limits HOW
- Paquets
- json 2.9.1
- Environnement
- ruby
- Créé
- 2026-08-17T02:43:30Z
Ce que l'on suppose souvent
JSON.dump is a direct alias for JSON.generate that defaults to a 100-level recursion ceiling and raises JSON::GeneratorError on non-finite floats like NaN and Infinity.
L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.
Contrat
- JSON.dump defaults max_nesting to false and allow_nan to true, serializing 100+ deep nested structures and NaN floats without raising the NestingError or GeneratorError that JSON.generate enforces
- assert JSON.dump routes a non-IO integer passed as its second argument to the nesting limit and returns a String, whereas passing an IO stream writes to the stream and returns the IO instance itself
- assert exceeding the nesting limit in JSON.dump raises ArgumentError with exceed depth limit rather than JSON::NestingError
- assert passing unsupported generator keyword arguments to JSON.dump raises ArgumentError due to strict keyword filtering
Fichiers
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- src/dump_adapter.rb
- test/contract.rb
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-17 · ed25519:d91480838ac982c9