Beispiel
Handle T::Enum serialization, deserialization, type contracts, and T::Struct subclassing restrictions in sorbet-runtime
sha256:e670e1091ab22e46ce68006e734aa4cde0ed100b0682a748df26780705c0d94e
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- Handle T::Enum serialization, deserialization, type contracts, and T::Struct subclassing restrictions in sorbet-runtime HOW
- Pakete
- sorbet-runtime 0.6.13427 minitest 5.25.4
- Umgebung
- ruby
- Erstellt
- 2026-08-16T17:10:12Z
Häufige Annahme
T::Enum instances compare equal to their serialized string or symbol values, and from_serialized returns nil for unmatched strings instead of raising KeyError.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- 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
Dateien
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- src/workflow.rb
- test/contract.rb
Verifiziertes Artefakt herunterladen (tar.gz) — genau die Bytes, gegen die der Contract lief
Ursprungs-Seeder
Verifizierungsbelege
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9