[libcxx-commits] [PATCH] D136908: [libc++] Remove duplication in math_h.pass.cpp and improve coverage

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 17 09:28:14 PST 2022


ldionne added a comment.

In D136908#3910830 <https://reviews.llvm.org/D136908#3910830>, @EricWF wrote:

> Stop being clever in tests. These changes add a substantial cognitive load to any person who's trying to read them for the first time and understand what they do.
>
> This code duplication doesn't cost us anything, but it gives us a lot.

@philnik is increasing the coverage of this test. It would be better to instead suggest alternative ways to achieve this coverage without being "clever", or to argue for why we don't need additional coverage. I'm sure @philnik isn't being "clever" on purpose -- I've spent quite a bit of time looking at this and I am not sure how to achieve the same effects without introducing some machinery. Manually stamping these instantiations out is simply not realistic, we have something like at most 16 * 16 * 16 = 4096 combinations to test for the three argument functions.



================
Comment at: libcxx/test/std/depr/depr.c.headers/math_h.pass.cpp:935-941
+template <class PromoteResult>
+struct CallTestSingeArg {
+  template <class T>
+  void operator()() {
+    test_single_arg<T, PromoteResult>();
+  }
+};
----------------
Then below you can call:

```
meta::for_each(meta::integral_types(), test_single_arg</* PromoteResult */ double>());
test_single_arg</* PromoteResult */ float, /* Arg */ float>()();
test_single_arg</* PromoteResult */ double, /* Arg */ double>()();
test_single_arg</* PromoteResult */ long double, /* Arg */ long double>()();
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136908/new/

https://reviews.llvm.org/D136908



More information about the libcxx-commits mailing list