From 2e752da616efd57083dbac93b4b6b2347e42a65c Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 18 Aug 2007 03:24:32 +0000 Subject: * sample/test.rb, test/ruby/test_system.rb(valid_syntax?): keep comment lines first. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_system.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/ruby') diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index f3a71598f7..3513577ec5 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -4,7 +4,10 @@ require 'envutil' class TestSystem < Test::Unit::TestCase def valid_syntax?(code, fname) - eval("BEGIN {return true}\n#{code}", nil, fname, 0) + code = code.sub(/\A(?:\s*\#.*$)*(\n)?/n) { + "#$&#{"\n" if $1 && !$2}BEGIN{return true}\n" + } + eval(code, nil, fname, 0) end def test_system -- cgit v1.2.3