diff options
author | Benoit Daloze <eregontp@gmail.com> | 2022-06-26 14:50:14 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2022-06-26 14:50:14 +0200 |
commit | d3d5ef0cca160fca538c7f556c5a6e08df5847e6 (patch) | |
tree | 57358b4b9cdd6f429d0383005ac393cb74dd3bff /spec/ruby/core/integer | |
parent | f616e816372d14e605879d2e43c7fbdda29ef837 (diff) | |
download | ruby-d3d5ef0cca160fca538c7f556c5a6e08df5847e6.tar.gz |
Update to ruby/spec@ab32a1a
Diffstat (limited to 'spec/ruby/core/integer')
-rw-r--r-- | spec/ruby/core/integer/chr_spec.rb | 39 | ||||
-rw-r--r-- | spec/ruby/core/integer/fdiv_spec.rb | 5 |
2 files changed, 24 insertions, 20 deletions
diff --git a/spec/ruby/core/integer/chr_spec.rb b/spec/ruby/core/integer/chr_spec.rb index 3e13f45480..8fe20ff812 100644 --- a/spec/ruby/core/integer/chr_spec.rb +++ b/spec/ruby/core/integer/chr_spec.rb @@ -223,26 +223,25 @@ 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, "BINARY"], - [0x0100, "EUC-JP"], - [0xA1A0, "EUC-JP"], - [0xA1, "EUC-JP"], - [0x80, "SHIFT_JIS"], - [0xE0, "SHIFT_JIS"], - [0x0100, "ISO-8859-9"], - [620, "TIS-620"], - [0xD800, "UTF-8"], - [0xDBFF, "UTF-8"], - [0xDC00, "UTF-8"], - [0xDFFF, "UTF-8"], - [0xD800, "UTF-16"], - [0xDBFF, "UTF-16"], - [0xDC00, "UTF-16"], - [0xDFFF, "UTF-16"], - ].each do |integer, encoding_name| - -> { integer.chr(encoding_name) }.should raise_error(RangeError) - end + -> { 0x80.chr("US-ASCII") }.should raise_error(RangeError) + -> { 0x0100.chr("BINARY") }.should raise_error(RangeError) + -> { 0x0100.chr("EUC-JP") }.should raise_error(RangeError) + -> { 0xA1A0.chr("EUC-JP") }.should raise_error(RangeError) + -> { 0xA1.chr("EUC-JP") }.should raise_error(RangeError) + -> { 0x80.chr("SHIFT_JIS") }.should raise_error(RangeError) + -> { 0xE0.chr("SHIFT_JIS") }.should raise_error(RangeError) + -> { 0x0100.chr("ISO-8859-9") }.should raise_error(RangeError) + -> { 620.chr("TIS-620") }.should raise_error(RangeError) + # UTF-16 surrogate range + -> { 0xD800.chr("UTF-8") }.should raise_error(RangeError) + -> { 0xDBFF.chr("UTF-8") }.should raise_error(RangeError) + -> { 0xDC00.chr("UTF-8") }.should raise_error(RangeError) + -> { 0xDFFF.chr("UTF-8") }.should raise_error(RangeError) + # UTF-16 surrogate range + -> { 0xD800.chr("UTF-16") }.should raise_error(RangeError) + -> { 0xDBFF.chr("UTF-16") }.should raise_error(RangeError) + -> { 0xDC00.chr("UTF-16") }.should raise_error(RangeError) + -> { 0xDFFF.chr("UTF-16") }.should raise_error(RangeError) end it 'returns a String encoding self interpreted as a codepoint in the CESU-8 encoding' do diff --git a/spec/ruby/core/integer/fdiv_spec.rb b/spec/ruby/core/integer/fdiv_spec.rb index d99a19eb0f..d9ea2fdf8d 100644 --- a/spec/ruby/core/integer/fdiv_spec.rb +++ b/spec/ruby/core/integer/fdiv_spec.rb @@ -55,6 +55,11 @@ describe "Integer#fdiv" do num.fdiv(den).should == -0.5555555555555556 end + it "rounds to the correct float for bignum denominators" do + 1.fdiv(10**324).should == 0.0 + 1.fdiv(10**323).should == 1.0e-323 + end + it "performs floating-point division between self and a Float" do 8.fdiv(9.0).should be_close(0.888888888888889, TOLERANCE) end |