1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_eval.rb (TestEval::test_instance_eval_cvar):

updated not to modify class variable of Object class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-11-26 01:31:20 +00:00
parent e42d6b8862
commit 691df99d6a
3 changed files with 11 additions and 17 deletions

View file

@ -16,6 +16,11 @@ Sun Nov 25 12:12:03 2007 Eric Hodel <drbrain@segment7.net>
* lib/rubygems*: Import RubyGems r1516.
Sat Nov 24 23:25:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* test/ruby/test_eval.rb (TestEval::test_instance_eval_cvar):
updated not to modify class variable of Object class.
Fri Nov 23 17:34:24 2007 Koichi Sasada <ko1@atdot.net>
* io.c: add rb_read_internal() as blocking function.

View file

@ -184,8 +184,7 @@ getclassvariable
()
(VALUE val)
{
VALUE klass = vm_get_cvar_base(th, GET_ISEQ());
val = rb_cvar_get(klass, id);
val = rb_cvar_get(vm_get_cvar_base(th, GET_ISEQ()), id);
}
/**

View file

@ -118,12 +118,9 @@ class TestEval < Test::Unit::TestCase
end
def forall_TYPE(mid)
objects = [Object.new, [], nil, true, false, 77, ] #:sym] # TODO: check
objects = [Object.new, [], nil, true, false, 77, :sym] # TODO: check
objects.each do |obj|
obj.instance_variable_set :@ivar, 12
obj.class.class_variable_set :@@cvar, 13
# Use same value with env. See also test_instance_variable_cvar.
obj.class.const_set :Const, 15 unless obj.class.const_defined?(:Const)
send mid, obj
end
end
@ -142,11 +139,7 @@ class TestEval < Test::Unit::TestCase
assert_equal 11, o.instance_eval("11")
assert_equal 12, o.instance_eval("@ivar")
begin
assert_equal 13, o.instance_eval("@@cvar")
rescue => err
assert false, "cannot get cvar from #{o.class}"
end
assert_equal 13, o.instance_eval("@@cvar")
assert_equal 14, o.instance_eval("$gvar__eval")
assert_equal 15, o.instance_eval("Const")
assert_equal 16, o.instance_eval("7 + 9")
@ -194,16 +187,13 @@ class TestEval < Test::Unit::TestCase
def test_instance_eval_cvar
env = @@cvar
cls = "class"
[Object.new, [], 7, ].each do |obj| # TODO: check :sym
obj.class.class_variable_set :@@cvar, cls
[Object.new, [], 7, :sym].each do |obj| # TODO: check :sym
assert_equal env, obj.instance_eval("@@cvar")
assert_equal env, obj.instance_eval { @@cvar }
end
[true, false, nil].each do |obj|
obj.class.class_variable_set :@@cvar, cls
assert_equal cls, obj.instance_eval("@@cvar")
assert_equal cls, obj.instance_eval { @@cvar }
assert_equal env, obj.instance_eval("@@cvar")
assert_equal env, obj.instance_eval { @@cvar }
end
end