diff options
Diffstat (limited to 'test/psych/test_parser.rb')
-rw-r--r-- | test/psych/test_parser.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index 3604e7c985..c1e0abb89d 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -16,13 +16,13 @@ module Psych (Handler.instance_methods(true) - Object.instance_methods).each do |m| - class_eval %{ + class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{m} *args super @marks << @parser.mark if @parser @calls << [:#{m}, args] end - } + RUBY end end @@ -85,6 +85,8 @@ module Psych def test_line_numbers assert_equal 0, @parser.mark.line + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + @parser.parse "---\n- hello\n- world" line_calls = @handler.marks.map(&:line).zip(@handler.calls.map(&:first)) assert_equal [ @@ -110,6 +112,8 @@ module Psych def test_column_numbers assert_equal 0, @parser.mark.column + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + @parser.parse "---\n- hello\n- world" col_calls = @handler.marks.map(&:column).zip(@handler.calls.map(&:first)) assert_equal [ @@ -135,6 +139,8 @@ module Psych def test_index_numbers assert_equal 0, @parser.mark.index + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + @parser.parse "---\n- hello\n- world" idx_calls = @handler.marks.map(&:index).zip(@handler.calls.map(&:first)) assert_equal [ @@ -352,6 +358,8 @@ module Psych end def test_event_location + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + @parser.parse "foo:\n" \ " barbaz: [1, 2]" @@ -376,6 +384,25 @@ module Psych [: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| |