mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_eval.rb: add new test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dea037cc67
commit
c4b30b4449
1 changed files with 17 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
require_relative 'envutil'
|
||||||
|
|
||||||
class TestEval < Test::Unit::TestCase
|
class TestEval < Test::Unit::TestCase
|
||||||
|
|
||||||
|
@ -7,6 +8,15 @@ class TestEval < Test::Unit::TestCase
|
||||||
$gvar__eval = 14
|
$gvar__eval = 14
|
||||||
Const = 15
|
Const = 15
|
||||||
|
|
||||||
|
def ruby(*args)
|
||||||
|
args = ['-e', '$>.write($<.read)'] if args.empty?
|
||||||
|
ruby = EnvUtil.rubybin
|
||||||
|
f = IO.popen([ruby] + args, 'r+')
|
||||||
|
yield(f)
|
||||||
|
ensure
|
||||||
|
f.close unless !f || f.closed?
|
||||||
|
end
|
||||||
|
|
||||||
def test_eval_basic
|
def test_eval_basic
|
||||||
assert_equal nil, eval("nil")
|
assert_equal nil, eval("nil")
|
||||||
assert_equal true, eval("true")
|
assert_equal true, eval("true")
|
||||||
|
@ -391,4 +401,11 @@ class TestEval < Test::Unit::TestCase
|
||||||
end.join
|
end.join
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_eval_with_toplevel_binding # [ruby-dev:37142]
|
||||||
|
ruby("-e", "x = 0; eval('p x', TOPLEVEL_BINDING)") do |f|
|
||||||
|
f.close_write
|
||||||
|
assert_equal("0", f.read.chomp)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue