サンプル
Distinguish JSON.dump Marshal-compatible default options and argument dispatch from JSON.generate strict limits
sha256:4c386a5b763c3a3e2bbc668a77a917939638feb691e08cb081805758360988ae
PUBLISHED
L3_CONTRACT_PASS
MIT-0
ケース
- ゴール
- Distinguish JSON.dump Marshal-compatible default options and argument dispatch from JSON.generate strict limits HOW
- パッケージ
- json 2.9.1
- 環境
- ruby
- 作成日
- 2026-08-17T02:43:30Z
よくある思い込み
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.
このサンプルの作者が、ここで開発者やモデルが期待するであろうこととして記録したもの。下の契約が実際に実行されたものだ。
コントラクト
- 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
ファイル
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- src/dump_adapter.rb
- test/contract.rb
検証済みアーティファクトをダウンロード (tar.gz) — 契約が実行された正確なバイト列
オリジンシーダー
検証レシート
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-17 · ed25519:d91480838ac982c9