summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-17 05:55:51 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-17 05:55:51 +0000
commit35c8ae84e5ca20a9263ce7b60cc5b656386c7842 (patch)
tree58b986417248df04fb6be0072b6811b0beaf7df3 /test
parentfaeff623e09cb77c23a93b56001b51b043b5aa6a (diff)
* lib/pathname.rb: backport from 1.9.
(Kernel#Pathname): new method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/pathname/test_pathname.rb25
1 files changed, 22 insertions, 3 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 20351fa..ecf7a71 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -5,8 +5,16 @@ require 'pathname'
require 'fileutils'
require 'tmpdir'
+require 'enumerator'
class TestPathname < Test::Unit::TestCase
+
+ if RUBY_VERSION < "1.9"
+ FUNCALL = :__send__
+ else
+ FUNCALL = :funcall
+ end
+
def self.define_assertion(name, &block)
@defassert_num ||= {}
@defassert_num[name] ||= 0
@@ -115,7 +123,7 @@ class TestPathname < Test::Unit::TestCase
# has_trailing_separator?(path) -> bool
def has_trailing_separator?(path)
- Pathname.allocate.funcall(:has_trailing_separator?, path)
+ Pathname.allocate.send(FUNCALL, :has_trailing_separator?, path)
end
defassert(:has_trailing_separator?, false, "/")
@@ -124,11 +132,11 @@ class TestPathname < Test::Unit::TestCase
defassert(:has_trailing_separator?, true, "a/")
def add_trailing_separator(path)
- Pathname.allocate.funcall(:add_trailing_separator, path)
+ Pathname.allocate.send(FUNCALL, :add_trailing_separator, path)
end
def del_trailing_separator(path)
- Pathname.allocate.funcall(:del_trailing_separator, path)
+ Pathname.allocate.send(FUNCALL, :del_trailing_separator, path)
end
defassert(:del_trailing_separator, "/", "/")
@@ -313,6 +321,10 @@ class TestPathname < Test::Unit::TestCase
assert_equal(p1, p2)
end
+ def test_initialize_nul
+ assert_raise(ArgumentError) { Pathname.new("a\0") }
+ end
+
class AnotherStringLike # :nodoc:
def initialize(s) @s = s end
def to_str() @s end
@@ -374,6 +386,9 @@ class TestPathname < Test::Unit::TestCase
assert_equal(nil, "a" <=> Pathname.new("a"))
end
+ def pathsub(path, pat, repl) Pathname.new(path).sub(pat, repl).to_s end
+ defassert(:pathsub, "a.o", "a.c", /\.c\z/, ".o")
+
def root?(path)
Pathname.new(path).root?
end
@@ -464,4 +479,8 @@ class TestPathname < Test::Unit::TestCase
Pathname.new("/usr/bin/ruby").each_filename {|f| result << f }
assert_equal(%w[usr bin ruby], result)
end
+
+ def test_kernel_pathname
+ assert_equal(Pathname.new("a"), Pathname("a"))
+ end
end