summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/numerics
Commit message (Collapse)AuthorAgeFilesLines
* [libcxx] [test] Fix valarray UB and MSVC warnings.Stephan T. Lavavej2019-12-122-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [libcxx] [test] Calling min and max on an empty valarray is UB. libcxx/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp libcxx/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp The calls `v1.min();` and `v1.max();` were emitting nodiscard warnings with MSVC's STL. Upon closer inspection, these calls were triggering undefined behavior. N4842 [valarray.members] says: "T min() const; 8 Preconditions: size() > 0 is true. T max() const; 10 Preconditions: size() > 0 is true." As these tests already provide coverage for non-empty valarrays (immediately above), I've simply deleted the code for empty valarrays. [libcxx] [test] Add macros to msvc_stdlib_force_include.h (NFC). libcxx/test/support/msvc_stdlib_force_include.h These macros are being used by: libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp Defining them to nothing allows that test to pass. [libcxx] [test] Silence MSVC warning C5063 for is_constant_evaluated (NFC). libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.pass.cpp This test is intentionally writing code that MSVC intentionally warns about, so the warning should be silenced. Additionally, comment an endif for clarity. [libcxx] [test] Silence MSVC warning C4127 (NFC). libcxx/test/support/charconv_test_helpers.h MSVC avoids emitting this warning when it sees a single constexpr value being tested, but this condition is a mix of compile-time and run-time. Using push-disable-pop is the least intrusive way to silence this. [libcxx] [test] Silence MSVC truncation warning (NFC). libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp This test is intentionally truncating float to int, which MSVC intentionally warns about, so push-disable-pop is necessary. [libcxx] [test] Avoid truncation warnings in erase_if tests (NFC). libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpp libcxx/test/std/containers/associative/multimap/multimap.erasure/erase_if.pass.cpp libcxx/test/std/containers/unord/unord.map/erase_if.pass.cpp libcxx/test/std/containers/unord/unord.multimap/erase_if.pass.cpp These tests use maps with `short` keys and values, emitting MSVC truncation warnings from `int`. Adding `static_cast` to `key_type` and `mapped_type` avoids these warnings. As these tests require C++20 mode (or newer), for brevity I've changed the multimap tests to use emplace to initialize the test data. This has no effect on the erase_if testing.
* [libc++] Fix potential OOB in poisson_distributionLouis Dionne2019-11-072-1/+74
| | | | | See details in the original Chromium bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=994957
* [libcxx][NFC] Strip trailing whitespace, fix typo.Stephan T. Lavavej2019-10-238-16/+16
|
* [NFC] Strip trailing whitespace from libc++Louis Dionne2019-10-2315-60/+60
|
* [libc++][NFC] Remove excess trailing newlines from most filesCasey Carter2019-10-231-1/+0
| | | | Testing git commit access.
* [libcxx][test][NFC] Fix comment typos.Stephan T. Lavavej2019-10-221-2/+2
| | | | (Testing git commit access.)
* [libc++][test] Miscellaneous MSVC cleanupsCasey Carter2019-10-092-4/+4
| | | | | | | | | | | | * Silence unused-local-typedef warnings: `map.cons/assign_initializer_list.pass.cpp` (and the `set.cons` variant) uses a local typedef only within `LIBCPP_ASSERT`s, so clang diagnoses it as unused when testing non-libc++. * Add missing include: `c.math/abs.pass.cpp` uses `std::numeric_limits` but failed to `#include <limits>`. * Don't test non-type: A "recent" change to `meta.trans.other/underlying_type.pass.cpp` unconditionally tests the type `F` which is conditionally defined. * Use `hash<long long>` instead of `hash<short>` with `int` in `unordered_meow` deduction guide tests to avoid truncation warnings. * Convert `3.14` explicitly in `midpoint.float.pass` since MSVC incorrectly diagnoses `float meow = 3.14;` as truncating. Differential Revision: https://reviews.llvm.org/D68681 llvm-svn: 374248
* [libc++] Fix broken <random> testLouis Dionne2019-08-221-16/+23
| | | | | | | | | | | | In r369429, I hoisted a floating point computation to a variable in order to remove a warning. However, it turns out this doesn't play well with floating point arithmetic. This commit reverts r369429 and instead casts the result of the floating point computation to remove the warning. Whether hoisting the computaiton to a variable should give the same result can be investigated independently. llvm-svn: 369693
* [libc++] Fix std::abs testsZoe Carver2019-08-201-7/+14
| | | | | | | | | | On systems where sizeof(long) == sizeof(int) the current tests failed. This commit updates those tests to work on all systems. std::abs has specific long specializations which can be used instead. llvm-svn: 369437
* [libc++] Avoid implicit conversion warning in a <random> testLouis Dionne2019-08-201-23/+16
| | | | | | | | | | By stashing the computation of `E::max() - E::min()` in a variable, we avoid the warning introduced in r367497. Note that we use `auto` to avoid having to deduce the type of the computation, which is not a problem since Clang provides `auto` as an extension even in C++03 (and we disable warnings related to using C++11 extensions in the test suite). llvm-svn: 369429
* [libc++] fix test for unsigned charZoe Carver2019-08-201-1/+7
| | | | | | | | | On some systems char is unsigned. If that is the case, we will now test signed char twice in std::abs. NFC. Fixes the build bots. llvm-svn: 369413
* [libc++] std::abs should not return doubleZoe Carver2019-08-202-0/+97
| | | | | | | | Implement LWG Issue 2735 by adding std::abs tests for several types and checking their return value. NFC. llvm-svn: 369394
* Implement most of P1612R1: Relocate endian. Moves the std::endian ↵Marshall Clow2019-07-231-0/+49
| | | | | | functionality from 'type-traits' to 'bit'. No other change. The reason that this is 'partial' is that P1621 also recommends a feature-test macro, but I don't have the value for that one yet. In a month or so, I'll add that llvm-svn: 366776
* Bit Operations: P0556, P0553 and P1355. Reviewed as: ↵Marshall Clow2019-07-0113-0/+1904
| | | | | | https://reviews.llvm.org/D51262 llvm-svn: 364862
* Disable the 'nextafter' portions of these tests on PPC when using 128-bit ↵Marshall Clow2019-06-181-19/+27
| | | | | | doubles because the 'nextafter' call doesn't work right. Reviewed as https://reviews.llvm.org/D62384. Thanks to Xing Xue for the patch, and Hubert for the explanation. llvm-svn: 363740
* Fix the floating point version of midpoint. It wasn't constexpr, among other ↵Marshall Clow2019-06-181-5/+16
| | | | | | things. Add more tests. As a drive-by, the LCD implementation had a class named '__abs' which did a 'absolute value to a common-type' conversion. Rename that to be '__ct_abs'. llvm-svn: 363714
* Add include for 'test_macros.h' to all the tests that were missing them. ↵Marshall Clow2019-05-31754-0/+1455
| | | | | | Thanks to Zoe for the (big, but simple) patch. NFC intended. llvm-svn: 362252
* Add additional constraints on midpoint(pointer, pointer). Fixes PR#42037.Marshall Clow2019-05-291-3/+12
| | | | llvm-svn: 361970
* [libc++] [test] Use std::nextafter() instead of std::nexttoward()Michal Gorny2019-05-141-2/+2
| | | | | | | | | | | | Use std::nextafter() instead of std::nexttoward() in midpoint tests. In the context of this test, this should not cause any difference. Since nexttowardl() is not implemented on NetBSD 8, the latter function combined with 'long double' type caused test failure. nextafterl() does not have this problem. Differential Revision: https://reviews.llvm.org/D61748 llvm-svn: 360673
* Implement 'lerp'; which is the last bit of P0811. Mark that paper as complete.Marshall Clow2019-04-251-0/+75
| | | | llvm-svn: 359211
* Implement midpoint for floating point types. Reviewed as ↵Marshall Clow2019-04-251-0/+113
| | | | | | https://reviews.llvm.org/D61014. llvm-svn: 359184
* Fix implementation of ::abs and std::abs LWG 2192.Eric Fiselier2019-04-231-7/+46
| | | | | | | | | | | | | | | | | | | Summary: All overloads of `::abs` and `std::abs` must be present in both `<cmath>` and `<cstdlib>`. This is problematic to implement because C defines `fabs` in `math.h` and `labs` in `stdlib.h`. This introduces a circular dependency between the two headers. This patch implements that requirement by moving `abs` into `math.h` and making `stdlib.h` include `math.h`. In order to get the underlying C declarations from the "real" `stdlib.h` inside our `math.h` we need some trickery. Specifically we need to make `stdlib.h` include next itself. Suggestions for a cleaner implementation are welcome. Reviewers: mclow.lists, ldionne Reviewed By: ldionne Subscribers: krytarowski, fedor.sergeev, dexonsmith, jdoerfert, jsji, libcxx-commits Differential Revision: https://reviews.llvm.org/D60097 llvm-svn: 359020
* [libc++] [test] Add missing required headers to midpoint.integer.pass.cppBilly Robert O'Neal III2019-04-181-0/+2
| | | | | | This change authored by Paolo Torres <t-pator@microsoft.com> llvm-svn: 358698
* Fix a number of bugs in __val_expr's subset operator[].Eric Fiselier2019-04-028-218/+340
| | | | | | | | The current definitions were entirely broken. They didn't call any existing constructor and the forgot to friend the expression types they were trying to construct. llvm-svn: 357453
* [libc++] Remove unnecessary <iostream> #includes in testsLouis Dionne2019-03-284-8/+0
| | | | | | | Some tests #include <iostream> but they don't use anything from the header. Those are probably artifacts of when the tests were developped. llvm-svn: 357181
* Reorg the midpoint pointer test into runtime and constexpr tests; comment ↵Marshall Clow2019-03-141-10/+40
| | | | | | out the volatile constexpr tests for GCC because our experimental gcc bot barfs on them. llvm-svn: 356177
* Fix two of the three bot failures for midpoint; the ones regarding the lack ↵Marshall Clow2019-03-141-1/+4
| | | | | | of '__int128_t' llvm-svn: 356169
* Add std::midpoint for integral and poiner types. Described in P0811, ↵Marshall Clow2019-03-143-0/+224
| | | | | | reviewed as D59099. llvm-svn: 356162
* Support tests in freestandingJF Bastien2019-02-04841-842/+2524
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Freestanding is *weird*. The standard allows it to differ in a bunch of odd manners from regular C++, and the committee would like to improve that situation. I'd like to make libc++ behave better with what freestanding should be, so that it can be a tool we use in improving the standard. To do that we need to try stuff out, both with "freestanding the language mode" and "freestanding the library subset". Let's start with the super basic: run the libc++ tests in freestanding, using clang as the compiler, and see what works. The easiest hack to do this: In utils/libcxx/test/config.py add: self.cxx.compile_flags += ['-ffreestanding'] Run the tests and they all fail. Why? Because in freestanding `main` isn't special. This "not special" property has two effects: main doesn't get mangled, and main isn't allowed to omit its `return` statement. The first means main gets mangled and the linker can't create a valid executable for us to test. The second means we spew out warnings (ew) and the compiler doesn't insert the `return` we omitted, and main just falls of the end and does whatever undefined behavior (if you're luck, ud2 leading to non-zero return code). Let's start my work with the basics. This patch changes all libc++ tests to declare `main` as `int main(int, char**` so it mangles consistently (enabling us to declare another `extern "C"` main for freestanding which calls the mangled one), and adds `return 0;` to all places where it was missing. This touches 6124 files, and I apologize. The former was done with The Magic Of Sed. The later was done with a (not quite correct but decent) clang tool: https://gist.github.com/jfbastien/793819ff360baa845483dde81170feed This works for most tests, though I did have to adjust a few places when e.g. the test runs with `-x c`, macros are used for main (such as for the filesystem tests), etc. Once this is in we can create a freestanding bot which will prevent further regressions. After that, we can start the real work of supporting C++ freestanding fairly well in libc++. <rdar://problem/47754795> Reviewers: ldionne, mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commits Differential Revision: https://reviews.llvm.org/D57624 llvm-svn: 353086
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-19842-3368/+2526
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* Fix FP comparisons when SSE isn't availableEric Fiselier2018-12-172-14/+17
| | | | llvm-svn: 349387
* [libcxx] Don't depend on availability markup to provide the streams in the dylibLouis Dionne2018-12-061-2/+0
| | | | | | | | | | | | Whether an explicit instantiation declaration should be provided is not a matter of availability markup. This problem is exemplified by the fact that some tests were incorrectly marked as XFAIL when they should instead have been using the definition of streams from the headers, and hence passing, and that, regardless of whether visibility annotations are enabled. llvm-svn: 348436
* [libc++] Use correct rand.eng.mers all-zeroes seed sequence fallbackHubert Tong2018-08-161-0/+81
| | | | | | | | | | | | | | | | | | | | | | | Summary: When a seed sequence would lead to having no non-zero significant bits in the initial state of a `mersenne_twister_engine`, the fallback is to flip the most significant bit of the first value that appears in the textual representation of the initial state. rand.eng.mers describes this as setting the value to be 2 to the power of one less than w; the previous value encoded in the implementation, namely one less than "2 to the power of w", is replaced by the correct value in this patch. Reviewers: mclow.lists, EricWF, jasonliu Reviewed By: mclow.lists Subscribers: mclow.lists, jasonliu, EricWF, christof, ldionne, cfe-commits Differential Revision: https://reviews.llvm.org/D50736 llvm-svn: 339969
* [libcxx] [test] Remove unused local typedef in ↵Billy Robert O'Neal III2018-05-171-1/+0
| | | | | | test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp llvm-svn: 332571
* Add void casts to suppress nodiscard on linear_congruential_engine.Billy Robert O'Neal III2018-05-172-3/+3
| | | | llvm-svn: 332567
* Fix return type of isinf(double) and isnan(double) where possible.Richard Smith2018-05-011-6/+8
| | | | | | | | | | | When using an old version of glibc, a ::isinf(double) and ::isnan(double) function is provided, rather than just the macro required by C and C++. Displace this function using _LIBCPP_PREFERRED_OVERLOAD where possible. The only remaining case where we should get the wrong return type is now glibc + libc++ + a non-clang compiler. llvm-svn: 331241
* [libcxx] [test] Use TEST_COMPILER_C1XX.Stephan T. Lavavej2018-04-121-4/+4
| | | | | | Also TEST_COMPILER_CLANG in one place. (More could be changed.) llvm-svn: 329977
* Include <system_error> since we use it. Thanks to Andrey Maksimov for the catch.Marshall Clow2018-03-071-0/+1
| | | | llvm-svn: 326958
* [libcxx] [test] Fix MSVC warnings and errors.Stephan T. Lavavej2018-02-268-74/+74
| | | | | | | | | | | | | | | | | | | | | | | | test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp Fix MSVC x64 truncation warnings. warning C4267: conversion from 'size_t' to 'int', possible loss of data test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp Fix MSVC uninitialized memory warning. warning C6001: Using uninitialized memory 'vl'. test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp Include <cassert> for the assert() macro. Fixes D43273. llvm-svn: 326120
* [libcxx] Improve accuracy of complex asinh and acoshMikhail Maltsev2018-02-192-0/+18
| | | | | | | | | | | | | | | | | | | | Summary: Currently std::asinh and std::acosh use std::pow to compute x^2. This results in a significant error when computing e.g. asinh(i) or acosh(-1). This patch expresses x^2 directly via x.real() and x.imag(), like it is done in libstdc++/glibc, and adds tests that checks the accuracy. Reviewers: EricWF, mclow.lists Reviewed By: mclow.lists Subscribers: christof, cfe-commits Differential Revision: https://reviews.llvm.org/D41629 llvm-svn: 325510
* [libcxx] Avoid spurious construction of valarray elementsMikhail Maltsev2018-02-084-0/+81
| | | | | | | | | | | | | | | | | | | | | Summary: Currently libc++ implements some operations on valarray by using the resize method. This method has a parameter with a default value. Because of this, valarray may spuriously construct and destruct objects of valarray's element type. This patch fixes this issue and adds corresponding test cases. Reviewers: EricWF, mclow.lists Reviewed By: mclow.lists Subscribers: rogfer01, cfe-commits Differential Revision: https://reviews.llvm.org/D41992 llvm-svn: 324596
* Implement LWG2870: Default value of parameter theta of polar should be dependentMarshall Clow2018-01-311-1/+1
| | | | llvm-svn: 323918
* Change add_ten to add_one to avoid triggering ubsan integer overflow.Billy Robert O'Neal III2018-01-083-67/+67
| | | | llvm-svn: 322021
* Add casts to prevent narrowing warnings.Billy Robert O'Neal III2018-01-063-6/+6
| | | | llvm-svn: 321923
* [libcxx] [test] Remove nonstandard things and resolve warnings in Xxx_scan testsBilly Robert O'Neal III2018-01-068-101/+98
| | | | | | | | | | | Reviewed as https://reviews.llvm.org/D41748 * These tests use function objects from functional, back_inserter from iterator, and equal from algorithm, so add those headers. * The use of iota targeting vector<unsigned char> with an int parameter triggers warnings on MSVC++ assigning an into a unsigned char&; so change the parameter to unsigned char with a static_cast. * Avoid naming unary_function in identity here as that is removed in '17. (This also fixes naming _VSTD, _NOEXCEPT_, and other libcxx-isms) * Change the predicate in the transform tests to add_ten so that problems with multiple application are caught. llvm-svn: 321922
* Move + and * operators of MoveOnly into MoveOnly.h.Billy Robert O'Neal III2018-01-051-10/+0
| | | | llvm-svn: 321852
* Fix incorrect handling of move-only types in transform_reduce iter iter iter ↵Billy Robert O'Neal III2018-01-051-0/+22
| | | | | | init, and add test. llvm-svn: 321851
* Add move-only types test to transform_reduce iter iter iter init op op.Billy Robert O'Neal III2018-01-051-0/+14
| | | | llvm-svn: 321849
* Add move-only types test for transform_reduce bop/uop.Billy Robert O'Neal III2018-01-051-0/+13
| | | | llvm-svn: 321848
* Fix nonstandard bits in transform_reduce_iter_iter_init_bop_uop.Billy Robert O'Neal III2018-01-051-43/+27
| | | | | | | | * _VSTD should be std. * <utility> is needed for forward. * unary_function is no longer standard (and unnecessary for this, a C++17-only test) llvm-svn: 321847
OpenPOWER on IntegriCloud