Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON failures with Ruby 3.1 / Psych 4.0 #72

Closed
voxik opened this issue Mar 11, 2022 · 0 comments · Fixed by #74
Closed

JSON failures with Ruby 3.1 / Psych 4.0 #72

voxik opened this issue Mar 11, 2022 · 0 comments · Fixed by #74

Comments

@voxik
Copy link
Contributor

voxik commented Mar 11, 2022

Testing with Ruby 3.1 / Psych 4.0, I observe a lot of test failures:

$ ruby -Ilib:test -e 'Dir.glob "./test/**/json_test.rb", &method(:require)'
Run options: --seed 18403

# Running:

EEEEEEEEEEEEEEEEEEE.EEEEEEEEEEEEEEEEEEEE

Finished in 0.476219s, 83.9950 runs/s, 2.0999 assertions/s.

  1) Error:
JSON Parsing#test_0017_decode json ({"bio": "1985-01-29: birthdate"}):
Crack::ParseError: Invalid JSON string
    /builddir/build/BUILD/crack-0.4.5/usr/share/gems/gems/crack-0.4.5/lib/crack/json.rb:19:in `rescue in parse'
    /builddir/build/BUILD/crack-0.4.5/usr/share/gems/gems/crack-0.4.5/lib/crack/json.rb:15:in `parse'
    /builddir/build/BUILD/crack-0.4.5/usr/share/gems/gems/crack-0.4.5/test/json_test.rb:50:in `block (3 levels) in <top (required)>'

... snip ...

 39) Error:
JSON Parsing#test_0002_decode json ({"html": "\u003Cdiv\u003E"}):
Crack::ParseError: Invalid JSON string
    /builddir/build/BUILD/crack-0.4.5/usr/share/gems/gems/crack-0.4.5/lib/crack/json.rb:19:in `rescue in parse'
    /builddir/build/BUILD/crack-0.4.5/usr/share/gems/gems/crack-0.4.5/lib/crack/json.rb:15:in `parse'
    /builddir/build/BUILD/crack-0.4.5/usr/share/gems/gems/crack-0.4.5/test/json_test.rb:50:in `block (3 levels) in <top (required)>'

40 runs, 1 assertions, 0 failures, 39 errors, 0 skips

And I wonder, these days, what is the reason for converting JSON to YAML? Wouldn't it be better to replace all these by JSON.parser?

voxik added a commit to voxik/crack that referenced this issue Mar 11, 2022
This is available since Psych 3.1 [[1], [2]], but mandatory since Psych
4.0 [[3]].

Fixes jnunemaker#72

[1]: ruby/psych#358
[2]: ruby/psych#378
[3]: ruby/psych@0767227
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant