From 4cfc93d67aa185ca768cf83be0e43fd3ab3d1c60 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 18 Apr 2026 03:07:31 +0300 Subject: [PATCH] all: fix tests --- cmd/tools/vtest-self.v | 2 -- vlib/builtin/float.c.v | 18 ++++++++++++++---- vlib/builtin/js/map_test.js.v | 1 - vlib/builtin/map_test.v | 1 - vlib/v/checker/str.v | 1 + 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cmd/tools/vtest-self.v b/cmd/tools/vtest-self.v index 620fcbf82..9c71fc22c 100644 --- a/cmd/tools/vtest-self.v +++ b/cmd/tools/vtest-self.v @@ -90,8 +90,6 @@ const essential_list = [ 'vlib/v/fmt/fmt_test.v', 'vlib/v/gen/c/coutput_test.v', 'vlib/v/gen/js/program_test.v', - 'vlib/v/gen/native/macho_test.v', - 'vlib/v/gen/native/tests/native_test.v', 'vlib/v/pkgconfig/pkgconfig_test.v', 'vlib/v/slow_tests/inout/compiler_test.v', 'vlib/x/json2/tests/json2_test.v', diff --git a/vlib/builtin/float.c.v b/vlib/builtin/float.c.v index 9cd19f3c0..f0b2b31d3 100644 --- a/vlib/builtin/float.c.v +++ b/vlib/builtin/float.c.v @@ -33,8 +33,13 @@ pub fn (x f64) str() string { // strg return a `f64` as `string` in "g" printf format. @[inline] pub fn (x f64) strg() string { - if x == 0 { - return '0.0' + unsafe { + f := strconv.Float64u{ + f: x + } + if f.u == strconv.double_minus_zero || f.u == strconv.double_plus_zero { + return '0.0' + } } abs_x := f64_abs(x) if abs_x >= 0.0001 && abs_x < 1.0e6 { @@ -99,8 +104,13 @@ pub fn (x f32) str() string { // strg return a `f32` as `string` in "g" printf format @[inline] pub fn (x f32) strg() string { - if x == 0 { - return '0.0' + unsafe { + f := strconv.Float32u{ + f: x + } + if f.u == strconv.single_minus_zero || f.u == strconv.single_plus_zero { + return '0.0' + } } abs_x := f32_abs(x) if abs_x >= 0.0001 && abs_x < 1.0e6 { diff --git a/vlib/builtin/js/map_test.js.v b/vlib/builtin/js/map_test.js.v index d28ffd7a8..3a0470f41 100644 --- a/vlib/builtin/js/map_test.js.v +++ b/vlib/builtin/js/map_test.js.v @@ -1,7 +1,6 @@ // vtest retry: 3 // vtest build: present_node? import rand -import strings const strings = unique_strings(200, 10) diff --git a/vlib/builtin/map_test.v b/vlib/builtin/map_test.v index dda730d27..d33f9f639 100644 --- a/vlib/builtin/map_test.v +++ b/vlib/builtin/map_test.v @@ -1,5 +1,4 @@ import rand -import strings const strings = unique_strings(7000, 10) diff --git a/vlib/v/checker/str.v b/vlib/v/checker/str.v index bac76d00e..8eb7aeb84 100644 --- a/vlib/v/checker/str.v +++ b/vlib/v/checker/str.v @@ -168,6 +168,7 @@ fn (mut c Checker) string_inter_lit(mut node ast.StringInterLiteral) ast.Type { node.fmt_poss[i]) } node.need_fmts[i] = fmt != c.get_default_fmt(ftyp, typ) + || (typ.is_float() && fmt in [`g`, `G`]) } // check recursive str if c.table.cur_fn != unsafe { nil } && c.table.cur_fn.is_method -- 2.39.5