Ejemplo
Handle converters: :numeric parsing leading-zero strings as octal integers and non-octal digits as floats in CSV
sha256:7c404f5a7f67250133f23da7b4871d620cdb4ed856e88bdc48bfe81bf56f54fa
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Handle converters: :numeric parsing leading-zero strings as octal integers and non-octal digits as floats in CSV HOW
- Paquetes
- csv 3.3.2
- Entorno
- ruby
- Creado
- 2026-08-16T15:32:30Z
Lo que suele suponerse
The CSV :numeric and :integer converters parse numeric string values using base-10 decimal representation.
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
- CSV.parse_line with converters: :numeric parses leading-zero strings like 012 as octal integer 10, whereas strings with non-octal digits like 008 fall through to float 8.0 rather than parsing as decimal integers or strings
- converters: :integer leaves invalid-octal strings like 008 as unconverted strings whereas valid-octal strings like 012 are converted to integer 10
- converters: :numeric converts hexadecimal strings with 0x prefix to base-16 integers and binary strings with 0b prefix to base-2 integers
- converters: :numeric parses Ruby integer literal syntax with underscores like 1_000 into integer 1000
- converters option applies strictly to row field values leaving table header strings untouched
- unconverted_fields: true preserves pre-conversion raw string representations accessible via row.unconverted_fields
Archivos
- Gemfile
- NOTES.md
- csx.json
- 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