From 6d66fcab264406bc9d5aef7f0cd3e1467969008f Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 17 Jun 2009 05:37:23 +0000 Subject: * sample/test.rb (valid_syntax?): skips BOM. [ruby-dev:38666] * test/ruby/test_system.rb (TestSystem#valid_syntax?): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_system.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index 4aae0d54f..2143fcad7 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -4,10 +4,11 @@ require_relative 'envutil' class TestSystem < Test::Unit::TestCase def valid_syntax?(code, fname) - code.force_encoding("ascii-8bit") - code = code.sub(/\A(?:\s*\#.*$)*(\n)?/n) { + code = code.dup.force_encoding("ascii-8bit") + code.sub!(/\A(\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) { "#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n" } + code.force_encoding("us-ascii") catch {|tag| eval(code, binding, fname, 0)} end -- cgit