Actions
Bug #14687
closedTestM17N#test_str_dump, String.dump, frozen-string
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-04-12 trunk 63140) [x64-mingw32]
Description
The test TestM17N#test_str_dump
located in test/ruby/test_m17n.rb
(link at https://github.com/ruby/ruby/blob/83c961665def138e78a66d8bef0b4fa1da49ac69/test/ruby/test_m17n.rb#L324-L363), fails when run with frozen-string.
The test is similar to
def test_str_dump # Note: several array elements removed to shorten
[
"\u3042".encode("UTF-16LE"),
"\u3042".encode("UTF-16BE"),
].each do |str|
assert_equal(str, eval(str.dump), "[ruby-dev:33142]")
end
end
Since the following
"\u3042".encode("UTF-16LE").dump #-> "B0".force_encoding("UTF-16LE")
"\u3042".encode("UTF-16BE").dump #-> "0B".force_encoding("UTF-16BE")
When eval'd by the test, there is a failure due to the string being frozen. Not being a c type, not really sure what the solution is.
Possibly change line 5969 of string.c from
static const char nonascii_suffix[] = ".force_encoding(\"%s\")";
to
static const char nonascii_suffix[] = "dup.force_encoding(\"%s\")";
Thanks, Greg
Actions
Like0
Like0Like0Like0