Use wide character startup
[ruby.git] / spec / ruby / command_line / dash_upper_k_spec.rb
blob7e71532295cf94b60da1d0427b50e658f2e0e390
1 require_relative '../spec_helper'
3 describe 'The -K command line option' do
4   before :each do
5     @test_string = "print [__ENCODING__&.name, Encoding.default_external&.name, Encoding.default_internal&.name].inspect"
6   end
8   describe 'sets __ENCODING__ and Encoding.default_external' do
9     it "to Encoding::BINARY with -Ka" do
10       ruby_exe(@test_string, options: '-Ka').should ==
11         [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
12     end
14     it "to Encoding::BINARY with -KA" do
15       ruby_exe(@test_string, options: '-KA').should ==
16         [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
17     end
19     it "to Encoding::BINARY with -Kn" do
20       ruby_exe(@test_string, options: '-Kn').should ==
21         [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
22     end
24     it "to Encoding::BINARY with -KN" do
25       ruby_exe(@test_string, options: '-KN').should ==
26         [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
27     end
29     it "to Encoding::EUC_JP with -Ke" do
30       ruby_exe(@test_string, options: '-Ke').should ==
31         [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
32     end
34     it "to Encoding::EUC_JP with -KE" do
35       ruby_exe(@test_string, options: '-KE').should ==
36         [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
37     end
39     it "to Encoding::UTF_8 with -Ku" do
40       ruby_exe(@test_string, options: '-Ku').should ==
41         [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
42     end
44     it "to Encoding::UTF_8 with -KU" do
45       ruby_exe(@test_string, options: '-KU').should ==
46         [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
47     end
49     it "to Encoding::Windows_31J with -Ks" do
50       ruby_exe(@test_string, options: '-Ks').should ==
51         [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
52     end
54     it "to Encoding::Windows_31J with -KS" do
55       ruby_exe(@test_string, options: '-KS').should ==
56         [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
57     end
58   end
60   it "ignores unknown codes" do
61     external = Encoding.find('external')
62     ruby_exe(@test_string, options: '-KZ').should ==
63       [Encoding::UTF_8.name, external.name, nil].inspect
64   end
65 end