summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-14 06:40:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-14 06:40:55 +0000
commitc81b224edca453ed8ea3030cc74b2ede5ac9e63a (patch)
tree91fad68f293185c4ac2ee01e568b91896ae04bb9 /test/lib
parentfcb4ab8d1c917b3f2a998f9b6eab3d9cec27670a (diff)
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
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/test/unit/assertions.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index 65c467b..201e245 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