@@ -153,13 +153,13 @@ def test_excluding_via_block
153153
154154 def test_exclude_return_on_create
155155 fl = FileList [ 'testdata/*' ] . exclude ( /.*\. [hcx]$/ )
156- assert_equal [ 'testdata/existing' ] , fl
156+ assert_equal [ 'testdata/existing' , 'testdata/cfiles' ] . sort , fl . sort
157157 assert_equal FileList , fl . class
158158 end
159159
160160 def test_exclude_with_string_return_on_create
161161 fl = FileList [ 'testdata/*' ] . exclude ( 'testdata/abc.c' )
162- assert_equal %w( testdata/existing testdata/x.c testdata/abc.h testdata/abc.x testdata/xyz.c ) . sort , fl . sort
162+ assert_equal %w( testdata/existing testdata/cfiles testdata/ x.c testdata/abc.h testdata/abc.x testdata/xyz.c ) . sort , fl . sort
163163 assert_equal FileList , fl . class
164164 end
165165
@@ -215,6 +215,28 @@ def test_sub
215215 assert_equal [ "testdata/abc.o" , "testdata/x.o" , "testdata/xyz.o" ] . sort ,
216216 f3 . sort
217217 end
218+
219+ def test_claim_to_be_a_kind_of_array
220+ fl = FileList [ 'testdata/*.c' ]
221+ assert fl . is_a? ( Array )
222+ assert fl . kind_of? ( Array )
223+ end
224+
225+ def test_claim_to_be_a_kind_of_filelist
226+ fl = FileList [ 'testdata/*.c' ]
227+ assert fl . is_a? ( FileList )
228+ assert fl . kind_of? ( FileList )
229+ end
230+
231+ def test_claim_to_be_a_filelist_instance
232+ fl = FileList [ 'testdata/*.c' ]
233+ assert fl . instance_of? ( FileList )
234+ end
235+
236+ def test_dont_claim_to_be_an_array_instance
237+ fl = FileList [ 'testdata/*.c' ]
238+ assert ! fl . instance_of? ( Array )
239+ end
218240
219241 def test_sub!
220242 f = "x/a.c"
@@ -300,6 +322,18 @@ def test_egrep_with_block
300322 assert found , "should have found a matching line"
301323 end
302324
325+ def test_existing
326+ fl = FileList [ 'testdata/abc.c' , 'testdata/notthere.c' ]
327+ assert_equal [ "testdata/abc.c" ] , fl . existing
328+ assert fl . existing . is_a? ( FileList )
329+ end
330+
331+ def test_existing!
332+ fl = FileList [ 'testdata/abc.c' , 'testdata/notthere.c' ]
333+ result = fl . existing!
334+ assert_equal [ "testdata/abc.c" ] , fl
335+ assert_equal fl . object_id , result . object_id
336+ end
303337
304338 def test_ignore_special
305339 f = FileList [ 'testdata/*' ]
@@ -505,12 +539,25 @@ def test_other_array_returning_methods
505539 assert_equal [ 'b' , 'd' ] , r
506540 assert_equal FileList , r . class
507541 end
542+
543+ def test_file_utils_can_use_filelists
544+ cfiles = FileList [ 'testdata/*.c' ]
545+
546+ cp cfiles , @cdir
547+
548+ assert File . exist? ( File . join ( @cdir , 'abc.c' ) )
549+ assert File . exist? ( File . join ( @cdir , 'xyz.c' ) )
550+ assert File . exist? ( File . join ( @cdir , 'x.c' ) )
551+ end
508552
509553 def create_test_data
510554 verbose ( false ) do
555+
511556 mkdir "testdata" unless File . exist? "testdata"
512557 mkdir "testdata/CVS" rescue nil
513558 mkdir "testdata/.svn" rescue nil
559+ @cdir = "testdata/cfiles"
560+ mkdir @cdir rescue nil
514561 touch "testdata/.dummy"
515562 touch "testdata/x.bak"
516563 touch "testdata/x~"
0 commit comments