summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_string.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index cffc121..c7d5c60 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -2,6 +2,31 @@ require 'psych/helper'
module Psych
class TestString < TestCase
+ class X < String
+ end
+
+ class Y < String
+ attr_accessor :val
+ end
+
+ def test_backwards_with_syck
+ x = Psych.load "--- !str:#{X.name} foo\n\n"
+ assert_equal X, x.class
+ assert_equal 'foo', x
+ end
+
+ def test_empty_subclass
+ assert_match "!ruby/string:#{X}", Psych.dump(X.new)
+ x = Psych.load Psych.dump X.new
+ assert_equal X, x.class
+ end
+
+ def test_subclass_with_attributes
+ y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1}
+ assert_equal Y, y.class
+ assert_equal 1, y.val
+ end
+
def test_string_with_base_60
yaml = Psych.dump '01:03:05'
assert_match "'01:03:05'", yaml