about summary refs log tree commit diff
path: root/library/core/tests
AgeCommit message (Collapse)AuthorLines
2020-11-09Rollup merge of #77640 - ethanboxx:int_error_matching_attempt_2, r=KodrAusDylan DPC-28/+41
Refactor IntErrorKind to avoid "underflow" terminology This PR is a continuation of #76455 # Changes - `Overflow` renamed to `PosOverflow` and `Underflow` renamed to `NegOverflow` after discussion in #76455 - Changed some of the parsing code to return `InvalidDigit` rather than `Empty` for strings "+" and "-". https://users.rust-lang.org/t/misleading-error-in-str-parse-for-int-types/49178 - Carry the problem `char` with the `InvalidDigit` variant. - Necessary changes were made to the compiler as it depends on `int_error_matching`. - Redid tests to match on specific errors. r? ```@KodrAus```
2020-11-08Rollup merge of #78728 - a1phyr:const_cell_into_inner, r=dtolnayMara Bos-0/+13
Constantify `UnsafeCell::into_inner` and related Tracking issue: #78729 This PR constantifies: - `UnsafeCell::into_inner` - `Cell::into_inner` - `RefCell::into_inner` - `Atomic*::into_inner` r? `````@dtolnay`````
2020-11-08Rollup merge of #76227 - CDirkx:const-poll, r=KodrAusMara Bos-0/+15
Stabilize `Poll::is_ready` and `is_pending` as const Insta-stabilize the methods `is_ready` and `is_pending` of `std::task::Poll` as const, in the same way as [PR#76198](https://github.com/rust-lang/rust/pull/76198). Possible because of the recent stabilization of const control flow. Part of #76225.
2020-11-07Test structural matching for all range typesChristiaan Dirkx-1/+47
Adds structural match tests for all range types. Note: also adds the otherwise unrelated test `test_range_to_inclusive` for completeness
2020-11-05Rollup merge of #78738 - sasurau4:test/move-range-test-to-library-core, r=jyn514Mara Bos-1/+58
Move range in ui test to ops test in library/core Helps with #76268 r? ````@matklad````
2020-11-05Add `mod nan` for testchansuke-0/+2
2020-11-05Fix formatchansuke-5/+5
2020-11-05Move f64::NAN ui tests into `library`chansuke-0/+8
2020-11-05Move range in ui test to ops test in library/coreDaiki Ihara-1/+58
2020-11-04Constantify `UnsafeCell::into_inner` and relatedBenoît du Garreau-0/+13
Also includes: - Cell::into_inner - RefCell::into_inner - Atomic*::into_inner
2020-10-27Fixup tests: Duration::MIN -> ::ZEROJubilee Young-4/+4
2020-10-26Apply suggested changesEthan Brierley-9/+10
2020-10-21Duration::zero() -> Duration::ZEROJubilee Young-15/+10
Duration::ZERO composes better with match and various other things, at the cost of an occasional parens, and results in less work for the optimizer, so let's use that instead.
2020-10-21Dogfood Duration API in std::time testsJubilee Young-45/+45
This expands time's test suite to use more and in more places the range of methods and constants added to Duration in recent proposals for the sake of testing more API surface area and improving legibility.
2020-10-20Check for exhaustion in SliceIndex for RangeInclusiveJosh Stone-0/+30
2020-10-19Fix braces in panic message in test.Mara Bos-1/+1
2020-10-14Rollup merge of #77892 - est31:remove_redundant_absolute_paths, r=lcnrYuki Okushi-2/+2
Replace absolute paths with relative ones Modern compilers allow reaching external crates like std or core via relative paths in modules outside of lib.rs and main.rs.
2020-10-13Replace absolute paths with relative onesest31-2/+2
Modern compilers allow reaching external crates like std or core via relative paths in modules outside of lib.rs and main.rs.
2020-10-12Stabilize slice_select_nth_unstableJames Gill-16/+16
This stabilizes the functionality in slice_partition_at_index, but under the names `select_nth_unstable*`. The functions `partition_at_index*` are left as deprecated, to be removed in a later release. Closes #55300
2020-10-07Add comment to helper functionEthan Brierley-0/+1
2020-10-06remove OnlySign in favour of InvalidDigitEthan Brierley-2/+3
2020-10-06Bring char along with InvalidDigitEthan Brierley-6/+6
2020-10-06Fill in things needed to stabilize int_error_matchingEthan Brierley-29/+39
2020-10-06Auto merge of #77594 - timvermeulen:chain_advance_by, r=scottmcmbors-0/+103
Implement advance_by, advance_back_by for iter::Chain Part of #77404. This PR does two things: - implement `Chain::advance[_back]_by` in terms of `advance[_back]_by` on `self.a` and `advance[_back]_by` on `self.b` - change `Chain::nth[_back]` to use `advance[_back]_by` on `self.a` and `nth[_back]` on `self.b` This ensures that `Chain::nth` can take advantage of an efficient `nth` implementation on the second iterator, in case it doesn't implement `advance_by`. cc `@scottmcm` in case you want to review this
2020-10-06Test with non-fused iteratorsTim Vermeulen-4/+41
2020-10-05Add testsTim Vermeulen-0/+66
2020-10-03Rollup merge of #76745 - workingjubilee:move-wrapping-tests, r=matkladJonas Schievink-0/+76
Move Wrapping<T> ui tests into library Part of #76268 r? @matklad
2020-10-02Remove unnecessary mod-cfgJubilee Young-17/+14
2020-10-01Rollup merge of #76909 - timvermeulen:advance_by, r=AmanieuDylan DPC-0/+61
Add Iterator::advance_by and DoubleEndedIterator::advance_back_by This PR adds the iterator method ```rust fn advance_by(&mut self, n: usize) -> Result<(), usize> ``` that advances the iterator by `n` elements, returning `Ok(())` if this succeeds or `Err(len)` if the length of the iterator was less than `n`. Currently `Iterator::nth` is the method to override for efficiently advancing an iterator by multiple elements at once. `advance_by` is superior for this purpose because - it's simpler to implement: instead of advancing the iterator and producing the next element you only need to advance the iterator - it composes better: iterators like `Chain` and `FlatMap` can implement `advance_by` in terms of `advance_by` on their inner iterators, but they cannot implement `nth` in terms of `nth` on their inner iterators (see #60395) - the default implementation of `nth` can trivially be implemented in terms of `advance_by` and `next`, which this PR also does This PR also adds `DoubleEndedIterator::advance_back_by` for all the same reasons. I'll make a tracking issue if it's decided this is worth merging. Also let me know if anything can be improved, this went through several iterations so there might very well still be room for improvement (especially in the doc comments). I've written overrides of these methods for most iterators that already override `nth`/`nth_back`, but those still need tests so I'll add them in a later PR. cc @cuviper @scottmcm @Amanieu
2020-09-28Rollup merge of #76454 - poliorcetics:ui-to-unit-test-1, r=matkladRalf Jung-0/+239
UI to unit test for those using Cell/RefCell/UnsafeCell Helps with #76268. I'm working on all files using `Cell` and moving them to unit tests when possible. r? @matklad
2020-09-27Rollup merge of #77167 - ↵Jonas Schievink-1/+13
fusion-engineering-forks:fix-fixme-min-max-sign-test, r=nagisa Fix FIXME in core::num test: Check sign of zero in min/max tests. r? nagisa @rustbot modify labels: +C-cleanup
2020-09-25review: fix nits and move panic safety tests to the correct placeAlexis Bourget-61/+2
2020-09-25Rollup merge of #76973 - lzutao:unstably-const-assume, r=oli-obkJonas Schievink-0/+17
Unstably allow assume intrinsic in const contexts Not sure much about this usage because there are concerns about [blocking optimization][1] and [slowing down LLVM][2] when using `assme` intrinsic in inline functions. But since Oli suggested in https://github.com/rust-lang/rust/issues/76960#issuecomment-695772221, here we are. [1]: https://github.com/rust-lang/rust/pull/54995#issuecomment-429302709 [2]: https://github.com/rust-lang/rust/issues/49572#issuecomment-589615423
2020-09-24Fix FIXME in core::num test: Check sign of zero in min/max tests.Mara Bos-1/+13
2020-09-24move test to intergrated test in library/coreLzu Tao-0/+17
2020-09-22add array from_refBastian Kauschke-1/+17
2020-09-21Rollup merge of #76655 - CDirkx:const-pin, r=ecstatic-morseecstatic-morse-0/+34
Make some methods of `Pin` unstable const Make the following methods unstable const under the `const_pin` feature: - `new` - `new_unchecked` - `into_inner` - `into_inner_unchecked` - `get_ref` - `into_ref` - `get_mut` - `get_unchecked_mut` Of these, `into_inner` and `into_inner_unchecked` require the unstable `const_precise_live_drops`. Also adds tests for these methods in a const context. Tracking issue: #76654 r? @ecstatic-morse
2020-09-21Move format-ref-cell testAlexis Bourget-0/+8
2020-09-21Move vec-slice-drop testAlexis Bourget-0/+29
2020-09-21Move array cycle testAlexis Bourget-0/+29
2020-09-21Move panic safety traits testsAlexis Bourget-0/+57
2020-09-21fmtAlexis Bourget-5/+7
2020-09-21move 'test zip ...' testsAlexis Bourget-0/+95
2020-09-21move 'cell does not clone' testAlexis Bourget-0/+23
2020-09-21Move more tests using Cell to unit testsAlexis Bourget-0/+31
2020-09-21Move cell exterior test into library unit testsAlexis Bourget-0/+24
2020-09-20Move const tests for `Option` to `library\core`Christiaan Dirkx-0/+16
Part of #76268
2020-09-20Add advance_by and advance_back_byTim Vermeulen-0/+61
2020-09-20Auto merge of #76136 - CDirkx:const-result, r=dtolnaybors-0/+16
Stabilize some Result methods as const Stabilize the following methods of Result as const: - `is_ok` - `is_err` - `as_ref` A test is also included, analogous to the test for `const_option`. These methods are currently const under the unstable feature `const_result` (tracking issue: #67520). I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](https://github.com/rust-lang/rust/pull/75463) and [PR#76135](https://github.com/rust-lang/rust/pull/76135). Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature. Related: #76225
2020-09-19Use `T::BITS` instead of `size_of::<T> * 8`.Mara Bos-25/+18