Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (35 sloc) 0.786 kb
b453745 @tenderlove sync with ruby trunk
authored
1 require_relative 'helper'
b79d64d @tenderlove classes can be emitted as scalar and map
authored
2
2195fb1 @tenderlove moving tests under the psych directory
authored
3 module Psych
b79d64d @tenderlove classes can be emitted as scalar and map
authored
4 class Tagged
5 yaml_tag '!foo'
6
7 attr_accessor :baz
8
9 def initialize
10 @baz = 'bar'
11 end
12 end
13
478a7ac @tenderlove fixing cyclic object reference handling. Thanks to @CvX for the test. f...
authored
14 class Foo
15 attr_accessor :parent
16
17 def initialize parent
18 @parent = parent
19 end
20 end
21
47c4176 @tenderlove adding a test helper superclass
authored
22 class TestObject < TestCase
b79d64d @tenderlove classes can be emitted as scalar and map
authored
23 def test_dump_with_tag
24 tag = Tagged.new
25 assert_match('foo', Psych.dump(tag))
26 end
27
28 def test_tag_round_trip
29 tag = Tagged.new
30 tag2 = Psych.load(Psych.dump(tag))
31 assert_equal tag.baz, tag2.baz
32 assert_instance_of(Tagged, tag2)
33 end
478a7ac @tenderlove fixing cyclic object reference handling. Thanks to @CvX for the test. f...
authored
34
35 def test_cyclic_references
36 foo = Foo.new(nil)
37 foo.parent = foo
38 loaded = Psych.load Psych.dump foo
39
40 assert_instance_of(Foo, loaded)
41 assert_equal loaded, loaded.parent
42 end
b79d64d @tenderlove classes can be emitted as scalar and map
authored
43 end
44 end
Something went wrong with that request. Please try again.