From 19853fc49b20626052d6cc92dbd7b08ecce03039 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 15 Jun 2011 03:36:57 +0000 Subject: * test/ruby/test_io.rb (test_copy_stream_socket): wait a child process before SIGUSR1 handler is removed. * test/pathname/test_pathname.rb (define_assertion): use line number for test method names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/pathname/test_pathname.rb | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'test/pathname') diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 8f2445eacd..ac9b415022 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -10,15 +10,21 @@ require 'enumerator' require_relative '../ruby/envutil' class TestPathname < Test::Unit::TestCase - def self.define_assertion(name, &block) - @defassert_num ||= {} - @defassert_num[name] ||= 0 - @defassert_num[name] += 1 - define_method("test_#{name}_#{@defassert_num[name]}", &block) + def self.define_assertion(name, linenum, &block) + name = "test_#{name}_#{linenum}" + define_method(name, &block) + end + + def self.get_linenum + if /:(\d+):/ =~ caller[1] + $1.to_i + else + nil + end end def self.defassert(name, result, *args) - define_assertion(name) { + define_assertion(name, get_linenum) { mesg = "#{name}(#{args.map {|a| a.inspect }.join(', ')})" assert_nothing_raised(mesg) { assert_equal(result, self.send(name, *args), mesg) @@ -26,6 +32,13 @@ class TestPathname < Test::Unit::TestCase } end + def self.defassert_raise(name, exc, *args) + define_assertion(name, get_linenum) { + message = "#{name}(#{args.map {|a| a.inspect }.join(', ')})" + assert_raise(exc, message) { self.send(name, *args) } + } + end + DOSISH = File::ALT_SEPARATOR != nil DOSISH_DRIVE_LETTER = File.dirname("A:") == "A:." DOSISH_UNC = File.dirname("//") == "//" @@ -294,13 +307,6 @@ class TestPathname < Test::Unit::TestCase defassert(:relative_path_from, "a", "a", "b/..") defassert(:relative_path_from, "b/c", "b/c", "b/..") - def self.defassert_raise(name, exc, *args) - define_assertion(name) { - message = "#{name}(#{args.map {|a| a.inspect }.join(', ')})" - assert_raise(exc, message) { self.send(name, *args) } - } - end - defassert_raise(:relative_path_from, ArgumentError, "/", ".") defassert_raise(:relative_path_from, ArgumentError, ".", "/") defassert_raise(:relative_path_from, ArgumentError, "a", "..") -- cgit v1.2.3