Permalink
Browse files

Testing custom character-based class.

  • Loading branch information...
1 parent 6a3ac11 commit dc9190ec2dc3db43aa991bf6d6db9ebe41c2432f @pck pck committed Jan 6, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 test/psych/test_string.rb
View
@@ -9,6 +9,12 @@ class Y < String
attr_accessor :val
end
+ class Z < String
+ def initialize
+ force_encoding Encoding::US_ASCII
+ end
+ end
+
def test_another_subclass_with_attributes
y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1}
assert_equal "foo", y
@@ -28,6 +34,12 @@ def test_empty_subclass
assert_equal X, x.class
end
+ def test_empty_character_subclass
+ assert_match "!ruby/string:#{Z}", Psych.dump(Z.new)
+ x = Psych.load Psych.dump Z.new
+ assert_equal Z, 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

0 comments on commit dc9190e

Please sign in to comment.