зеркало из https://github.com/github/ruby.git
* insns.def (defined): fix to checking class variable.
A patch by Magnus Holm <judofyr@gmail.com>. Thanks! * test/ruby/test_variable.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
61920a128a
Коммит
4f03f0cb67
|
@ -1,3 +1,10 @@
|
|||
Wed Aug 24 09:49:10 2011 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* insns.def (defined): fix to checking class variable.
|
||||
A patch by Magnus Holm <judofyr@gmail.com>. Thanks!
|
||||
|
||||
* test/ruby/test_variable.rb: add a test for above.
|
||||
|
||||
Wed Aug 24 08:53:06 2011 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rdoc: Update to RDoc 3.9.3. Fixes RDoc with `ruby -Ku`. Allows
|
||||
|
|
|
@ -773,11 +773,14 @@ defined
|
|||
}
|
||||
break;
|
||||
case DEFINED_CVAR:
|
||||
klass = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP());
|
||||
{
|
||||
NODE *cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
|
||||
klass = vm_get_cvar_base(cref);
|
||||
if (rb_cvar_defined(klass, SYM2ID(obj))) {
|
||||
expr_type = "class variable";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DEFINED_CONST:
|
||||
klass = v;
|
||||
if (vm_get_ev_const(th, GET_ISEQ(), klass, SYM2ID(obj), 1)) {
|
||||
|
|
|
@ -55,6 +55,11 @@ class TestVariable < Test::Unit::TestCase
|
|||
assert_equal("Cronus", atlas.ruler0)
|
||||
assert_equal("Zeus", atlas.ruler3)
|
||||
assert_equal("Cronus", atlas.ruler4)
|
||||
assert_nothing_raised do
|
||||
class << Gods
|
||||
defined?(@@rule) && @@rule
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_local_variables
|
||||
|
|
Загрузка…
Ссылка в новой задаче