summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-01-17 19:53:44 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-01-17 19:53:44 -0800
commite2fcf9af9e95535401f816bc893839b9ad743a9e (patch)
tree2abd39ed9d2cc8ddf87113312f86bf09d7a8e7ba /test
parent59ecddb311265d4dc9e2ddec7122509c8526afc6 (diff)
downloadpsych-e2fcf9af9e95535401f816bc893839b9ad743a9e.zip
* ext/psych/lib/psych/visitors/to_ruby.rb: Added support for loading
subclasses of String with ivars * ext/psych/lib/psych/visitors/yaml_tree.rb: Added support for dumping subclasses of String with ivars * test/psych/test_string.rb: corresponding tests
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