diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-22 15:03:32 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-22 15:03:32 +0000 |
commit | bebd7e4511aca3141532d95ee5bd0237f621c059 (patch) | |
tree | 79738669405e1ba00f25637b9681e6c5aeb0265f /test/ruby/test_dir.rb | |
parent | d8d5e67184e0647f56576a500993c064e60fc26a (diff) | |
download | ruby-bebd7e4511aca3141532d95ee5bd0237f621c059.tar.gz |
* test/ruby/test_array.rb: add a test for Array#rotate, rotate!.
* test/ruby/test_dir.rb, test/ruby/test_fnmatch.rb: add some tests
(for coverage of dir.c).
* test/ruby/test_enum.rb: add a test for Enumerable#minmax.
* test/ruby/test_enumerator.rb: add some tests for Enumerator#inspect,
Enumerator::Generator and Yielder.
* test/ruby/test_env.rb: add a test for ENV#index.
* test/ruby/test_exception.rb: add some tests (for coverage of
error.c).
* test/ruby/test_hash.rb: add a test for recursive check.
* test/ruby/test_integer.rb: add a test for number of argument of
Integer.
* test/ruby/test_method.rb: add a test for define_method.
* test/ruby/test_module.rb: add a test for constant of included
module.
* test/ruby/test_proc.rb: add a test for parameters with cfunc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_dir.rb')
-rw-r--r-- | test/ruby/test_dir.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index eb315d3d85..cabe38270e 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -162,6 +162,9 @@ class TestDir < Test::Unit::TestCase assert_equal([], Dir.glob(File.join(@root, '['))) assert_equal([], Dir.glob(File.join(@root, '[a-\\'))) + assert_equal([File.join(@root, "a")], Dir.glob(File.join(@root, 'a\\'))) + assert_equal((?a..?f).map {|f| File.join(@root, f) }.sort, Dir.glob(File.join(@root, '[abc/def]')).sort) + d = "\u{3042}\u{3044}".encode("utf-16le") assert_raise(Encoding::CompatibilityError) {Dir.glob(d)} m = Class.new {define_method(:to_path) {d}} @@ -172,4 +175,42 @@ class TestDir < Test::Unit::TestCase assert_equal(Dir.foreach(@root).to_a.sort, %w(. ..) + (?a..?z).to_a) end + def test_dir_enc + dir = Dir.open(@root, encoding: "UTF-8") + begin + while name = dir.read + assert_equal(Encoding.find("UTF-8"), name.encoding) + end + ensure + dir.close + end + + dir = Dir.open(@root, encoding: "ASCII-8BIT") + begin + while name = dir.read + assert_equal(Encoding.find("ASCII-8BIT"), name.encoding) + end + ensure + dir.close + end + end + + def test_symlink + begin + [:dummy, *?a..?z].each do |f| + File.symlink(File.join(@root, f), + File.join(@root, "symlink-#{ f }")) + end + rescue NotImplementedError + return + end + + assert_equal([*?a..?z, *"symlink-a".."symlink-z"].each_slice(2).map {|f, _| File.join(@root, f + "/") }.sort, + Dir.glob(File.join(@root, "*/")).sort) + + puts("1"); + Dir.glob(File.join(@root, "**/")) + puts("2"); + end + end |