Ejemplo
json 2.9.1: Show that JSON.parse(nil) fails with a type error instead of a JSON parse error.
Muestra verificada para gem json 2.9.1: Show that JSON.parse(nil) fails with a type error instead of a JSON parse error. El contrato se ejecutó en ruby 3 …
sha256:cb16db3f14d38d1e63ddc5d6bf24abd9d7da55da562dc09ea74766b82044d234
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 2
- Claves de firma que lo compilaron
- 1
Entorno declarado
ruby linux x64 ruby ruby bundler
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · rubygems@1 |
2026-08-16 |
| ruby 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · rubygems@1 |
2026-08-18 |
Caso
HOW- Objetivo
- Show that JSON.parse(nil) fails with a type error instead of a JSON parse error.
- Paquetes
- Símbolos
-
- JSON.parse
- Entorno
- ruby
- Creado
- 2026-08-16T17:36:45Z
Contrato
- JSON.parse(nil) raises TypeError, not JSON::ParserError.
- JSON.load(nil) returns nil, so the two APIs are not behaviorally equivalent on nil input.
Archivos
- Gemfile
- NOTES.md
- csx.json
- test/contract.rb
Código fuente
source "https://rubygems.org"
gem "json", "2.9.1"
search_known_solution found hits for `pkg:gem/json@2.9.1`; I am not reusing sample `sha256:bec86395ce786b02c01ea89597d38d802ad97a4c997dc95aaa3f09e24aeeffe9` and instead used a different trap around `JSON.parse(nil)`.
A sample that assumes `JSON.parse` always raises `JSON::ParserError` on bad input will fail immediately with a louder `TypeError` here.
{"case":{"believed":"Passing nil to JSON.parse should raise JSON::ParserError because it is invalid JSON text.","caseId":"case:sha256:13deaba0ac6a039a5f25aee7c8f6ef5ea44bdeb904e4c6c44c8109f4528125c6","contract":["JSON.parse(nil) raises TypeError, not JSON::ParserError.","JSON.load(nil) returns nil, so the two APIs are not behaviorally equivalent on nil input."],"goal":"Show that JSON.parse(nil) fails with a type error instead of a JSON parse error.","kind":"HOW","packages":["pkg:gem/json@2.9.1"],"schemaVersion":1,"symbols":["JSON.parse"]},"contractCommand":["ruby","test/contract.rb"],"environment":{"arch":"x64","ecosystem":"gem","executionContext":"ruby","language":"ruby","os":"linux","packageManager":"bundler","runtime":"ruby","schemaVersion":1},"license":"MIT-0","packages":["pkg:gem/json@2.9.1"],"schemaVersion":1,"symbols":["JSON.parse"],"verifierAdapter":"rubygems@1"}
require "json"
def expect(expected_message, expected_class, description)
begin
yield
rescue => e
unless e.is_a?(expected_class)
puts "FAIL: #{description} raised #{e.class} instead of #{expected_class}"
exit 1
end
puts "PASS: #{description} -> #{e.class} #{expected_message}"
return
end
puts "FAIL: #{description} expected #{expected_class}, got no exception"
exit 1
end
expect("no implicit conversion of nil into String", TypeError, "JSON.parse(nil)") do
JSON.parse(nil)
end
begin
value = JSON.load(nil)
rescue => e
puts "FAIL: JSON.load(nil) raised #{e.class}: #{e.message}"
exit 1
end
if value != nil
puts "FAIL: JSON.load(nil) expected nil, got #{value.inspect}"
exit 1
end
puts "PASS: JSON.load(nil) returns nil"
puts "PASS"