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

* ext/psych/parser.c: just get the constant defined in Ruby.

* ext/psych/lib/psych/syntax_error.rb: Psych::SyntaxError now inherits
  from StandardError rather than SyntaxError.  Thanks Eric Hodel!

* test/psych/test_exception.rb: tests for change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2012-10-22 21:25:02 +00:00
parent 6c6d4568e8
commit 3c73f44c7f
4 changed files with 35 additions and 2 deletions

View file

@ -1,3 +1,12 @@
Tue Oct 23 06:21:05 2012 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/parser.c: just get the constant defined in Ruby.
* ext/psych/lib/psych/syntax_error.rb: Psych::SyntaxError now inherits
from StandardError rather than SyntaxError. Thanks Eric Hodel!
* test/psych/test_exception.rb: tests for change.
Tue Oct 23 06:17:36 2012 Aaron Patterson <aaron@tenderlovemaking.com> Tue Oct 23 06:17:36 2012 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/scalar_scanner.rb: Cache symbols while * ext/psych/lib/psych/scalar_scanner.rb: Cache symbols while

View file

@ -1,5 +1,8 @@
module Psych module Psych
class SyntaxError < ::SyntaxError class Error < RuntimeError
end
class SyntaxError < Error
attr_reader :file, :line, :column, :offset, :problem, :context attr_reader :file, :line, :column, :offset, :problem, :context
def initialize file, line, col, offset, problem, context def initialize file, line, col, offset, problem, context

View file

@ -557,7 +557,7 @@ void Init_psych_parser()
rb_define_const(cPsychParser, "UTF16BE", INT2NUM(YAML_UTF16BE_ENCODING)); rb_define_const(cPsychParser, "UTF16BE", INT2NUM(YAML_UTF16BE_ENCODING));
rb_require("psych/syntax_error"); rb_require("psych/syntax_error");
ePsychSyntaxError = rb_define_class_under(mPsych, "SyntaxError", rb_eSyntaxError); ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
rb_define_method(cPsychParser, "parse", parse, -1); rb_define_method(cPsychParser, "parse", parse, -1);
rb_define_method(cPsychParser, "mark", mark, 0); rb_define_method(cPsychParser, "mark", mark, 0);

View file

@ -126,5 +126,26 @@ module Psych
assert_equal 1, w.foo assert_equal 1, w.foo
assert_nil w.bar assert_nil w.bar
end end
def test_psych_syntax_error
Tempfile.open(['parsefile', 'yml']) do |t|
t.binmode
t.write '--- `'
t.close
begin
Psych.parse_file t.path
rescue StandardError
assert true # count assertion
ensure
return unless $!
ancestors = $!.class.ancestors.inspect
flunk "Psych::SyntaxError not rescued by StandardError: #{ancestors}"
end
end
end
end end
end end