[ruby-dev:21097] Re: rubicon for ruby 1.8
From:
Koji Arai <JCA02266@...>
Date:
2003-08-03 08:26:28 UTC
List:
ruby-dev #21097
新井です。
In message "[ruby-dev:21092] rubicon for ruby 1.8"
on 03 Aug 2003 15:25:22 +0900,
Koji Arai <JCA02266@nifty.ne.jp> wrote:
> 新井です。
>
> リリースも間近ですし、rubicon を試してみようと思ったのですが、
> 大量の warning はともかく、テストの失敗がかなり出ます。
再度、rubicon のパッチを作成しました。
まだ、
* TestIO が失敗します。
* TestKernel.rb の test_singleton_methods は自身がありません
(1.8.0 の挙動にテストを合わせただけ)
* TestModule.rb の test_instance_methods も同様
* TestTime で、assert_not_equal() というのを使ったため、RubyUnit では
失敗します。(TestUnit (の RubyUnit 互換ライブラリ)で使用可)
* TestAssignment.rb, TestBlockProcs.rb, TestLoopStuff.rb の
多重代入まわりは自身がありません。
(1.8.0 の挙動にテストを合わせただけ)
結果は、以下の通りです。
========================================================================
All Tests Test Results V0.3.5
========================================================================
Name OK? Tests Asserts Failures Errors
------------------------------------------------------------
Rubicon::TestCase 0 0
:
:
IO FAIL 53 1237 3
:
:
TrueClass 6 17
========================================================================
All 71 files FAIL 917 30188 0 3
========================================================================
Error Report
========================================================================
TestIO:
-------
TestIO#test_LSHIFT
....Bad file descriptor - _test/_10lines
TestIO#test_clone
....Bad file descriptor - _test/_10lines
TestIO#test_s_new
....Bad file descriptor
========================================================================
Index: builtin/ArrayBase.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/builtin/ArrayBase.rb,v
retrieving revision 1.9
diff -u -r1.9 ArrayBase.rb
--- builtin/ArrayBase.rb 16 Mar 2003 11:36:22 -0000 1.9
+++ builtin/ArrayBase.rb 3 Aug 2003 08:10:16 -0000
@@ -68,12 +68,24 @@
def test_MINUS # '-'
assert_equal(@cls[], @cls[1] - @cls[1])
assert_equal(@cls[1], @cls[1, 2, 3, 4, 5] - @cls[2, 3, 4, 5])
- assert_equal(@cls[1], @cls[1, 2, 1, 3, 1, 4, 1, 5] - @cls[2, 3, 4, 5])
+ Version.less_than("1.8") do
+ assert_equal(@cls[1], @cls[1, 2, 1, 3, 1, 4, 1, 5] - @cls[2, 3, 4, 5])
+ end
+ Version.greater_or_equal("1.8") do
+ assert_equal(@cls[1,1,1,1],
+ @cls[1, 2, 1, 3, 1, 4, 1, 5] - @cls[2, 3, 4, 5])
+ end
a = @cls[]
1000.times { a << 1 }
assert_equal(1000, a.length)
- assert_equal(@cls[1], a - @cls[2])
- assert_equal(@cls[1], @cls[ 1, 2, 1] - @cls[2])
+ Version.less_than("1.8") do
+ assert_equal(@cls[1], a - @cls[2])
+ assert_equal(@cls[1], @cls[ 1, 2, 1] - @cls[2])
+ end
+ Version.greater_or_equal("1.8") do
+ assert_equal(@cls[1] * 1000, a - @cls[2])
+ assert_equal(@cls[1,1], @cls[ 1, 2, 1] - @cls[2])
+ end
assert_equal(@cls[1, 2, 3], @cls[1, 2, 3] - @cls[4, 5, 6])
end
@@ -747,10 +759,13 @@
def test_push
a = @cls[1, 2, 3]
assert_equal(@cls[1, 2, 3, 4, 5], a.push(4, 5))
- Version.greater_or_equal("1.6.2") do
+ Version.less_than("1.6.2") do
+ assert_equal(@cls[1, 2, 3, 4, 5], a.push())
+ end
+ Version.in("1.6.2".."1.8") do
assert_exception(ArgumentError, "a.push()") { a.push() }
end
- Version.less_than("1.6.2") do
+ Version.greater_or_equal("1.8") do
assert_equal(@cls[1, 2, 3, 4, 5], a.push())
end
assert_equal(@cls[1, 2, 3, 4, 5, nil], a.push(nil))
@@ -804,7 +819,12 @@
a = @cls[*%w( dog cat bee ant )]
assert_equal(@cls[*%w(ant bee cat dog)], a.reverse!)
assert_equal(@cls[*%w(ant bee cat dog)], a)
- assert_nil(@cls[].reverse!)
+ Version.less_than("1.8") do
+ assert_nil(@cls[].reverse!)
+ end
+ Version.greater_or_equal("1.8") do
+ assert_equal(@cls[], @cls[].reverse!)
+ end
end
def test_reverse_each
Index: builtin/StringBase.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/builtin/StringBase.rb,v
retrieving revision 1.15
diff -u -r1.15 StringBase.rb
--- builtin/StringBase.rb 16 Mar 2003 11:36:22 -0000 1.15
+++ builtin/StringBase.rb 3 Aug 2003 08:10:40 -0000
@@ -167,7 +167,12 @@
end
def test_EQUAL # '=='
- assert_equal(false, S("foo") == :foo)
+ Version.less_than("1.8") do
+ assert_equal(false, S("foo") == :foo)
+ end
+ Version.greater_or_equal("1.8") do
+ assert_equal(nil, S("foo") == :foo)
+ end
assert(S("abcdef") == S("abcdef"))
pre_1_7_1 do
Index: builtin/TestFile.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/builtin/TestFile.rb,v
retrieving revision 1.37
diff -u -r1.37 TestFile.rb
--- builtin/TestFile.rb 12 Feb 2003 03:48:20 -0000 1.37
+++ builtin/TestFile.rb 3 Aug 2003 08:11:45 -0000
@@ -485,10 +485,18 @@
[ Time.at(121314), Time.now.to_i ]
].each { |aTime, mTime|
File.utime(aTime, mTime, "_file1", "_file2")
-
+
for file in [ "_file1", "_file2" ]
- assert_equal(aTime, File.stat(file).atime) # does automatic conversion
- assert_equal(mTime, File.stat(file).mtime)
+ Version.less_than("1.8") do
+ # does automatic conversion
+ assert_equal(aTime, File.stat(file).atime)
+ assert_equal(mTime, File.stat(file).mtime)
+ end
+ Version.greater_or_equal("1.8") do
+ # does not automatic conversion
+ assert_equal(Time.at(aTime), File.stat(file).atime)
+ assert_equal(Time.at(mTime), File.stat(file).mtime)
+ end
end
}
ensure
Index: builtin/TestKernel.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/builtin/TestKernel.rb,v
retrieving revision 1.40
diff -u -r1.40 TestKernel.rb
--- builtin/TestKernel.rb 16 Mar 2003 11:36:22 -0000 1.40
+++ builtin/TestKernel.rb 3 Aug 2003 08:12:34 -0000
@@ -422,9 +422,15 @@
end
def test_singleton_methods
- assert_equal(%w(singleton), MethodsTest.singleton_methods)
- assert_equal(%w(singleton), PrivateMethods.singleton_methods)
-
+ Version.less_than("1.8") do
+ assert_equal(%w(singleton), MethodsTest.singleton_methods)
+ assert_equal(%w(singleton), PrivateMethods.singleton_methods)
+ end
+ Version.greater_or_equal("1.8") do
+ assert_equal(%w(singleton), MethodsTest.singleton_methods(false))
+ assert_equal(%w(singleton), PrivateMethods.singleton_methods(true))
+ end
+
mt = MethodsTest.new
assert_equal([], mt.singleton_methods)
eval "def mt.wombat() end"
Index: builtin/TestMath.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/builtin/TestMath.rb,v
retrieving revision 1.4
diff -u -r1.4 TestMath.rb
--- builtin/TestMath.rb 7 Feb 2003 06:51:08 -0000 1.4
+++ builtin/TestMath.rb 3 Aug 2003 08:12:54 -0000
@@ -115,9 +115,16 @@
end
# and some special cases
- assert_equal(-1, Math.log(0).infinite?)
- assert_equal(-1, Math.log10(0).infinite?)
- assert_exception(ArgumentError) { Math.sqrt(-1) }
+ Version.less_than("1.8") do
+ assert_equal(-1, Math.log(0).infinite?)
+ assert_equal(-1, Math.log10(0).infinite?)
+ assert_exception(ArgumentError) { Math.sqrt(-1) }
+ end
+ Version.greater_or_equal("1.8") do
+ assert_exception(Errno::ERANGE) { Math.log(0) }
+ assert_exception(Errno::ERANGE) { Math.log10(0) }
+ assert_exception(Errno::EDOM) { Math.sqrt(-1) }
+ end
end
end
Index: builtin/TestModule.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/builtin/TestModule.rb,v
retrieving revision 1.13
diff -u -r1.13 TestModule.rb
--- builtin/TestModule.rb 21 May 2002 05:51:07 -0000 1.13
+++ builtin/TestModule.rb 3 Aug 2003 08:05:50 -0000
@@ -193,12 +193,19 @@
def test_instance_methods
assert_equal(["user" ], User.instance_methods)
- assert_equal(["user", "mixin"], User.instance_methods(true))
+ assert_equal(["user", "mixin"].sort, User.instance_methods(true).sort)
assert_equal(["mixin"], Mixin.instance_methods)
assert_equal(["mixin"], Mixin.instance_methods(true))
- assert_equal(["aClass"], AClass.instance_methods)
- assert_equal(["aClass"], AClass.instance_methods(true) -
- Object.instance_methods(true))
+ Version.less_than("1.8") do
+ assert_equal(["aClass"], AClass.instance_methods)
+ assert_equal(["aClass"], AClass.instance_methods(true) -
+ Object.instance_methods(true))
+ end
+ Version.greater_or_equal("1.8") do
+ assert_equal(["aClass", "aClass2"].sort, AClass.instance_methods.sort)
+ assert_equal(["aClass", "aClass2"].sort, AClass.instance_methods(true) -
+ Object.instance_methods(true).sort)
+ end
end
def test_method_defined?
Index: builtin/TestProc.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/builtin/TestProc.rb,v
retrieving revision 1.7
diff -u -r1.7 TestProc.rb
--- builtin/TestProc.rb 5 Jan 2002 14:35:05 -0000 1.7
+++ builtin/TestProc.rb 3 Aug 2003 08:13:21 -0000
@@ -28,11 +28,16 @@
[Proc.new { || }, -1] <<
[Proc.new { |x| }, -2]
end
- Version.greater_than("1.6.1") do
+ Version.in("1.6.2" ... "1.8") do
tests <<
[Proc.new { || }, 0] <<
[Proc.new { |x| }, -1]
end
+ Version.greater_or_equal("1.8") do
+ tests <<
+ [Proc.new { || }, 0] <<
+ [Proc.new { |x| }, 1]
+ end
tests.each do |proc, expected_arity|
assert_equal(expected_arity, proc.arity)
Index: builtin/TestTime.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/builtin/TestTime.rb,v
retrieving revision 1.17
diff -u -r1.17 TestTime.rb
--- builtin/TestTime.rb 16 Mar 2003 11:36:22 -0000 1.17
+++ builtin/TestTime.rb 3 Aug 2003 08:13:52 -0000
@@ -407,7 +407,13 @@
def test_s_at
t = Time.now
sec = t.to_i
- assert_equal(0, Time.at(0))
+ Version.less_than("1.8") do
+ assert_equal(0, Time.at(0))
+ end
+ Version.greater_or_equal("1.8") do
+ assert_not_equal(0, Time.at(0))
+ end
+
assert_equal(t, Time.at(t))
assert((Time.at(sec,1000000).to_f - Time.at(sec).to_f) == 1.0)
end
Index: language/TestAssignment.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/language/TestAssignment.rb,v
retrieving revision 1.4
diff -u -r1.4 TestAssignment.rb
--- language/TestAssignment.rb 5 Jan 2002 14:35:05 -0000 1.4
+++ language/TestAssignment.rb 3 Aug 2003 08:14:33 -0000
@@ -32,17 +32,32 @@
a = *[[]]; assert_equal([], a)
a = *[*[]]; assert_nil(a)
a = *[*[1]]; assert_equal(1, a)
- *a = nil; assert_equal([], a)
+ Version.less_than("1.8") do
+ *a = nil; assert_equal([], a)
+ end
+ Version.greater_or_equal("1.8") do
+ *a = nil; assert_equal([nil], a)
+ end
end
a = *[*[1,2]]; assert_equal([1,2], a)
*a = 1; assert_equal([1], a)
- *a = []; assert_equal([], a)
- *a = [1]; assert_equal([1], a)
- *a = [nil]; assert_equal([nil], a)
- *a = [[]]; assert_equal([[]], a)
- *a = [*[]]; assert_equal([], a)
- *a = [*[1]]; assert_equal([1], a)
+ Version.less_than("1.8") do
+ *a = []; assert_equal([], a)
+ *a = [1]; assert_equal([1], a)
+ *a = [nil]; assert_equal([nil], a)
+ *a = [[]]; assert_equal([[]], a)
+ *a = [*[]]; assert_equal([], a)
+ *a = [*[1]]; assert_equal([1], a)
+ end
+ Version.greater_or_equal("1.8") do
+ *a = []; assert_equal([[]], a)
+ *a = [1]; assert_equal([[1]], a)
+ *a = [nil]; assert_equal([[nil]], a)
+ *a = [[]]; assert_equal([[[]]], a)
+ *a = [*[]]; assert_equal([[]], a)
+ *a = [*[1]]; assert_equal([[1]], a)
+ end
*a = [*[1,2]]; assert_equal([1,2], a)
Version.less_than("1.7") do
@@ -50,11 +65,16 @@
*a = *[nil]; assert_equal([nil], a)
*a = *[[]]; assert_equal([[]], a)
end
- Version.greater_or_equal("1.7") do
+ Version.in("1.7".."1.8") do
*a = *nil; assert_equal([], a)
*a = *[nil]; assert_equal([], a)
*a = *[[]]; assert_equal([], a)
end
+ Version.greater_or_equal("1.8") do
+ *a = *nil; assert_equal([nil], a)
+ *a = *[nil]; assert_equal([nil], a)
+ *a = *[[]]; assert_equal([[]], a)
+ end
*a = *1; assert_equal([1], a)
*a = *[]; assert_equal([], a)
*a = *[1]; assert_equal([1], a)
@@ -131,9 +151,12 @@
Version.less_than("1.7") do
assert_equal([nil], a)
end
- Version.greater_or_equal("1.7") do
+ Version.in("1.7".."1.8") do
assert_equal([], a)
end
+ Version.greater_or_equal("1.8") do
+ assert_equal([nil], a)
+ end
end
def testConditionalAssignment
Index: language/TestBlocksProcs.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/language/TestBlocksProcs.rb,v
retrieving revision 1.6
diff -u -r1.6 TestBlocksProcs.rb
--- language/TestBlocksProcs.rb 28 Jan 2002 19:09:36 -0000 1.6
+++ language/TestBlocksProcs.rb 3 Aug 2003 08:15:32 -0000
@@ -60,27 +60,54 @@
def o.f; yield *[*[]]; end; o.f {|a| assert_nil(a)}
def o.f; yield *[*[1]]; end; o.f {|a| assert_equal(1, a)}
def o.f; yield *[*[1,2]]; end; o.f {|a| assert_equal([1,2], a)}
-
- def o.f; yield nil; end; o.f {|*a| assert_equal([], a)}
+
+ Version.less_than("1.8") do
+ def o.f; yield nil; end; o.f {|*a| assert_equal([], a)}
+ end
+ Version.greater_or_equal("1.8") do
+ def o.f; yield nil; end; o.f {|*a| assert_equal([nil], a)}
+ end
+
def o.f; yield 1; end; o.f {|*a| assert_equal([1], a)}
- def o.f; yield []; end; o.f {|*a| assert_equal([], a)}
- def o.f; yield [1]; end; o.f {|*a| assert_equal([1], a)}
- def o.f; yield [nil]; end; o.f {|*a| assert_equal([nil], a)}
- def o.f; yield [[]]; end; o.f {|*a| assert_equal([[]], a)}
- def o.f; yield [*[]]; end; o.f {|*a| assert_equal([], a)}
- def o.f; yield [*[1]]; end; o.f {|*a| assert_equal([1], a)}
+ Version.less_than("1.8") do
+ def o.f; yield []; end; o.f {|*a| assert_equal([], a)}
+ def o.f; yield [1]; end; o.f {|*a| assert_equal([1], a)}
+ def o.f; yield [nil]; end; o.f {|*a| assert_equal([nil], a)}
+ def o.f; yield [[]]; end; o.f {|*a| assert_equal([[]], a)}
+ def o.f; yield [*[]]; end; o.f {|*a| assert_equal([], a)}
+ def o.f; yield [*[1]]; end; o.f {|*a| assert_equal([1], a)}
+ end
+ Version.greater_or_equal("1.8") do
+ def o.f; yield []; end; o.f {|*a| assert_equal([[]], a)}
+ def o.f; yield [1]; end; o.f {|*a| assert_equal([[1]], a)}
+ def o.f; yield [nil]; end; o.f {|*a| assert_equal([[nil]], a)}
+ def o.f; yield [[]]; end; o.f {|*a| assert_equal([[[]]], a)}
+ def o.f; yield [*[]]; end; o.f {|*a| assert_equal([[]], a)}
+ def o.f; yield [*[1]]; end; o.f {|*a| assert_equal([[1]], a)}
+ end
def o.f; yield [*[1,2]]; end; o.f {|*a| assert_equal([1,2], a)}
- def o.f; yield *nil; end; o.f {|*a| assert_equal([], a)}
+ Version.less_than("1.8") do
+ def o.f; yield *nil; end; o.f {|*a| assert_equal([], a)}
+ end
+ Version.greater_or_equal("1.8") do
+ def o.f; yield *nil; end; o.f {|*a| assert_equal([nil], a)}
+ end
def o.f; yield *1; end; o.f {|*a| assert_equal([1], a)}
def o.f; yield *[]; end; o.f {|*a| assert_equal([], a)}
def o.f; yield *[1]; end; o.f {|*a| assert_equal([1], a)}
- def o.f; yield *[nil]; end; o.f {|*a| assert_equal([], a)}
- def o.f; yield *[[]]; end; o.f {|*a| assert_equal([], a)}
+ Version.less_than("1.8") do
+ def o.f; yield *[nil]; end; o.f {|*a| assert_equal([], a)}
+ def o.f; yield *[[]]; end; o.f {|*a| assert_equal([], a)}
+ end
+ Version.greater_or_equal("1.8") do
+ def o.f; yield *[nil]; end; o.f {|*a| assert_equal([nil], a)}
+ def o.f; yield *[[]]; end; o.f {|*a| assert_equal([[]], a)}
+ end
def o.f; yield *[*[]]; end; o.f {|*a| assert_equal([], a)}
def o.f; yield *[*[1]]; end; o.f {|*a| assert_equal([1], a)}
def o.f; yield *[*[1,2]]; end; o.f {|*a| assert_equal([1,2], a)}
-
+
def o.f; yield nil; end; o.f {|a,b,*c| assert([a,b,c] == [nil, nil, []])}
def o.f; yield 1; end; o.f {|a,b,*c| assert([a,b,c] == [1, nil, []])}
def o.f; yield []; end; o.f {|a,b,*c| assert([a,b,c] == [nil, nil, []])}
@@ -90,7 +117,7 @@
def o.f; yield [*[]]; end; o.f {|a,b,*c| assert([a,b,c] == [nil, nil, []])}
def o.f; yield [*[1]]; end; o.f {|a,b,*c| assert([a,b,c] == [1, nil, []])}
def o.f; yield [*[1,2]]; end; o.f {|a,b,*c| assert([a,b,c] == [1, 2, []])}
-
+
def o.f; yield *nil; end; o.f {|a,b,*c| assert([a,b,c] == [nil, nil, []])}
def o.f; yield *1; end; o.f {|a,b,*c| assert([a,b,c] == [1, nil, []])}
def o.f; yield *[]; end; o.f {|a,b,*c| assert([a,b,c] == [nil, nil, []])}
Index: language/TestLoopStuff.rb
===================================================================
RCS file: /usr/local/cvsup/ruby/rubicon/language/TestLoopStuff.rb,v
retrieving revision 1.6
diff -u -r1.6 TestLoopStuff.rb
--- language/TestLoopStuff.rb 5 Jan 2002 14:35:05 -0000 1.6
+++ language/TestLoopStuff.rb 3 Aug 2003 08:02:49 -0000
@@ -268,23 +268,39 @@
IterTest.new([[0]]).each0 { |x| x = x }
assert_equal([0], x)
- IterTest.new([[1]]).each1 { |x| x = x }
- assert_equal(1, x)
- IterTest.new([[2]]).each2 { |x| x = x }
- assert_equal([2], x)
- IterTest.new([[3]]).each3 { |x| x = x }
- assert_equal(3, x)
+ Version.less_than("1.8") do
+ IterTest.new([[1]]).each1 { |x| x = x }
+ assert_equal(1, x)
+ IterTest.new([[2]]).each2 { |x| x = x }
+ assert_equal([2], x)
+ IterTest.new([[3]]).each3 { |x| x = x }
+ assert_equal(3, x)
+ IterTest.new([[5]]).each5 { |x| x = x }
+ assert_equal(5, x)
+ IterTest.new([[6]]).each6 { |x| x = x }
+ assert_equal([6], x)
+ IterTest.new([[7]]).each7 { |x| x = x }
+ assert_equal(7, x)
+ end
+ Version.greater_or_equal("1.8") do
+ IterTest.new([[1]]).each1 { |x| x = x }
+ assert_equal([1], x)
+ IterTest.new([[2]]).each2 { |x| x = x }
+ assert_equal([[2]], x)
+ IterTest.new([[3]]).each3 { |x| x = x }
+ assert_equal(3, x)
+ IterTest.new([[5]]).each5 { |x| x = x }
+ assert_equal([5], x)
+ IterTest.new([[6]]).each6 { |x| x = x }
+ assert_equal([[6]], x)
+ end
IterTest.new([[4]]).each4 { |x| x = x }
assert_equal([4], x)
- IterTest.new([[5]]).each5 { |x| x = x }
- assert_equal(5, x)
- IterTest.new([[6]]).each6 { |x| x = x }
- assert_equal([6], x)
IterTest.new([[7]]).each7 { |x| x = x }
assert_equal(7, x)
IterTest.new([[8]]).each8 { |x| x = x }
assert_equal([8], x)
-
+
IterTest.new([[0,0]]).each0 { |x| x = x }
assert_equal([0, 0], x)
IterTest.new([[8,8]]).each8 { |x| x = x }
--
新井康司 (Koji Arai)