about summary refs log tree commit diff
path: root/src/libcoretest/num
AgeCommit message (Collapse)AuthorLines
2017-04-03Move libXtest into libX/testsStjepan Glavina-2929/+0
This change moves: 1. `libcoretest` into `libcore/tests` 2. `libcollectionstest` into `libcollections/tests` This is a follow-up to #39561.
2017-02-05Auto merge of #39567 - frewsxcv:rollup, r=frewsxcvbors-171/+1
Rollup of 12 pull requests - Successful merges: #39439, #39472, #39481, #39491, #39501, #39509, #39514, #39519, #39526, #39528, #39530, #39538 - Failed merges:
2017-02-04Fix TryFrom for i128/u128Oliver Middleton-0/+32
Another case of `as` cast silent truncation being error prone. This also adds a few missing TryFrom tests to libcoretest.
2017-02-04Extract libcore benchmarks to a separate folderSon-171/+1
2016-11-21Stabilize RFC 1560.Jeffrey Seyfried-2/+0
2016-09-30Call emcc with ERROR_ON_UNDEFINED_SYMBOLSBrian Anderson-2/+5
2016-09-30Ignore another emscripten test because missing intrinsicsBrian Anderson-0/+2
2016-07-03std: Stabilize APIs for the 1.11.0 releaseAlex Crichton-20/+45
Although the set of APIs being stabilized this release is relatively small, the trains keep going! Listed below are the APIs in the standard library which have either transitioned from unstable to stable or those from unstable to deprecated. Stable * `BTreeMap::{append, split_off}` * `BTreeSet::{append, split_off}` * `Cell::get_mut` * `RefCell::get_mut` * `BinaryHeap::append` * `{f32, f64}::{to_degrees, to_radians}` - libcore stabilizations mirroring past libstd stabilizations * `Iterator::sum` * `Iterator::product` Deprecated * `{f32, f64}::next_after` * `{f32, f64}::integer_decode` * `{f32, f64}::ldexp` * `{f32, f64}::frexp` * `num::One` * `num::Zero` Added APIs (all unstable) * `iter::Sum` * `iter::Product` * `iter::Step` - a few methods were added to accomodate deprecation of One/Zero Removed APIs * `From<Range<T>> for RangeInclusive<T>` - everything about `RangeInclusive` is unstable Closes #27739 Closes #27752 Closes #32526 Closes #33444 Closes #34152 cc #34529 (new tracking issue)
2016-05-08Rollup merge of #33426 - sfackler:try-from, r=aturonManish Goregaokar-146/+299
Implement RFC 1542 cc #33417 r? @aturon
2016-05-07Implement RFC 1542Steven Fackler-147/+300
cc #33417
2016-05-03Remove unused trait imports flagged by lintSeo Sanghyeon-1/+0
2016-03-11cleanup int suffixes in libcoretestsrinivasreddy-6/+6
2016-02-26Use .copy_from_slice() where applicableUlrik Sverdrup-2/+2
.copy_from_slice() does the same job of .clone_from_slice(), but the former is explicitly for Copy elements and calls `memcpy` directly, and thus is it efficient without optimization too.
2016-02-06Auto merge of #31410 - rkruppe:issue31109, r=pnkfelixbors-7/+16
Issue #31109 uncovered two semi-related problems: * A panic in `str::parse::<f64>` * A panic in `rustc::middle::const_eval::lit_to_const` where the result of float parsing was unwrapped. This series of commits fixes both issues and also drive-by-fixes some things I noticed while tracking down the parsing panic.
2016-02-04Enable unit tests for literals that overflow. I have no idea why this ↵Robin Kruppe-7/+5
condition was ever added.
2016-02-04Prevent the immediate panic uncovered by #31109 and add a test.Robin Kruppe-0/+11
The code there still triggers an ICE, but for different reasons (const eval unwraps the parse result).
2016-01-30test: Deny warnings in {core,collections}testAlex Crichton-6/+11
Help cleans up our build a bit and stays in line with the rest of our crates denying warnings traditionally.
2016-01-16std: Stabilize APIs for the 1.7 releaseAlex Crichton-2/+2
This commit stabilizes and deprecates the FCP (final comment period) APIs for the upcoming 1.7 beta release. The specific APIs which changed were: Stabilized * `Path::strip_prefix` (renamed from `relative_from`) * `path::StripPrefixError` (new error type returned from `strip_prefix`) * `Ipv4Addr::is_loopback` * `Ipv4Addr::is_private` * `Ipv4Addr::is_link_local` * `Ipv4Addr::is_multicast` * `Ipv4Addr::is_broadcast` * `Ipv4Addr::is_documentation` * `Ipv6Addr::is_unspecified` * `Ipv6Addr::is_loopback` * `Ipv6Addr::is_unique_local` * `Ipv6Addr::is_multicast` * `Vec::as_slice` * `Vec::as_mut_slice` * `String::as_str` * `String::as_mut_str` * `<[T]>::clone_from_slice` - the `usize` return value is removed * `<[T]>::sort_by_key` * `i32::checked_rem` (and other signed types) * `i32::checked_neg` (and other signed types) * `i32::checked_shl` (and other signed types) * `i32::checked_shr` (and other signed types) * `i32::saturating_mul` (and other signed types) * `i32::overflowing_add` (and other signed types) * `i32::overflowing_sub` (and other signed types) * `i32::overflowing_mul` (and other signed types) * `i32::overflowing_div` (and other signed types) * `i32::overflowing_rem` (and other signed types) * `i32::overflowing_neg` (and other signed types) * `i32::overflowing_shl` (and other signed types) * `i32::overflowing_shr` (and other signed types) * `u32::checked_rem` (and other unsigned types) * `u32::checked_neg` (and other unsigned types) * `u32::checked_shl` (and other unsigned types) * `u32::saturating_mul` (and other unsigned types) * `u32::overflowing_add` (and other unsigned types) * `u32::overflowing_sub` (and other unsigned types) * `u32::overflowing_mul` (and other unsigned types) * `u32::overflowing_div` (and other unsigned types) * `u32::overflowing_rem` (and other unsigned types) * `u32::overflowing_neg` (and other unsigned types) * `u32::overflowing_shl` (and other unsigned types) * `u32::overflowing_shr` (and other unsigned types) * `ffi::IntoStringError` * `CString::into_string` * `CString::into_bytes` * `CString::into_bytes_with_nul` * `From<CString> for Vec<u8>` * `From<CString> for Vec<u8>` * `IntoStringError::into_cstring` * `IntoStringError::utf8_error` * `Error for IntoStringError` Deprecated * `Path::relative_from` - renamed to `strip_prefix` * `Path::prefix` - use `components().next()` instead * `os::unix::fs` constants - moved to the `libc` crate * `fmt::{radix, Radix, RadixFmt}` - not used enough to stabilize * `IntoCow` - conflicts with `Into` and may come back later * `i32::{BITS, BYTES}` (and other integers) - not pulling their weight * `DebugTuple::formatter` - will be removed * `sync::Semaphore` - not used enough and confused with system semaphores Closes #23284 cc #27709 (still lots more methods though) Closes #27712 Closes #27722 Closes #27728 Closes #27735 Closes #27729 Closes #27755 Closes #27782 Closes #27798
2016-01-04Make float parsing "." return ErrToby Scrace-1/+2
This makes both of the following return Err: ".".parse::<f32>() ".".parse::<f64>() This is a [breaking-change], which the libs team have classified as a bug fix.
2015-12-13restore tests accidentally removed in #30182Tamir Duberstein-0/+8
2015-12-10std: Remove deprecated functionality from 1.5Alex Crichton-32/+2
This is a standard "clean out libstd" commit which removes all 1.5-and-before deprecated functionality as it's now all been deprecated for at least one entire cycle.
2015-10-17Implement conversion traits for primitive float typesJosh Stone-0/+57
2015-10-15Auto merge of #29050 - rkruppe:dec2flt-lonely-sign, r=alexcrichtonbors-0/+12
Fixes #29042
2015-10-15Auto merge of #28921 - petrochenkov:intconv, r=alexcrichtonbors-0/+40
Part of https://github.com/rust-lang/rfcs/pull/1218#issuecomment-146615171 r? @aturon
2015-10-15Implement conversion traits for primitive integer typesVadim Petrochenkov-0/+40
2015-10-14Reject "+" and "-" when parsing floats.Robin Kruppe-0/+12
Fixes #29042
2015-10-08Auto merge of #28900 - cristicbz:typos, r=alexcrichtonbors-1/+1
I found these automatically, but fixed them manually to ensure the semantics are correct. I know things like these are hardly important, since they only marginally improve clarity. But at least for me typos and simple grammatical errors trigger an---unjustified---sense of unprofessionalism, despite the fact that I make them all the time and I understand that they're the sort of thing that is bound to slip through review. Anyway, to find most of these I used: * `ag '.*//.*(\b[A-Za-z]{2,}\b) \1\b'` for repeated words * `ag '\b(the|this|those|these|a|it) (a|the|this|those|these|it)\b'` to find constructs like 'the this' etc. many false positives, but not too hard to scroll through them to actually find the mistakes. * `cat ../../typos.txt | paste -d'|' - - - - - - - - - - - - - - - - - - - - - - | tr '\n' '\0' | xargs -0 -P4 -n1 ag`. Hacky way to find misspellings, but it works ok. I got `typos.txt` from [Wikipedia](https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines) * `ag '.*//.* a ([ae][a-z]|(o[^n])|(i[a-rt-z]))'` to find places where 'a' was followed by a vowel (requiring 'an' instead). I also used a handful more one off regexes that are too boring to reproduce here.
2015-10-08typos: fix a grabbag of typos all over the placeCristi Cobzarenco-1/+1
2015-10-03integer parsing should accept leading plusarthurprs-0/+8
2015-09-20Reorganize core::num internalsRobin Kruppe-6/+6
Move private bignum module to core::num, because it is not only used in flt2dec. Extract private 80-bit soft-float into new core::num module for the same reason.
2015-08-22Auto merge of #27871 - alexcrichton:stabilize-libcore, r=aturonbors-27/+56
These commits move libcore into a state so that it's ready for stabilization, performing some minor cleanup: * The primitive modules for integers in the standard library were all removed from the source tree as they were just straight reexports of the libcore variants. * The `core::atomic` module now lives in `core::sync::atomic`. The `core::sync` module is otherwise empty, but ripe for expansion! * The `core::prelude::v1` module was stabilized after auditing that it is a subset of the standard library's prelude plus some primitive extension traits (char, str, and slice) * Some unstable-hacks for float parsing errors were shifted around to not use the same unstable hacks (e.g. the `flt2dec` module is now used for "privacy"). After this commit, the remaining large unstable functionality specific to libcore is: * `raw`, `intrinsics`, `nonzero`, `array`, `panicking`, `simd` -- these modules are all unstable or not reexported in the standard library, so they're just remaining in the same status quo as before * `num::Float` - this extension trait for floats needs to be audited for functionality (much of that is happening in #27823) and may also want to be renamed to `FloatExt` or `F32Ext`/`F64Ext`. * Should the extension traits for primitives be stabilized in libcore? I believe other unstable pieces are not isolated to just libcore but also affect the standard library. cc #27701
2015-08-18Auto merge of #27823 - eefriedman:float-dep-core, r=alexcrichtonbors-2/+16
There wasn't any particular reason the functions needed to be there anyway, so just get rid of them, and adjust libstd to compensate. With this change, libcore depends on exactly two floating-point functions: fmod and fmodf. They are implicitly referenced because they are used to implement "%". Dependencies of libcore on Linux x86-x64 with this patch: ``` 0000000000000000 *UND* 0000000000000000 __powidf2 0000000000000000 *UND* 0000000000000000 __powisf2 0000000000000000 *UND* 0000000000000000 fmod 0000000000000000 *UND* 0000000000000000 fmodf 0000000000000000 *UND* 0000000000000000 memcmp 0000000000000000 *UND* 0000000000000000 memcpy 0000000000000000 *UND* 0000000000000000 memset 0000000000000000 *UND* 0000000000000000 rust_begin_unwind 0000000000000000 *UND* 0000000000000000 rust_eh_personality ```
2015-08-17core: Shuffle around float parsingAlex Crichton-28/+27
Stop using stability to hide the implementation details of ParseFloatError and instead move the error type into the `dec2flt` module. Also move the implementation blocks of `FromStr for f{32,64}` into `dec2flt` directly.
2015-08-17std: Clean up primitive integer modulesAlex Crichton-1/+31
All of the modules in the standard library were just straight reexports of those in libcore, so remove all the "macro modules" from the standard library and just reexport what's in core directly.
2015-08-17Remove dependencies on libm functions from libcore.Eli Friedman-2/+16
There wasn't any particular reason the functions needed to be there anyway, so just get rid of them, and adjust libstd to compensate. With this change, libcore depends on exactly two floating-point functions: fmod and fmodf. They are implicitly referenced because they are used to implement "%".
2015-08-14Auto merge of #27786 - alexcrichton:start-testing-msvc, r=brsonbors-2/+21
* An apparent bug in VS 2013's implementation of the `exp2` function is worked around in one of flt2dec's tests. Turns out this was the only fix necessary!
2015-08-13Get `make check` working on MSVCAlex Crichton-2/+21
* An apparent bug in VS 2013's implementation of the `exp2` function is worked around in one of flt2dec's tests.
2015-08-12Mention that the fast path is broken without SSE.Robin Kruppe-0/+7
2015-08-08Accurate decimal-to-float parsing routines.Robin Kruppe-0/+366
This commit primarily adds implementations of the algorithms from William Clinger's paper "How to Read Floating Point Numbers Accurately". It also includes a lot of infrastructure necessary for those algorithms, and some unit tests. Since these algorithms reject a few (extreme) inputs that were previously accepted, this could be seen as a [breaking-change]
2015-08-08Add various methods to Bignum:Robin Kruppe-0/+89
- Exposing digits and individual bits - Counting the number of bits - Add small (digit-sized) values - Multiplication by power of 5 - Division with remainder All are necessary for decimal to floating point conversions. All but the most trivial ones come with tests.
2015-08-08Enlarge Bignum type from 1152 to 1280 bits.Robin Kruppe-1/+1
This is necessary for decimal-to-float code (in a later commit) to handle inputs such as 4.9406564584124654e-324 (the smallest subnormal f64). According to the benchmarks for flt2dec::dragon, this does not affect performance measurably. It probably uses slightly more stack space though.
2015-07-19optimize from_str_radixarthurprs-2/+9
2015-05-06core: use banker's rounding for the exact mode in flt2dec.Kang Seonghoon-5/+18
For the shortest mode the IEEE 754 decoder already provides an exact rounding range accounting for banker's rounding, but it was not the case for the exact mode. This commit alters the exact mode algorithm for Dragon so that any number ending at `...x5000...` with even `x` and infinite zeroes will round to `...x` instead of `...(x+1)` as it was. Grisu is not affected by this change because this halfway case always results in the failure for Grisu.
2015-05-06core: updated for the master changes.Kang Seonghoon-98/+91
The master no longer has `std::num::Float`, so a generic `ldexp` is not readily available. `DecodableFloat::ldexpi` works around this.
2015-05-06core: fixed a slight bug.Kang Seonghoon-3/+17
The bug involves the incorrect logic for `core::num::flt2dec::decoder`. This makes some numbers in the form of 2^n missing one final digits, which breaks the bijectivity criterion. The regression tests have been added, and f32 exhaustive test is rerun to get the updated result.
2015-05-06core: fixed typos and revised comments in flt2dec.Kang Seonghoon-1/+1
2015-05-06core: tweaked flt2dec to match the casing of the older formatting code.Kang Seonghoon-32/+32
2015-05-06core: added core::num::flt2dec for floating-point formatting.Kang Seonghoon-0/+1675
This is a fork of the flt2dec portion of rust-strconv [1] with a necessary relicensing (the original code was licensed CC0-1.0). Each module is accompanied with large unit tests, integrated in this commit as coretest::num::flt2dec. This module is added in order to replace the existing core::fmt::float method. The forked revision of rust-strconv is from 2015-04-20, with a commit ID 9adf6d3571c6764a6f240a740c823024f70dc1c7. [1] https://github.com/lifthrasiir/rust-strconv/
2015-04-24Change name of unit test sub-module to "tests".Johannes Oertel-1/+1
Changes the style guidelines regarding unit tests to recommend using a sub-module named "tests" instead of "test" for unit tests as "test" might clash with imports of libtest.
2015-04-21std: Bring back f32::from_str_radix as an unstable APIAlex Crichton-67/+58
This API was exercised in a few tests and mirrors the `from_str_radix` functionality of the integer types.