Skip to content

Commit

Permalink
Add test for code_point_limit
Browse files Browse the repository at this point in the history
Only supported on JRuby currently.
  • Loading branch information
headius committed Sep 18, 2023
1 parent fb97d89 commit 0c1754e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/psych/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,25 @@ def test_event_location
[:end_stream, [2, 0, 2, 0]]], events
end

if Psych::Parser.method_defined?(:code_point_limit)
def test_code_point_limit
yaml = "foo: bar\n" * 500_000
assert_raise(org.snakeyaml.engine.v2.exceptions.YamlEngineException) do
Psych.load(yaml)
end

assert_nothing_raised do
begin
old_code_point_limit, Psych::Parser.code_point_limit = Psych::Parser::code_point_limit, 5_000_000

Psych.load(yaml)
ensure
Psych::Parser.code_point_limit = old_code_point_limit
end
end
end
end

def assert_called call, with = nil, parser = @parser
if with
call = parser.handler.calls.find { |x|
Expand Down

0 comments on commit 0c1754e

Please sign in to comment.