diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-28 01:47:58 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-28 01:47:58 +0000 |
commit | f114089585d486920f53c0c4cb92d73dc4ed577c (patch) | |
tree | 6e504795ed0f8049fd18cbe7793487eaf41c0d24 /test/psych/test_psych.rb | |
parent | 13dc8e4ef0c45dc51af820bbca1315edc0b70fb2 (diff) | |
download | ruby-f114089585d486920f53c0c4cb92d73dc4ed577c.tar.gz |
Merge Pysch 3.0.3.pre1.
I added the following additional commits from 3.0.3.pre1:
* https://github.com/ruby/psych/pull/356
* https://github.com/ruby/psych/pull/357
* https://github.com/ruby/psych/pull/359
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_psych.rb')
-rw-r--r-- | test/psych/test_psych.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb index 2812fd1bd8..8f9a10013d 100644 --- a/test/psych/test_psych.rb +++ b/test/psych/test_psych.rb @@ -144,12 +144,49 @@ class TestPsych < Psych::TestCase } end + def test_load_file_default_return_value + Tempfile.create(['empty', 'yml']) {|t| + assert_equal false, Psych.load_file(t.path) + } + end + def test_load_file_with_fallback Tempfile.create(['empty', 'yml']) {|t| + assert_equal 42, Psych.load_file(t.path, fallback: 42) + } + end + + def test_load_file_with_fallback_nil_or_false + Tempfile.create(['empty', 'yml']) {|t| + assert_nil Psych.load_file(t.path, fallback: nil) + assert_equal false, Psych.load_file(t.path, fallback: false) + } + end + + def test_load_file_with_fallback_hash + Tempfile.create(['empty', 'yml']) {|t| assert_equal Hash.new, Psych.load_file(t.path, fallback: Hash.new) } end + def test_load_file_with_fallback_for_nil + Tempfile.create(['nil', 'yml']) {|t| + t.binmode + t.write('--- null') + t.close + assert_nil Psych.load_file(t.path, fallback: 42) + } + end + + def test_load_file_with_fallback_for_false + Tempfile.create(['false', 'yml']) {|t| + t.binmode + t.write('--- false') + t.close + assert_equal false, Psych.load_file(t.path, fallback: 42) + } + end + def test_parse_file Tempfile.create(['yikes', 'yml']) {|t| t.binmode |