summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-26 05:54:48 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-26 05:54:48 +0000
commit9fa2c9ea98eb97f8547aa71eaf9d6f97e7201944 (patch)
treef54e03ddc76c828697b9d48bddbb1169307dc27b /test
parentb7a1cb6251c4eb661f15d2990e6d922161ee88dd (diff)
merges r20984 from trunk. c.f. [ruby-dev:37240]
* test/ruby/test_eval.rb: add new test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_eval.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb
index 23d34a5f81..2f4b0bfbbd 100644
--- a/test/ruby/test_eval.rb
+++ b/test/ruby/test_eval.rb
@@ -1,4 +1,5 @@
require 'test/unit'
+require_relative 'envutil'
class TestEval < Test::Unit::TestCase
@@ -7,6 +8,15 @@ class TestEval < Test::Unit::TestCase
$gvar__eval = 14
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
assert_equal nil, eval("nil")
assert_equal true, eval("true")
@@ -391,4 +401,11 @@ class TestEval < Test::Unit::TestCase
end.join
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