Skip to content

Commit 2db4b5c

Browse files
committed
---
yaml --- r: 130079 b: refs/heads/snap-stage3 c: f7ec95e h: refs/heads/master i: 130077: faba22a 130075: 4891e13 130071: 6cea7d5 130063: b5cbd56 130047: 7a2c647 v: v3
1 parent ab672d6 commit 2db4b5c

File tree

9 files changed

+113
-32
lines changed

9 files changed

+113
-32
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: 0bdac78da87605f6f7f6e7924872617226b19c85
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 7f72884f1366ee9a46cd2b231c09c5c0e44f7ba3
4+
refs/heads/snap-stage3: f7ec95efbb96f8e9bcb8b5e71b5d13803e840dc9
55
refs/heads/try: 28d5878c1f0465c11c8e7a3085008b0c592d48d0
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libnum/complex.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
//! Complex numbers.
1313
1414
use std::fmt;
15-
use std::num::{Zero,One,ToStrRadix};
15+
use std::num::{Zero, One, ToStrRadix};
1616

1717
// FIXME #1284: handle complex NaN & infinity etc. This
1818
// probably doesn't map to C's _Complex correctly.
1919

2020
/// A complex number in Cartesian form.
21-
#[deriving(PartialEq,Clone)]
21+
#[deriving(PartialEq, Clone, Hash)]
2222
pub struct Complex<T> {
2323
/// Real portion of the complex number
2424
pub re: T,
@@ -36,10 +36,8 @@ impl<T: Clone + Num> Complex<T> {
3636
Complex { re: re, im: im }
3737
}
3838

39-
/**
40-
Returns the square of the norm (since `T` doesn't necessarily
41-
have a sqrt function), i.e. `re^2 + im^2`.
42-
*/
39+
/// Returns the square of the norm (since `T` doesn't necessarily
40+
/// have a sqrt function), i.e. `re^2 + im^2`.
4341
#[inline]
4442
pub fn norm_sqr(&self) -> T {
4543
self.re * self.re + self.im * self.im
@@ -193,7 +191,8 @@ mod test {
193191
#![allow(non_uppercase_statics)]
194192

195193
use super::{Complex64, Complex};
196-
use std::num::{Zero,One,Float};
194+
use std::num::{Zero, One, Float};
195+
use std::hash::hash;
197196

198197
pub static _0_0i : Complex64 = Complex { re: 0.0, im: 0.0 };
199198
pub static _1_0i : Complex64 = Complex { re: 1.0, im: 0.0 };
@@ -367,4 +366,14 @@ mod test {
367366
test(-_neg1_1i, "1-1i".to_string());
368367
test(_05_05i, "0.5+0.5i".to_string());
369368
}
369+
370+
#[test]
371+
fn test_hash() {
372+
let a = Complex::new(0i32, 0i32);
373+
let b = Complex::new(1i32, 0i32);
374+
let c = Complex::new(0i32, 1i32);
375+
assert!(hash(&a) != hash(&b));
376+
assert!(hash(&b) != hash(&c));
377+
assert!(hash(&c) != hash(&a));
378+
}
370379
}

branches/snap-stage3/src/libnum/rational.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::num::{Zero, One, ToStrRadix, FromStrRadix};
2121
use bigint::{BigInt, BigUint, Sign, Plus, Minus};
2222

2323
/// Represents the ratio between 2 numbers.
24-
#[deriving(Clone)]
24+
#[deriving(Clone, Hash)]
2525
#[allow(missing_doc)]
2626
pub struct Ratio<T> {
2727
numer: T,
@@ -380,6 +380,7 @@ mod test {
380380
use super::{Ratio, Rational, BigRational};
381381
use std::num::{Zero, One, FromStrRadix, FromPrimitive, ToStrRadix};
382382
use std::from_str::FromStr;
383+
use std::hash::hash;
383384
use std::num;
384385

385386
pub static _0 : Rational = Ratio { numer: 0, denom: 1};
@@ -751,4 +752,10 @@ mod test {
751752
assert!(! _neg1_2.is_positive());
752753
assert!(! _1_2.is_negative());
753754
}
755+
756+
#[test]
757+
fn test_hash() {
758+
assert!(hash(&_0) != hash(&_1));
759+
assert!(hash(&_0) != hash(&_3_2));
760+
}
754761
}

branches/snap-stage3/src/librustc/front/test.rs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ struct TestCtxt<'a> {
5050
path: Vec<ast::Ident>,
5151
ext_cx: ExtCtxt<'a>,
5252
testfns: Vec<Test>,
53-
reexport_mod_ident: ast::Ident,
5453
reexport_test_harness_main: Option<InternedString>,
5554
is_test_crate: bool,
5655
config: ast::CrateConfig,
56+
57+
// top-level re-export submodule, filled out after folding is finished
58+
toplevel_reexport: Option<ast::Ident>,
5759
}
5860

5961
// Traverse the crate, collecting all the test functions, eliding any
@@ -83,7 +85,9 @@ pub fn modify_for_testing(sess: &Session,
8385
struct TestHarnessGenerator<'a> {
8486
cx: TestCtxt<'a>,
8587
tests: Vec<ast::Ident>,
86-
tested_submods: Vec<ast::Ident>,
88+
89+
// submodule name, gensym'd identifier for re-exports
90+
tested_submods: Vec<(ast::Ident, ast::Ident)>,
8791
}
8892

8993
impl<'a> fold::Folder for TestHarnessGenerator<'a> {
@@ -168,10 +172,14 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
168172
*i = nomain(*i);
169173
}
170174
if !tests.is_empty() || !tested_submods.is_empty() {
171-
mod_folded.items.push(mk_reexport_mod(&mut self.cx, tests,
172-
tested_submods));
175+
let (it, sym) = mk_reexport_mod(&mut self.cx, tests, tested_submods);
176+
mod_folded.items.push(it);
177+
173178
if !self.cx.path.is_empty() {
174-
self.tested_submods.push(self.cx.path[self.cx.path.len()-1]);
179+
self.tested_submods.push((self.cx.path[self.cx.path.len()-1], sym));
180+
} else {
181+
debug!("pushing nothing, sym: {}", sym);
182+
self.cx.toplevel_reexport = Some(sym);
175183
}
176184
}
177185

@@ -180,16 +188,16 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
180188
}
181189

182190
fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
183-
tested_submods: Vec<ast::Ident>) -> Gc<ast::Item> {
191+
tested_submods: Vec<(ast::Ident, ast::Ident)>) -> (Gc<ast::Item>, ast::Ident) {
184192
let mut view_items = Vec::new();
185193
let super_ = token::str_to_ident("super");
186194

187195
view_items.extend(tests.move_iter().map(|r| {
188196
cx.ext_cx.view_use_simple(DUMMY_SP, ast::Public,
189197
cx.ext_cx.path(DUMMY_SP, vec![super_, r]))
190198
}));
191-
view_items.extend(tested_submods.move_iter().map(|r| {
192-
let path = cx.ext_cx.path(DUMMY_SP, vec![super_, r, cx.reexport_mod_ident]);
199+
view_items.extend(tested_submods.move_iter().map(|(r, sym)| {
200+
let path = cx.ext_cx.path(DUMMY_SP, vec![super_, r, sym]);
193201
cx.ext_cx.view_use_simple_(DUMMY_SP, ast::Public, r, path)
194202
}));
195203

@@ -198,14 +206,18 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
198206
view_items: view_items,
199207
items: Vec::new(),
200208
};
201-
box(GC) ast::Item {
202-
ident: cx.reexport_mod_ident.clone(),
209+
210+
let sym = token::gensym_ident("__test_reexports");
211+
let it = box(GC) ast::Item {
212+
ident: sym.clone(),
203213
attrs: Vec::new(),
204214
id: ast::DUMMY_NODE_ID,
205215
node: ast::ItemMod(reexport_mod),
206216
vis: ast::Public,
207217
span: DUMMY_SP,
208-
}
218+
};
219+
220+
(it, sym)
209221
}
210222

211223
fn generate_test_harness(sess: &Session,
@@ -220,10 +232,10 @@ fn generate_test_harness(sess: &Session,
220232
}),
221233
path: Vec::new(),
222234
testfns: Vec::new(),
223-
reexport_mod_ident: token::gensym_ident("__test_reexports"),
224235
reexport_test_harness_main: reexport_test_harness_main,
225236
is_test_crate: is_test_crate(&krate),
226237
config: krate.config.clone(),
238+
toplevel_reexport: None,
227239
};
228240

229241
cx.ext_cx.bt_push(ExpnInfo {
@@ -530,7 +542,14 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> Gc<ast::Expr> {
530542
field("should_fail", fail_expr)]);
531543

532544

533-
let mut visible_path = vec![cx.reexport_mod_ident.clone()];
545+
let mut visible_path = match cx.toplevel_reexport {
546+
Some(id) => vec![id],
547+
None => {
548+
cx.sess.bug(
549+
"expected to find top-level re-export name, but found None"
550+
);
551+
}
552+
};
534553
visible_path.extend(path.move_iter());
535554

536555
let fn_expr = ecx.expr_path(ecx.path_global(span, visible_path));

branches/snap-stage3/src/test/debuginfo/gdb-pretty-struct-and-enums-pre-gdb-7-7.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// older versions of GDB too. A more extensive test can be found in
1313
// gdb-pretty-struct-and-enums.rs
1414

15+
// ignore-test FIXME(#16919)
1516
// ignore-tidy-linelength
1617
// ignore-lldb
1718
// ignore-android: FIXME(#10381)

branches/snap-stage3/src/test/debuginfo/gdb-pretty-struct-and-enums.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-test FIXME(#16919)
1112
// ignore-tidy-linelength
1213
// ignore-lldb
1314
// ignore-android: FIXME(#10381)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2014 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+
// compile-flags:--test
12+
13+
// This verifies that the test generation doesn't crash when we have
14+
// no tests - for more information, see PR #16892.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 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+
// compile-flags:--test
12+
// ignore-pretty turns out the pretty-printer doesn't handle gensym'd things...
13+
14+
#![feature(globs)]
15+
16+
mod test {
17+
use super::*;
18+
19+
#[test]
20+
fn test(){}
21+
}

branches/snap-stage3/src/test/run-pass/tcp-accept-stress.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-macos osx really doesn't like cycling through large numbers of
12+
// sockets as calls to connect() will start returning EADDRNOTAVAIL
13+
// quite quickly and it takes a few seconds for the sockets to get
14+
// recycled.
15+
1116
#![feature(phase)]
1217

1318
#[phase(plugin)]
@@ -20,7 +25,7 @@ use std::task::TaskBuilder;
2025
use native::NativeTaskBuilder;
2126

2227
static N: uint = 8;
23-
static M: uint = 100;
28+
static M: uint = 20;
2429

2530
green_start!(main)
2631

@@ -40,11 +45,12 @@ fn test() {
4045
let mut a = l.listen().unwrap();
4146
let cnt = Arc::new(atomic::AtomicUint::new(0));
4247

43-
let (tx, rx) = channel();
48+
let (srv_tx, srv_rx) = channel();
49+
let (cli_tx, cli_rx) = channel();
4450
for _ in range(0, N) {
4551
let a = a.clone();
4652
let cnt = cnt.clone();
47-
let tx = tx.clone();
53+
let srv_tx = srv_tx.clone();
4854
spawn(proc() {
4955
let mut a = a;
5056
loop {
@@ -58,33 +64,36 @@ fn test() {
5864
Err(e) => fail!("{}", e),
5965
}
6066
}
61-
tx.send(());
67+
srv_tx.send(());
6268
});
6369
}
6470

6571
for _ in range(0, N) {
66-
let tx = tx.clone();
72+
let cli_tx = cli_tx.clone();
6773
spawn(proc() {
6874
for _ in range(0, M) {
6975
let _s = TcpStream::connect(addr.ip.to_string().as_slice(),
7076
addr.port).unwrap();
7177
}
72-
tx.send(());
78+
cli_tx.send(());
7379
});
7480
}
75-
drop(tx);
81+
drop((cli_tx, srv_tx));
7682

7783
// wait for senders
78-
assert_eq!(rx.iter().take(N).count(), N);
84+
if cli_rx.iter().take(N).count() != N {
85+
a.close_accept().unwrap();
86+
fail!("clients failed");
87+
}
7988

8089
// wait for one acceptor to die
81-
let _ = rx.recv();
90+
let _ = srv_rx.recv();
8291

8392
// Notify other receivers should die
8493
a.close_accept().unwrap();
8594

8695
// wait for receivers
87-
assert_eq!(rx.iter().take(N - 1).count(), N - 1);
96+
assert_eq!(srv_rx.iter().take(N - 1).count(), N - 1);
8897

8998
// Everything should have been accepted.
9099
assert_eq!(cnt.load(atomic::SeqCst), N * M);

0 commit comments

Comments
 (0)