summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-06 03:06:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-06 03:06:11 +0000
commitacc55c25c587fef5c7327c5912f3aa50a969ec34 (patch)
treec8a1bcb549bc6b3a251a3d2c865c17ec1385acd8 /test
parentc31e7c1e8b2895ef33204938487597e2b3acaaf7 (diff)
merge revision(s) 34919:
* lib/yaml/rubytypes.rb (Exception.yaml_new): fix bug that causes YAML serialization problem for Exception. Exception#initialize doesn't use visible instance variable for the exception message, so call the method with the message. patched by Jingwen Owen Ou <jingweno AT gmail.com>. http://github.com/ruby/ruby/pull/41 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@34920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/yaml/test_exception.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/yaml/test_exception.rb b/test/yaml/test_exception.rb
new file mode 100644
index 0000000000..1dc3044a94
--- /dev/null
+++ b/test/yaml/test_exception.rb
@@ -0,0 +1,52 @@
+require 'test/unit'
+require 'yaml'
+
+module Syck
+ class TestException < Test::Unit::TestCase
+ class Wups < Exception
+ attr_reader :foo, :bar
+ def initialize *args
+ super
+ @foo = 1
+ @bar = 2
+ end
+
+ def ==(other)
+ self.class == other.class and
+ self.message == other.message and
+ self.backtrace == other.backtrace
+ end
+ end
+
+ def setup
+ @wups = Wups.new('test_message')
+ end
+
+ def test_to_yaml
+ w = YAML.load(@wups.to_yaml)
+ assert_equal @wups, w
+ assert_equal 1, w.foo
+ assert_equal 2, w.bar
+ end
+
+ def test_dump
+ w = YAML.load(@wups.to_yaml)
+ assert_equal @wups, w
+ assert_equal 1, w.foo
+ assert_equal 2, w.bar
+ end
+
+ def test_to_yaml_properties
+ class << @wups
+ def to_yaml_properties
+ [:@foo]
+ end
+ end
+
+ w = YAML.load(YAML.dump(@wups))
+ assert_equal @wups, w
+ assert_equal 1, w.foo
+ assert_nil w.bar
+ end
+ end
+end