Skip to content

Commit c304269

Browse files
committed
---
yaml --- r: 113662 b: refs/heads/snap-stage3 c: e9018f9 h: refs/heads/master v: v3
1 parent 091813a commit c304269

File tree

11 files changed

+105
-53
lines changed

11 files changed

+105
-53
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: abdacecdf86b4b5a4f432560445a24e1c5f4751b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: a211907f88a8ac7a7deb3bd4c028e5dd34be95a2
4+
refs/heads/snap-stage3: e9018f9c75f190aae6714b7f2e774fdd784eacc1
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/doc/rust.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,7 +2943,7 @@ See [Break expressions](#break-expressions) and [Continue expressions](#continue
29432943
break_expr : "break" [ lifetime ];
29442944
~~~~
29452945

2946-
A `break` expression has an optional `label`.
2946+
A `break` expression has an optional _label_.
29472947
If the label is absent, then executing a `break` expression immediately terminates the innermost loop enclosing it.
29482948
It is only permitted in the body of a loop.
29492949
If the label is present, then `break foo` terminates the loop with label `foo`,
@@ -2956,7 +2956,7 @@ but must enclose it.
29562956
continue_expr : "continue" [ lifetime ];
29572957
~~~~
29582958

2959-
A `continue` expression has an optional `label`.
2959+
A `continue` expression has an optional _label_.
29602960
If the label is absent,
29612961
then executing a `continue` expression immediately terminates the current iteration of the innermost loop enclosing it,
29622962
returning control to the loop *head*.
@@ -3115,7 +3115,7 @@ let x: List<int> = Cons(10, box Cons(11, box Nil));
31153115
31163116
match x {
31173117
Cons(a, box Cons(b, _)) => {
3118-
process_pair(a,b);
3118+
process_pair(a, b);
31193119
}
31203120
Cons(10, _) => {
31213121
process_ten();
@@ -3329,8 +3329,8 @@ order specified by the tuple type.
33293329
An example of a tuple type and its use:
33303330

33313331
~~~~
3332-
type Pair<'a> = (int,&'a str);
3333-
let p: Pair<'static> = (10,"hello");
3332+
type Pair<'a> = (int, &'a str);
3333+
let p: Pair<'static> = (10, "hello");
33343334
let (a, b) = p;
33353335
assert!(b != "world");
33363336
~~~~

branches/snap-stage3/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2602,7 +2602,7 @@ fn main() {
26022602
~~~
26032603

26042604
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
2605-
`TotalOrd`, `Encodable` `Decodable`, `Clone`,
2605+
`TotalOrd`, `Encodable`, `Decodable`, `Clone`,
26062606
`Hash`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`.
26072607

26082608
# Crates and the module system

branches/snap-stage3/src/libcore/bool.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
//! Implementations of the following traits:
1616
//!
1717
//! * `Not`
18+
//! * `BitAnd`
19+
//! * `BitOr`
20+
//! * `BitXor`
1821
//! * `Ord`
1922
//! * `TotalOrd`
2023
//! * `Eq`
24+
//! * `TotalEq`
2125
//! * `Default`
22-
//! * `Zero`
2326
//!
2427
//! A `to_bit` conversion function.
2528

branches/snap-stage3/src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//!
1818
//! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
1919
//! often generated by LLVM. Additionally, this library can make explicit
20-
//! calls to these funcitons. Their signatures are the same as found in C.
20+
//! calls to these functions. Their signatures are the same as found in C.
2121
//! These functions are often provided by the system libc, but can also be
2222
//! provided by `librlibc` which is distributed with the standard rust
2323
//! distribution.

branches/snap-stage3/src/libcore/num/mod.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Numeric traits and functions for generic mathematics
1212
//!
1313
//! These are implemented for the primitive numeric types in `std::{u8, u16,
14-
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float}`.
14+
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64}`.
1515
1616
#![allow(missing_doc)]
1717

@@ -97,7 +97,7 @@ pub trait One: Mul<Self, Self> {
9797
pub trait Signed: Num + Neg<Self> {
9898
/// Computes the absolute value.
9999
///
100-
/// For float, f32, and f64, `NaN` will be returned if the number is `NaN`.
100+
/// For `f32` and `f64`, `NaN` will be returned if the number is `NaN`.
101101
fn abs(&self) -> Self;
102102

103103
/// The positive difference of two numbers.
@@ -108,15 +108,17 @@ pub trait Signed: Num + Neg<Self> {
108108

109109
/// Returns the sign of the number.
110110
///
111-
/// For `float`, `f32`, `f64`:
112-
/// * `1.0` if the number is positive, `+0.0` or `INFINITY`
113-
/// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
114-
/// * `NaN` if the number is `NaN`
111+
/// For `f32` and `f64`:
112+
///
113+
/// * `1.0` if the number is positive, `+0.0` or `INFINITY`
114+
/// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
115+
/// * `NaN` if the number is `NaN`
115116
///
116117
/// For `int`:
117-
/// * `0` if the number is zero
118-
/// * `1` if the number is positive
119-
/// * `-1` if the number is negative
118+
///
119+
/// * `0` if the number is zero
120+
/// * `1` if the number is positive
121+
/// * `-1` if the number is negative
120122
fn signum(&self) -> Self;
121123

122124
/// Returns true if the number is positive and false if the number is zero or negative.
@@ -128,7 +130,7 @@ pub trait Signed: Num + Neg<Self> {
128130

129131
/// Computes the absolute value.
130132
///
131-
/// For float, f32, and f64, `NaN` will be returned if the number is `NaN`
133+
/// For `f32` and `f64`, `NaN` will be returned if the number is `NaN`
132134
#[inline(always)]
133135
pub fn abs<T: Signed>(value: T) -> T {
134136
value.abs()
@@ -145,15 +147,17 @@ pub fn abs_sub<T: Signed>(x: T, y: T) -> T {
145147

146148
/// Returns the sign of the number.
147149
///
148-
/// For float, f32, f64:
149-
/// - `1.0` if the number is positive, `+0.0` or `INFINITY`
150-
/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
151-
/// - `NAN` if the number is `NAN`
150+
/// For `f32` and `f64`:
151+
///
152+
/// * `1.0` if the number is positive, `+0.0` or `INFINITY`
153+
/// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
154+
/// * `NaN` if the number is `NaN`
152155
///
153156
/// For int:
154-
/// - `0` if the number is zero
155-
/// - `1` if the number is positive
156-
/// - `-1` if the number is negative
157+
///
158+
/// * `0` if the number is zero
159+
/// * `1` if the number is positive
160+
/// * `-1` if the number is negative
157161
#[inline(always)] pub fn signum<T: Signed>(value: T) -> T { value.signum() }
158162

159163
/// A trait for values which cannot be negative

branches/snap-stage3/src/libcore/result.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,19 @@ impl<T, E> Result<T, E> {
508508
/// Unwraps a result, yielding the content of an `Ok`.
509509
/// If the value is an `Err` then it calls `op` with its value.
510510
#[inline]
511-
pub fn unwrap_or_handle(self, op: |E| -> T) -> T {
511+
pub fn unwrap_or_else(self, op: |E| -> T) -> T {
512512
match self {
513513
Ok(t) => t,
514514
Err(e) => op(e)
515515
}
516516
}
517+
518+
/// Deprecated name for `unwrap_or_else()`.
519+
#[deprecated = "replaced by .unwrap_or_else()"]
520+
#[inline]
521+
pub fn unwrap_or_handle(self, op: |E| -> T) -> T {
522+
self.unwrap_or_else(op)
523+
}
517524
}
518525

519526
impl<T, E: Show> Result<T, E> {
@@ -758,8 +765,8 @@ mod tests {
758765
let ok: Result<int, ~str> = Ok(100);
759766
let ok_err: Result<int, ~str> = Err("I got this.".to_owned());
760767

761-
assert_eq!(ok.unwrap_or_handle(handler), 100);
762-
assert_eq!(ok_err.unwrap_or_handle(handler), 50);
768+
assert_eq!(ok.unwrap_or_else(handler), 100);
769+
assert_eq!(ok_err.unwrap_or_else(handler), 50);
763770
}
764771

765772
#[test]
@@ -774,6 +781,6 @@ mod tests {
774781
}
775782

776783
let bad_err: Result<int, ~str> = Err("Unrecoverable mess.".to_owned());
777-
let _ : int = bad_err.unwrap_or_handle(handler);
784+
let _ : int = bad_err.unwrap_or_else(handler);
778785
}
779786
}

branches/snap-stage3/src/libstd/num/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Numeric traits and functions for generic mathematics
1212
//!
1313
//! These are implemented for the primitive numeric types in `std::{u8, u16,
14-
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float}`.
14+
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64}`.
1515
1616
#![allow(missing_doc)]
1717

branches/snap-stage3/src/libtest/lib.rs

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
3333
html_root_url = "http://static.rust-lang.org/doc/master")]
3434

35-
#![feature(asm, macro_rules)]
35+
#![feature(asm, macro_rules, phase)]
3636
#![deny(deprecated_owned_vector)]
3737

3838
extern crate collections;
@@ -83,7 +83,7 @@ pub mod stats;
8383
// colons. This way if some test runner wants to arrange the tests
8484
// hierarchically it may.
8585

86-
#[deriving(Clone)]
86+
#[deriving(Clone, Eq, TotalEq, Hash)]
8787
pub enum TestName {
8888
StaticTestName(&'static str),
8989
DynTestName(StrBuf)
@@ -156,6 +156,19 @@ impl TestFn {
156156
}
157157
}
158158

159+
impl fmt::Show for TestFn {
160+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
161+
f.write(match *self {
162+
StaticTestFn(..) => "StaticTestFn(..)",
163+
StaticBenchFn(..) => "StaticBenchFn(..)",
164+
StaticMetricFn(..) => "StaticMetricFn(..)",
165+
DynTestFn(..) => "DynTestFn(..)",
166+
DynMetricFn(..) => "DynMetricFn(..)",
167+
DynBenchFn(..) => "DynBenchFn(..)"
168+
}.as_bytes())
169+
}
170+
}
171+
159172
/// Manager of the benchmarking runs.
160173
///
161174
/// This is feed into functions marked with `#[bench]` to allow for
@@ -170,13 +183,14 @@ pub struct Bencher {
170183

171184
// The definition of a single test. A test runner will run a list of
172185
// these.
173-
#[deriving(Clone)]
186+
#[deriving(Clone, Show, Eq, TotalEq, Hash)]
174187
pub struct TestDesc {
175188
pub name: TestName,
176189
pub ignore: bool,
177190
pub should_fail: bool,
178191
}
179192

193+
#[deriving(Show)]
180194
pub struct TestDescAndFn {
181195
pub desc: TestDesc,
182196
pub testfn: TestFn,
@@ -242,15 +256,9 @@ pub fn test_main(args: &[StrBuf], tests: Vec<TestDescAndFn> ) {
242256
pub fn test_main_static(args: &[StrBuf], tests: &[TestDescAndFn]) {
243257
let owned_tests = tests.iter().map(|t| {
244258
match t.testfn {
245-
StaticTestFn(f) =>
246-
TestDescAndFn { testfn: StaticTestFn(f), desc: t.desc.clone() },
247-
248-
StaticBenchFn(f) =>
249-
TestDescAndFn { testfn: StaticBenchFn(f), desc: t.desc.clone() },
250-
251-
_ => {
252-
fail!("non-static tests passed to test::test_main_static");
253-
}
259+
StaticTestFn(f) => TestDescAndFn { testfn: StaticTestFn(f), desc: t.desc.clone() },
260+
StaticBenchFn(f) => TestDescAndFn { testfn: StaticBenchFn(f), desc: t.desc.clone() },
261+
_ => fail!("non-static tests passed to test::test_main_static")
254262
}
255263
}).collect();
256264
test_main(args, owned_tests)
@@ -419,8 +427,15 @@ pub fn opt_shard(maybestr: Option<StrBuf>) -> Option<(uint,uint)> {
419427
None => None,
420428
Some(s) => {
421429
let mut it = s.as_slice().split('.');
422-
match (it.next().and_then(from_str), it.next().and_then(from_str), it.next()) {
423-
(Some(a), Some(b), None) => Some((a, b)),
430+
match (it.next().and_then(from_str::<uint>), it.next().and_then(from_str::<uint>),
431+
it.next()) {
432+
(Some(a), Some(b), None) => {
433+
if a <= 0 || a > b {
434+
fail!("tried to run shard {a}.{b}, but {a} is out of bounds \
435+
(should be between 1 and {b}", a=a, b=b)
436+
}
437+
Some((a, b))
438+
}
424439
_ => None,
425440
}
426441
}
@@ -739,10 +754,9 @@ pub fn fmt_bench_samples(bs: &BenchSamples) -> StrBuf {
739754
}
740755

741756
// A simple console test runner
742-
pub fn run_tests_console(opts: &TestOpts,
743-
tests: Vec<TestDescAndFn> ) -> io::IoResult<bool> {
744-
fn callback<T: Writer>(event: &TestEvent,
745-
st: &mut ConsoleTestState<T>) -> io::IoResult<()> {
757+
pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn> ) -> io::IoResult<bool> {
758+
759+
fn callback<T: Writer>(event: &TestEvent, st: &mut ConsoleTestState<T>) -> io::IoResult<()> {
746760
match (*event).clone() {
747761
TeFiltered(ref filtered_tests) => st.write_run_start(filtered_tests.len()),
748762
TeWait(ref test, padding) => st.write_test_start(test, padding),
@@ -778,6 +792,7 @@ pub fn run_tests_console(opts: &TestOpts,
778792
}
779793
}
780794
}
795+
781796
let mut st = try!(ConsoleTestState::new(opts, None::<StdWriter>));
782797
fn len_if_padded(t: &TestDescAndFn) -> uint {
783798
match t.testfn.padding() {
@@ -933,9 +948,7 @@ fn get_concurrency() -> uint {
933948
}
934949
}
935950

936-
pub fn filter_tests(
937-
opts: &TestOpts,
938-
tests: Vec<TestDescAndFn> ) -> Vec<TestDescAndFn> {
951+
pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> {
939952
let mut filtered = tests;
940953

941954
// Remove tests that don't match the test filter
@@ -973,7 +986,9 @@ pub fn filter_tests(
973986
None => filtered,
974987
Some((a,b)) => {
975988
filtered.move_iter().enumerate()
976-
.filter(|&(i,_)| i % b == a)
989+
// note: using a - 1 so that the valid shards, for example, are
990+
// 1.2 and 2.2 instead of 0.2 and 1.2
991+
.filter(|&(i,_)| i % b == (a - 1))
977992
.map(|(_,t)| t)
978993
.collect()
979994
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-include ../tools.mk
2+
3+
all:
4+
# Running all the shards should hit every test
5+
$(RUSTC) --test main.rs
6+
$(call RUN,main) --test-shard 1.2 | grep "test_1 ... ok"
7+
$(call RUN,main) --test-shard 2.2 | grep "test_2 ... ok"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type = "lib"]
12+
13+
#[test]
14+
fn test_1() { }
15+
#[test]
16+
fn test_2() { }

0 commit comments

Comments
 (0)