aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/language
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-28 09:41:26 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-28 09:41:26 +0000
commitd36cd0b04d672c79213498c0a85786b4b961836b (patch)
tree7a319c7ac897912f5e0b83496a1c7f7006abe708 /spec/ruby/language
parent1f4efb9aedfb8f537630f7c13e431bb230bebd31 (diff)
downloadruby-d36cd0b04d672c79213498c0a85786b4b961836b.tar.gz
Update to ruby/spec@6fd9472
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/language')
-rw-r--r--spec/ruby/language/fixtures/utf16-be-bom.rbbin70 -> 0 bytes
-rw-r--r--spec/ruby/language/fixtures/utf16-le-bom.rbbin71 -> 0 bytes
-rw-r--r--spec/ruby/language/predefined/data_spec.rb2
-rw-r--r--spec/ruby/language/source_encoding_spec.rb24
4 files changed, 23 insertions, 3 deletions
diff --git a/spec/ruby/language/fixtures/utf16-be-bom.rb b/spec/ruby/language/fixtures/utf16-be-bom.rb
deleted file mode 100644
index 8cb31e42f0..0000000000
--- a/spec/ruby/language/fixtures/utf16-be-bom.rb
+++ /dev/null
Binary files differ
diff --git a/spec/ruby/language/fixtures/utf16-le-bom.rb b/spec/ruby/language/fixtures/utf16-le-bom.rb
deleted file mode 100644
index 935a9041fa..0000000000
--- a/spec/ruby/language/fixtures/utf16-le-bom.rb
+++ /dev/null
Binary files differ
diff --git a/spec/ruby/language/predefined/data_spec.rb b/spec/ruby/language/predefined/data_spec.rb
index 7bbccdaca1..921d236ee9 100644
--- a/spec/ruby/language/predefined/data_spec.rb
+++ b/spec/ruby/language/predefined/data_spec.rb
@@ -34,7 +34,7 @@ describe "The DATA constant" do
it "is set even if there is no newline after __END__" do
path = tmp("no_newline_data.rb")
code = File.binread(fixture(__FILE__, "empty_data.rb"))
- touch(path) { |f| f.write code.chomp }
+ touch(path, "wb") { |f| f.write code.chomp }
begin
ruby_exe(path).should == "30\n\"\"\n"
ensure
diff --git a/spec/ruby/language/source_encoding_spec.rb b/spec/ruby/language/source_encoding_spec.rb
index d4240cee39..a0a29f63de 100644
--- a/spec/ruby/language/source_encoding_spec.rb
+++ b/spec/ruby/language/source_encoding_spec.rb
@@ -22,7 +22,17 @@ describe "Source files" do
describe "encoded in UTF-16 LE with a BOM" do
it "are invalid because they contain an invalid UTF-8 sequence before the encoding comment" do
- ruby_exe(fixture(__FILE__, "utf16-le-bom.rb"), args: "2>&1").should =~ /invalid multibyte char/
+ bom = "\xFF\xFE".b
+ source = "# encoding: utf-16le\nputs 'hello'\n"
+ source = bom + source.bytes.zip([0]*source.bytesize).flatten.pack('C*')
+ path = tmp("utf16-le-bom.rb")
+
+ touch(path, "wb") { |f| f.write source }
+ begin
+ ruby_exe(path, args: "2>&1").should =~ /invalid multibyte char/
+ ensure
+ rm_r path
+ end
end
end
@@ -34,7 +44,17 @@ describe "Source files" do
describe "encoded in UTF-16 BE with a BOM" do
it "are invalid because they contain an invalid UTF-8 sequence before the encoding comment" do
- ruby_exe(fixture(__FILE__, "utf16-be-bom.rb"), args: "2>&1").should =~ /invalid multibyte char/
+ bom = "\xFE\xFF".b
+ source = "# encoding: utf-16be\nputs 'hello'\n"
+ source = bom + ([0]*source.bytesize).zip(source.bytes).flatten.pack('C*')
+ path = tmp("utf16-be-bom.rb")
+
+ touch(path, "wb") { |f| f.write source }
+ begin
+ ruby_exe(path, args: "2>&1").should =~ /invalid multibyte char/
+ ensure
+ rm_r path
+ end
end
end