about summary refs log tree commit diff
path: root/src/libtest/lib.rs
AgeCommit message (Collapse)AuthorLines
2014-12-14Mostly rote conversion of `proc()` to `move||` (and occasionally `Thunk::new`)Niko Matsakis-19/+21
2014-12-13libtest: use unboxed closuresJorge Aparicio-8/+10
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-3/+16
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]
2014-12-08auto merge of #19560 : sfackler/rust/should-fail-reason, r=alexcrichtonbors-23/+70
The test harness will make sure that the panic message contains the specified string. This is useful to help make `#[should_fail]` tests a bit less brittle by decreasing the chance that the test isn't "accidentally" passing due to a panic occurring earlier than expected. The behavior is in some ways similar to JUnit's `expected` feature: `@Test(expected=NullPointerException.class)`. Without the message assertion, this test would pass even though it's not actually reaching the intended part of the code: ```rust #[test] #[should_fail(message = "out of bounds")] fn test_oob_array_access() { let idx: uint = from_str("13o").unwrap(); // oops, this will panic [1i32, 2, 3][idx]; } ```
2014-12-06libtest: remove unnecessary `to_string()` callsJorge Aparicio-1/+1
2014-12-06libtest: remove unnecessary `as_mut_slice()` callsJorge Aparicio-1/+1
2014-12-06libtest: remove unnecessary `as_slice()` callsJorge Aparicio-3/+3
2014-12-06Change from message to expectedSteven Fackler-1/+1
2014-12-06Allow message specification for should_failSteven Fackler-23/+70
The test harness will make sure that the panic message contains the specified string. This is useful to help make `#[should_fail]` tests a bit less brittle by decreasing the chance that the test isn't "accidentally" passing due to a panic occurring earlier than expected. The behavior is in some ways similar to JUnit's `expected` feature: `@Test(expected=NullPointerException.class)`. Without the message assertion, this test would pass even though it's not actually reaching the intended part of the code: ```rust #[test] #[should_fail(message = "out of bounds")] fn test_oob_array_access() { let idx: uint = from_str("13o").unwrap(); // oops, this will panic [1i32, 2, 3][idx]; } ```
2014-12-05auto merge of #19508 : cmr/rust/rollup-2014_12_03, r=cmrbors-21/+3
2014-12-05test: expose boxplot and the extra stats test keeps track ofErick Tryzelaar-5/+64
[breaking-change]
2014-12-03libtest: get rid of dependency to ToJsonOliver Schneider-21/+3
deriving encodable + using json::PrettyEncoder removes the only ToJson trait implementation in the rust repository outside of libserialize
2014-11-27auto merge of #19343 : sfackler/rust/less-special-attrs, r=alexcrichtonbors-2/+0
Descriptions and licenses are handled by Cargo now, so there's no reason to keep these attributes around.
2014-11-26Test fixes and rebase conflictsAlex Crichton-3/+3
2014-11-26rollup merge of #19299: nikomatsakis/stop-indenting-test-outputAlex Crichton-3/+1
This fixes a long-time irritant of mine. Inserting tabs causes M-x next-error to not work in emacs and seems to serve relatively little purpose in improving overall readability. r? @brson
2014-11-26Remove special casing for some meta attributesSteven Fackler-2/+0
Descriptions and licenses are handled by Cargo now, so there's no reason to keep these attributes around.
2014-11-25Stop indenting error messages. It throws off M-x next-error in emacs and ↵Niko Matsakis-3/+1
seems to serve little purpose.
2014-11-23Rename unwrap functions to into_innerAlex Crichton-1/+1
This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all `unwrap` methods are retained as `#[deprecated]` for the near future. To update code rename `unwrap` method calls to `into_inner`. [rfc]: https://github.com/rust-lang/rfcs/pull/430 [breaking-change] Closes #13159 cc #19091
2014-11-18std: Stabilize std::fmtAlex Crichton-2/+2
This commit applies the stabilization of std::fmt as outlined in [RFC 380][rfc]. There are a number of breaking changes as a part of this commit which will need to be handled to migrated old code: * A number of formatting traits have been removed: String, Bool, Char, Unsigned, Signed, and Float. It is recommended to instead use Show wherever possible or to use adaptor structs to implement other methods of formatting. * The format specifier for Boolean has changed from `t` to `b`. * The enum `FormatError` has been renamed to `Error` as well as becoming a unit struct instead of an enum. The `WriteError` variant no longer exists. * The `format_args_method!` macro has been removed with no replacement. Alter code to use the `format_args!` macro instead. * The public fields of a `Formatter` have become read-only with no replacement. Use a new formatting string to alter the formatting flags in combination with the `write!` macro. The fields can be accessed through accessor methods on the `Formatter` structure. Other than these breaking changes, the contents of std::fmt should now also all contain stability markers. Most of them are still #[unstable] or #[experimental] [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0380-stabilize-std-fmt.md [breaking-change] Closes #18904
2014-11-18implement Writer for Vec<u8>Daniel Micay-5/+3
The trait has an obvious, sensible implementation directly on vectors so the MemWriter wrapper is unnecessary. This will halt the trend towards providing all of the vector methods on MemWriter along with eliminating the noise caused by conversions between the two types. It also provides the useful default Writer methods on Vec<u8>. After the type is removed and code has been migrated, it would make sense to add a new implementation of MemWriter with seeking support. The simple use cases can be covered with vectors alone, and ones with the need for seeks can use a new MemWriter implementation.
2014-11-17Switch to purely namespaced enumsSteven Fackler-1/+10
This breaks code that referred to variant names in the same namespace as their enum. Reexport the variants in the old location or alter code to refer to the new locations: ``` pub enum Foo { A, B } fn main() { let a = A; } ``` => ``` pub use self::Foo::{A, B}; pub enum Foo { A, B } fn main() { let a = A; } ``` or ``` pub enum Foo { A, B } fn main() { let a = Foo::A; } ``` [breaking-change]
2014-11-17Fix fallout from coercion removalNick Cameron-1/+1
2014-11-16Move FromStr to core::strBrendan Zabarauskas-1/+1
2014-11-14auto merge of #18880 : barosl/rust/doc-fail-to-panic, r=alexcrichtonbors-1/+1
I found some occurrences of "failure" and "fails" in the documentation. I changed them to "panics" if it means a task panic. Otherwise I left it as is, or changed it to "errors" to clearly distinguish them. Also, I made a minor fix that is breaking the layout of a module page. "Example" is shown in an irrelevant place from the following page: http://doc.rust-lang.org/std/os/index.html
2014-11-14auto merge of #18827 : bjz/rust/rfc369-numerics, r=alexcrichtonbors-1/+1
This implements a considerable portion of rust-lang/rfcs#369 (tracked in #18640). Some interpretations had to be made in order to get this to work. The breaking changes are listed below: [breaking-change] - `core::num::{Num, Unsigned, Primitive}` have been deprecated and their re-exports removed from the `{std, core}::prelude`. - `core::num::{Zero, One, Bounded}` have been deprecated. Use the static methods on `core::num::{Float, Int}` instead. There is no equivalent to `Zero::is_zero`. Use `(==)` with `{Float, Int}::zero` instead. - `Signed::abs_sub` has been moved to `std::num::FloatMath`, and is no longer implemented for signed integers. - `core::num::Signed` has been removed, and its methods have been moved to `core::num::Float` and a new trait, `core::num::SignedInt`. The methods now take the `self` parameter by value. - `core::num::{Saturating, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv}` have been removed, and their methods moved to `core::num::Int`. Their parameters are now taken by value. This means that - `std::time::Duration` no longer implements `core::num::{Zero, CheckedAdd, CheckedSub}` instead defining the required methods non-polymorphically. - `core::num::{zero, one, abs, signum}` have been deprecated. Use their respective methods instead. - The `core::num::{next_power_of_two, is_power_of_two, checked_next_power_of_two}` functions have been deprecated in favor of methods defined a new trait, `core::num::UnsignedInt` - `core::iter::{AdditiveIterator, MultiplicativeIterator}` are now only implemented for the built-in numeric types. - `core::iter::{range, range_inclusive, range_step, range_step_inclusive}` now require `core::num::Int` to be implemented for the type they a re parametrized over.
2014-11-12auto merge of #18858 : alexcrichton/rust/remove-time, r=jakubbors-37/+34
This commit deprecates the entire libtime library in favor of the externally-provided libtime in the rust-lang organization. Users of the `libtime` crate as-is today should add this to their Cargo manifests: [dependencies.time] git = "https://github.com/rust-lang/time" To implement this transition, a new function `Duration::span` was added to the `std::time::Duration` time. This function takes a closure and then returns the duration of time it took that closure to execute. This interface will likely improve with `FnOnce` unboxed closures as moving in and out will be a little easier. Due to the deprecation of the in-tree crate, this is a: [breaking-change] cc #18855, some of the conversions in the `src/test/bench` area may have been a little nicer with that implemented
2014-11-12Register new snapshotsAlex Crichton-50/+0
2014-11-12time: Deprecate the library in the distributionAlex Crichton-37/+34
This commit deprecates the entire libtime library in favor of the externally-provided libtime in the rust-lang organization. Users of the `libtime` crate as-is today should add this to their Cargo manifests: [dependencies.time] git = "https://github.com/rust-lang/time" To implement this transition, a new function `Duration::span` was added to the `std::time::Duration` time. This function takes a closure and then returns the duration of time it took that closure to execute. This interface will likely improve with `FnOnce` unboxed closures as moving in and out will be a little easier. Due to the deprecation of the in-tree crate, this is a: [breaking-change] cc #18855, some of the conversions in the `src/test/bench` area may have been a little nicer with that implemented
2014-11-13Remove Signed trait and add SignedInt traitBrendan Zabarauskas-1/+1
The methods have been moved into Float and SignedInt
2014-11-13Remove lots of numeric traits from the preludesBrendan Zabarauskas-0/+1
Num, NumCast, Unsigned, Float, Primitive and Int have been removed.
2014-11-13Move saturating operator methods into IntBrendan Zabarauskas-1/+0
2014-11-12Fix remaining documentation to reflect fail!() -> panic!()Barosl Lee-1/+1
Throughout the docs, "failure" was replaced with "panics" if it means a task panic. Otherwise, it remained as is, or changed to "errors" to clearly differentiate it from a task panic.
2014-11-06Fallout from collection conventionsAlexis Beingessner-23/+23
2014-11-05Fix fallout of DSTifying PartialEq, PartialOrd, Eq, OrdJorge Aparicio-0/+50
2014-10-29Rename fail! to panic!Steve Klabnik-15/+15
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-09Use the same html_root_url for all docsBrian Anderson-1/+1
2014-10-09Revert "Update html_root_url for 0.12.0 release"Brian Anderson-1/+1
This reverts commit 2288f332301b9e22db2890df256322650a7f3445.
2014-10-07Update html_root_url for 0.12.0 releaseBrian Anderson-1/+1
2014-09-23Deprecate `#[ignore(cfg(...))]`Steven Fackler-2/+1
Replace `#[ignore(cfg(a, b))]` with `#[cfg_attr(all(a, b), ignore)]`
2014-09-22Update calls of deprecated functions in macros.Victor Berger-2/+2
Fallout of #17185.
2014-09-16Fallout from renamingAaron Turon-7/+7
2014-09-13librustc: Forbid inherent implementations that aren't adjacent to thePatrick Walton-0/+1
type they provide an implementation for. This breaks code like: mod foo { struct Foo { ... } } impl foo::Foo { ... } Change this code to: mod foo { struct Foo { ... } impl Foo { ... } } Additionally, if you used the I/O path extension methods `stat`, `lstat`, `exists`, `is_file`, or `is_dir`, note that these methods have been moved to the the `std::io::fs::PathExtensions` trait. This breaks code like: fn is_it_there() -> bool { Path::new("/foo/bar/baz").exists() } Change this code to: use std::io::fs::PathExtensions; fn is_it_there() -> bool { Path::new("/foo/bar/baz").exists() } Closes #17059. RFC #155. [breaking-change]
2014-08-31Have std::io::TempDir::new and new_in return IoResultSimon Sapin-1/+1
This allows using `try!()` [breaking-change] Fixes #16875
2014-08-27Implement generalized object and type parameter bounds (Fixes #16462)Niko Matsakis-3/+3
2014-08-19serialize: add json bounds checks, support for u64s, and testsErick Tryzelaar-2/+2
2014-08-19serialize: add json::{Integer,Floating} to parse large integers properlyErick Tryzelaar-2/+2
[breaking-change]
2014-07-21Get rid of few warnings in testsPiotr Jawniak-1/+0
2014-07-17deprecate Vec::getNick Cameron-1/+1
2014-07-15Deprecate `str::from_utf8_lossy`Adolfo Ochagavía-3/+2
Use `String::from_utf8_lossy` instead [breaking-change]
2014-07-11Update doc URLs for version bumpBrian Anderson-1/+1