From f38fde68de8b4915fb610eb34503890f10ebaa4d Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 5 Nov 2024 09:52:17 +0100 Subject: [PATCH] Fix some warnings in the test suite --- test/json/json_parser_test.rb | 116 +++++++++++++++++----------------- test/json/test_helper.rb | 4 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb index 9c9b4442..9cbaa42f 100644 --- a/test/json/json_parser_test.rb +++ b/test/json/json_parser_test.rb @@ -210,64 +210,64 @@ def test_parse_arrays_with_allow_trailing_comma end def test_parse_object_with_allow_trailing_comma - assert_equal({}, parse('{}', allow_trailing_comma: true)) - assert_equal({}, parse('{}', allow_trailing_comma: false)) - assert_raise(JSON::ParserError) { parse('{,}', allow_trailing_comma: true) } - assert_raise(JSON::ParserError) { parse('{,}', allow_trailing_comma: false) } - - assert_equal({'foo'=>'bar'}, parse('{"foo":"bar"}', allow_trailing_comma: true)) - assert_equal({'foo'=>'bar'}, parse('{"foo":"bar"}', allow_trailing_comma: false)) - assert_equal({'foo'=>'bar'}, parse('{"foo":"bar",}', allow_trailing_comma: true)) - assert_raise(JSON::ParserError) { parse('{"foo":"bar",}', allow_trailing_comma: false) } - - assert_equal( - {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, - parse('{"foo":"bar","baz":"qux","quux":"garply"}', allow_trailing_comma: true) - ) - assert_equal( - {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, - parse('{"foo":"bar","baz":"qux","quux":"garply"}', allow_trailing_comma: false) - ) - assert_equal( - {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, - parse('{"foo":"bar","baz":"qux","quux":"garply",}', allow_trailing_comma: true) - ) - assert_raise(JSON::ParserError) { - parse('{"foo":"bar","baz":"qux","quux":"garply",}', allow_trailing_comma: false) - } - - assert_equal( - {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, - parse('{ "foo":"bar" , "baz":"qux" , "quux":"garply" }', allow_trailing_comma: true) - ) - assert_equal( - {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, - parse('{ "foo":"bar" , "baz":"qux" , "quux":"garply" }', allow_trailing_comma: false) - ) - assert_equal( - {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, - parse('{ "foo":"bar" , "baz":"qux" , "quux":"garply" , }', allow_trailing_comma: true) - ) - assert_raise(JSON::ParserError) { - parse('{ "foo":"bar" , "baz":"qux" , "quux":"garply" , }', allow_trailing_comma: false) - } - - assert_equal( - [{'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}], - parse('[{"foo":"bar","baz":"qux","quux":"garply"}]', allow_trailing_comma: true) - ) - assert_equal( - [{'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}], - parse('[{"foo":"bar","baz":"qux","quux":"garply"}]', allow_trailing_comma: false) - ) - assert_equal( - [{'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}], - parse('[{"foo":"bar","baz":"qux","quux":"garply",}]', allow_trailing_comma: true) - ) - assert_raise(JSON::ParserError) { - parse('[{"foo":"bar","baz":"qux","quux":"garply",}]', allow_trailing_comma: false) - } - end + assert_equal({}, parse('{}', allow_trailing_comma: true)) + assert_equal({}, parse('{}', allow_trailing_comma: false)) + assert_raise(JSON::ParserError) { parse('{,}', allow_trailing_comma: true) } + assert_raise(JSON::ParserError) { parse('{,}', allow_trailing_comma: false) } + + assert_equal({'foo'=>'bar'}, parse('{"foo":"bar"}', allow_trailing_comma: true)) + assert_equal({'foo'=>'bar'}, parse('{"foo":"bar"}', allow_trailing_comma: false)) + assert_equal({'foo'=>'bar'}, parse('{"foo":"bar",}', allow_trailing_comma: true)) + assert_raise(JSON::ParserError) { parse('{"foo":"bar",}', allow_trailing_comma: false) } + + assert_equal( + {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, + parse('{"foo":"bar","baz":"qux","quux":"garply"}', allow_trailing_comma: true) + ) + assert_equal( + {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, + parse('{"foo":"bar","baz":"qux","quux":"garply"}', allow_trailing_comma: false) + ) + assert_equal( + {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, + parse('{"foo":"bar","baz":"qux","quux":"garply",}', allow_trailing_comma: true) + ) + assert_raise(JSON::ParserError) { + parse('{"foo":"bar","baz":"qux","quux":"garply",}', allow_trailing_comma: false) + } + + assert_equal( + {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, + parse('{ "foo":"bar" , "baz":"qux" , "quux":"garply" }', allow_trailing_comma: true) + ) + assert_equal( + {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, + parse('{ "foo":"bar" , "baz":"qux" , "quux":"garply" }', allow_trailing_comma: false) + ) + assert_equal( + {'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}, + parse('{ "foo":"bar" , "baz":"qux" , "quux":"garply" , }', allow_trailing_comma: true) + ) + assert_raise(JSON::ParserError) { + parse('{ "foo":"bar" , "baz":"qux" , "quux":"garply" , }', allow_trailing_comma: false) + } + + assert_equal( + [{'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}], + parse('[{"foo":"bar","baz":"qux","quux":"garply"}]', allow_trailing_comma: true) + ) + assert_equal( + [{'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}], + parse('[{"foo":"bar","baz":"qux","quux":"garply"}]', allow_trailing_comma: false) + ) + assert_equal( + [{'foo'=>'bar', 'baz'=>'qux', 'quux'=>'garply'}], + parse('[{"foo":"bar","baz":"qux","quux":"garply",}]', allow_trailing_comma: true) + ) + assert_raise(JSON::ParserError) { + parse('[{"foo":"bar","baz":"qux","quux":"garply",}]', allow_trailing_comma: false) + } + end def test_parse_some_strings assert_equal([""], parse('[""]')) diff --git a/test/json/test_helper.rb b/test/json/test_helper.rb index 6fcb76ed..f81eeec1 100644 --- a/test/json/test_helper.rb +++ b/test/json/test_helper.rb @@ -23,8 +23,8 @@ # This method was added in Ruby 3.0.0. Calling it this way asks the GC to # move objects around, helping to find object movement bugs. begin - GC.verify_compaction_references(double_heap: true, toward: :empty) - rescue NotImplementedError + GC.verify_compaction_references(expand_heap: true, toward: :empty) + rescue NotImplementedError, ArgumentError # Some platforms don't support compaction end end