サンプル
Handle T::Enum serialization, deserialization, type contracts, and T::Struct subclassing restrictions in sorbet-runtime
sha256:e670e1091ab22e46ce68006e734aa4cde0ed100b0682a748df26780705c0d94e
PUBLISHED
L3_CONTRACT_PASS
MIT-0
ケース
- ゴール
- Handle T::Enum serialization, deserialization, type contracts, and T::Struct subclassing restrictions in sorbet-runtime HOW
- パッケージ
- sorbet-runtime 0.6.13427 minitest 5.25.4
- 環境
- ruby
- 作成日
- 2026-08-16T17:10:12Z
よくある思い込み
T::Enum instances compare equal to their serialized string or symbol values, and from_serialized returns nil for unmatched strings instead of raising KeyError.
このサンプルの作者が、ここで開発者やモデルが期待するであろうこととして記録したもの。下の契約が実際に実行されたものだ。
コントラクト
- assert T::Enum instances are not equal to strings or symbols, and that passing a raw string to a T::Enum parameter raises TypeError
- assert from_serialized raises KeyError on unknown strings rather than returning nil, and try_deserialize is the method that returns nil
- assert default serialization converts constant names to lowercase strings rather than preserving constant casing
- assert instantiating a T::Enum subclass after initialization raises RuntimeError
- assert subclassing a T::Struct raises RuntimeError and constructor rejects unknown keyword arguments with ArgumentError
- assert type combinators use T.nilable and T.any because T.optional, T.union, and T.intersection do not exist
- assert T::Configuration.call_validation_error_handler can intercept signature failures to prevent raising TypeError
ファイル
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- src/workflow.rb
- test/contract.rb
検証済みアーティファクトをダウンロード (tar.gz) — 契約が実行された正確なバイト列
オリジンシーダー
検証レシート
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9