aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/integer
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-06-27 21:02:36 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-06-27 21:02:36 +0200
commitd80e44deec77678fe2d72f94c17b2409b3e794d5 (patch)
tree612bf2313550e0982dda452f48492cc069e1c21a /spec/ruby/core/integer
parentc940397116c5aef76b1c0d05561c11d43ef596a7 (diff)
downloadruby-d80e44deec77678fe2d72f94c17b2409b3e794d5.tar.gz
Update to ruby/spec@8d74d49
Diffstat (limited to 'spec/ruby/core/integer')
-rw-r--r--spec/ruby/core/integer/chr_spec.rb30
-rw-r--r--spec/ruby/core/integer/round_spec.rb8
2 files changed, 23 insertions, 15 deletions
diff --git a/spec/ruby/core/integer/chr_spec.rb b/spec/ruby/core/integer/chr_spec.rb
index 8420d85cf6..a519961d7c 100644
--- a/spec/ruby/core/integer/chr_spec.rb
+++ b/spec/ruby/core/integer/chr_spec.rb
@@ -30,9 +30,9 @@ describe "Integer#chr without argument" do
end
describe "and self is between 128 and 255 (inclusive)" do
- it "returns an ASCII-8BIT String" do
+ it "returns an BINARY String" do
(128..255).each do |c|
- c.chr.encoding.should == Encoding::ASCII_8BIT
+ c.chr.encoding.should == Encoding::BINARY
end
end
@@ -81,13 +81,13 @@ describe "Integer#chr without argument" do
end
describe "and self is between 128 and 255 (inclusive)" do
- it "returns an ASCII-8BIT String" do
+ it "returns an BINARY String" do
(128..255).each do |c|
Encoding.default_internal = Encoding::UTF_8
- c.chr.encoding.should == Encoding::ASCII_8BIT
+ c.chr.encoding.should == Encoding::BINARY
Encoding.default_internal = Encoding::SHIFT_JIS
- c.chr.encoding.should == Encoding::ASCII_8BIT
+ c.chr.encoding.should == Encoding::BINARY
end
end
@@ -126,7 +126,7 @@ describe "Integer#chr without argument" do
# #5864
it "raises RangeError if self is invalid as a codepoint in the default internal encoding" do
[ [0x0100, "US-ASCII"],
- [0x0100, "ASCII-8BIT"],
+ [0x0100, "BINARY"],
[0x0100, "EUC-JP"],
[0xA1A0, "EUC-JP"],
[0x0100, "ISO-8859-9"],
@@ -173,10 +173,10 @@ describe "Integer#chr with an encoding argument" do
0x0000.chr(Encoding::US_ASCII).encoding.should == Encoding::US_ASCII
0x007F.chr(Encoding::US_ASCII).encoding.should == Encoding::US_ASCII
- 0x0000.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT
- 0x007F.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT
- 0x0080.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT
- 0x00FF.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT
+ 0x0000.chr(Encoding::BINARY).encoding.should == Encoding::BINARY
+ 0x007F.chr(Encoding::BINARY).encoding.should == Encoding::BINARY
+ 0x0080.chr(Encoding::BINARY).encoding.should == Encoding::BINARY
+ 0x00FF.chr(Encoding::BINARY).encoding.should == Encoding::BINARY
0x0000.chr(Encoding::UTF_8).encoding.should == Encoding::UTF_8
0x007F.chr(Encoding::UTF_8).encoding.should == Encoding::UTF_8
@@ -197,10 +197,10 @@ describe "Integer#chr with an encoding argument" do
0x0000.chr(Encoding::US_ASCII).bytes.to_a.should == [0x00]
0x007F.chr(Encoding::US_ASCII).bytes.to_a.should == [0x7F]
- 0x0000.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0x00]
- 0x007F.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0x7F]
- 0x0080.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0x80]
- 0x00FF.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0xFF]
+ 0x0000.chr(Encoding::BINARY).bytes.to_a.should == [0x00]
+ 0x007F.chr(Encoding::BINARY).bytes.to_a.should == [0x7F]
+ 0x0080.chr(Encoding::BINARY).bytes.to_a.should == [0x80]
+ 0x00FF.chr(Encoding::BINARY).bytes.to_a.should == [0xFF]
0x0000.chr(Encoding::UTF_8).bytes.to_a.should == [0x00]
0x007F.chr(Encoding::UTF_8).bytes.to_a.should == [0x7F]
@@ -220,7 +220,7 @@ describe "Integer#chr with an encoding argument" do
# #5864
it "raises RangeError if self is invalid as a codepoint in the specified encoding" do
[ [0x80, "US-ASCII"],
- [0x0100, "ASCII-8BIT"],
+ [0x0100, "BINARY"],
[0x0100, "EUC-JP"],
[0xA1A0, "EUC-JP"],
[0xA1, "EUC-JP"],
diff --git a/spec/ruby/core/integer/round_spec.rb b/spec/ruby/core/integer/round_spec.rb
index 622a55280e..a45a7b5fb3 100644
--- a/spec/ruby/core/integer/round_spec.rb
+++ b/spec/ruby/core/integer/round_spec.rb
@@ -67,12 +67,15 @@ describe "Integer#round" do
25.round(-1, half: :up).should eql(30)
25.round(-1, half: :down).should eql(20)
25.round(-1, half: :even).should eql(20)
+ 25.round(-1, half: nil).should eql(30)
35.round(-1, half: :up).should eql(40)
35.round(-1, half: :down).should eql(30)
35.round(-1, half: :even).should eql(40)
+ 35.round(-1, half: nil).should eql(40)
(-25).round(-1, half: :up).should eql(-30)
(-25).round(-1, half: :down).should eql(-20)
(-25).round(-1, half: :even).should eql(-20)
+ (-25).round(-1, half: nil).should eql(-30)
end
ruby_version_is "2.4"..."2.5" do
@@ -90,4 +93,9 @@ describe "Integer#round" do
35.round(1, half: :even).should eql(35)
end
end
+
+ it "raises ArgumentError for an unknown rounding mode" do
+ lambda { 42.round(-1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/)
+ lambda { 42.round(1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/)
+ end
end