1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#!/usr/bin/env ruby
require 'test/unit'
require 'test/filecreation'
require 'rake/contrib/sys'
class TestSys < Test::Unit::TestCase
include FileCreation
# def test_delete
# create_file("testdata/a")
# Sys.delete_all("testdata/a")
# assert ! File.exist?("testdata/a")
# end
# def test_copy
# create_file("testdata/a")
# Sys.copy("testdata/a", "testdata/b")
# assert File.exist?("testdata/b")
# end
# def test_for_files
# test_files = ["testdata/a.pl", "testdata/c.pl", "testdata/b.rb"]
# test_files.each { |fn| create_file(fn) }
# list = []
# Sys.for_files("testdata/*.pl", "testdata/*.rb") { |fn|
# list << fn
# }
# assert_equal test_files.sort, list.sort
# end
# def test_indir
# here = Dir.pwd
# Sys.makedirs("testdata/dir")
# assert_equal "#{here}/testdata/dir", Sys.indir("testdata/dir") { Dir.pwd }
# assert_equal here, Dir.pwd
# end
def test_split_all
assert_equal ['a'], Sys.split_all('a')
assert_equal ['..'], Sys.split_all('..')
assert_equal ['/'], Sys.split_all('/')
assert_equal ['a', 'b'], Sys.split_all('a/b')
assert_equal ['/', 'a', 'b'], Sys.split_all('/a/b')
assert_equal ['..', 'a', 'b'], Sys.split_all('../a/b')
end
end
|