File: dash_upper_k_spec.rb

package info (click to toggle)
ruby3.3 3.3.8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 153,620 kB
  • sloc: ruby: 1,244,308; ansic: 836,474; yacc: 28,074; pascal: 6,748; sh: 3,913; python: 1,719; cpp: 1,158; makefile: 742; asm: 712; javascript: 394; lisp: 97; perl: 62; awk: 36; sed: 23; xml: 4
file content (65 lines) | stat: -rw-r--r-- 2,240 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require_relative '../spec_helper'

describe 'The -K command line option' do
  before :each do
    @test_string = "print [__ENCODING__&.name, Encoding.default_external&.name, Encoding.default_internal&.name].inspect"
  end

  describe 'sets __ENCODING__ and Encoding.default_external' do
    it "to Encoding::BINARY with -Ka" do
      ruby_exe(@test_string, options: '-Ka').should ==
        [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
    end

    it "to Encoding::BINARY with -KA" do
      ruby_exe(@test_string, options: '-KA').should ==
        [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
    end

    it "to Encoding::BINARY with -Kn" do
      ruby_exe(@test_string, options: '-Kn').should ==
        [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
    end

    it "to Encoding::BINARY with -KN" do
      ruby_exe(@test_string, options: '-KN').should ==
        [Encoding::BINARY.name, Encoding::BINARY.name, nil].inspect
    end

    it "to Encoding::EUC_JP with -Ke" do
      ruby_exe(@test_string, options: '-Ke').should ==
        [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
    end

    it "to Encoding::EUC_JP with -KE" do
      ruby_exe(@test_string, options: '-KE').should ==
        [Encoding::EUC_JP.name, Encoding::EUC_JP.name, nil].inspect
    end

    it "to Encoding::UTF_8 with -Ku" do
      ruby_exe(@test_string, options: '-Ku').should ==
        [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
    end

    it "to Encoding::UTF_8 with -KU" do
      ruby_exe(@test_string, options: '-KU').should ==
        [Encoding::UTF_8.name, Encoding::UTF_8.name, nil].inspect
    end

    it "to Encoding::Windows_31J with -Ks" do
      ruby_exe(@test_string, options: '-Ks').should ==
        [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
    end

    it "to Encoding::Windows_31J with -KS" do
      ruby_exe(@test_string, options: '-KS').should ==
        [Encoding::Windows_31J.name, Encoding::Windows_31J.name, nil].inspect
    end
  end

  it "ignores unknown codes" do
    external = Encoding.find('external')
    ruby_exe(@test_string, options: '-KZ').should ==
      [Encoding::UTF_8.name, external.name, nil].inspect
  end
end