strconv: fix fxx_to_str_l_parse/fxx_to_str_l_parse_no_dot returning s without cloning

pull/10509/head
Delyan Angelov 2021-06-19 07:48:46 +03:00
parent acf9d168cb
commit aea23e8a40
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 4 additions and 6 deletions

View File

@ -1092,8 +1092,6 @@ fn test_array_int_pop() {
assert z == 4 assert z == 4
x1 := a.pop() x1 := a.pop()
x2 := a.pop() x2 := a.pop()
dump(x1)
dump(x2)
final := a.pop() final := a.pop()
assert final == 1 assert final == 1
} }

View File

@ -186,7 +186,7 @@ fn test_signed_cast() {
} }
// test g format // test g format
{ unsafe {
mut u := strconv.Float64u{ mut u := strconv.Float64u{
u: strconv.double_plus_zero u: strconv.double_plus_zero
} }
@ -202,7 +202,7 @@ fn test_signed_cast() {
assert '${u.f:g}' == '-inf' assert '${u.f:g}' == '-inf'
assert '${u.f:G}' == '-INF' assert '${u.f:G}' == '-INF'
} }
{ unsafe {
mut u := strconv.Float32u{ mut u := strconv.Float32u{
u: strconv.single_plus_zero u: strconv.single_plus_zero
} }

View File

@ -272,7 +272,7 @@ pub fn f64_to_str_l_no_dot(f f64) string {
pub fn fxx_to_str_l_parse(s string) string { pub fn fxx_to_str_l_parse(s string) string {
// check for +inf -inf Nan // check for +inf -inf Nan
if s.len > 2 && (s[0] == `n` || s[1] == `i`) { if s.len > 2 && (s[0] == `n` || s[1] == `i`) {
return s return s.clone()
} }
m_sgn_flag := false m_sgn_flag := false
@ -395,7 +395,7 @@ pub fn fxx_to_str_l_parse(s string) string {
pub fn fxx_to_str_l_parse_no_dot(s string) string { pub fn fxx_to_str_l_parse_no_dot(s string) string {
// check for +inf -inf Nan // check for +inf -inf Nan
if s.len > 2 && (s[0] == `n` || s[1] == `i`) { if s.len > 2 && (s[0] == `n` || s[1] == `i`) {
return s return s.clone()
} }
m_sgn_flag := false m_sgn_flag := false