[Bug #20719] Float
argument must be ASCII compatible
This commit is contained in:
parent
c1a510a8df
commit
c1862cbb89
Notes:
git
2024-09-07 08:29:29 +00:00
1
object.c
1
object.c
@ -3530,6 +3530,7 @@ rb_str_to_dbl_raise(VALUE str, int badcheck, int raise, int *error)
|
|||||||
VALUE v = 0;
|
VALUE v = 0;
|
||||||
|
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
|
rb_must_asciicompat(str);
|
||||||
s = RSTRING_PTR(str);
|
s = RSTRING_PTR(str);
|
||||||
len = RSTRING_LEN(str);
|
len = RSTRING_LEN(str);
|
||||||
if (s) {
|
if (s) {
|
||||||
|
@ -850,6 +850,12 @@ class TestFloat < Test::Unit::TestCase
|
|||||||
o = Object.new
|
o = Object.new
|
||||||
def o.to_f; inf = Float::INFINITY; inf/inf; end
|
def o.to_f; inf = Float::INFINITY; inf/inf; end
|
||||||
assert_predicate(Float(o), :nan?)
|
assert_predicate(Float(o), :nan?)
|
||||||
|
|
||||||
|
assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-16be"))}
|
||||||
|
assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-16le"))}
|
||||||
|
assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-32be"))}
|
||||||
|
assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-32le"))}
|
||||||
|
assert_raise(Encoding::CompatibilityError) {Float("0".encode("iso-2022-jp"))}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_str
|
def test_invalid_str
|
||||||
|
Loading…
x
Reference in New Issue
Block a user