about summary refs log tree commit diff
path: root/library/alloc/tests
AgeCommit message (Collapse)AuthorLines
2020-12-02break formatting so rustfmt is happyRalf Jung-1/+2
2020-12-02disable a ptr equality test on MiriRalf Jung-1/+5
2020-11-30Make ui test that are run-pass and do not test the compiler itself library testsChristiaan Dirkx-1/+95
2020-11-26Fix new 'unnecessary trailing semicolon' warningsAaron Hill-3/+3
2020-11-15stabilize deque_rangeSpyros Roum-1/+0
2020-11-05Rollup merge of #76718 - poliorcetics:vec-ui-to-unit-test, r=jyn514Mara Bos-1/+193
Move Vec UI tests to unit tests when possible Helps with #76268. I'm moving the tests using `Vec` or `VecDeque`. ````@rustbot```` modify labels: A-testsuite C-cleanup T-libs
2020-10-29Added test for issue #78498Giacomo Stevanato-0/+15
2020-10-20Check for exhaustion in SliceIndex for RangeInclusiveJosh Stone-0/+29
2020-10-17Move subslice pattern tests to alloc/tests/slice.rsAlexis Bourget-0/+120
2020-10-17Move vec swap testAlexis Bourget-1/+13
2020-10-17Move vec-macro-repeat testAlexis Bourget-0/+13
2020-10-17Rebase conflictsAlexis Bourget-0/+30
2020-10-17Move zero-sized-vec-push testAlexis Bourget-0/+17
2020-10-09liballoc: VecDeque: Add binary search functionsVojtech Kral-0/+40
2020-10-07Auto merge of #74194 - mbrubeck:slice-eq, r=sfacklerbors-1/+2
Add PartialEq impls for Vec <-> slice This is a follow-up to #71660 and rust-lang/rfcs#2917 to add two more missing vec/slice PartialEq impls: ``` impl<A, B> PartialEq<[B]> for Vec<A> where A: PartialEq<B> { .. } impl<A, B> PartialEq<Vec<B>> for [A] where A: PartialEq<B> { .. } ``` Since this is insta-stable, it should go through the `@rust-lang/libs` FCP process. Note that I used version 1.47.0 for the `stable` attribute because I assume this will not merge before the 1.46.0 branch is cut next week.
2020-09-28Rollup merge of #76454 - poliorcetics:ui-to-unit-test-1, r=matkladRalf Jung-1/+409
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-25review: fix nits and move panic safety tests to the correct placeAlexis Bourget-13/+11
2020-09-23Rollup merge of #76993 - blitzerr:alloc-ref, r=AmanieuDylan DPC-1/+1
Changing the alloc() to accept &self instead of &mut self Fixes: [#55](https://github.com/rust-lang/wg-allocators/issues/55) This is the first cut. It only makes the change for `alloc` method.
2020-09-22Update library functions with stability attributesDylan MacKenzie-0/+1
This may not be strictly minimal, but all unstable functions also need a `rustc_const_unstable` attribute.
2020-09-22removing &mut self for other methods of AllocRefblitzerr-1/+1
2020-09-21Move vec-cycle-wrapped testAlexis Bourget-0/+41
2020-09-21Move vec-cycle testAlexis Bourget-0/+39
2020-09-21Move deref-lval testAlexis Bourget-0/+9
2020-09-21move format! interface testsAlexis Bourget-1/+322
2020-09-19Use `T::BITS` instead of `size_of::<T> * 8`.Mara Bos-4/+4
2020-09-16Rollup merge of #76662 - RalfJung:lib-test-miri, r=Mark-SimulacrumRalf Jung-1/+1
Fix liballoc test suite for Miri Mostly, fix the regression introduced by https://github.com/rust-lang/rust/pull/75207 that caused slices (i.e., references) to be created to invalid memory or memory that has aliasing pointers that we want to keep valid. @dylni this changes the type of `check_range` to only require the length, not the full reference to the slice, which indeed is all the information this function requires. Also reduce the size of a test introduced in https://github.com/rust-lang/rust/pull/70793 to make it not take 3 minutes in Miri. This makes https://github.com/RalfJung/miri-test-libstd work again.
2020-09-16Rollup merge of #76369 - ayushmishra2005:move_various_str_tests_library, ↵Ralf Jung-0/+21
r=jyn514 Move Various str tests in library Moved various string ui tests in library as a part of #76268 r? @matklad
2020-09-16Rollup merge of #75882 - pickfire:patch-6, r=jyn514Dylan DPC-2/+2
Use translated variable for test string Test should be educative, added english translation and pronounciation.
2020-09-16Rollup merge of #75146 - tmiasko:range-overflow, r=Mark-SimulacrumDylan DPC-0/+70
Detect overflow in proc_macro_server subspan * Detect overflow in proc_macro_server subspan * Add tests for overflow in Vec::drain * Add tests for overflow in String / VecDeque operations using ranges
2020-09-15fix slice::check_range aliasing problemsRalf Jung-1/+1
2020-09-15reduce size of test_from_iter_specialization_with_iterator_adapters test in MiriRalf Jung-1/+1
2020-09-15Auto merge of #76682 - richkadel:vec-take, r=Mark-Simulacrumbors-0/+18
Optimize behavior of vec.split_off(0) (take all) Optimization improvement to `split_off()` so the performance meets the intuitively expected behavior when `at == 0`, avoiding the current behavior of copying the entire vector. The change honors documented behavior that the original vector's "previous capacity unchanged". This improvement better supports the pattern for building and flushing a buffer of elements, such as the following: ```rust let mut vec = Vec::new(); loop { vec.push(something); if condition_is_met { process(vec.split_off(0)); } } ``` `Option` wrapping is the first alternative I thought of, but is much less obvious and more verbose: ```rust let mut capacity = 1; let mut vec: Option<Vec<Stuff>> = None; loop { vec.get_or_insert_with(|| Vec::with_capacity(capacity)).push(something); if condition_is_met { capacity = vec.capacity(); process(vec.take().unwrap()); } } ``` Directly using `mem::replace()` (instead of calling`split_off()`) could work, but `mem::replace()` is a more advanced tool for Rust developers, and in this case, I believe developers would assume the standard library should be sufficient for the purpose described here. The benefit of the approach to this change is it does not change the existing API contract, but improves the peformance of `split_off(0)` for `Vec`, `String` (which delegates `split_off()` to `Vec`), and any other existing use cases. This change adds tests to validate the behavior of `split_off()` with regard to capacity, as originally documented, and confirm that behavior still holds, when `at == 0`. The change is an implementation detail, and does not require a documentation change, but documenting the new behavior as part of its API contract may benefit future users. (Let me know if I should make that documentation update.) Note, for future consideration: I think it would be helpful to introduce an additional method to `Vec` (if not also to `String`): ``` pub fn take_all(&mut self) -> Self { self.split_off(0) } ``` This would make it more clear how `Vec` supports the pattern, and make it easier to find, since the behavior is similar to other `take()` methods in the Rust standard library. r? `@wesleywiser` FYI: `@tmandry`
2020-09-13Optimize behavior of vec.split_off(0) (take all)Rich Kadel-0/+18
Optimization improvement to `split_off()` so the performance meets the intuitively expected behavior when `at == 0`, avoiding the current behavior of copying the entire vector. The change honors documented behavior that the method leaves the original vector's "previous capacity unchanged". This improvement better supports the pattern for building and flushing a buffer of elements, such as the following: ```rust let mut vec = Vec::new(); loop { vec.push(something); if condition_is_met { process(vec.split_off(0)); } } ``` `Option` wrapping is the first alternative I thought of, but is much less obvious and more verbose: ```rust let mut capacity = 1; let mut vec: Option<Vec<Stuff>> = None; loop { vec.get_or_insert_with(|| Vec::with_capacity(capacity)).push(something); if condition_is_met { capacity = vec.capacity(); process(vec.take().unwrap()); } } ``` Directly applying `mem::replace()` could work, but `mem::` functions are typically a last resort, when a developer is actively seeking better performance than the standard library provides, for example. The benefit of the approach to this change is it does not change the existing API contract, but improves the peformance of `split_off(0)` for `Vec`, `String` (which delegates `split_off()` to `Vec`), and any other existing use cases. This change adds tests to validate the behavior of `split_off()` with regard to capacity, as originally documented, and confirm that behavior still holds, when `at == 0`. The change is an implementation detail, and does not require a documentation change, but documenting the new behavior as part of its API contract may benefit future users. (Let me know if I should make that documentation update.) Note, for future consideration: I think it would be helpful to introduce an additional method to `Vec` (if not also to `String`): ``` pub fn take_all(&mut self) -> Self { self.split_off(0) } ``` This would make it more clear how `Vec` supports the pattern, and make it easier to find, since the behavior is similar to other `take()` methods in the Rust standard library.
2020-09-13note that test_stable_pointers does not reflect a stable guaranteeRalf Jung-0/+3
2020-09-07Auto merge of #76368 - ayushmishra2005:move_str_contact_library, r=jyn514bors-0/+8
Added str tests in library Added str tests in library as a part of #76268 r? @matklad
2020-09-07Rollup merge of #76324 - ayushmishra2005:move_vec_tests_in_library, r=matkladDylan DPC-0/+23
Move Vec slice UI tests in library Moved some of Vec slice UI tests in Library as a part of #76268 r? @matklad
2020-09-07Rollup merge of #76305 - CDirkx:const-tests, r=matkladDylan DPC-0/+14
Move various ui const tests to `library` Move: - `src\test\ui\consts\const-nonzero.rs` to `library\core` - `src\test\ui\consts\ascii.rs` to `library\core` - `src\test\ui\consts\cow-is-borrowed` to `library\alloc` Part of #76268 r? @matklad
2020-09-07Rollup merge of #76273 - CraftSpider:master, r=matkladDylan DPC-0/+56
Move some Vec UI tests into alloc unit tests A bit of work towards #76268, makes a number of the Vec UI tests that are simply running code into unit tests. Ensured that they are being run when testing liballoc locally.
2020-09-06Move test-cases in string.rsAyush Kumar Mishra-8/+8
2020-09-05Move Various str tests in libraryAyush Kumar Mishra-0/+21
2020-09-05Added str tests in libraryAyush Kumar Mishra-0/+8
2020-09-04Move Vec slice UI tests in libraryAyush Kumar Mishra-0/+23
2020-09-04Move various ui const tests to `library`Christiaan Dirkx-0/+14
Move: - `src\test\ui\consts\const-nonzero.rs` to `library\core` - `src\test\ui\consts\ascii.rs` to `library\core` - `src\test\ui\consts\cow-is-borrowed` to `library\alloc` Part of #76268
2020-09-04Add tests for overflow in String / VecDeque operations using rangesTomasz Miąsko-0/+45
2020-09-04Add tests for overflow in Vec::drainTomasz Miąsko-0/+25
2020-09-03Remove vec-to_str.rs, merge the remaining test in with vecRune Tynan-0/+3
2020-09-03remove empty Vec extend optimizationThe8472-10/+0
The optimization meant that every extend code path had to emit llvm IR for from_iter and extend spec_extend, which likely impacts compile times while only improving a few edge-cases
2020-09-03support in-place collect for MapWhile adaptersThe8472-0/+2
2020-09-03generalize in-place collect to types of same size and alignmentThe8472-2/+3
2020-09-03test drops during in-place iterationThe8472-0/+40