mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	eval.c: fix message as same as previous versions
* eval.c (rb_frozen_class_p): fix message for singleton class of class/module as same as previous versions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									92c1d1a950
								
							
						
					
					
						commit
						0fa9553604
					
				
					 2 changed files with 19 additions and 2 deletions
				
			
		
							
								
								
									
										15
									
								
								eval.c
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								eval.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -412,8 +412,21 @@ rb_frozen_class_p(VALUE klass)
 | 
			
		|||
    if (OBJ_FROZEN(klass)) {
 | 
			
		||||
	const char *desc;
 | 
			
		||||
 | 
			
		||||
	if (FL_TEST(klass, FL_SINGLETON))
 | 
			
		||||
	if (FL_TEST(klass, FL_SINGLETON)) {
 | 
			
		||||
	    desc = "object";
 | 
			
		||||
	    klass = rb_ivar_get(klass, id__attached__);
 | 
			
		||||
	    if (!SPECIAL_CONST_P(klass)) {
 | 
			
		||||
		switch (BUILTIN_TYPE(klass)) {
 | 
			
		||||
		  case T_MODULE:
 | 
			
		||||
		  case T_ICLASS:
 | 
			
		||||
		    desc = "Module";
 | 
			
		||||
		    break;
 | 
			
		||||
		  case T_CLASS:
 | 
			
		||||
		    desc = "Class";
 | 
			
		||||
		    break;
 | 
			
		||||
		}
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
	    switch (BUILTIN_TYPE(klass)) {
 | 
			
		||||
	      case T_MODULE:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -389,8 +389,12 @@ class TestClass < Test::Unit::TestCase
 | 
			
		|||
    obj = Object.new
 | 
			
		||||
    c = obj.singleton_class
 | 
			
		||||
    obj.freeze
 | 
			
		||||
    assert_raise(RuntimeError, /frozen object/) {
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen object/) {
 | 
			
		||||
      c.class_eval {def f; end}
 | 
			
		||||
    }
 | 
			
		||||
    c = Class.new.freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen Class/) {
 | 
			
		||||
      def c.f; end
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue