mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@21944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
61fc0c6cf4
commit
ce720ca0dc
3 changed files with 10 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
|||
Mon Feb 2 12:39:00 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* sample/test.rb (valid_syntax?), test/ruby/test_system.rb
|
||||
(TestSystem::valid_syntax?): use catch and throw instead of
|
||||
return inside BEGIN block.
|
||||
|
||||
Mon Feb 2 11:45:10 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/rubysocket.h (cmsg_type_arg): declared.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue