mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/psych/parser.c (parse): fix assertion error when reusing a
parser after an exception has been raised * test/psych/test_parser.rb: test for assertion error git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
960720ef4f
commit
0331314d27
3 changed files with 20 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
|||
Sat Jan 22 10:12:30 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* ext/psych/parser.c (parse): fix assertion error when reusing a
|
||||
parser after an exception has been raised
|
||||
|
||||
* test/psych/test_parser.rb: test for assertion error
|
||||
|
||||
Sat Jan 22 04:09:22 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* ext/psych/lib/psych/nodes/node.rb: Make Psych::Nodes::Node
|
||||
|
|
|
@ -96,6 +96,9 @@ static VALUE parse(VALUE self, VALUE yaml)
|
|||
size_t line = parser->mark.line;
|
||||
size_t column = parser->mark.column;
|
||||
|
||||
yaml_parser_delete(parser);
|
||||
yaml_parser_initialize(parser);
|
||||
|
||||
rb_raise(ePsychSyntaxError, "couldn't parse YAML at line %d column %d",
|
||||
(int)line, (int)column);
|
||||
}
|
||||
|
|
|
@ -128,6 +128,16 @@ module Psych
|
|||
end
|
||||
end
|
||||
|
||||
def test_syntax_error_twice
|
||||
assert_raises(Psych::SyntaxError) do
|
||||
@parser.parse("---\n\"foo\"\n\"bar\"\n")
|
||||
end
|
||||
|
||||
assert_raises(Psych::SyntaxError) do
|
||||
@parser.parse("---\n\"foo\"\n\"bar\"\n")
|
||||
end
|
||||
end
|
||||
|
||||
def test_mapping_end
|
||||
@parser.parse("---\n!!map { key: value }")
|
||||
assert_called :end_mapping
|
||||
|
|
Loading…
Reference in a new issue