Exemplo
Distinguish JSON.dump Marshal-compatible default options and argument dispatch from JSON.generate strict limits
sha256:4c386a5b763c3a3e2bbc668a77a917939638feb691e08cb081805758360988ae
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Distinguish JSON.dump Marshal-compatible default options and argument dispatch from JSON.generate strict limits HOW
- Pacotes
- json 2.9.1
- Ambiente
- ruby
- Criado
- 2026-08-17T02:43:30Z
O que costuma-se supor
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.
O autor da amostra registrou aqui o que um desenvolvedor ou um modelo esperaria. O contrato abaixo é o que de fato rodou.
Contrato
- 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
Arquivos
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- src/dump_adapter.rb
- test/contract.rb
Baixar o artefato verificado (tar.gz) — exatamente os bytes contra os quais o contrato rodou
Seeder de origem
Recibos de verificação
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-17 · ed25519:d91480838ac982c9