summaryrefslogtreecommitdiff
path: root/spec/ruby/library/English/English_spec.rb
blob: 480602d5e5937c2eb981c553add9d7f00715d3d8 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
require_relative '../../spec_helper'

require 'English'

describe "English" do
  it "aliases $ERROR_INFO to $!" do
    begin
      raise "error"
    rescue
      $ERROR_INFO.should_not be_nil
      $ERROR_INFO.should == $!
    end
    $ERROR_INFO.should be_nil
  end

  it "aliases $ERROR_POSITION to $@" do
    begin
      raise "error"
    rescue
      $ERROR_POSITION.should_not be_nil
      $ERROR_POSITION.should == $@
    end
    $ERROR_POSITION.should be_nil
  end

  it "aliases $FS to $;" do
    original = $;
    suppress_warning {$; = ","}
    $FS.should_not be_nil
    $FS.should == $;
    suppress_warning {$; = original}
  end

  it "aliases $FIELD_SEPARATOR to $;" do
    original = $;
    suppress_warning {$; = ","}
    $FIELD_SEPARATOR.should_not be_nil
    $FIELD_SEPARATOR.should == $;
    suppress_warning {$; = original}
  end

  it "aliases $OFS to $," do
    original = $,
    suppress_warning {$, = "|"}
    $OFS.should_not be_nil
    $OFS.should == $,
    suppress_warning {$, = original}
  end

  it "aliases $OUTPUT_FIELD_SEPARATOR to $," do
    original = $,
    suppress_warning {$, = "|"}
    $OUTPUT_FIELD_SEPARATOR.should_not be_nil
    $OUTPUT_FIELD_SEPARATOR.should == $,
    suppress_warning {$, = original}
  end

  it "aliases $RS to $/" do
    $RS.should_not be_nil
    $RS.should == $/
  end

  it "aliases $INPUT_RECORD_SEPARATOR to $/" do
    $INPUT_RECORD_SEPARATOR.should_not be_nil
    $INPUT_RECORD_SEPARATOR.should == $/
  end

  it "aliases $ORS to $\\" do
    original = $\
    suppress_warning {$\ = "\t"}
    $ORS.should_not be_nil
    $ORS.should == $\
    suppress_warning {$\ = original}
  end

  it "aliases $OUTPUT_RECORD_SEPARATOR to $\\" do
    original = $\
    suppress_warning {$\ = "\t"}
    $OUTPUT_RECORD_SEPARATOR.should_not be_nil
    $OUTPUT_RECORD_SEPARATOR.should == $\
    suppress_warning {$\ = original}
  end

  it "aliases $INPUT_LINE_NUMBER to $." do
    $INPUT_LINE_NUMBER.should_not be_nil
    $INPUT_LINE_NUMBER.should == $.
  end

  it "aliases $NR to $." do
    $NR.should_not be_nil
    $NR.should == $.
  end

  it "aliases $LAST_READ_LINE to $_ needs to be reviewed for spec completeness"

  it "aliases $DEFAULT_OUTPUT to $>" do
    $DEFAULT_OUTPUT.should_not be_nil
    $DEFAULT_OUTPUT.should == $>
  end

  it "aliases $DEFAULT_INPUT to $<" do
    $DEFAULT_INPUT.should_not be_nil
    $DEFAULT_INPUT.should == $<
  end

  it "aliases $PID to $$" do
    $PID.should_not be_nil
    $PID.should == $$
  end

  it "aliases $PID to $$" do
    $PID.should_not be_nil
    $PID.should == $$
  end

  it "aliases $PROCESS_ID to $$" do
    $PROCESS_ID.should_not be_nil
    $PROCESS_ID.should == $$
  end

  it "aliases $CHILD_STATUS to $?" do
    ruby_exe('exit 0')
    $CHILD_STATUS.should_not be_nil
    $CHILD_STATUS.should == $?
  end

  it "aliases $LAST_MATCH_INFO to $~" do
    /c(a)t/ =~ "cat"
    $LAST_MATCH_INFO.should_not be_nil
    $LAST_MATCH_INFO.should == $~
  end

  it "aliases $IGNORECASE to $=" do
    $VERBOSE, verbose = nil, $VERBOSE
    begin
      $IGNORECASE.should_not be_nil
      $IGNORECASE.should == $=
    ensure
      $VERBOSE = verbose
    end
  end

  it "aliases $ARGV to $*" do
    $ARGV.should_not be_nil
    $ARGV.should == $*
  end

  it "aliases $MATCH to $&" do
    /c(a)t/ =~ "cat"
    $MATCH.should_not be_nil
    $MATCH.should == $&
  end

  it "aliases $PREMATCH to $`" do
    /c(a)t/ =~ "cat"
    $PREMATCH.should_not be_nil
    $PREMATCH.should == $`
  end

  it "aliases $POSTMATCH to $'" do
    /c(a)t/ =~ "cat"
    $POSTMATCH.should_not be_nil
    $POSTMATCH.should == $'
  end

  it "aliases $LAST_PAREN_MATCH to $+" do
    /c(a)t/ =~ "cat"
    $LAST_PAREN_MATCH.should_not be_nil
    $LAST_PAREN_MATCH.should == $+
  end
end