mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	object.c: fix prepend cmp
* object.c (rb_class_inherited_p): search the corresponding ancestor to prepended module from prepending class itself. [ruby-core:72493] [Bug #11878] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									d252e224f6
								
							
						
					
					
						commit
						a974041b0e
					
				
					 3 changed files with 14 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,9 @@
 | 
			
		|||
Wed Dec 30 09:58:56 2015  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* object.c (rb_class_inherited_p): search the corresponding
 | 
			
		||||
	  ancestor to prepended module from prepending class itself.
 | 
			
		||||
	  [ruby-core:72493] [Bug #11878]
 | 
			
		||||
 | 
			
		||||
Wed Dec 30 09:20:00 2015  Yuki Kurihara  <co000ri@gmail.com>
 | 
			
		||||
 | 
			
		||||
	* test/stringio/test_io.rb (test_flag): add assertion for error when
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										7
									
								
								object.c
									
										
									
									
									
								
							
							
						
						
									
										7
									
								
								object.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1549,18 +1549,15 @@ rb_mod_eqq(VALUE mod, VALUE arg)
 | 
			
		|||
VALUE
 | 
			
		||||
rb_class_inherited_p(VALUE mod, VALUE arg)
 | 
			
		||||
{
 | 
			
		||||
    VALUE start = mod;
 | 
			
		||||
 | 
			
		||||
    if (mod == arg) return Qtrue;
 | 
			
		||||
    if (!CLASS_OR_MODULE_P(arg) && !RB_TYPE_P(arg, T_ICLASS)) {
 | 
			
		||||
	rb_raise(rb_eTypeError, "compared with non class/module");
 | 
			
		||||
    }
 | 
			
		||||
    arg = RCLASS_ORIGIN(arg);
 | 
			
		||||
    if (class_search_ancestor(mod, arg)) {
 | 
			
		||||
    if (class_search_ancestor(mod, RCLASS_ORIGIN(arg))) {
 | 
			
		||||
	return Qtrue;
 | 
			
		||||
    }
 | 
			
		||||
    /* not mod < arg; check if mod > arg */
 | 
			
		||||
    if (class_search_ancestor(arg, start)) {
 | 
			
		||||
    if (class_search_ancestor(arg, mod)) {
 | 
			
		||||
	return Qfalse;
 | 
			
		||||
    }
 | 
			
		||||
    return Qnil;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1566,6 +1566,12 @@ class TestModule < Test::Unit::TestCase
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_prepend_CMP
 | 
			
		||||
    bug11878 = '[ruby-core:72493] [Bug #11878]'
 | 
			
		||||
    assert_equal(-1, C1 <=> M2)
 | 
			
		||||
    assert_equal(+1, M2 <=> C1, bug11878)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_prepend_inheritance
 | 
			
		||||
    bug6654 = '[ruby-core:45914]'
 | 
			
		||||
    a = labeled_module("a")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue