diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-02 03:39:01 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-02 03:39:01 +0000 |
commit | 5f39ad86ddf525792a943d7688ea76121de97a8d (patch) | |
tree | 8fc391820b2d123423d9c0f19522cd262b56a600 /sample/test.rb | |
parent | 03d02a49d6eea5fbfde9e3a5a60b554a867e8d89 (diff) | |
download | ruby-5f39ad86ddf525792a943d7688ea76121de97a8d.tar.gz ruby-5f39ad86ddf525792a943d7688ea76121de97a8d.tar.xz ruby-5f39ad86ddf525792a943d7688ea76121de97a8d.zip |
* 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
Diffstat (limited to 'sample/test.rb')
-rw-r--r-- | sample/test.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sample/test.rb b/sample/test.rb index 21656885f..03ab435e0 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -1931,9 +1931,9 @@ def valid_syntax?(code, fname) p 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)} rescue Exception STDERR.puts $!.message false |