diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-06 22:36:07 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-06 22:36:07 +0000 |
| commit | 5cd42d40d30143be26129c2f1b1622da6b919dda (patch) | |
| tree | 4b228174576bb81459dc6c7b93049adfce417293 /test | |
| parent | 98ea943cbb9eb94d258c407e645e784aa3256709 (diff) | |
| download | ruby-5cd42d40d30143be26129c2f1b1622da6b919dda.tar.gz ruby-5cd42d40d30143be26129c2f1b1622da6b919dda.tar.xz ruby-5cd42d40d30143be26129c2f1b1622da6b919dda.zip | |
* lib/yaml/rubytypes.rb: support Rational and Complex as 1.8
does. a patch from Hiroshi Moriyama in [ruby-dev:36899].
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
| -rw-r--r-- | test/yaml/test_yaml.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/yaml/test_yaml.rb b/test/yaml/test_yaml.rb index 74a2fa851..ed94705fc 100644 --- a/test/yaml/test_yaml.rb +++ b/test/yaml/test_yaml.rb @@ -1107,6 +1107,30 @@ EOY end + def test_ruby_rational + assert_to_yaml( Rational(1, 2), <<EOY ) +--- !ruby/object:Rational +numerator: 1 +denominator: 2 +EOY + + # Read YAML dumped by the ruby 1.8.3. + assert_to_yaml( Rational(1, 2), "!ruby/object:Rational 1/2\n" ) + assert_raise( ArgumentError ) { YAML.load("!ruby/object:Rational INVALID/RATIONAL\n") } + end + + def test_ruby_complex + assert_to_yaml( Complex(3, 4), <<EOY ) +--- !ruby/object:Complex +image: 4 +real: 3 +EOY + + # Read YAML dumped by the ruby 1.8.3. + assert_to_yaml( Complex(3, 4), "!ruby/object:Complex 3+4i\n" ) + assert_raise( ArgumentError ) { YAML.load("!ruby/object:Complex INVALID+COMPLEXi\n") } + end + def test_emitting_indicators assert_to_yaml( "Hi, from Object 1. You passed: please, pretty please", <<EOY --- "Hi, from Object 1. You passed: please, pretty please" |
