1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
tenderlove 2011-10-04 17:53:41 +00:00
parent 77e58a3398
commit 137c547c3e
4 changed files with 62 additions and 6 deletions

View file

@ -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