1require 'psych/helper'
2require 'yaml'
3
4module Psych
5 class TestEngineManager < TestCase
6   def test_bad_engine
7     assert_raises(ArgumentError) do
8       YAML::ENGINE.yamler = 'foooo'
9     end
10   end
11
12   def test_set_psych
13     YAML::ENGINE.yamler = 'psych'
14     assert_equal Psych, YAML
15     assert_equal 'psych', YAML::ENGINE.yamler
16   end
17
18   A = Struct.new(:name)
19
20   def test_dump_types
21     YAML::ENGINE.yamler = 'psych'
22
23     assert_to_yaml ::Object.new
24     assert_to_yaml Time.now
25     assert_to_yaml Date.today
26     assert_to_yaml('a' => 'b')
27     assert_to_yaml A.new('foo')
28     assert_to_yaml %w{a b}
29     assert_to_yaml Exception.new('foo')
30     assert_to_yaml "hello!"
31     assert_to_yaml :fooo
32     assert_to_yaml(1..10)
33     assert_to_yaml(/hello!~/)
34     assert_to_yaml 1
35     assert_to_yaml 1.2
36     assert_to_yaml Rational(1, 2)
37     assert_to_yaml Complex(1, 2)
38     assert_to_yaml true
39     assert_to_yaml false
40     assert_to_yaml nil
41   end
42
43   def assert_to_yaml obj
44     assert obj.to_yaml, "#{obj.class} to_yaml works"
45   end
46 end
47end
48