From 5f39ad86ddf525792a943d7688ea76121de97a8d Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 2 Feb 2009 03:39:01 +0000 Subject: * sample/test.rb (valid_syntax?), test/ruby/test_system.rb (TestSystem::valid_syntax?): use catch and throw instead of return inside BEGIN block. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_system.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index ec8aca74c..4aae0d54f 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -6,9 +6,9 @@ class TestSystem < Test::Unit::TestCase def valid_syntax?(code, fname) code.force_encoding("ascii-8bit") code = code.sub(/\A(?:\s*\#.*$)*(\n)?/n) { - "#$&#{"\n" if $1 && !$2}BEGIN{return true}\n" + "#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n" } - eval(code, nil, fname, 0) + catch {|tag| eval(code, binding, fname, 0)} end def test_system -- cgit