|
10 | 10 | end
|
11 | 11 |
|
12 | 12 | it "raises a RangeError is self is less than 0" do
|
13 |
| - -> { -1.chr }.should raise_error(RangeError) |
14 |
| - -> { (-bignum_value).chr }.should raise_error(RangeError) |
| 13 | + -> { -1.chr }.should raise_error(RangeError, /-1 out of char range/) |
| 14 | + -> { (-bignum_value).chr }.should raise_error(RangeError, /bignum out of char range/) |
15 | 15 | end
|
16 | 16 |
|
17 | 17 | it "raises a RangeError if self is too large" do
|
18 |
| - -> { 2206368128.chr(Encoding::UTF_8) }.should raise_error(RangeError) |
| 18 | + -> { 2206368128.chr(Encoding::UTF_8) }.should raise_error(RangeError, /2206368128 out of char range/) |
19 | 19 | end
|
20 | 20 |
|
21 | 21 | describe "when Encoding.default_internal is nil" do
|
|
48 | 48 | end
|
49 | 49 |
|
50 | 50 | it "raises a RangeError is self is greater than 255" do
|
51 |
| - -> { 256.chr }.should raise_error(RangeError) |
52 |
| - -> { bignum_value.chr }.should raise_error(RangeError) |
| 51 | + -> { 256.chr }.should raise_error(RangeError, /256 out of char range/) |
| 52 | + -> { bignum_value.chr }.should raise_error(RangeError, /bignum out of char range/) |
53 | 53 | end
|
54 | 54 | end
|
55 | 55 |
|
|
137 | 137 | [620, "TIS-620"]
|
138 | 138 | ].each do |integer, encoding_name|
|
139 | 139 | Encoding.default_internal = Encoding.find(encoding_name)
|
140 |
| - -> { integer.chr }.should raise_error(RangeError) |
| 140 | + -> { integer.chr }.should raise_error(RangeError, /(invalid codepoint|out of char range)/) |
141 | 141 | end
|
142 | 142 | end
|
143 | 143 | end
|
|
165 | 165 |
|
166 | 166 | # http://redmine.ruby-lang.org/issues/4869
|
167 | 167 | it "raises a RangeError is self is less than 0" do
|
168 |
| - -> { -1.chr(Encoding::UTF_8) }.should raise_error(RangeError) |
169 |
| - -> { (-bignum_value).chr(Encoding::EUC_JP) }.should raise_error(RangeError) |
| 168 | + -> { -1.chr(Encoding::UTF_8) }.should raise_error(RangeError, /-1 out of char range/) |
| 169 | + -> { (-bignum_value).chr(Encoding::EUC_JP) }.should raise_error(RangeError, /bignum out of char range/) |
170 | 170 | end
|
171 | 171 |
|
172 | 172 | it "raises a RangeError if self is too large" do
|
173 |
| - -> { 2206368128.chr(Encoding::UTF_8) }.should raise_error(RangeError) |
| 173 | + -> { 2206368128.chr(Encoding::UTF_8) }.should raise_error(RangeError, /2206368128 out of char range/) |
174 | 174 | end
|
175 | 175 |
|
176 | 176 | it "returns a String with the specified encoding" do
|
|
0 commit comments