From 5159f500fdab17c053075c7dd62b5050fdb80bc5 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 29 Aug 2008 22:50:16 +0000 Subject: [PATCH] * encoding.c (enc_compatible_p): add SPECIAL_CONST_P check. * test/ruby/test_m17n.rb (test_compatible): fix test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ encoding.c | 14 ++++++++------ test/ruby/test_m17n.rb | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4fc8d28baa..56d8b5b6bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Aug 30 07:48:48 2008 NARUSE, Yui + + * encoding.c (enc_compatible_p): add SPECIAL_CONST_P check. + + * test/ruby/test_m17n.rb (test_compatible): fix test. + Sat Aug 30 02:48:11 2008 Yukihiro Matsumoto * object.c (rb_obj_freeze): update rdoc to mention RuntimeError diff --git a/encoding.c b/encoding.c index 21614245ae..bb6f5b269e 100644 --- a/encoding.c +++ b/encoding.c @@ -880,13 +880,15 @@ enc_compatible_p(VALUE klass, VALUE str1, VALUE str2) { rb_encoding *enc; - if (BUILTIN_TYPE(str1) != T_STRING && BUILTIN_TYPE(str1) != T_REGEXP) { - rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)", - rb_obj_classname(str1)); + if (SPECIAL_CONST_P(str1) || + BUILTIN_TYPE(str1) != T_STRING && BUILTIN_TYPE(str1) != T_REGEXP) { + rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)", + rb_obj_classname(str1)); } - if (BUILTIN_TYPE(str2) != T_STRING && BUILTIN_TYPE(str2) != T_REGEXP) { - rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)", - rb_obj_classname(str2)); + if (SPECIAL_CONST_P(str2) || + BUILTIN_TYPE(str2) != T_STRING && BUILTIN_TYPE(str2) != T_REGEXP) { + rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)", + rb_obj_classname(str2)); } if (!enc_capable(str1)) return Qnil; if (!enc_capable(str2)) return Qnil; diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index e82e04beb7..a878227534 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1280,7 +1280,7 @@ class TestM17N < Test::Unit::TestCase end def test_compatible - assert_equal(nil, Encoding.compatible?("",0), "moved from btest/knownbug") + assert_raise(TypeError) {Encoding.compatible?("",0)} end def test_force_encoding