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

CI: Fix failures with Ruby 3.5-dev #957

Merged
merged 2 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions test/json_gem/json_ext_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@ class JSONExtParserTest < Test::Unit::TestCase
include Test::Unit::TestCaseOmissionSupport

if defined?(JSON::Ext::Parser)
def test_allocate
parser = JSON::Ext::Parser.new("{}")
assert_raise(TypeError, '[ruby-core:35079]') do
if REAL_JSON_GEM && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.5.0')
def test_allocate
parser = JSON::Ext::Parser.new("{}")
parser.__send__(:initialize, "{}")
assert_equal "{}", parser.source

parser = JSON::Ext::Parser.allocate
assert_nil parser.source
end
else
# Ruby 3.4.x or before
def test_allocate
parser = JSON::Ext::Parser.new("{}")
assert_raise(TypeError, '[ruby-core:35079]') do
parser.__send__(:initialize, "{}")
end
parser = JSON::Ext::Parser.allocate
assert_raise(TypeError, '[ruby-core:35079]') { parser.source }
end
parser = JSON::Ext::Parser.allocate
assert_raise(TypeError, '[ruby-core:35079]') { parser.source }
end
end
end
30 changes: 24 additions & 6 deletions test/json_gem/json_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def test_pretty_state
actual.delete(:escape_slash)
actual.delete(:strict)
actual.delete(:script_safe)
assert_equal({

expected = {
:allow_nan => false,
:array_nl => "\n",
:ascii_only => false,
Expand All @@ -155,7 +156,12 @@ def test_pretty_state
:object_nl => "\n",
:space => " ",
:space_before => "",
}.sort_by { |n,| n.to_s }, actual.sort_by { |n,| n.to_s })
}
if REAL_JSON_GEM && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.5.0')
expected[:as_json] = false
end

assert_equal(expected.sort_by { |n,| n.to_s }, actual.sort_by { |n,| n.to_s })
end

def test_safe_state
Expand All @@ -166,7 +172,8 @@ def test_safe_state
actual.delete(:escape_slash)
actual.delete(:strict)
actual.delete(:script_safe)
assert_equal({

expected = {
:allow_nan => false,
:array_nl => "",
:ascii_only => false,
Expand All @@ -177,7 +184,12 @@ def test_safe_state
:object_nl => "",
:space => "",
:space_before => "",
}.sort_by { |n,| n.to_s }, actual.sort_by { |n,| n.to_s })
}
if REAL_JSON_GEM && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.5.0')
expected[:as_json] = false
end

assert_equal(expected.sort_by { |n,| n.to_s }, actual.sort_by { |n,| n.to_s })
end

def test_fast_state
Expand All @@ -188,7 +200,8 @@ def test_fast_state
actual.delete(:escape_slash)
actual.delete(:strict)
actual.delete(:script_safe)
assert_equal({

expected = {
:allow_nan => false,
:array_nl => "",
:ascii_only => false,
Expand All @@ -199,7 +212,12 @@ def test_fast_state
:object_nl => "",
:space => "",
:space_before => "",
}.sort_by { |n,| n.to_s }, actual.sort_by { |n,| n.to_s })
}
if REAL_JSON_GEM && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.5.0')
expected[:as_json] = false
end

assert_equal(expected.sort_by { |n,| n.to_s }, actual.sort_by { |n,| n.to_s })
end

def test_allow_nan
Expand Down