summaryrefslogtreecommitdiff
path: root/test/psych/test_parser.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-22 01:26:40 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-22 01:26:40 +0000
commit8dd3a4af668cd92245af86206371d3d2e9619571 (patch)
tree1f617dfc6f151f32528b463789b93645d74c487f /test/psych/test_parser.rb
parent0331314d278d0590ff26eb7ec156f859b590464f (diff)
* 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
Diffstat (limited to 'test/psych/test_parser.rb')
-rw-r--r--test/psych/test_parser.rb17
1 files changed, 17 insertions, 0 deletions
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 '(<unknown>):', 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