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.rb: define a new BadAlias error class.

* ext/psych/lib/psych/visitors/to_ruby.rb: raise an exception when
  deserializing an alias that does not exist.
* test/psych/test_merge_keys.rb: corresponding test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2011-07-18 04:38:37 +00:00
parent d95cb16234
commit dc22968239
4 changed files with 22 additions and 1 deletions

View file

@ -1,3 +1,12 @@
Mon Jul 18 13:36:47 2011 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych.rb: define a new BadAlias error class.
* ext/psych/lib/psych/visitors/to_ruby.rb: raise an exception when
deserializing an alias that does not exist.
* test/psych/test_merge_keys.rb: corresponding test.
Mon Jul 18 00:00:46 2011 Shugo Maeda <shugo@ruby-lang.org>
* ext/curses/curses.c: added the new class Curses::Pad, which

View file

@ -98,6 +98,9 @@ module Psych
class Exception < RuntimeError
end
class BadAlias < Exception
end
autoload :Stream, 'psych/stream'
###

View file

@ -201,7 +201,7 @@ module Psych
end
def visit_Psych_Nodes_Alias o
@st[o.anchor]
@st.fetch(o.anchor) { raise BadAlias, "Unknown alias: #{o.anchor}" }
end
private

View file

@ -2,6 +2,15 @@ require 'psych/helper'
module Psych
class TestMergeKeys < TestCase
def test_missing_merge_key
yaml = <<-eoyml
bar:
<< : *foo
eoyml
exp = assert_raises(Psych::BadAlias) { Psych.load yaml }
assert_match 'foo', exp.message
end
# [ruby-core:34679]
def test_merge_key
yaml = <<-eoyml