From 8dd3a4af668cd92245af86206371d3d2e9619571 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Sat, 22 Jan 2011 01:26:40 +0000 Subject: * ext/psych/parser.c (parse): add the file name to the exception when parse errors occur. * test/psych/test_parser.rb: test for parse error file name git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/psych/test_parser.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/psych/test_parser.rb') diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index ca69b1a1e3..a60a0c6d86 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -138,6 +138,23 @@ module Psych end end + def test_syntax_error_has_path_for_string + e = assert_raises(Psych::SyntaxError) do + @parser.parse("---\n\"foo\"\n\"bar\"\n") + end + assert_match '():', e.message + end + + def test_syntax_error_has_path_for_io + io = StringIO.new "---\n\"foo\"\n\"bar\"\n" + def io.path; "hello!"; end + + e = assert_raises(Psych::SyntaxError) do + @parser.parse(io) + end + assert_match "(#{io.path}):", e.message + end + def test_mapping_end @parser.parse("---\n!!map { key: value }") assert_called :end_mapping -- cgit v1.2.3