Skip to content

Commit d01e4d9

Browse files
committed
---
yaml --- r: 97967 b: refs/heads/master c: 01f42ee h: refs/heads/master i: 97965: 2d6b844 97963: 4f993ee 97959: d508ffe 97951: 1d7408a v: v3
1 parent cac8206 commit d01e4d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1580
-1730
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1b0f5b23fc08ff22dc513c5f333569b7e8b9313d
2+
refs/heads/master: 01f42eed803e7e01bb27be17461d0cc8f0643a70
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b6400f998497c3958f40997a71756ead344a776d
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36

trunk/doc/guide-testing.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ value. To run the tests in a crate, it must be compiled with the
4848
the resulting executable will run all the tests in the crate. A test
4949
is considered successful if its function returns; if the task running
5050
the test fails, through a call to `fail!`, a failed `check` or
51-
`assert`, or some other (`assert_eq`, ...) means, then the test fails.
51+
`assert`, or some other (`assert_eq`, `assert_approx_eq`, ...) means,
52+
then the test fails.
5253

5354
When compiling a crate with the '--test' flag '--cfg test' is also
5455
implied, so that tests can be conditionally compiled.

trunk/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ syn keyword rustTrait Bool
7171
syn keyword rustTrait ToCStr
7272
syn keyword rustTrait Char
7373
syn keyword rustTrait Clone DeepClone
74-
syn keyword rustTrait Eq Ord TotalEq TotalOrd Ordering Equiv
74+
syn keyword rustTrait Eq ApproxEq Ord TotalEq TotalOrd Ordering Equiv
7575
syn keyword rustEnumVariant Less Equal Greater
7676
syn keyword rustTrait Container Mutable Map MutableMap Set MutableSet
7777
syn keyword rustTrait Default

