From d3d9307e5fc4976e7d072ba5b37b211464a28801 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 19:25:11 +0800 Subject: [PATCH 01/15] '\0'->'e' --- stl/inc/format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/format b/stl/inc/format index 56f5b11bb6..2dc6363250 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -2864,7 +2864,7 @@ _NODISCARD _OutputIt _Fmt_write( auto _To_upper = false; auto _Format = chars_format::general; - auto _Exponent = '\0'; + auto _Exponent = 'e'; auto _Precision = _Specs._Precision; switch (_Specs._Type) { From 58ee3681f39d869dd3a80a1692757d95721cf606 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 20:19:17 +0800 Subject: [PATCH 02/15] std::format("{:#.5}", 1200) == "1200." --- stl/inc/format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/format b/stl/inc/format index 2dc6363250..653b58d2e6 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -3015,7 +3015,7 @@ _NODISCARD _OutputIt _Fmt_write( _Zeroes_to_append = _Extra_precision; break; case chars_format::general: - if (_Specs._Alt) { + if (_Specs._Alt && (_Specs._Type == 'g' || _Specs._Type == 'G')) { auto _Digits = static_cast(_Exponent_start - _Buffer_start); if (!_Append_decimal) { From e2fc2ecbfd532d0b5b4306eb94322e14debf6860 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 20:38:16 +0800 Subject: [PATCH 03/15] Create env.lst --- .../env.lst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst new file mode 100644 index 0000000000..5fd5287e94 --- /dev/null +++ b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_latest_matrix.lst From 265bcb02751a8eb992f3e0dc7d81b158eb850a62 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 20:39:20 +0800 Subject: [PATCH 04/15] Add test.cpp --- .../test.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp new file mode 100644 index 0000000000..b733f759a4 --- /dev/null +++ b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +int main() { + assert(std::format("{:#.0}", 1200.0) == "1.e+03"); + assert(std::format("{:#.1}", 1200.0) == "1.e+03"); + assert(std::format("{:#.2}", 1200.0) == "1.2e+03"); + assert(std::format("{:#.3}", 1200.0) == "1.2e+03"); + assert(std::format("{:#.4}", 1200.0) == "1200."); + assert(std::format("{:#.5}", 1200.0) == "1200."); + assert(std::format("{:#.6}", 1200.0) == "1200."); + + assert(std::format("{:#.0}", 0.123) == "0.1"); + assert(std::format("{:#.1}", 0.123) == "0.1"); + assert(std::format("{:#.2}", 0.123) == "0.12"); + assert(std::format("{:#.3}", 0.123) == "0.123"); + assert(std::format("{:#.4}", 0.123) == "0.123"); + assert(std::format("{:#.5}", 0.123) == "0.123"); + + assert(std::format("{:#.0}", 0.0) == "0."); + assert(std::format("{:#.1}", 0.0) == "0."); + assert(std::format("{:#.2}", 0.0) == "0."); +} From 848a5f8f6c9a841730380175ef04dd53e2eba12e Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 20:41:32 +0800 Subject: [PATCH 05/15] Update test.cpp --- .../test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp index b733f759a4..d291150b36 100644 --- a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp +++ b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp @@ -5,6 +5,10 @@ #include int main() { + assert(std::format("{:#.0}", 0.0) == "0."); + assert(std::format("{:#.1}", 0.0) == "0."); + assert(std::format("{:#.2}", 0.0) == "0."); + assert(std::format("{:#.0}", 1200.0) == "1.e+03"); assert(std::format("{:#.1}", 1200.0) == "1.e+03"); assert(std::format("{:#.2}", 1200.0) == "1.2e+03"); @@ -19,8 +23,4 @@ int main() { assert(std::format("{:#.3}", 0.123) == "0.123"); assert(std::format("{:#.4}", 0.123) == "0.123"); assert(std::format("{:#.5}", 0.123) == "0.123"); - - assert(std::format("{:#.0}", 0.0) == "0."); - assert(std::format("{:#.1}", 0.0) == "0."); - assert(std::format("{:#.2}", 0.0) == "0."); } From 41d30b859802bd54c1b9b8a93517db0e34bd20a3 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 20:49:22 +0800 Subject: [PATCH 06/15] more tests --- .../test.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp index d291150b36..f905257740 100644 --- a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp +++ b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp @@ -23,4 +23,11 @@ int main() { assert(std::format("{:#.3}", 0.123) == "0.123"); assert(std::format("{:#.4}", 0.123) == "0.123"); assert(std::format("{:#.5}", 0.123) == "0.123"); + + assert(std::format("{:#.0}", 10.1) == "1.e+01"); + assert(std::format("{:#.1}", 10.1) == "1.e+01"); + assert(std::format("{:#.2}", 10.1) == "10."); + assert(std::format("{:#.3}", 10.1) == "10.1"); + assert(std::format("{:#.4}", 10.1) == "10.1"); + assert(std::format("{:#.5}", 10.1) == "10.1"); } From d399cde0a94095be2377a354438796414353c619 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 21:01:50 +0800 Subject: [PATCH 07/15] Delete env.lst --- .../env.lst | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst deleted file mode 100644 index 5fd5287e94..0000000000 --- a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -RUNALL_INCLUDE ..\usual_latest_matrix.lst From 1942a4316655066e2b2f30af73097a8b4e2ac872 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 21:03:04 +0800 Subject: [PATCH 08/15] Add files via upload --- .../env.lst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst new file mode 100644 index 0000000000..642f530ffa --- /dev/null +++ b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_latest_matrix.lst From 48cab61947fec487cc4091529c9d1c52d24812c4 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 21:12:46 +0800 Subject: [PATCH 09/15] minor formatting --- .../test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp index f905257740..1b5d1e99f9 100644 --- a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp +++ b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp @@ -23,7 +23,7 @@ int main() { assert(std::format("{:#.3}", 0.123) == "0.123"); assert(std::format("{:#.4}", 0.123) == "0.123"); assert(std::format("{:#.5}", 0.123) == "0.123"); - + assert(std::format("{:#.0}", 10.1) == "1.e+01"); assert(std::format("{:#.1}", 10.1) == "1.e+01"); assert(std::format("{:#.2}", 10.1) == "10."); From b4e58b766f017ad5e6c155c8e87502f5f4768558 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 21:32:13 +0800 Subject: [PATCH 10/15] Update /env.lst Co-authored-by: A. Jiang --- .../env.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst index 642f530ffa..d6d824b587 100644 --- a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst +++ b/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst @@ -1,4 +1,4 @@ # Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -RUNALL_INCLUDE ..\usual_latest_matrix.lst +RUNALL_INCLUDE ..\concepts_20_matrix.lst From 2d858636105cb16bf940c28e49db23a420202565 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 21:57:49 +0800 Subject: [PATCH 11/15] relocate env.lst --- .../env.lst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/std/tests/{GH_003003_format_fix_decimal_point_and_trailing_zero => GH_003003_format_decimal_point}/env.lst (100%) diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst b/tests/std/tests/GH_003003_format_decimal_point/env.lst similarity index 100% rename from tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/env.lst rename to tests/std/tests/GH_003003_format_decimal_point/env.lst From 4622f364ec242e2b0ff6114a93c013e44dd4b865 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 21:59:09 +0800 Subject: [PATCH 12/15] Rename test.cpp to test.cpp --- .../test.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/std/tests/{GH_003003_format_fix_decimal_point_and_trailing_zero => GH_003003_format_decimal_point}/test.cpp (100%) diff --git a/tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp b/tests/std/tests/GH_003003_format_decimal_point/test.cpp similarity index 100% rename from tests/std/tests/GH_003003_format_fix_decimal_point_and_trailing_zero/test.cpp rename to tests/std/tests/GH_003003_format_decimal_point/test.cpp From 0c750249dab1b18b138056bd64d1204372371603 Mon Sep 17 00:00:00 2001 From: achabense <60953653+achabense@users.noreply.github.com> Date: Tue, 20 Jun 2023 22:52:01 +0800 Subject: [PATCH 13/15] Update test.lst --- tests/std/test.lst | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/std/test.lst b/tests/std/test.lst index 822cf153b8..fed37b9202 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -218,6 +218,7 @@ tests\GH_002769_handle_deque_block_pointers tests\GH_002789_Hash_vec_Tidy tests\GH_002989_nothrow_unwrappable tests\GH_002992_unwrappable_iter_sent_pairs +tests\GH_003003_format_decimal_point tests\GH_003022_substr_allocator tests\GH_003105_piecewise_densities tests\GH_003119_error_category_ctor From 1982fc18912192279fcaa092f23449ccbc8d14f9 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Wed, 21 Jun 2023 11:37:08 -0700 Subject: [PATCH 14/15] Remove FAILs for some std/utilities/format/format.functions tests. --- tests/libcxx/expected_results.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 4c39a78d07..9cca579fe7 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -1062,11 +1062,7 @@ std/ranges/range.adaptors/range.take/adaptor.pass.cpp FAIL std/ranges/range.factories/range.single.view/cpo.pass.cpp FAIL std/thread/futures/futures.task/futures.task.members/ctor2.compile.pass.cpp FAIL std/utilities/format/format.functions/escaped_output.ascii.pass.cpp FAIL -std/utilities/format/format.functions/format.locale.pass.cpp FAIL -std/utilities/format/format.functions/format.pass.cpp FAIL std/utilities/format/format.functions/locale-specific_form.pass.cpp FAIL -std/utilities/format/format.functions/vformat.locale.pass.cpp FAIL -std/utilities/format/format.functions/vformat.pass.cpp FAIL std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp FAIL std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp:0 FAIL std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp:0 FAIL From 75309ba76549fd21eee14091677cc181be7aff99 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Wed, 21 Jun 2023 12:18:25 -0700 Subject: [PATCH 15/15] Remove unnecessary assignments. --- stl/inc/format | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/stl/inc/format b/stl/inc/format index 653b58d2e6..077f445743 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -2882,8 +2882,7 @@ _NODISCARD _OutputIt _Fmt_write( if (_Precision == -1) { _Precision = 6; } - _Format = chars_format::scientific; - _Exponent = 'e'; + _Format = chars_format::scientific; break; case 'F': _To_upper = true; @@ -2901,8 +2900,7 @@ _NODISCARD _OutputIt _Fmt_write( if (_Precision == -1) { _Precision = 6; } - _Format = chars_format::general; - _Exponent = 'e'; + _Format = chars_format::general; break; }