1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/pathname.rb: use assert_raise instead of assert_raises.

* lib/pp.rb: ditto.

* lib/time.rb: ditto.

* lib/tsort.rb: ditto.
  use TSortHash and TSortArray instead of Hash and Array in test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2004-02-11 17:36:37 +00:00
parent b187d1933b
commit 166b3957e0
5 changed files with 81 additions and 70 deletions

View file

@ -1,3 +1,14 @@
Thu Feb 12 02:23:56 2004 Tanaka Akira <akr@m17n.org>
* lib/pathname.rb: use assert_raise instead of assert_raises.
* lib/pp.rb: ditto.
* lib/time.rb: ditto.
* lib/tsort.rb: ditto.
use TSortHash and TSortArray instead of Hash and Array in test.
Wed Feb 11 23:24:22 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: properly treat a Tcl/Tk's string with escaping

View file

@ -719,7 +719,7 @@ class Pathname # * FileTest *
# See <tt>FileTest.readable?</tt>.
def readable?() FileTest.readable?(@path) end
# See <tt>FileTest.readable_world?</tt>.
# See <tt>FileTest.world_readable?</tt>.
def world_readable?() FileTest.world_readable?(@path) end
# See <tt>FileTest.readable_real?</tt>.
@ -746,7 +746,7 @@ class Pathname # * FileTest *
# See <tt>FileTest.writable?</tt>.
def writable?() FileTest.writable?(@path) end
# See <tt>FileTest.writable_world?</tt>.
# See <tt>FileTest.world_writable?</tt>.
def world_writable?() FileTest.world_writable?(@path) end
# See <tt>FileTest.writable_real?</tt>.
@ -1040,7 +1040,7 @@ if $0 == __FILE__
end
def test_null_character
assert_raises(ArgumentError) { Pathname.new("\0") }
assert_raise(ArgumentError) { Pathname.new("\0") }
end
def assert_relpath(result, dest, base)
@ -1049,7 +1049,7 @@ if $0 == __FILE__
end
def assert_relpath_err(dest, base)
assert_raises(ArgumentError) {
assert_raise(ArgumentError) {
Pathname.new(dest).relative_path_from(Pathname.new(base))
}
end

View file

@ -522,7 +522,7 @@ if __FILE__ == $0
a = PrettyPrintInspect.new(1)
assert_equal("<pretty_print:1>", a.inspect)
a = PrettyPrintInspectWithoutPrettyPrint.new
assert_raises(RuntimeError) { a.inspect }
assert_raise(RuntimeError) { a.inspect }
end
def test_proc

View file

@ -417,7 +417,7 @@ if __FILE__ == $0
Time.rfc2822("21 Nov 97 09:55:06 GMT"))
assert_equal(Time.utc(1997, 11, 21, 9, 55, 6) + 6 * 3600,
Time.rfc2822("Fri, 21 Nov 1997 09 : 55 : 06 -0600"))
assert_raises(ArgumentError) {
assert_raise(ArgumentError) {
# inner comment is not supported.
Time.rfc2822("Fri, 21 Nov 1997 09(comment): 55 : 06 -0600")
}
@ -552,65 +552,65 @@ if __FILE__ == $0
def test_invalid
# They were actually used in some web sites.
assert_raises(ArgumentError) { Time.httpdate("1 Dec 2001 10:23:57 GMT") }
assert_raises(ArgumentError) { Time.httpdate("Sat, 1 Dec 2001 10:25:42 GMT") }
assert_raises(ArgumentError) { Time.httpdate("Sat, 1-Dec-2001 10:53:55 GMT") }
assert_raises(ArgumentError) { Time.httpdate("Saturday, 01-Dec-2001 10:15:34 GMT") }
assert_raises(ArgumentError) { Time.httpdate("Saturday, 01-Dec-101 11:10:07 GMT") }
assert_raises(ArgumentError) { Time.httpdate("Fri, 30 Nov 2001 21:30:00 JST") }
assert_raise(ArgumentError) { Time.httpdate("1 Dec 2001 10:23:57 GMT") }
assert_raise(ArgumentError) { Time.httpdate("Sat, 1 Dec 2001 10:25:42 GMT") }
assert_raise(ArgumentError) { Time.httpdate("Sat, 1-Dec-2001 10:53:55 GMT") }
assert_raise(ArgumentError) { Time.httpdate("Saturday, 01-Dec-2001 10:15:34 GMT") }
assert_raise(ArgumentError) { Time.httpdate("Saturday, 01-Dec-101 11:10:07 GMT") }
assert_raise(ArgumentError) { Time.httpdate("Fri, 30 Nov 2001 21:30:00 JST") }
# They were actually used in some mails.
assert_raises(ArgumentError) { Time.rfc2822("01-5-20") }
assert_raises(ArgumentError) { Time.rfc2822("7/21/00") }
assert_raises(ArgumentError) { Time.rfc2822("2001-8-28") }
assert_raises(ArgumentError) { Time.rfc2822("00-5-6 1:13:06") }
assert_raises(ArgumentError) { Time.rfc2822("2001-9-27 9:36:49") }
assert_raises(ArgumentError) { Time.rfc2822("2000-12-13 11:01:11") }
assert_raises(ArgumentError) { Time.rfc2822("2001/10/17 04:29:55") }
assert_raises(ArgumentError) { Time.rfc2822("9/4/2001 9:23:19 PM") }
assert_raises(ArgumentError) { Time.rfc2822("01 Nov 2001 09:04:31") }
assert_raises(ArgumentError) { Time.rfc2822("13 Feb 2001 16:4 GMT") }
assert_raises(ArgumentError) { Time.rfc2822("01 Oct 00 5:41:19 PM") }
assert_raises(ArgumentError) { Time.rfc2822("2 Jul 00 00:51:37 JST") }
assert_raises(ArgumentError) { Time.rfc2822("01 11 2001 06:55:57 -0500") }
assert_raises(ArgumentError) { Time.rfc2822("18 \343\366\356\341\370 2000") }
assert_raises(ArgumentError) { Time.rfc2822("Fri, Oct 2001 18:53:32") }
assert_raises(ArgumentError) { Time.rfc2822("Fri, 2 Nov 2001 03:47:54") }
assert_raises(ArgumentError) { Time.rfc2822("Fri, 27 Jul 2001 11.14.14 +0200") }
assert_raises(ArgumentError) { Time.rfc2822("Thu, 2 Nov 2000 04:13:53 -600") }
assert_raises(ArgumentError) { Time.rfc2822("Wed, 5 Apr 2000 22:57:09 JST") }
assert_raises(ArgumentError) { Time.rfc2822("Mon, 11 Sep 2000 19:47:33 00000") }
assert_raises(ArgumentError) { Time.rfc2822("Fri, 28 Apr 2000 20:40:47 +-900") }
assert_raises(ArgumentError) { Time.rfc2822("Fri, 19 Jan 2001 8:15:36 AM -0500") }
assert_raises(ArgumentError) { Time.rfc2822("Thursday, Sep 27 2001 7:42:35 AM EST") }
assert_raises(ArgumentError) { Time.rfc2822("3/11/2001 1:31:57 PM Pacific Daylight Time") }
assert_raises(ArgumentError) { Time.rfc2822("Mi, 28 Mrz 2001 11:51:36") }
assert_raises(ArgumentError) { Time.rfc2822("P, 30 sept 2001 23:03:14") }
assert_raises(ArgumentError) { Time.rfc2822("fr, 11 aug 2000 18:39:22") }
assert_raises(ArgumentError) { Time.rfc2822("Fr, 21 Sep 2001 17:44:03 -1000") }
assert_raises(ArgumentError) { Time.rfc2822("Mo, 18 Jun 2001 19:21:40 -1000") }
assert_raises(ArgumentError) { Time.rfc2822("l\366, 12 aug 2000 18:53:20") }
assert_raises(ArgumentError) { Time.rfc2822("l\366, 26 maj 2001 00:15:58") }
assert_raises(ArgumentError) { Time.rfc2822("Dom, 30 Sep 2001 17:36:30") }
assert_raises(ArgumentError) { Time.rfc2822("%&, 31 %2/ 2000 15:44:47 -0500") }
assert_raises(ArgumentError) { Time.rfc2822("dom, 26 ago 2001 03:57:07 -0300") }
assert_raises(ArgumentError) { Time.rfc2822("ter, 04 set 2001 16:27:58 -0300") }
assert_raises(ArgumentError) { Time.rfc2822("Wen, 3 oct 2001 23:17:49 -0400") }
assert_raises(ArgumentError) { Time.rfc2822("Wen, 3 oct 2001 23:17:49 -0400") }
assert_raises(ArgumentError) { Time.rfc2822("ele, 11 h: 2000 12:42:15 -0500") }
assert_raises(ArgumentError) { Time.rfc2822("Tue, 14 Aug 2001 3:55:3 +0200") }
assert_raises(ArgumentError) { Time.rfc2822("Fri, 25 Aug 2000 9:3:48 +0800") }
assert_raises(ArgumentError) { Time.rfc2822("Fri, 1 Dec 2000 0:57:50 EST") }
assert_raises(ArgumentError) { Time.rfc2822("Mon, 7 May 2001 9:39:51 +0200") }
assert_raises(ArgumentError) { Time.rfc2822("Wed, 1 Aug 2001 16:9:15 +0200") }
assert_raises(ArgumentError) { Time.rfc2822("Wed, 23 Aug 2000 9:17:36 +0800") }
assert_raises(ArgumentError) { Time.rfc2822("Fri, 11 Aug 2000 10:4:42 +0800") }
assert_raises(ArgumentError) { Time.rfc2822("Sat, 15 Sep 2001 13:22:2 +0300") }
assert_raises(ArgumentError) { Time.rfc2822("Wed,16 \276\305\324\302 2001 20:06:25 +0800") }
assert_raises(ArgumentError) { Time.rfc2822("Wed,7 \312\256\322\273\324\302 2001 23:47:22 +0800") }
assert_raises(ArgumentError) { Time.rfc2822("=?iso-8859-1?Q?(=C5=DA),?= 10 2 2001 23:32:26 +0900 (JST)") }
assert_raises(ArgumentError) { Time.rfc2822("\307\341\314\343\332\311, 30 \344\346\335\343\310\321 2001 10:01:06") }
assert_raises(ArgumentError) { Time.rfc2822("=?iso-8859-1?Q?(=BF=E5),?= 12 =?iso-8859-1?Q?9=B7=EE?= 2001 14:52:41\n+0900 (JST)") }
assert_raise(ArgumentError) { Time.rfc2822("01-5-20") }
assert_raise(ArgumentError) { Time.rfc2822("7/21/00") }
assert_raise(ArgumentError) { Time.rfc2822("2001-8-28") }
assert_raise(ArgumentError) { Time.rfc2822("00-5-6 1:13:06") }
assert_raise(ArgumentError) { Time.rfc2822("2001-9-27 9:36:49") }
assert_raise(ArgumentError) { Time.rfc2822("2000-12-13 11:01:11") }
assert_raise(ArgumentError) { Time.rfc2822("2001/10/17 04:29:55") }
assert_raise(ArgumentError) { Time.rfc2822("9/4/2001 9:23:19 PM") }
assert_raise(ArgumentError) { Time.rfc2822("01 Nov 2001 09:04:31") }
assert_raise(ArgumentError) { Time.rfc2822("13 Feb 2001 16:4 GMT") }
assert_raise(ArgumentError) { Time.rfc2822("01 Oct 00 5:41:19 PM") }
assert_raise(ArgumentError) { Time.rfc2822("2 Jul 00 00:51:37 JST") }
assert_raise(ArgumentError) { Time.rfc2822("01 11 2001 06:55:57 -0500") }
assert_raise(ArgumentError) { Time.rfc2822("18 \343\366\356\341\370 2000") }
assert_raise(ArgumentError) { Time.rfc2822("Fri, Oct 2001 18:53:32") }
assert_raise(ArgumentError) { Time.rfc2822("Fri, 2 Nov 2001 03:47:54") }
assert_raise(ArgumentError) { Time.rfc2822("Fri, 27 Jul 2001 11.14.14 +0200") }
assert_raise(ArgumentError) { Time.rfc2822("Thu, 2 Nov 2000 04:13:53 -600") }
assert_raise(ArgumentError) { Time.rfc2822("Wed, 5 Apr 2000 22:57:09 JST") }
assert_raise(ArgumentError) { Time.rfc2822("Mon, 11 Sep 2000 19:47:33 00000") }
assert_raise(ArgumentError) { Time.rfc2822("Fri, 28 Apr 2000 20:40:47 +-900") }
assert_raise(ArgumentError) { Time.rfc2822("Fri, 19 Jan 2001 8:15:36 AM -0500") }
assert_raise(ArgumentError) { Time.rfc2822("Thursday, Sep 27 2001 7:42:35 AM EST") }
assert_raise(ArgumentError) { Time.rfc2822("3/11/2001 1:31:57 PM Pacific Daylight Time") }
assert_raise(ArgumentError) { Time.rfc2822("Mi, 28 Mrz 2001 11:51:36") }
assert_raise(ArgumentError) { Time.rfc2822("P, 30 sept 2001 23:03:14") }
assert_raise(ArgumentError) { Time.rfc2822("fr, 11 aug 2000 18:39:22") }
assert_raise(ArgumentError) { Time.rfc2822("Fr, 21 Sep 2001 17:44:03 -1000") }
assert_raise(ArgumentError) { Time.rfc2822("Mo, 18 Jun 2001 19:21:40 -1000") }
assert_raise(ArgumentError) { Time.rfc2822("l\366, 12 aug 2000 18:53:20") }
assert_raise(ArgumentError) { Time.rfc2822("l\366, 26 maj 2001 00:15:58") }
assert_raise(ArgumentError) { Time.rfc2822("Dom, 30 Sep 2001 17:36:30") }
assert_raise(ArgumentError) { Time.rfc2822("%&, 31 %2/ 2000 15:44:47 -0500") }
assert_raise(ArgumentError) { Time.rfc2822("dom, 26 ago 2001 03:57:07 -0300") }
assert_raise(ArgumentError) { Time.rfc2822("ter, 04 set 2001 16:27:58 -0300") }
assert_raise(ArgumentError) { Time.rfc2822("Wen, 3 oct 2001 23:17:49 -0400") }
assert_raise(ArgumentError) { Time.rfc2822("Wen, 3 oct 2001 23:17:49 -0400") }
assert_raise(ArgumentError) { Time.rfc2822("ele, 11 h: 2000 12:42:15 -0500") }
assert_raise(ArgumentError) { Time.rfc2822("Tue, 14 Aug 2001 3:55:3 +0200") }
assert_raise(ArgumentError) { Time.rfc2822("Fri, 25 Aug 2000 9:3:48 +0800") }
assert_raise(ArgumentError) { Time.rfc2822("Fri, 1 Dec 2000 0:57:50 EST") }
assert_raise(ArgumentError) { Time.rfc2822("Mon, 7 May 2001 9:39:51 +0200") }
assert_raise(ArgumentError) { Time.rfc2822("Wed, 1 Aug 2001 16:9:15 +0200") }
assert_raise(ArgumentError) { Time.rfc2822("Wed, 23 Aug 2000 9:17:36 +0800") }
assert_raise(ArgumentError) { Time.rfc2822("Fri, 11 Aug 2000 10:4:42 +0800") }
assert_raise(ArgumentError) { Time.rfc2822("Sat, 15 Sep 2001 13:22:2 +0300") }
assert_raise(ArgumentError) { Time.rfc2822("Wed,16 \276\305\324\302 2001 20:06:25 +0800") }
assert_raise(ArgumentError) { Time.rfc2822("Wed,7 \312\256\322\273\324\302 2001 23:47:22 +0800") }
assert_raise(ArgumentError) { Time.rfc2822("=?iso-8859-1?Q?(=C5=DA),?= 10 2 2001 23:32:26 +0900 (JST)") }
assert_raise(ArgumentError) { Time.rfc2822("\307\341\314\343\332\311, 30 \344\346\335\343\310\321 2001 10:01:06") }
assert_raise(ArgumentError) { Time.rfc2822("=?iso-8859-1?Q?(=BF=E5),?= 12 =?iso-8859-1?Q?9=B7=EE?= 2001 14:52:41\n+0900 (JST)") }
end
end

View file

@ -244,7 +244,7 @@ end
if __FILE__ == $0
require 'test/unit'
class Hash # :nodoc:
class TSortHash < Hash # :nodoc:
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
@ -252,7 +252,7 @@ if __FILE__ == $0
end
end
class Array # :nodoc:
class TSortArray < Array # :nodoc:
include TSort
alias tsort_each_node each_index
def tsort_each_child(node, &block)
@ -262,24 +262,24 @@ if __FILE__ == $0
class TSortTest < Test::Unit::TestCase # :nodoc:
def test_dag
h = {1=>[2, 3], 2=>[3], 3=>[]}
h = TSortHash[{1=>[2, 3], 2=>[3], 3=>[]}]
assert_equal([3, 2, 1], h.tsort)
assert_equal([[3], [2], [1]], h.strongly_connected_components)
end
def test_cycle
h = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
h = TSortHash[{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}]
assert_equal([[4], [2, 3], [1]],
h.strongly_connected_components.map {|nodes| nodes.sort})
assert_raises(TSort::Cyclic) { h.tsort }
assert_raise(TSort::Cyclic) { h.tsort }
end
def test_array
a = [[1], [0], [0], [2]]
a = TSortArray[[1], [0], [0], [2]]
assert_equal([[0, 1], [2], [3]],
a.strongly_connected_components.map {|nodes| nodes.sort})
a = [[], [0]]
a = TSortArray[[], [0]]
assert_equal([[0], [1]],
a.strongly_connected_components.map {|nodes| nodes.sort})
end