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: class variable test updated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-12-21 17:22:34 +00:00
parent 2bed2cdc7f
commit 2c40f3a7a9

View file

@ -139,7 +139,7 @@ class TestEval < Test::Unit::TestCase
assert_equal 11, o.instance_eval("11")
assert_equal 12, o.instance_eval("@ivar")
assert_equal 13, o.instance_eval("@@cvar")
assert_raise(NameError) {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")
@ -149,7 +149,7 @@ class TestEval < Test::Unit::TestCase
1.times {
assert_equal 12, o.instance_eval("@ivar")
assert_equal 13, o.instance_eval("@@cvar")
assert_raise(NameError) {o.instance_eval("@@cvar")}
assert_equal 14, o.instance_eval("$gvar__eval")
assert_equal 15, o.instance_eval("Const")
}
@ -169,7 +169,7 @@ class TestEval < Test::Unit::TestCase
assert_equal 11, o.instance_eval { 11 }
assert_equal 12, o.instance_eval { @ivar }
assert_equal 13, o.instance_eval { @@cvar }
assert_raise(NameError) {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 }
@ -179,21 +179,16 @@ class TestEval < Test::Unit::TestCase
1.times {
assert_equal 12, o.instance_eval { @ivar }
assert_equal 13, o.instance_eval { @@cvar }
assert_raise(NameError) {o.instance_eval{ @@cvar }}
assert_equal 14, o.instance_eval { $gvar__eval }
assert_equal 15, o.instance_eval { Const }
}
end
def test_instance_eval_cvar
env = @@cvar
[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|
assert_equal env, obj.instance_eval("@@cvar")
assert_equal env, obj.instance_eval { @@cvar }
[Object.new, [], 7, :sym, true, false, nil].each do |obj|
assert_raise(NameError){obj.instance_eval("@@cvar")}
assert_raise(NameError){obj.instance_eval{@@cvar}}
end
end