[前][次][番号順一覧][スレッド一覧]

ruby-changes:39278

From: nobu <ko1@a...>
Date: Fri, 24 Jul 2015 16:36:11 +0900 (JST)
Subject: [ruby-changes:39278] nobu:r51359 (trunk): Add tests for `File.extname`

nobu	2015-07-24 16:35:38 +0900 (Fri, 24 Jul 2015)

  New Revision: 51359

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51359

  Log:
    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')

  Modified files:
    trunk/ChangeLog
    trunk/file.c
    trunk/test/ruby/test_path.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51358)
+++ ChangeLog	(revision 51359)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jul 24 16:35:34 2015  yui-knk  <spiketeika@g...>
+
+	* 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@a...>
 
 	* vm_core.h: constify rb_iseq_constant_body::local_table and
Index: test/ruby/test_path.rb
===================================================================
--- test/ruby/test_path.rb	(revision 51358)
+++ test/ruby/test_path.rb	(revision 51359)
@@ -230,6 +230,9 @@ class TestPath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_path.rb#L230
     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 = ''
Index: file.c
===================================================================
--- file.c	(revision 51358)
+++ file.c	(revision 51359)
@@ -4237,6 +4237,7 @@ ruby_enc_find_extname(const char *name, https://github.com/ruby/ruby/blob/trunk/file.c#L4237
  *
  *     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")        #=> ""

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]