1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* sample/test.rb (valid_syntax?): should not capture BOM.

* test/ruby/test_system.rb (TestSystem#valid_syntax?): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-06-17 06:22:58 +00:00
parent 53ecede90b
commit a6db50e02b
2 changed files with 2 additions and 2 deletions

View file

@ -1931,7 +1931,7 @@ end
def valid_syntax?(code, fname)
p fname
code = code.dup.force_encoding("ascii-8bit")
code.sub!(/\A(\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
}
code.force_encoding("us-ascii")

View file

@ -5,7 +5,7 @@ require_relative 'envutil'
class TestSystem < Test::Unit::TestCase
def valid_syntax?(code, fname)
code = code.dup.force_encoding("ascii-8bit")
code.sub!(/\A(\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
}
code.force_encoding("us-ascii")