Skip to content

Commit

Permalink
Merge pull request ruby#681 from casperisfine/fix-warnings
Browse files Browse the repository at this point in the history
Fix some warnings in the test suite
  • Loading branch information
byroot authored Nov 5, 2024
2 parents 5ce7142 + f38fde6 commit dcd8292
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 60 deletions.
116 changes: 58 additions & 58 deletions test/json/json_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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('[""]'))
Expand Down
4 changes: 2 additions & 2 deletions test/json/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dcd8292

Please sign in to comment.