summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-04 17:53:41 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-04 17:53:41 +0000
commit137c547c3ef8167630170275ba2ae5a14fa0af95 (patch)
tree6faa8acdcfe3ac9f79b33cca6b9e5971903ace9e /test/psych
parent77e58a3398cde8a0e9b0cb07ffe20e6137efe41c (diff)
* ext/psych/lib/psych/syntax_error.rb: Add file, line, offset, and
message attributes during parse failure. * ext/psych/parser.c: Update parser to raise exception with correct values. * test/psych/test_exception.rb: corresponding tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/test_exception.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/psych/test_exception.rb b/test/psych/test_exception.rb
index 806c5e2641..5530a69626 100644
--- a/test/psych/test_exception.rb
+++ b/test/psych/test_exception.rb
@@ -16,6 +16,21 @@ module Psych
@wups = Wups.new
end
+ def test_attributes
+ e = assert_raises(Psych::SyntaxError) {
+ Psych.load '--- `foo'
+ }
+
+ assert_equal '<unknown>', e.file
+ assert_equal 1, e.line
+ assert_equal 5, e.column
+ # FIXME: offset isn't being set correctly by libyaml
+ # assert_equal 5, e.offset
+
+ assert e.problem
+ assert e.context
+ end
+
def test_convert
w = Psych.load(Psych.dump(@wups))
assert_equal @wups, w