Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Testing custom character-based class.
  • Loading branch information
pck committed Jan 6, 2013
1 parent 6a3ac11 commit dc9190e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/psych/test_string.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit dc9190e

Please sign in to comment.