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::Parser does not expose #quirks_mode? #4282

Closed
headius opened this issue Nov 14, 2016 · 2 comments
Closed

JSON::Parser does not expose #quirks_mode? #4282

headius opened this issue Nov 14, 2016 · 2 comments

Comments

@headius
Copy link
Member

headius commented Nov 14, 2016

Environment

JRuby master running updated Ruby 2.3 tests.

Expected Behavior

The following test was added to MRI's json tests at some point:

  def test_parse_json_primitive_values
    assert_raise(JSON::ParserError) { JSON.parse('') }
    assert_raise(JSON::ParserError) { JSON.parse('', :quirks_mode => true) }
    assert_raise(TypeError) { JSON::Parser.new(nil).parse }
    assert_raise(TypeError) { JSON::Parser.new(nil, :quirks_mode => true).parse }
    assert_raise(TypeError) { JSON.parse(nil) }
    assert_raise(TypeError) { JSON.parse(nil, :quirks_mode => true) }
    assert_raise(JSON::ParserError) { JSON.parse('  /* foo */ ') }
    assert_raise(JSON::ParserError) { JSON.parse('  /* foo */ ', :quirks_mode => true) }
    parser = JSON::Parser.new('null')
    assert_equal false, parser.quirks_mode?
    assert_raise(JSON::ParserError) { parser.parse }
    assert_raise(JSON::ParserError) { JSON.parse('null') }
    assert_equal nil, JSON.parse('null', :quirks_mode => true)
    parser = JSON::Parser.new('null', :quirks_mode => true)
    assert_equal true, parser.quirks_mode?
    assert_equal nil, parser.parse
    assert_raise(JSON::ParserError) { JSON.parse('false') }
    assert_equal false, JSON.parse('false', :quirks_mode => true)
    assert_raise(JSON::ParserError) { JSON.parse('true') }
    assert_equal true, JSON.parse('true', :quirks_mode => true)
    assert_raise(JSON::ParserError) { JSON.parse('23') }
    assert_equal 23, JSON.parse('23', :quirks_mode => true)
    assert_raise(JSON::ParserError) { JSON.parse('1') }
    assert_equal 1, JSON.parse('1', :quirks_mode => true)
    assert_raise(JSON::ParserError) { JSON.parse('3.141') }
    assert_in_delta 3.141, JSON.parse('3.141', :quirks_mode => true), 1E-3
    assert_raise(JSON::ParserError) { JSON.parse('18446744073709551616') }
    assert_equal 2 ** 64, JSON.parse('18446744073709551616', :quirks_mode => true)
    assert_raise(JSON::ParserError) { JSON.parse('"foo"') }
    assert_equal 'foo', JSON.parse('"foo"', :quirks_mode => true)
    assert_raise(JSON::ParserError) { JSON.parse('NaN', :allow_nan => true) }
    assert JSON.parse('NaN', :quirks_mode => true, :allow_nan => true).nan?
    assert_raise(JSON::ParserError) { JSON.parse('Infinity', :allow_nan => true) }
    assert JSON.parse('Infinity', :quirks_mode => true, :allow_nan => true).infinite?
    assert_raise(JSON::ParserError) { JSON.parse('-Infinity', :allow_nan => true) }
    assert JSON.parse('-Infinity', :quirks_mode => true, :allow_nan => true).infinite?
    assert_raise(JSON::ParserError) { JSON.parse('[ 1, ]', :quirks_mode => true) }
  end

Actual Behavior

The test fails because we do not expose a quirks_mode? accessor in our json.

@headius
Copy link
Member Author

headius commented Dec 13, 2016

Copy @flori since he still maintains the json library.

@headius
Copy link
Member Author

headius commented May 15, 2018

Quirks mode no longer appears to exist in json or its tests.

flori/json@7d2ad6d

@headius headius closed this as completed May 15, 2018
@headius headius modified the milestones: JRuby 9.2.0.0, Won't Fix May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant