[前][次][番号順一覧][スレッド一覧]

ruby-changes:52363

From: eregon <ko1@a...>
Date: Tue, 28 Aug 2018 01:22:33 +0900 (JST)
Subject: [ruby-changes:52363] eregon:r64571 (trunk): Update to ruby/spec@007e908

eregon	2018-08-28 01:22:21 +0900 (Tue, 28 Aug 2018)

  New Revision: 64571

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64571

  Log:
    Update to ruby/spec@007e908

  Modified files:
    trunk/spec/ruby/command_line/dash_upper_k_spec.rb
    trunk/spec/ruby/language/fixtures/utf16-le-bom.rb
    trunk/spec/ruby/language/magic_comment_spec.rb
    trunk/spec/ruby/language/predefined/data_spec.rb
Index: spec/ruby/language/predefined/data_spec.rb
===================================================================
--- spec/ruby/language/predefined/data_spec.rb	(revision 64570)
+++ spec/ruby/language/predefined/data_spec.rb	(revision 64571)
@@ -33,7 +33,7 @@ describe "The DATA constant" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/predefined/data_spec.rb#L33
 
   it "is set even if there is no newline after __END__" do
     path = tmp("no_newline_data.rb")
-    code = File.read(fixture(__FILE__, "empty_data.rb"))
+    code = File.binread(fixture(__FILE__, "empty_data.rb"))
     touch(path) { |f| f.write code.chomp }
     begin
       ruby_exe(path).should == "30\n\"\"\n"
Index: spec/ruby/language/fixtures/utf16-le-bom.rb
===================================================================
Binary files spec/ruby/language/fixtures/utf16-le-bom.rb	(revision 64570) and spec/ruby/language/fixtures/utf16-le-bom.rb	(revision 64571) differ
Index: spec/ruby/language/magic_comment_spec.rb
===================================================================
--- spec/ruby/language/magic_comment_spec.rb	(revision 64570)
+++ spec/ruby/language/magic_comment_spec.rb	(revision 64571)
@@ -2,8 +2,12 @@ require_relative '../spec_helper' https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/magic_comment_spec.rb#L2
 
 # See core/kernel/eval_spec.rb for more magic comments specs for eval()
 describe :magic_comments, shared: true do
+  before :each do
+    @default = @method == :locale ? Encoding.find('locale') : Encoding::UTF_8
+  end
+
   it "are optional" do
-    @object.call('no_magic_comment.rb').should == Encoding::UTF_8.name
+    @object.call('no_magic_comment.rb').should == @default.name
   end
 
   it "are case-insensitive" do
@@ -11,11 +15,11 @@ describe :magic_comments, shared: true d https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/magic_comment_spec.rb#L15
   end
 
   it "must be at the first line" do
-    @object.call('second_line_magic_comment.rb').should == Encoding::UTF_8.name
+    @object.call('second_line_magic_comment.rb').should == @default.name
   end
 
   it "must be the first token of the line" do
-    @object.call('second_token_magic_comment.rb').should == Encoding::UTF_8.name
+    @object.call('second_token_magic_comment.rb').should == @default.name
   end
 
   it "can be after the shebang" do
@@ -40,16 +44,16 @@ describe :magic_comments, shared: true d https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/magic_comment_spec.rb#L44
 end
 
 describe "Magic comments" do
-  platform_is_not :windows do
-    describe "in stdin" do
-      it_behaves_like :magic_comments, nil, -> file {
-        print_at_exit = fixture(__FILE__, "print_magic_comment_result_at_exit.rb")
-        ruby_exe(nil, args: "< #{fixture(__FILE__, file)}", options: "-r#{print_at_exit}")
-      }
-    end
+  describe "in stdin" do
+    it_behaves_like :magic_comments, :locale, -> file {
+      print_at_exit = fixture(__FILE__, "print_magic_comment_result_at_exit.rb")
+      ruby_exe(nil, args: "< #{fixture(__FILE__, file)}", options: "-r#{print_at_exit}")
+    }
+  end
 
+  platform_is_not :windows do
     describe "in an -e argument" do
-      it_behaves_like :magic_comments, nil, -> file {
+      it_behaves_like :magic_comments, :locale, -> file {
         print_at_exit = fixture(__FILE__, "print_magic_comment_result_at_exit.rb")
         # Use UTF-8, as it is the default source encoding for files
         code = File.read(fixture(__FILE__, file), encoding: 'utf-8')
@@ -59,28 +63,28 @@ describe "Magic comments" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/magic_comment_spec.rb#L63
   end
 
   describe "in the main file" do
-    it_behaves_like :magic_comments, nil, -> file {
+    it_behaves_like :magic_comments, :UTF8, -> file {
       print_at_exit = fixture(__FILE__, "print_magic_comment_result_at_exit.rb")
       ruby_exe(fixture(__FILE__, file), options: "-r#{print_at_exit}")
     }
   end
 
   describe "in a loaded file" do
-    it_behaves_like :magic_comments, nil, -> file {
+    it_behaves_like :magic_comments, :UTF8, -> file {
       load fixture(__FILE__, file)
       $magic_comment_result
     }
   end
 
   describe "in a required file" do
-    it_behaves_like :magic_comments, nil, -> file {
+    it_behaves_like :magic_comments, :UTF8, -> file {
       require fixture(__FILE__, file)
       $magic_comment_result
     }
   end
 
   describe "in an eval" do
-    it_behaves_like :magic_comments, nil, -> file {
+    it_behaves_like :magic_comments, :UTF8, -> file {
       # Use UTF-8, as it is the default source encoding for files
       eval(File.read(fixture(__FILE__, file), encoding: 'utf-8'))
     }
Index: spec/ruby/command_line/dash_upper_k_spec.rb
===================================================================
--- spec/ruby/command_line/dash_upper_k_spec.rb	(revision 64570)
+++ spec/ruby/command_line/dash_upper_k_spec.rb	(revision 64571)
@@ -57,10 +57,9 @@ describe 'The -K command line option' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_upper_k_spec.rb#L57
     end
   end
 
-  platform_is_not :windows do
-    it "ignores unknown codes" do
-      ruby_exe(@test_string, options: '-KZ').should ==
-        [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
-    end
+  it "ignores unknown codes" do
+    locale = Encoding.find('locale')
+    ruby_exe(@test_string, options: '-KZ').should ==
+      [Encoding::UTF_8.name, locale.name, nil].inspect
   end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]