From c81b224edca453ed8ea3030cc74b2ede5ac9e63a Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 14 Dec 2015 06:40:55 +0000 Subject: test: use String#b instead of dup.force_encoding git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/lib/test/unit/assertions.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/lib/test') diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb index 65c467bfe9..201e24592a 100644 --- a/test/lib/test/unit/assertions.rb +++ b/test/lib/test/unit/assertions.rb @@ -447,7 +447,7 @@ EOT end def assert_valid_syntax(code, fname = caller_locations(1, 1)[0], mesg = fname.to_s, verbose: nil) - code = code.dup.force_encoding("ascii-8bit") + code = code.b code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) { "#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n" } @@ -470,11 +470,11 @@ EOT end def assert_syntax_error(code, error, fname = caller_locations(1, 1)[0], mesg = fname.to_s) - code = code.dup.force_encoding("ascii-8bit") + code = code.b code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) { "#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ng}\n" } - code.force_encoding("us-ascii") + code.force_encoding(Encoding::US_ASCII) verbose, $VERBOSE = $VERBOSE, nil yield if defined?(yield) case -- cgit v1.2.3