mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_eval.rb: use block
* test/ruby/test_eval.rb (forall_TYPE): use block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c5617b357d
commit
f58feecd36
1 changed files with 6 additions and 10 deletions
|
@ -127,19 +127,16 @@ class TestEval < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def forall_TYPE(mid)
|
def forall_TYPE
|
||||||
objects = [Object.new, [], nil, true, false, 77, :sym] # TODO: check
|
objects = [Object.new, [], nil, true, false, 77, :sym] # TODO: check
|
||||||
objects.each do |obj|
|
objects.each do |obj|
|
||||||
obj.instance_variable_set :@ivar, 12
|
obj.instance_variable_set :@ivar, 12
|
||||||
send mid, obj
|
yield obj
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_instance_eval_string_basic
|
def test_instance_eval_string_basic
|
||||||
forall_TYPE :instance_eval_string_basic_i
|
forall_TYPE do |o|
|
||||||
end
|
|
||||||
|
|
||||||
def instance_eval_string_basic_i(o)
|
|
||||||
assert_equal nil, o.instance_eval("nil")
|
assert_equal nil, o.instance_eval("nil")
|
||||||
assert_equal true, o.instance_eval("true")
|
assert_equal true, o.instance_eval("true")
|
||||||
assert_equal false, o.instance_eval("false")
|
assert_equal false, o.instance_eval("false")
|
||||||
|
@ -164,12 +161,10 @@ class TestEval < Test::Unit::TestCase
|
||||||
assert_equal 15, o.instance_eval("Const")
|
assert_equal 15, o.instance_eval("Const")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_instance_eval_block_basic
|
|
||||||
forall_TYPE :instance_eval_block_basic_i
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def instance_eval_block_basic_i(o)
|
def test_instance_eval_block_basic
|
||||||
|
forall_TYPE do |o|
|
||||||
assert_equal nil, o.instance_eval { nil }
|
assert_equal nil, o.instance_eval { nil }
|
||||||
assert_equal true, o.instance_eval { true }
|
assert_equal true, o.instance_eval { true }
|
||||||
assert_equal false, o.instance_eval { false }
|
assert_equal false, o.instance_eval { false }
|
||||||
|
@ -194,6 +189,7 @@ class TestEval < Test::Unit::TestCase
|
||||||
assert_equal 15, o.instance_eval { Const }
|
assert_equal 15, o.instance_eval { Const }
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_instance_eval_cvar
|
def test_instance_eval_cvar
|
||||||
[Object.new, [], 7, :sym, true, false, nil].each do |obj|
|
[Object.new, [], 7, :sym, true, false, nil].each do |obj|
|
||||||
|
|
Loading…
Reference in a new issue