提交 4e58f21f 编写于 作者: N nobu

Add tests for `File.extname`

* file.c (rb_file_s_extname): [DOC] add an example.
* test/ruby/test_path.rb (test_extname): add tests.  [Fix GH-978]
  * path starts with dot ('.a.rb')
  * path includes dir name ('a/b/d/test.rb')
  * path includes dir name and dir name starts with dot
    ('.a/b/d/test.rb')

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
上级 a34343b3
Fri Jul 24 16:35:34 2015 yui-knk <spiketeika@gmail.com>
* file.c (rb_file_s_extname): [DOC] add an example.
* test/ruby/test_path.rb (test_extname): add tests. [Fix GH-978]
* path starts with dot ('.a.rb')
* path includes dir name ('a/b/d/test.rb')
* path includes dir name and dir name starts with dot
('.a/b/d/test.rb')
Thu Jul 23 18:50:43 2015 Koichi Sasada <ko1@atdot.net>
* vm_core.h: constify rb_iseq_constant_body::local_table and
......
......@@ -4237,6 +4237,7 @@ ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
*
* File.extname("test.rb") #=> ".rb"
* File.extname("a/b/d/test.rb") #=> ".rb"
* File.extname(".a/b/d/test.rb") #=> ".rb"
* File.extname("foo.") #=> ""
* File.extname("test") #=> ""
* File.extname(".profile") #=> ""
......
......@@ -230,6 +230,9 @@ def test_extname
assert_equal('', File.extname('a'))
ext = '.rb'
assert_equal(ext, File.extname('a.rb'))
assert_equal(ext, File.extname('.a.rb'))
assert_equal(ext, File.extname('a/b/d/test.rb'))
assert_equal(ext, File.extname('.a/b/d/test.rb'))
unless /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
# trailing spaces and dots are ignored on NTFS.
ext = ''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册