trunk/src/libextra/ebml.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ mod tests {
935935
use serialize::Encodable;
936936
use serialize;
937937

938+
use std::io::Decorator;
938939
use std::io::mem::MemWriter;
939940
use std::option::{None, Option, Some};
940941

@@ -947,7 +948,7 @@ mod tests {
947948
let mut ebml_w = writer::Encoder(&mut wr);
948949
v.encode(&mut ebml_w);
949950
}
950-
let ebml_doc = reader::Doc(wr.get_ref());
951+
let ebml_doc = reader::Doc(*wr.inner_ref());
951952
let mut deser = reader::Decoder(ebml_doc);
952953
let v1 = serialize::Decodable::decode(&mut deser);
953954
debug!("v1 == {:?}", v1);

trunk/src/libextra/json.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use std::cast::transmute;
2121
use std::f64;
2222
use std::hashmap::HashMap;
2323
use std::io;
24+
use std::io::Decorator;
2425
use std::io::mem::MemWriter;
2526
use std::num;
2627
use std::str;
@@ -463,7 +464,7 @@ impl Json{
463464
pub fn to_pretty_str(&self) -> ~str {
464465
let mut s = MemWriter::new();
465466
self.to_pretty_writer(&mut s as &mut io::Writer);
466-
str::from_utf8_owned(s.unwrap())
467+
str::from_utf8_owned(s.inner())
467468
}
468469
}
469470

@@ -1320,7 +1321,7 @@ impl to_str::ToStr for Json {
13201321
fn to_str(&self) -> ~str {
13211322
let mut s = MemWriter::new();
13221323
self.to_writer(&mut s as &mut io::Writer);
1323-
str::from_utf8_owned(s.unwrap())
1324+
str::from_utf8_owned(s.inner())
13241325
}
13251326
}
13261327

@@ -1507,11 +1508,12 @@ mod tests {
15071508
15081509
fn with_str_writer(f: |&mut io::Writer|) -> ~str {
15091510
use std::io::mem::MemWriter;
1511+
use std::io::Decorator;
15101512
use std::str;
15111513
15121514
let mut m = MemWriter::new();
15131515
f(&mut m as &mut io::Writer);
1514-
str::from_utf8_owned(m.unwrap())
1516+
str::from_utf8_owned(m.inner())
15151517
}
15161518
15171519
#[test]

trunk/src/libextra/num/complex.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
//! Complex numbers.
1313
14+
1415
use std::num::{Zero,One,ToStrRadix};
1516

1617
// FIXME #1284: handle complex NaN & infinity etc. This
@@ -77,15 +78,15 @@ impl<T: Clone + Num> Cmplx<T> {
7778
}
7879
}
7980

80-
impl<T: Clone + Real> Cmplx<T> {
81+
impl<T: Clone + Algebraic + Num> Cmplx<T> {
8182
/// Calculate |self|
8283
#[inline]
8384
pub fn norm(&self) -> T {
8485
self.re.hypot(&self.im)
8586
}
8687
}
8788

88-
impl<T: Clone + Real> Cmplx<T> {
89+
impl<T: Clone + Trigonometric + Algebraic + Num> Cmplx<T> {
8990
/// Calculate the principal Arg of self.
9091
#[inline]
9192
pub fn arg(&self) -> T {
@@ -267,7 +268,7 @@ mod test {
267268
#[test]
268269
fn test_arg() {
269270
fn test(c: Complex64, arg: f64) {
270-
assert!((c.arg() - arg).abs() < 1.0e-6)
271+
assert!(c.arg().approx_eq(&arg))
271272
}
272273
test(_1_0i, 0.0);
273274
test(_1_1i, 0.25 * Real::pi());

trunk/src/libextra/num/rational.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ impl<T: Clone + Integer + Ord>
105105
ret.reduce();
106106
ret
107107
}
108-
109-
/// Return the reciprocal
110-
#[inline]
111-
pub fn recip(&self) -> Ratio<T> {
112-
Ratio::new_raw(self.denom.clone(), self.numer.clone())
113-
}
114108
}
115109

116110
impl Ratio<BigInt> {
@@ -294,6 +288,13 @@ impl<T: Clone + Integer + Ord>
294288
}
295289
}
296290

291+
impl<T: Clone + Integer + Ord> Fractional for Ratio<T> {
292+
#[inline]
293+
fn recip(&self) -> Ratio<T> {
294+
Ratio::new_raw(self.denom.clone(), self.numer.clone())
295+
}
296+
}
297+
297298
/* String conversions */
298299
impl<T: ToStr> ToStr for Ratio<T> {
299300
/// Renders as `numer/denom`.

trunk/src/libextra/stats.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,6 @@ mod tests {
439439
use std::io;
440440
use std::str;
441441

442-
macro_rules! assert_approx_eq(
443-
($a:expr, $b:expr) => ({
444-
let (a, b) = (&$a, &$b);
445-
assert!((*a - *b).abs() < 1.0e-6,
446-
"{} is not approximately equal to {}", *a, *b);
447-
})
448-
)
449-
450442
fn check(samples: &[f64], summ: &Summary) {
451443

452444
let summ2 = Summary::new(samples);
@@ -999,9 +991,10 @@ mod tests {
999991
fn test_boxplot_nonpositive() {
1000992
fn t(s: &Summary, expected: ~str) {
1001993
use std::io::mem::MemWriter;
994+
use std::io::Decorator;
1002995
let mut m = MemWriter::new();
1003996
write_boxplot(&mut m as &mut io::Writer, s, 30);
1004-
let out = str::from_utf8_owned(m.unwrap());
997+
let out = str::from_utf8_owned(m.inner());
1005998
assert_eq!(out, expected);
1006999
}
10071000

trunk/src/libextra/term.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#[allow(missing_doc)];
1414

1515

16+
use std::io::{Decorator, Writer};
17+
1618
use std::os;
1719
use terminfo::*;
1820
use terminfo::searcher::open;
@@ -232,12 +234,20 @@ impl<T: Writer> Terminal<T> {
232234
color-8
233235
} else { color }
234236
}
237+
}
235238

236-
pub fn unwrap(self) -> T { self.out }
239+
impl<T: Writer> Decorator<T> for Terminal<T> {
240+
fn inner(self) -> T {
241+
self.out
242+
}
237243

238-
pub fn get_ref<'a>(&'a self) -> &'a T { &self.out }
244+
fn inner_ref<'a>(&'a self) -> &'a T {
245+
&self.out
246+
}
239247

240-
pub fn get_mut<'a>(&'a mut self) -> &'a mut T { &mut self.out }
248+
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut T {
249+
&mut self.out
250+
}
241251
}
242252

243253
impl<T: Writer> Writer for Terminal<T> {

trunk/src/libextra/test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ pub fn run_tests_console(opts: &TestOpts,
673673

674674
#[test]
675675
fn should_sort_failures_before_printing_them() {
676+
use std::io::Decorator;
676677
use std::io::mem::MemWriter;
677678
use std::str;
678679

@@ -704,7 +705,7 @@ fn should_sort_failures_before_printing_them() {
704705

705706
st.write_failures();
706707
let s = match st.out {
707-
Raw(ref m) => str::from_utf8(m.get_ref()),
708+
Raw(ref m) => str::from_utf8(*m.inner_ref()),
708709
Pretty(_) => unreachable!()
709710
};
710711

trunk/src/libextra/uuid.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ mod test {
522522
use std::str;
523523
use std::rand;
524524
use std::num::Zero;
525+
use std::io::Decorator;
525526
use std::io::mem::MemWriter;
526527

527528
#[test]
@@ -797,7 +798,7 @@ mod test {
797798
let u = Uuid::new_v4();
798799
let mut wr = MemWriter::new();
799800
u.encode(&mut ebml::writer::Encoder(&mut wr));
800-
let doc = ebml::reader::Doc(wr.get_ref());
801+
let doc = ebml::reader::Doc(wr.inner_ref().as_slice());
801802
let u2 = Decodable::decode(&mut ebml::reader::Decoder(doc));
802803
assert_eq!(u, u2);
803804
}

trunk/src/libextra/workcache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use arc::{Arc,RWArc};
1717
use treemap::TreeMap;
1818
use std::str;
1919
use std::io;
20-
use std::io::File;
20+
use std::io::{File, Decorator};
2121
use std::io::mem::MemWriter;
2222

2323
/**
@@ -261,7 +261,7 @@ fn json_encode<'a, T:Encodable<json::Encoder<'a>>>(t: &T) -> ~str {
261261
let mut writer = MemWriter::new();
262262
let mut encoder = json::Encoder::new(&mut writer as &mut io::Writer);
263263
t.encode(&mut encoder);
264-
str::from_utf8_owned(writer.unwrap())
264+
str::from_utf8_owned(writer.inner())
265265
}
266266

267267
// FIXME(#5121)

trunk/src/librustc/metadata/encoder.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use std::cast;
2525
use std::cell::{Cell, RefCell};
2626
use std::hashmap::{HashMap, HashSet};
2727
use std::io::mem::MemWriter;
28+
use std::io::{Writer, Seek, Decorator};
2829
use std::str;
2930
use std::vec;
3031

@@ -1806,7 +1807,7 @@ pub static metadata_encoding_version : &'static [u8] =
18061807
pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
18071808
let mut wr = MemWriter::new();
18081809
encode_metadata_inner(&mut wr, parms, crate);
1809-
wr.unwrap()
1810+
wr.inner()
18101811
}
18111812

18121813
fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, crate: &Crate) {
@@ -1899,7 +1900,7 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, crate: &Crate)
18991900
ecx.stats.total_bytes.set(ebml_w.writer.tell());
19001901

19011902
if (tcx.sess.meta_stats()) {
1902-
for e in ebml_w.writer.get_ref().iter() {
1903+
for e in ebml_w.writer.inner_ref().iter() {
19031904
if *e == 0 {
19041905
ecx.stats.zero_bytes.set(ecx.stats.zero_bytes.get() + 1);
19051906
}
@@ -1929,5 +1930,5 @@ pub fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str {
19291930
abbrevs: tyencode::ac_no_abbrevs};
19301931
let mut wr = MemWriter::new();
19311932
tyencode::enc_ty(&mut wr, cx, t);
1932-
str::from_utf8_owned(wr.get_ref().to_owned())
1933+
str::from_utf8_owned(wr.inner_ref().to_owned())
19331934
}

trunk/src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use std::cell::RefCell;
1414
use std::hashmap::HashMap;
1515
use std::io;
16+
use std::io::{Decorator, Writer, Seek};
1617
use std::io::mem::MemWriter;
1718
use std::str;
1819
use std::fmt;
@@ -72,7 +73,7 @@ pub fn enc_ty(w: &mut MemWriter, cx: @ctxt, t: ty::t) {
7273
None => {
7374
let wr = &mut MemWriter::new();
7475
enc_sty(wr, cx, &ty::get(t).sty);
75-
let s = str::from_utf8(wr.get_ref()).to_managed();
76+
let s = str::from_utf8(*wr.inner_ref()).to_managed();
7677
let mut short_names_cache = cx.tcx
7778
.short_names_cache
7879
.borrow_mut();

trunk/src/librustc/middle/astencode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,7 @@ fn mk_ctxt() -> @fake_ext_ctxt {
14651465

14661466
#[cfg(test)]
14671467
fn roundtrip(in_item: Option<@ast::item>) {
1468+
use std::io::Decorator;
14681469
use std::io::mem::MemWriter;
14691470

14701471
let in_item = in_item.unwrap();
@@ -1473,7 +1474,7 @@ fn roundtrip(in_item: Option<@ast::item>) {
14731474
let mut ebml_w = writer::Encoder(&mut wr);
14741475
encode_item_ast(&mut ebml_w, in_item);
14751476
}
1476-
let ebml_doc = reader::Doc(wr.get_ref());
1477+
let ebml_doc = reader::Doc(wr.inner_ref().as_slice());
14771478
let out_item = decode_item_ast(ebml_doc);
14781479

14791480
assert_eq!(in_item, out_item);

0 commit comments

Comments
 (0)