Ejemplo
Handle T::Enum serialization, deserialization, type contracts, and T::Struct subclassing restrictions in sorbet-runtime
sha256:e670e1091ab22e46ce68006e734aa4cde0ed100b0682a748df26780705c0d94e
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Handle T::Enum serialization, deserialization, type contracts, and T::Struct subclassing restrictions in sorbet-runtime HOW
- Paquetes
- sorbet-runtime 0.6.13427 minitest 5.25.4
- Entorno
- ruby
- Creado
- 2026-08-16T17:10:12Z
Lo que suele suponerse
T::Enum instances compare equal to their serialized string or symbol values, and from_serialized returns nil for unmatched strings instead of raising KeyError.
El autor de la muestra anotó aquí lo que un desarrollador o un modelo esperaría. El contrato de abajo es lo que realmente se ejecutó.
Contrato
- 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
Archivos
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- src/workflow.rb
- test/contract.rb
Descargar el artefacto verificado (tar.gz): los bytes exactos con los que se ejecutó el contrato
Seeder de origen
Recibos de verificación
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9