about summary refs log tree commit diff
path: root/src/liballoc/tests
AgeCommit message (Collapse)AuthorLines
2018-08-05Remove unnecessary or invalid feature attributesvarkor-1/+0
2018-08-02Add trim_start, trim_end, trim_start_matches and trim_end_matchesvarkor-0/+59
2018-07-28Rollup merge of #52769 - sinkuu:stray_test, r=alexcrichtonkennytm-0/+12
Incorporate a stray test `liballoc/repeat-generic-slice.rs` doesn't seem to be tested (I think it was intended to be placed in `run-pass`). This PR incorporates the test into `liballoc/tests`.
2018-07-27Incorporate a stray testShotaro Yamada-0/+12
2018-07-25Add missing dynTatsuyuki Ishi-8/+8
2018-07-22Simplify vecdeque append testPazzaz-42/+64
2018-07-22Rollup merge of #51807 - newpavlov:deprecate_str_slice, r=alexcrichtonkennytm-4/+4
Deprecation of str::slice_unchecked(_mut) Closes #51715 I am not sure if 1.28.0 or 1.29.0 should be used for deprecation version, for now it's 1.28.0. Additionally I've replaced `slice_unchecked` uses with `get_unchecked`. The only places where this method is still used are `src/liballoc/tests/str.rs` and `src/liballoc/tests/str.rs`.
2018-07-19Non-naive implementation for `VecDeque.append`Pazzaz-0/+54
2018-07-07Add some unit tests for dangling Weak referencesSimon Sapin-0/+112
2018-06-26removed slice_uncheked from src/liballoc/tests/str.rsnewpavlov-4/+4
2018-06-10Auto merge of #51320 - tmccombs:step-by, r=SimonSapinbors-1/+0
Stabilize Iterator::step_by Fixes #27741
2018-06-02Stabilize Iterator::step_byThayne McCombs-1/+0
Fixes #27741
2018-06-03impl Default for &mut strkennytm-0/+1
2018-06-01add more join testsEmerentius-0/+22
old tests cover the new fast path of str joining already this adds tests for joining into Strings with long separators (>4 byte) and for joining into Vec<T>, T: Clone + !Copy. Vec<T: Copy> will be specialised when specialisation type inference bugs are fixed.
2018-05-21Auto merge of #49283 - varkor:combining-chars-escape_debug, r=SimonSapinbors-0/+7
Escape combining characters in char::Debug Although combining characters are technically printable, they make little sense to print on their own with `Debug`: it'd be better to escape them like non-printable characters. This is a breaking change, but I imagine the fact `escape_debug` is rare and almost certainly primarily used for debugging that this is an acceptable change. Resolves #41922. r? @alexcrichton cc @clarcharr
2018-05-21Avoid counting characters and add explanatory comment to testvarkor-0/+6
2018-05-21Only escape extended grapheme characters in the first positionvarkor-1/+1
2018-05-21Make {char, str}::escape_debug and impl Debug for {char, str} consistentvarkor-0/+1
2018-05-17Stabilise inclusive_range_methodsvarkor-1/+0
2018-05-10Skip a memory-hungry test that OOMsAlex Crichton-0/+1
Attempting to fix https://travis-ci.org/rust-lang/rust/jobs/377407894 via some selective ignoring tests
2018-05-10Rollup merge of #50010 - ExpHP:slice-bounds, r=alexcrichtonAlex Crichton-134/+355
Give SliceIndex impls a test suite of girth befitting the implementation (and fix a UTF8 boundary check) So one day I was writing something in my codebase that basically amounted to `impl SliceIndex for (Bound<usize>, Bound<usize>)`, and I said to myself: *Boy, gee, golly! I never realized bounds checking was so tricky!* At some point when I had around 60 lines of tests for it, I decided to go see how the standard library does it to see if I missed any edge cases. ...That's when I discovered that libcore only had about 40 lines of tests for slicing altogether, and none of them even used `..=`. --- This PR includes: * **Literally the first appearance of the word `get_unchecked_mut` in any directory named `test` or `tests`.** * Likewise the first appearance of `get_mut` used with _any type of range argument_ in these directories. * Tests for the panics on overflow with `..=`. * I wanted to test on `[(); usize::MAX]` as well but that takes linear time in debug mode </3 * A horrible and ugly test-generating macro for the `should_panic` tests that increases the DRYness by a single order of magnitude (which IMO wasn't enough, but I didn't want to go any further and risk making the tests inaccessible to next guy). * Same stuff for str! * Actually, the existing `str` tests were pretty good. I just helped filled in the holes. * [A fix for the bug it caught](https://github.com/rust-lang/rust/issues/50002). (only one ~~sadly~~)
2018-05-01Auto merge of #49724 - kennytm:range-inc-start-end-methods, r=Kimundibors-1/+1
Introduce RangeInclusive::{new, start, end} methods and make the fields private. cc #49022
2018-04-30revise test gen macro for strMichael Lamparski-144/+81
2018-04-30Make the fields of RangeInclusive private.kennytm-1/+1
Added new()/start()/end() methods to RangeInclusive. Changed the lowering of `..=` to use RangeInclusive::new().
2018-04-30decrease false negatives for str overflow testMichael Lamparski-1/+3
2018-04-30flesh out tests for SliceIndexMichael Lamparski-99/+378
m*n lines of implementation deserves m*n lines of tests
2018-04-30collect str SliceIndex tests into a modMichael Lamparski-137/+140
GitHub users: I think you can add ?w=1 to the url for a vastly cleaner whitespace-ignoring diff
2018-04-28stabilize `#[must_use]` for functions and must-use operatorsZack M. Davis-0/+1
This is in the matter of RFC 1940 and tracking issue #43302.
2018-04-18fix my unit test that was horrendously wrongMichael Lamparski-3/+17
and add one for non-mut slicing since I touched that method too
2018-04-17smaller PR just to fix #50002Michael Lamparski-0/+16
2018-04-12Use NonNull<Void> instead of *mut u8 in the Alloc traitMike Hommey-1/+2
Fixes #49608
2018-04-12Remove the now-unit-struct AllocErr field inside CollectionAllocErrSimon Sapin-20/+20
2018-04-12Actually deprecate the Heap typeSimon Sapin-2/+2
2018-04-12Mark the rest of the `unicode` feature flag as perma-unstable.Simon Sapin-1/+0
2018-04-12Merge unstable Utf16Encoder into EncodeUtf16Simon Sapin-2/+1
2018-04-12Merge core::unicode::str into core::strSimon Sapin-1/+1
And the UnicodeStr trait into StrExt
2018-04-12Reexport from core::unicode::char in core::char rather than vice versaSimon Sapin-1/+1
2018-04-12Deprecate the std_unicode crateSimon Sapin-3/+3
2018-04-08Move deny(warnings) into rustbuildMark Simulacrum-2/+0
This permits easier iteration without having to worry about warnings being denied. Fixes #49517
2018-04-05Bump the bootstrap compiler to 1.26.0 betaAlex Crichton-1/+0
Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language features!
2018-04-04Rollup merge of #49577 - tmccombs:string-splice-stabilize, r=TimNNkennytm-15/+15
Stabilize String::replace_range Fixes #44643
2018-04-03Remove all unstable placement featuresAidan Hobson Sayers-63/+1
Closes #22181, #27779
2018-04-01Stabilize String::replace_rangeThayne McCombs-15/+15
Fixes #44643
2018-03-29Move alloc::Bound to {core,std}::opsSimon Sapin-1/+1
The stable reexport `std::collections::Bound` is now deprecated. Another deprecated reexport could be added in `alloc`, but that crate is unstable.
2018-03-27Rollup merge of #48639 - varkor:sort_by_key-cached, r=blusskennytm-3/+17
Add slice::sort_by_cached_key as a memoised sort_by_key At present, `slice::sort_by_key` calls its key function twice for each comparison that is made. When the key function is expensive (which can often be the case when `sort_by_key` is chosen over `sort_by`), this can lead to very suboptimal behaviour. To address this, I've introduced a new slice method, `sort_by_cached_key`, which has identical semantic behaviour to `sort_by_key`, except that it guarantees the key function will only be called once per element. Where there are `n` elements and the key function is `O(m)`: - `slice::sort_by_cached_key` time complexity is `O(m n log m n)`, compared to `slice::sort_by_key`'s `O(m n + n log n)`. - `slice::sort_by_cached_key` space complexity remains at `O(n + m)`. (Technically, it now reserves a slice of size `n`, whereas before it reserved a slice of size `n/2`.) `slice::sort_unstable_by_key` has not been given an analogue, as it is important that unstable sorts are in-place, which is not a property that is guaranteed here. However, this also means that `slice::sort_unstable_by_key` is likely to be slower than `slice::sort_by_cached_key` when the key function does not have negligible complexity. We might want to explore this trade-off further in the future. Benchmarks (for a vector of 100 `i32`s): ``` # Lexicographic: `|x| x.to_string()` test bench_sort_by_key ... bench: 112,638 ns/iter (+/- 19,563) test bench_sort_by_cached_key ... bench: 15,038 ns/iter (+/- 4,814) # Identity: `|x| *x` test bench_sort_by_key ... bench: 1,346 ns/iter (+/- 238) test bench_sort_by_cached_key ... bench: 1,839 ns/iter (+/- 765) # Power: `|x| x.pow(31)` test bench_sort_by_key ... bench: 3,624 ns/iter (+/- 738) test bench_sort_by_cached_key ... bench: 1,997 ns/iter (+/- 311) # Abs: `|x| x.abs()` test bench_sort_by_key ... bench: 1,546 ns/iter (+/- 174) test bench_sort_by_cached_key ... bench: 1,668 ns/iter (+/- 790) ``` (So it seems functions that are single operations do perform slightly worse with this method, but for pretty much any more complex key, you're better off with this optimisation.) I've definitely found myself using expensive keys in the past and wishing this optimisation was made (e.g. for https://github.com/rust-lang/rust/pull/47415). This feels like both desirable and expected behaviour, at the small cost of slightly more stack allocation and minute degradation in performance for extremely trivial keys. Resolves #34447.
2018-03-19Add stability test for sort_by_cached_keyvarkor-3/+8
2018-03-17update FIXME(#5244) to point to RFC 1109 (Non-Copy array creation ergonomics)Niv Kaminer-1/+1
2018-03-17Fix use of unstable feature in testvarkor-0/+1
2018-03-16Add sort_by_cached_key methodvarkor-3/+6
2018-03-16Add a test for sort_by_keyvarkor-0/+5