File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ def to_f() 1.2 end
163163 -> { @object . send ( :Float , "+1." ) } . should raise_error ( ArgumentError )
164164 -> { @object . send ( :Float , "-1." ) } . should raise_error ( ArgumentError )
165165 -> { @object . send ( :Float , "1.e+0" ) } . should raise_error ( ArgumentError )
166+ -> { @object . send ( :Float , "1.e-2" ) } . should raise_error ( ArgumentError )
166167 end
167168 end
168169
@@ -172,6 +173,7 @@ def to_f() 1.2 end
172173 @object . send ( :Float , "+1." ) . should == 1.0
173174 @object . send ( :Float , "-1." ) . should == -1.0
174175 @object . send ( :Float , "1.e+0" ) . should == 1.0
176+ @object . send ( :Float , "1.e-2" ) . should be_close ( 0.01 , TOLERANCE )
175177 end
176178 end
177179
Original file line number Diff line number Diff line change 127127 } . should raise_error ( Encoding ::CompatibilityError , "ASCII incompatible encoding: UTF-16" )
128128 end
129129 end
130+
131+ it "allows String representation without a fractional part" do
132+ "1." . to_f . should == 1.0
133+ "+1." . to_f . should == 1.0
134+ "-1." . to_f . should == -1.0
135+ "1.e+0" . to_f . should == 1.0
136+ "1.e+0" . to_f . should == 1.0
137+
138+ ruby_bug "#20705" , "" ..."3.4" do
139+ "1.e-2" . to_f . should be_close ( 0.01 , TOLERANCE )
140+ end
141+ end
130142end
You can’t perform that action at this time.
0 commit comments