|
84 | 84 | (Rational(-1) ** bignum_value(3)).should eql(Rational(-1)) |
85 | 85 | end |
86 | 86 |
|
87 | | - it "returns positive Infinity when self is > 1" do |
88 | | - -> { |
89 | | - (Rational(2) ** bignum_value).infinite?.should == 1 |
90 | | - }.should complain(/warning: in a\*\*b, b may be too big/) |
91 | | - -> { |
92 | | - (Rational(fixnum_max) ** bignum_value).infinite?.should == 1 |
93 | | - }.should complain(/warning: in a\*\*b, b may be too big/) |
94 | | - end |
95 | | - |
96 | | - it "returns 0.0 when self is > 1 and the exponent is negative" do |
97 | | - -> { |
98 | | - (Rational(2) ** -bignum_value).should eql(0.0) |
99 | | - }.should complain(/warning: in a\*\*b, b may be too big/) |
100 | | - -> { |
101 | | - (Rational(fixnum_max) ** -bignum_value).should eql(0.0) |
102 | | - }.should complain(/warning: in a\*\*b, b may be too big/) |
103 | | - end |
104 | | - |
105 | | - # Fails on linux due to pow() bugs in glibc: http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866 |
106 | | - platform_is_not :linux do |
107 | | - it "returns positive Infinity when self < -1" do |
| 87 | + ruby_version_is ""..."3.4" do |
| 88 | + it "returns positive Infinity when self is > 1" do |
108 | 89 | -> { |
109 | | - (Rational(-2) ** bignum_value).infinite?.should == 1 |
| 90 | + (Rational(2) ** bignum_value).infinite?.should == 1 |
110 | 91 | }.should complain(/warning: in a\*\*b, b may be too big/) |
111 | 92 | -> { |
112 | | - (Rational(-2) ** (bignum_value + 1)).infinite?.should == 1 |
113 | | - }.should complain(/warning: in a\*\*b, b may be too big/) |
114 | | - -> { |
115 | | - (Rational(fixnum_min) ** bignum_value).infinite?.should == 1 |
| 93 | + (Rational(fixnum_max) ** bignum_value).infinite?.should == 1 |
116 | 94 | }.should complain(/warning: in a\*\*b, b may be too big/) |
117 | 95 | end |
118 | 96 |
|
119 | | - it "returns 0.0 when self is < -1 and the exponent is negative" do |
| 97 | + it "returns 0.0 when self is > 1 and the exponent is negative" do |
120 | 98 | -> { |
121 | | - (Rational(-2) ** -bignum_value).should eql(0.0) |
| 99 | + (Rational(2) ** -bignum_value).should eql(0.0) |
122 | 100 | }.should complain(/warning: in a\*\*b, b may be too big/) |
123 | 101 | -> { |
124 | | - (Rational(fixnum_min) ** -bignum_value).should eql(0.0) |
| 102 | + (Rational(fixnum_max) ** -bignum_value).should eql(0.0) |
125 | 103 | }.should complain(/warning: in a\*\*b, b may be too big/) |
126 | 104 | end |
127 | 105 | end |
| 106 | + |
| 107 | + ruby_version_is "3.4" do |
| 108 | + it "raises an ArgumentError when self is > 1" do |
| 109 | + -> { |
| 110 | + (Rational(2) ** bignum_value) |
| 111 | + }.should raise_error(ArgumentError) |
| 112 | + -> { |
| 113 | + (Rational(fixnum_max) ** bignum_value) |
| 114 | + }.should raise_error(ArgumentError) |
| 115 | + end |
| 116 | + |
| 117 | + it "raises an ArgumentError when self is > 1 and the exponent is negative" do |
| 118 | + -> { |
| 119 | + (Rational(2) ** -bignum_value) |
| 120 | + }.should raise_error(ArgumentError) |
| 121 | + -> { |
| 122 | + (Rational(fixnum_max) ** -bignum_value) |
| 123 | + }.should raise_error(ArgumentError) |
| 124 | + end |
| 125 | + end |
| 126 | + |
| 127 | + # Fails on linux due to pow() bugs in glibc: http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866 |
| 128 | + platform_is_not :linux do |
| 129 | + ruby_version_is ""..."3.4" do |
| 130 | + it "returns positive Infinity when self < -1" do |
| 131 | + -> { |
| 132 | + (Rational(-2) ** bignum_value).infinite?.should == 1 |
| 133 | + }.should complain(/warning: in a\*\*b, b may be too big/) |
| 134 | + -> { |
| 135 | + (Rational(-2) ** (bignum_value + 1)).infinite?.should == 1 |
| 136 | + }.should complain(/warning: in a\*\*b, b may be too big/) |
| 137 | + -> { |
| 138 | + (Rational(fixnum_min) ** bignum_value).infinite?.should == 1 |
| 139 | + }.should complain(/warning: in a\*\*b, b may be too big/) |
| 140 | + end |
| 141 | + |
| 142 | + it "returns 0.0 when self is < -1 and the exponent is negative" do |
| 143 | + -> { |
| 144 | + (Rational(-2) ** -bignum_value).should eql(0.0) |
| 145 | + }.should complain(/warning: in a\*\*b, b may be too big/) |
| 146 | + -> { |
| 147 | + (Rational(fixnum_min) ** -bignum_value).should eql(0.0) |
| 148 | + }.should complain(/warning: in a\*\*b, b may be too big/) |
| 149 | + end |
| 150 | + end |
| 151 | + |
| 152 | + ruby_version_is "3.4" do |
| 153 | + it "returns positive Infinity when self < -1" do |
| 154 | + -> { |
| 155 | + (Rational(-2) ** bignum_value) |
| 156 | + }.should raise_error(ArgumentError) |
| 157 | + -> { |
| 158 | + (Rational(fixnum_min) ** bignum_value) |
| 159 | + }.should raise_error(ArgumentError) |
| 160 | + end |
| 161 | + |
| 162 | + it "returns 0.0 when self is < -1 and the exponent is negative" do |
| 163 | + -> { |
| 164 | + (Rational(-2) ** -bignum_value) |
| 165 | + }.should raise_error(ArgumentError) |
| 166 | + -> { |
| 167 | + (Rational(fixnum_min) ** -bignum_value) |
| 168 | + }.should raise_error(ArgumentError) |
| 169 | + end |
| 170 | + end |
| 171 | + end |
128 | 172 | end |
129 | 173 |
|
130 | 174 | describe "when passed Float" do |
|
0 commit comments