From 8bb581f8dd4eeb0e3e784488f3c8d102df9327c3 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 14 Jun 2015 15:14:46 +0000 Subject: * ext/pathname/lib/pathname.rb (descend): Blockless form supported. (ascend): Ditto. [ruby-core:68820] [Feature #11052] Patch by Piotr Szotkowski. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/pathname/test_pathname.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'test/pathname') diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 046f3f034f..b012633a8c 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -430,7 +430,7 @@ class TestPathname < Test::Unit::TestCase end def descend(path) - Pathname.new(path).enum_for(:descend).map {|v| v.to_s } + Pathname.new(path).descend.map(&:to_s) end defassert(:descend, %w[/ /a /a/b /a/b/c], "/a/b/c") @@ -439,7 +439,7 @@ class TestPathname < Test::Unit::TestCase defassert(:descend, %w[a/], "a/") def ascend(path) - Pathname.new(path).enum_for(:ascend).map {|v| v.to_s } + Pathname.new(path).ascend.map(&:to_s) end defassert(:ascend, %w[/a/b/c /a/b /a /], "/a/b/c") @@ -447,6 +447,14 @@ class TestPathname < Test::Unit::TestCase defassert(:ascend, %w[./a/b/c ./a/b ./a .], "./a/b/c") defassert(:ascend, %w[a/], "a/") + def test_blockless_ascend_is_enumerator + assert_kind_of(Enumerator, Pathname.new('a').ascend) + end + + def test_blockless_descend_is_enumerator + assert_kind_of(Enumerator, Pathname.new('a').descend) + end + def test_initialize p1 = Pathname.new('a') assert_equal('a', p1.to_s) -- cgit v1.2.3