summary refs log tree commit diff
path: root/src/libcore/tests
AgeCommit message (Collapse)AuthorLines
2018-11-20Add std::iter::successorsSimon Sapin-0/+12
2018-11-20Auto merge of #56049 - newpavlov:revert_51601, r=sfacklerbors-0/+7
Revert #51601 Closes: #55985 Specialization of `StepBy<Range(Inclusive)>` results in an incorrectly behaving code when `step_by` is combined with `skip` or `nth`. If this will get merged we probably should reopen issues previously closed by #51601 (if there was any).
2018-11-19fix testАртём Павлов [Artyom Pavlov]-1/+1
2018-11-18testsАртём Павлов [Artyom Pavlov]-0/+10
2018-11-18revertАртём Павлов [Artyom Pavlov]-5/+2
2018-11-14core/tests/num: Simplify `test_int_from_str_overflow()` test codeTobias Bieniek-16/+8
This commit changes the test code to compare against easier-to-read, static values instead of relying on the result of `wrapping_add()` which may or may not result in the value that we expect.
2018-10-31Bump nightly to 1.32.0Alex Crichton-1/+0
* Also update the bootstrap compiler * Update cargo to 1.32.0 * Clean out stage0 annotations
2018-10-19Stabilize impl_header_lifetime_elision in 2015Scott McMurray-1/+1
It's already stable in 2018; this finishes the stabilization.
2018-10-18Stabilize slice::rchunks(), rchunks_mut(), rchunks_exact(), rchunk_exact_mut()Sebastian Dröge-1/+0
Fixes #55177
2018-10-18Stabilize slice::chunks_exact() and slice::chunks_exact_mut()Sebastian Dröge-1/+0
Fixes #47115
2018-10-18Add slice::rchunks(), rchunks_mut(), rchunks_exact() and rchunks_exact_mut()Sebastian Dröge-0/+223
These work exactly like the normal chunks iterators but start creating chunks from the end of the slice. See #55177 for the tracking issue
2018-10-08Stabilize the `Option::replace` methodClément Renault-1/+0
2018-09-29Activate the feature in the libcore tests tooScott McMurray-0/+1
2018-09-29Use impl_header_lifetime_elision in libcoreScott McMurray-1/+1
2018-09-29Auto merge of #54240 - csmoe:nonzero_from, r=alexcrichtonbors-0/+7
Impl From<NonZero<T>> for T Closes https://github.com/rust-lang/rust/issues/54171 r? @SimonSapin
2018-09-25Rollup merge of #54537 - sdroege:chunks-exact, r=alexcrichtonPietro Albini-30/+30
Rename slice::exact_chunks() to slice::chunks_exact() See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815 and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-09-24Rename slice::exact_chunks() to slice::chunks_exact()Sebastian Dröge-30/+30
See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815 and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-09-23Introduce the partition_dedup/by/by_key methods for slicesClément Renault-0/+60
2018-09-20add tests for copy_withinJack O'Connor-0/+47
2018-09-17move from_nonzero test from run-pass to libcorecsmoe-0/+7
2018-09-16Auto merge of #53754 - RalfJung:slice_align_to, r=alexcrichtonbors-1/+0
stabilize slice_align_to This is very hard to implement correctly, and leads to [serious bugs](https://github.com/llogiq/bytecount/pull/42) when done incorrectly. Moreover, this is needed to be able to run code that opportunistically exploits alignment on miri. So code using `align_to`/`align_to_mut` gets the benefit of a well-tested implementation *and* of being able to run in miri to test for (some kinds of) UB. This PR also clarifies the guarantee wrt. the middle part being as long as possible. Should the docs say under which circumstances the middle part could be shorter? Currently, that can only happen when running in miri.
2018-09-04Breaking change upgradesMark Rousskov-10/+10
2018-08-28stabilize slice_align_toRalf Jung-1/+0
2018-08-25Auto merge of #53385 - matklad:stabilize-find-map, r=KodrAusbors-1/+0
Stablize Iterator::find_map Stabilization PR for https://github.com/rust-lang/rust/issues/49602
2018-08-19Auto merge of #52972 - RalfJung:from_raw_parts_align, r=alexcrichtonbors-0/+14
debug_assert to ensure that from_raw_parts is only used properly aligned This does not help nearly as much as I would hope because everybody uses the distributed libstd which is compiled without debug assertions. For this reason, I am not sure if this is even worth it. OTOH, this would have caught the misalignment fixed by https://github.com/rust-lang/rust/issues/42789 *if* there had been any tests actually using ZSTs with alignment >1 (we have a CI runner which has debug assertions in libstd enabled), and it seems to currently [fail in the rg testsuite](https://ci.appveyor.com/project/rust-lang/rust/build/1.0.8403/job/v7dfdcgn8ay5j6sb). So maybe it is worth it, after all. I have seen the attribute `#[rustc_inherit_overflow_checks]` in some places, does that make it so that the *caller's* debug status is relevant? Is there a similar attribute for `debug_assert!`? That could even subsume `rustc_inherit_overflow_checks`: Something like `rustc_inherit_debug_flag` could affect *all* places that change the generated code depending on whether we are in debug or release mode. In fact, given that we have to keep around the MIR for generic functions anyway, is there ever a reason *not* to handle the debug flag that way? I guess currently we apply debug flags like `cfg` so this is dropped early during the MIR pipeline? EDIT: I learned from @eddyb that because of how `debug_assert!` works, this is not realistic. Well, we could still have it for the rustc CI runs and then maybe, eventually, when libstd gets compiled client-side and there is both a debug and a release build... then this will also benefit users.^^
2018-08-15Stablize Iterator::find_mapAleksey Kladov-1/+0
2018-08-14Auto merge of #53033 - RalfJung:manually_dro, r=SimonSapinbors-0/+5
unsized ManuallyDrop I think this matches what @eddyb had in https://github.com/rust-lang/rust/pull/52711 originally. ~~However, I have never added a `CoerceUnsized` before so I am not sure if I did this right. I copied the `unstable` attribute on the `impl` from elsewhere, but AFAIK it is useless because `impl`'s are insta-stable... so shouldn't this rather say "stable since 1.30"?~~ This is insta-stable and hence requires FCP, at least. Fixes https://github.com/rust-lang/rust/issues/47034
2018-08-06unconfuse @eddybRalf Jung-1/+2
2018-08-05Fix 2018 edition testsvarkor-1/+0
2018-08-05Fix stage 2 testsvarkor-1/+0
2018-08-05Remove unnecessary or invalid feature attributesvarkor-3/+0
2018-08-03unsized ManuallyDropRalf Jung-0/+4
2018-08-02test that align_of handles alignment properly for the mid partRalf Jung-0/+14
2018-08-02Auto merge of #52206 - RalfJung:zst-slices, r=alexcrichtonbors-0/+126
slices: fix ZST slice iterators making up pointers; debug_assert alignment in from_raw_parts This fixes the problem that we are fabricating pointers out of thin air. I also managed to share more code between the mutable and shared iterators, while reducing the amount of macros. I am not sure how useful it really is to add a `debug_assert!` in libcore. Everybody gets a release version of that anyway, right? Is there at least a CI job that runs the test suite with a debug version? Fixes #42789
2018-08-02test nth betterRalf Jung-11/+37
2018-08-02slice iterators: ZST iterators no longer just "make up" addressesRalf Jung-0/+100
2018-08-01Auto merge of #51609 - dscorbett:is_numeric, r=alexcrichtonbors-1/+2
Treat gc=No characters as numeric [`char::is_numeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_numeric) and [`char::is_alphanumeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_alphanumeric) are documented to be defined “in terms of the Unicode General Categories 'Nd', 'Nl', 'No'”, but unicode.py does not group 'No' with the other 'N' categories. These functions therefore currently return `false` for characters like ⟨¾⟩ and ⟨①⟩.
2018-08-01Rollup merge of #52732 - SimonSapin:spring, r=Mark-SimulacrumPietro Albini-51/+0
Remove unstable and deprecated APIs
2018-07-30Remove unstable and deprecated APIsSimon Sapin-51/+0
2018-07-29resolved upstream merge conflictsBrad Gibson-133/+885
2018-07-29Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkovbors-1/+1
Prefer to_string() to format!() Simple benchmarks suggest in some cases it can be faster by even 37%: ``` test converting_f64_long ... bench: 339 ns/iter (+/- 199) test converting_f64_short ... bench: 136 ns/iter (+/- 34) test converting_i32_long ... bench: 87 ns/iter (+/- 16) test converting_i32_short ... bench: 87 ns/iter (+/- 49) test converting_str ... bench: 54 ns/iter (+/- 15) test formatting_f64_long ... bench: 349 ns/iter (+/- 176) test formatting_f64_short ... bench: 145 ns/iter (+/- 14) test formatting_i32_long ... bench: 98 ns/iter (+/- 14) test formatting_i32_short ... bench: 93 ns/iter (+/- 15) test formatting_str ... bench: 86 ns/iter (+/- 23) ```
2018-07-29Auto merge of #52764 - sinkuu:cleanup, r=nikomatsakisbors-2/+1
Misc cleanups
2018-07-28Auto merge of #52711 - eddyb:unsized-manuallydrop, r=nikomatsakisbors-0/+25
Change ManuallyDrop<T> to a lang item. This PR implements the approach @RalfJung proposes in https://internals.rust-lang.org/t/pre-rfc-unions-drop-types-and-manuallydrop/8025 (lang item `struct` instead of `union`). A followup PR can easily solve #47034 as well, by just adding a few `?Sized` to `libcore/mem.rs`. r? @nikomatsakis
2018-07-27Use str::repeatShotaro Yamada-2/+1
2018-07-27add smoke test for ManuallyDropRalf Jung-0/+25
2018-07-27Prefer to_string() to format!()ljedrz-1/+1
2018-07-25Add missing dynTatsuyuki Ishi-22/+26
2018-07-14Rollup merge of #52003 - Kerollmops:option-replace, r=Kimundikennytm-0/+16
Implement `Option::replace` in the core library Here is the implementation of the `Option::replace` method. The first step of [the tracking issue #51998](https://github.com/rust-lang/rust/issues/51998).
2018-07-12Auto merge of #51339 - sdroege:exact-chunks-remainder, r=alexcrichtonbors-0/+14
Add ExactChunks::remainder and ExactChunks::into_remainder These allow to get the leftover items of the slice that are not being iterated as part of the iterator due to not filling a complete chunk. The mutable version consumes the slice because otherwise we would either a) have to borrow the iterator instead of taking the lifetime of the underlying slice, which is not what *any* of the other iterator functions is doing, or b) would allow returning multiple mutable references to the same data The current behaviour of consuming the iterator is consistent with IterMut::into_slice for the normal iterator. ---- This is related to https://github.com/rust-lang/rust/issues/47115#issuecomment-392685177 and the following comments. While there the discussion was first about a way to get the "tail" of the iterator (everything from the slice that is still not iterated yet), this gives kind of unintuitive behaviour and is inconsistent with how the other slice iterators work. Unintuitive because the `next_back` would have no effect on the tail (or otherwise the tail could not include the remainder items), inconsistent because a) generally the idea of the slice iterators seems to be to only ever return items that were not iterated yet (and don't provide a way to access the same item twice) and b) we would return a "flat" `&[T]` slice but the iterator's shape is `&[[T]]` instead, c) the mutable variant would have to borrow from the iterator instead of the underlying slice (all other iterator functions borrow from the underlying slice!) As such, I've only implemented functions to get the remainder. This also allows the implementation to be completely safe still (and around slices instead of raw pointers), while getting the tail would either be inefficient or would have to be implemented around raw pointers. CC @kerollmops
2018-07-09Add a basic test to `Option::replace`Clément RENAULT-0/+16