summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/numerics
Commit message (Collapse)AuthorAgeFilesLines
...
* Change (void) casts to TEST_IGNORE_NODISCARD, as requested by Eric. Reviewed ↵Billy Robert O'Neal III2017-11-211-1/+2
| | | | | | as https://reviews.llvm.org/D40065 llvm-svn: 318804
* Tolerate even more [[nodiscard]] in the STL. Reviewed as ↵Billy Robert O'Neal III2017-11-1519-54/+58
| | | | | | https://reviews.llvm.org/D39080 llvm-svn: 318277
* Placate unused variable warnings uncovered by improvements to clang's ↵Benjamin Kramer2017-10-142-0/+2
| | | | | | -Wunused-variable llvm-svn: 315809
* [libcxx] [test] Rename __x to x. NFCI.Stephan T. Lavavej2017-08-114-25/+26
| | | | | | | This improves readability and (theoretically) improves portability, as __ugly names are reserved. llvm-svn: 310760
* [libcxx] [test] Rename _Tp to T. NFCI.Stephan T. Lavavej2017-08-119-46/+46
| | | | | | | This improves readability and (theoretically) improves portability, as _Ugly names are reserved. llvm-svn: 310758
* [libcxx] [test] Untabify, NFC.Stephan T. Lavavej2017-07-294-8/+8
| | | | llvm-svn: 309464
* [libcxx] [test] Strip trailing whitespace, NFC.Stephan T. Lavavej2017-07-295-19/+17
| | | | llvm-svn: 309463
* [libcxx] [test] Fix Clang -Wunused-local-typedef warnings.Stephan T. Lavavej2017-07-1915-31/+0
| | | | | | Fix D34536. llvm-svn: 308534
* Implement inclusive_scan/transform_inclusive_scan for C++17.Marshall Clow2017-06-235-0/+635
| | | | llvm-svn: 306083
* [libcxx] [test] Strip trailing whitespace. NFC.Stephan T. Lavavej2017-06-207-21/+20
| | | | llvm-svn: 305848
* Renamed some of the newly added tests. No functional changeMarshall Clow2017-06-156-0/+0
| | | | llvm-svn: 305453
* Implement the non-parallel versions of reduce and transform_reduce for C++17Marshall Clow2017-06-146-0/+520
| | | | llvm-svn: 305365
* Add a test with an empty input range - should do nothingMarshall Clow2017-06-131-0/+6
| | | | llvm-svn: 305268
* Implement the non-parallel versions of exclusive_scan and ↵Marshall Clow2017-06-103-0/+338
| | | | | | transform_exclusive_scan. Reviewed as https://reviews.llvm.org/D34038. llvm-svn: 305136
* Resolve integer overflow warnings in GCD and LCM testsBilly Robert O'Neal III2017-05-082-42/+52
| | | | | | | | | | | | | | | | | | | | | lcm.pass.cpp: 19: Update headers to that actually used in the test. 41: test0 was triggering narrowing warnings for all callers, because the inputs were always ints, but some of the explicit template arguments were smaller than that. Instead, have this function accept ints and static_cast explicitly to the types we want before calling std::lcm. 47: Replace unnecessary ternary. 55: Use foo_t instead of typename foo<>::type 111/116: intX_t were not std::qualified but only <cfoo> headers were included. 141: C1XX has a bug where it interprets 2147483648 as unsigned int. Then the negation trips "negation of unsigned value, result still unsigned" warnings. Perma-workaround this issue by saying INT_MIN, which better documents the intended behavior and avoids triggering warnings on C1XX. gcd.pass.cpp: Same changes as lcm.pass.cpp but for GCD. llvm-svn: 302472
* Document XFAIL's with the relevent bug numberEric Fiselier2017-05-052-0/+4
| | | | llvm-svn: 302213
* Add markup for libc++ dylib availabilityMehdi Amini2017-05-043-0/+14
| | | | | | | | | | | | | | | Libc++ is used as a system library on macOS and iOS (amongst others). In order for users to be able to compile a binary that is intended to be deployed to an older version of the platform, clang provides the availability attribute <https://clang.llvm.org/docs/AttributeReference.html#availability>_ that can be placed on declarations to describe the lifecycle of a symbol in the library. See docs/DesignDocs/AvailabilityMarkup.rst for more information. Differential Revision: https://reviews.llvm.org/D31739 llvm-svn: 302172
* cmath: Skip Libc for integral types in isinf, etc.Duncan P. N. Exon Smith2017-04-211-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | For std::isinf, the standard requires effectively calling isinf as double from Libc for integral types. But integral types are never infinite; we don't need to call Libc to return false. Also short-circuit other functions where Libc won't have interesting answers: signbit, fpclassify, isfinite, isnan, and isnormal. I added correctness tests for integral types since we're no longer deferring to Libc. In review it was pointed out that in future revisions of the C++ standard we may add more types to std::is_arithmetic (e.g., std::is_fixed_point). I'll leave it to a future commit to hack this to allow using math functions on those. We'll need to change things like __libcpp_fpclassify anyway, so I'm not sure anything here would really be future-proof. https://reviews.llvm.org/D31561 rdar://problem/31361223 llvm-svn: 301060
* Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in the numeric tests and headersEric Fiselier2017-04-1930-34/+70
| | | | llvm-svn: 300632
* Clean up more usages of _LIBCPP_HAS_NO_RVALUE_REFERENCESEric Fiselier2017-03-034-8/+10
| | | | llvm-svn: 296854
* Make lcm/gcd work better in edge cases. Fixes a UBSAN failure.Marshall Clow2017-02-102-5/+4
| | | | llvm-svn: 294779
* Temporarily disable the LCM/GCD tests under UBSAN.Marshall Clow2017-02-082-0/+3
| | | | llvm-svn: 294417
* Add some tests to verify that we implement LWG#2837 correctly. No functional ↵Marshall Clow2017-02-062-0/+14
| | | | | | change. llvm-svn: 294194
* [libcxx] [test] Fix Clang -Wunused-local-typedef, part 2/3.Stephan T. Lavavej2017-02-058-18/+0
| | | | | | | | These typedefs were completely unused. Fixes D29136. llvm-svn: 294155
* Fix unused parameters and variablesEric Fiselier2016-12-2318-28/+11
| | | | llvm-svn: 290459
* Enable the -Wsign-compare warning to better support MSVCEric Fiselier2016-12-1132-147/+151
| | | | llvm-svn: 289363
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-083-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | loss of data", part 7/7. test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp Add static_cast<char> because basic_istream::get() returns int_type (N4606 27.7.2.3 [istream.unformatted]/4). test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp Add static_cast<char> because toupper() returns int (C11 7.4.2.2/1). test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp This test is intentionally writing doubles to ostream_iterator<int>. It's silencing -Wliteral-conversion for Clang, so I'm adding C4244 silencing for MSVC. test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp Given `extern float zero;`, the expression `1./zero` has type double, which emits a truncation warning when being passed to test<float>() taking float. The fix is to say `1.f/zero` which has type float. test/std/numerics/complex.number/cmplx.over/arg.pass.cpp test/std/numerics/complex.number/cmplx.over/norm.pass.cpp These tests were constructing std::complex<double>(x, 0), emitting truncation warnings when x is long long. Saying static_cast<double>(x) avoids this. test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp This was using `int s` to construct and seed a linear_congruential_engine<T, stuff>, where T is unsigned short/unsigned int/unsigned long/unsigned long long. That emits a truncation warning in the unsigned short case. Because the range [0, 20) is tiny and we aren't doing anything else with the index, we can just iterate with `T s`. test/std/re/re.traits/value.pass.cpp regex_traits<wchar_t>::value()'s first parameter is wchar_t (N4606 28.7 [re.traits]/13). This loop is using int to iterate through ['g', 0xFFFF), emitting a truncation warning from int to wchar_t (which is 16-bit for some of us). Because the bound is exclusive, we can just iterate with wchar_t. test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp This test is a little strange. It's trying to verify that basic_string's (InIt, InIt) range constructor isn't confused by "N copies of C" when N and C have the same integral type. To do this, it was testing (100, 65), but that eventually emits truncation warnings from int to char. There's a simple way to avoid this - passing (static_cast<char>(100), static_cast<char>(65)) also exercises the disambiguation. (And 100 is representable even when char has a signed range.) test/std/strings/string.view/string.view.hash/string_view.pass.cpp Add static_cast<char_type> because `'0' + i` has type int. test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp What's more horrible than nested bind()? pow() overloads! This operator()(T a, T b) was assuming that std::pow(a, b) can be returned as T. (In this case, T is int.) However, N4606 26.9.1 [cmath.syn]/2 says that pow(int, int) returns double, so this was truncating double to int. Adding static_cast<T> silences this. test/std/utilities/function.objects/unord.hash/integral.pass.cpp This was iterating `for (int i = 0; i <= 5; ++i)` and constructing `T t(i);` but that's truncating when T is short. (And super truncating when T is bool.) Adding static_cast<T> silences this. test/std/utilities/utility/exchange/exchange.pass.cpp First, this was exchanging 67.2 into an int, but that's inherently truncating. Changing this to static_cast<short>(67) avoids the truncation while preserving the "what if T and U are different" test coverage. Second, this was exchanging {} with the explicit type float into an int, and that's also inherently truncating. Specifying short is just as good. test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp Add static_cast<short>. Note that this affects template argument deduction for make_pair(), better fulfilling the test's intent. For example, this was saying `typedef std::pair<int, short> P1; P1 p1 = std::make_pair(3, 4);` but that was asking make_pair() to return pair<int, int>, which was then being converted to pair<int, short>. (pair's converting constructors are tested elsewhere.) Now, std::make_pair(3, static_cast<short>(4)) actually returns pair<int, short>. (There's still a conversion from pair<nullptr_t, short> to pair<unique_ptr<int>, short>.) Fixes D27544. llvm-svn: 289111
* [libcxx] [test] D27022: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-062-2/+4
| | | | | | | | | | part 9/12. Add static_cast<std::size_t> to more comparisons. (Performed manually, unlike part 8/12.) Also, include <cstddef> when it wasn't already being included. llvm-svn: 288746
* [libcxx] [test] D27027: Strip trailing whitespace.Stephan T. Lavavej2016-11-2314-25/+25
| | | | llvm-svn: 287829
* [libcxx] [test] D27020: Fix MSVC warning C4245 "conversion from 'X' to 'Y', ↵Stephan T. Lavavej2016-11-234-4/+4
| | | | | | | | | | signed/unsigned mismatch", part 7/12. When initializing unsigned integers to their maximum values, change "const T M(~0);" to "const T M(static_cast<T>(-1));". ~0 and -1 are equivalent, but I consider the -1 form to be significantly clearer (and more consistent with other tests). llvm-svn: 287827
* [libcxx] [test] D27018: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-232-2/+2
| | | | | | | | | | | | | | | | | | | part 5/12. Various changes: test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp Change M from unsigned to int. It's compared against "int x", and we binary_search() for it within a vector<int>. test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp Add static_cast<unsigned> when comparing int to unsigned. test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp Change unsigned indices to int when we're being given int as a bound. llvm-svn: 287825
* [libcxx] [test] D27013: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-23123-193/+316
| | | | | | | | | | part 1/12. Change loop indices from int to std::size_t. Also, include <cstddef> when it wasn't already being included. llvm-svn: 287820
* [libcxx] [test] D26812: In random tests, use real static_asserts and silence ↵Stephan T. Lavavej2016-11-186-20/+84
| | | | | | | | | | | | | a warning. In C++11 mode and newer, use real static_asserts. In C++03 mode, min() and max() aren't constexpr, so use plain asserts. One test triggers MSVC's warning C4310 "cast truncates constant value". The code is valid, and yet the warning is valid, so I'm silencing it through push-disable-pop. llvm-svn: 287391
* Fixes for LWG 2598, 2686, 2739, 2742, 2747, and 2759, which were adopted ↵Marshall Clow2016-11-1412-4/+208
| | | | | | last week in Issaquah llvm-svn: 286858
* [libcxx] [test] D26314: Fix MSVC warning C4189 "local variable is ↵Stephan T. Lavavej2016-11-143-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initialized but not referenced". test/std/depr/depr.c.headers/inttypes_h.pass.cpp test/std/input.output/file.streams/c.files/cinttypes.pass.cpp test/std/input.output/iostream.forward/iosfwd.pass.cpp Add test() to avoid a bunch of void-casts, although we still need a few. test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp skippingws was unused (it's unclear to me whether this was mistakenly copy-pasted from round_trip() below). test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp test/std/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp test/std/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp test/std/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp test/std/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp test/std/localization/locales/locale.global.templates/use_facet.pass.cpp When retrieving facets, the references are unused. test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp "std::ios_base::iostate err = ios.goodbit;" was completely unused here. test/std/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp test/std/numerics/c.math/ctgmath.pass.cpp test/std/numerics/rand/rand.device/entropy.pass.cpp test/std/numerics/rand/rand.device/eval.pass.cpp test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp test/std/thread/futures/futures.promise/dtor.pass.cpp test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp These variables are verifying types but are otherwise unused. test/std/strings/basic.string/string.capacity/reserve.pass.cpp old_cap was unused (it's unclear to me whether it was intended to be used). test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp These tests contained unused characters. llvm-svn: 286847
* [libcxx] [test] Replace _LIBCPP_STD_VER with TEST_STD_VER.Stephan T. Lavavej2016-11-049-11/+27
| | | | | | | | | | | This replaces every occurrence of _LIBCPP_STD_VER in the tests with TEST_STD_VER. Additionally, for every affected file, #include "test_macros.h" is being added explicitly if it wasn't already there. https://reviews.llvm.org/D26294 llvm-svn: 286007
* Protect tests that expect an exception for an unknown std::random_deviceRoger Ferrer Ibanez2016-11-012-2/+4
| | | | | | | | Skip these tests under libcpp-no-exceptions. Differential Revision: https://reviews.llvm.org/D26141 llvm-svn: 285677
* Remove usages of _LIBCPP_CONSTEXPR under test/stdEric Fiselier2016-10-124-12/+20
| | | | llvm-svn: 284002
* Remove all _LIBCPP_VERSION tests from under test/stdEric Fiselier2016-10-084-32/+0
| | | | llvm-svn: 283644
* Remove test for the sign of a NaN - doesn't work on MIPS, not strictly ↵Marshall Clow2016-08-111-1/+0
| | | | | | legal. Fixes bug 28936 llvm-svn: 278387
* Implement LCM and GCD for C++17. Same code as for Library Fundamentals TS.Marshall Clow2016-07-266-0/+359
| | | | llvm-svn: 276751
* Fix portability issues in <random> tests. Patch from STL@microsoft.comEric Fiselier2016-07-241-1/+3
| | | | llvm-svn: 276585
* Add SFINAE on additional overloads of std::complex functions. Fixes PR19921.Eric Fiselier2016-07-201-0/+74
| | | | | | | | | | The functions arg, conj, imag, norm, proj, and real have additional overloads for arguments of integral or floating point types. However these overloads should not allow conversions to the integral/floating point types, only exact matches. This patch constrains these functions so they no longer allow conversions. llvm-svn: 276067
* Add array bounds assertions to satisfy MSVC's /analyze flag. Patch from ↵Eric Fiselier2016-06-261-0/+3
| | | | | | STL@microsoft.com llvm-svn: 273820
* Move remaining _LIBCPP_VERSION tests into test/libcxxEric Fiselier2016-06-225-102/+0
| | | | llvm-svn: 273367
* Avoid huge main() functions and huge arrays. Patch from STL@microsoft.comEric Fiselier2016-06-229-2455/+2686
| | | | llvm-svn: 273354
* Fix operator precedence mistake in valarray/not.pass.cpp. Patch from ↵Eric Fiselier2016-06-221-1/+1
| | | | | | STL@microsoft.com llvm-svn: 273352
* Improve portability of random_device tests. Patch from STL@microsoft.comEric Fiselier2016-06-152-2/+6
| | | | llvm-svn: 272746
* Replace __cplusplus comparisons and dialect __has_feature checks with ↵Eric Fiselier2016-06-141-0/+1
| | | | | | | | | TEST_STD_VER. This is a huge cleanup that helps make the libc++ test suite more portable. Patch from STL@microsoft.com. Thanks STL! llvm-svn: 272716
* Rename variables to prevent shadowing. Patch from STL@microsoft.comEric Fiselier2016-06-1432-372/+372
| | | | llvm-svn: 272619
OpenPOWER on IntegriCloud