From: Kazuhiro NISHIYAMA Date: 2003-02-01T03:06:09+09:00 Subject: [ruby-dev:19447] shim/ruby16 patch 西山和広です。 Regexp#eql?, Regexp#hashが気になっていたのでshimを ちょっといじってみたパッチです。 test caseが足りないので適当になおして取り込んでください。 * test17をtest18に。 * make test16でFが出たのを修正。 * Regexp#eql?, Regexp#hash Index: Makefile =================================================================== RCS file: /src/shim/ruby16/Makefile,v retrieving revision 1.12 diff -u -p -r1.12 Makefile --- Makefile 11 Sep 2002 06:42:13 -0000 1.12 +++ Makefile 31 Jan 2003 17:53:02 -0000 @@ -47,5 +47,5 @@ test: $(SETUP_COOKIE) test16: $(MAKE) RUBY=ruby16 test -test17: - $(MAKE) RUBY=ruby17 test +test18: + $(MAKE) RUBY=ruby18 test Index: lib/features/ruby18/proc.rb =================================================================== RCS file: /src/shim/ruby16/lib/features/ruby18/proc.rb,v retrieving revision 1.4 diff -u -p -r1.4 proc.rb --- lib/features/ruby18/proc.rb 16 Apr 2002 00:22:54 -0000 1.4 +++ lib/features/ruby18/proc.rb 31 Jan 2003 17:53:02 -0000 @@ -4,11 +4,13 @@ require 'features/ruby18/base' class Proc def self.__ruby18_yield(args) - yield(*args) + yield(args) end def yield(*args) - if args.empty? or [nil] == args + if args.empty? call + elsif [nil] == args + call(nil) else type.__ruby18_yield(args, &self) end Index: lib/features/ruby18/regexp.rb =================================================================== RCS file: /src/shim/ruby16/lib/features/ruby18/regexp.rb,v retrieving revision 1.4 diff -u -p -r1.4 regexp.rb --- lib/features/ruby18/regexp.rb 11 Sep 2002 07:10:04 -0000 1.4 +++ lib/features/ruby18/regexp.rb 31 Jan 2003 17:53:02 -0000 @@ -3,6 +3,15 @@ require 'features/ruby18/base' class Regexp + def eql?(o) + return false unless o.is_a?(Regexp) + source.eql?(o.source) + end + + def hash + source.hash + end + def options str = inspect pos = str.rindex(?/) + 1 Index: tests/features/ruby18/tc_proc.rb =================================================================== RCS file: /src/shim/ruby16/tests/features/ruby18/tc_proc.rb,v retrieving revision 1.4 diff -u -p -r1.4 tc_proc.rb --- tests/features/ruby18/tc_proc.rb 16 Apr 2002 00:21:08 -0000 1.4 +++ tests/features/ruby18/tc_proc.rb 31 Jan 2003 17:53:02 -0000 @@ -84,8 +84,8 @@ class TC_Proc < Test::Unit::TestCase def test_yield_m f = proc {|*x| x} assert_equal([], f.yield()) - assert_equal([], f.yield([])) - assert_equal([], f.yield(nil)) - assert_equal([1], f.yield([1])) + assert_equal([[]], f.yield([])) + assert_equal([nil], f.yield(nil)) + assert_equal([[1]], f.yield([1])) end end Index: tests/features/ruby18/tc_regexp.rb =================================================================== RCS file: /src/shim/ruby16/tests/features/ruby18/tc_regexp.rb,v retrieving revision 1.4 diff -u -p -r1.4 tc_regexp.rb --- tests/features/ruby18/tc_regexp.rb 11 Sep 2002 07:10:04 -0000 1.4 +++ tests/features/ruby18/tc_regexp.rb 31 Jan 2003 17:53:02 -0000 @@ -6,6 +6,14 @@ begin rescue LoadError; end class TC_Regexp < Test::Unit::TestCase + def test_eql? + assert(/a/.eql?(/a/)) + end + + def test_hash + assert_equal(/a/.hash, /a/.hash) + end + def test_options re = /a/ -- |ZnZ(ゼット エヌ ゼット) |西山和広(Kazuhiro NISHIYAMA)