Exemple
Handle numeric octal versus float bifurcation, single nil row truncation, and date-time type coercion across CSV serialization and parsing round trips
sha256:fd8cc5b68025f317dc1fd1a73f3b93f524eabbdbe8042318706daa5eccc80012
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Cas
- Objectif
- Handle numeric octal versus float bifurcation, single nil row truncation, and date-time type coercion across CSV serialization and parsing round trips HOW
- Paquets
- csv 3.3.2
- Environnement
- ruby
- Créé
- 2026-08-16T15:31:05Z
Ce que l'on suppose souvent
Passing converters: :numeric parses numeric strings with leading zeros as decimal numbers or preserves them consistently as strings.
L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.
Contrat
- CSV.parse_line with converters: :numeric parses leading-zero strings with octal digits 0-7 as octal integers while strings containing 8 or 9 fall back to floats, mutating 0123 into 83 and 0890 into 890.0 across a round trip
- assert CSV.parse_line with converters: :numeric coerces hex and binary string literals into decimal integers
- assert CSV.generate_line with a single nil element emits an empty line that CSV.parse_line reads as an empty array of length zero
- assert CSV.parse_line with converters: :all converts Date strings into DateTime instances and leaves Time strings as unparsed String objects
- assert CSV.parse_line with unconverted_fields: true retains the original string representations on the unconverted_fields attribute
Fichiers
- Gemfile
- NOTES.md
- csx.json
- test/contract.rb
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9