about summary refs log tree commit diff
path: root/src/libtest
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2014-11-11 16:01:29 -0500
committerDaniel Micay <danielmicay@gmail.com>2014-11-18 01:09:46 -0500
commit85c2c2e38ce7c606fac1e9c8fa9d2ab71b35c8c8 (patch)
tree578802f9e774e104b1a271b92946208e0e0a0675 /src/libtest
parent9c96a79a74f10bed18b031ce0ac4126c56d6cfb3 (diff)
downloadrust-85c2c2e38ce7c606fac1e9c8fa9d2ab71b35c8c8.tar.gz
rust-85c2c2e38ce7c606fac1e9c8fa9d2ab71b35c8c8.zip
implement Writer for Vec<u8>
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.
Diffstat (limited to 'src/libtest')
-rw-r--r--src/libtest/lib.rs8
-rw-r--r--src/libtest/stats.rs5
2 files changed, 5 insertions, 8 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 8266765ba3f..d5d0e7aeb17 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -33,7 +33,7 @@
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/")]
 
-#![feature(asm, macro_rules, phase, globs)]
+#![feature(asm, macro_rules, phase, globs, slicing_syntax)]
 
 extern crate getopts;
 extern crate regex;
@@ -848,8 +848,6 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn> ) -> io::IoR
 
 #[test]
 fn should_sort_failures_before_printing_them() {
-    use std::io::MemWriter;
-
     let test_a = TestDesc {
         name: StaticTestName("a"),
         ignore: false,
@@ -864,7 +862,7 @@ fn should_sort_failures_before_printing_them() {
 
     let mut st = ConsoleTestState {
         log_out: None,
-        out: Raw(MemWriter::new()),
+        out: Raw(Vec::new()),
         use_color: false,
         total: 0u,
         passed: 0u,
@@ -878,7 +876,7 @@ fn should_sort_failures_before_printing_them() {
 
     st.write_failures().unwrap();
     let s = match st.out {
-        Raw(ref m) => String::from_utf8_lossy(m.get_ref()),
+        Raw(ref m) => String::from_utf8_lossy(m[]),
         Pretty(_) => unreachable!()
     };
 
diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs
index daef41666af..1929f1989d6 100644
--- a/src/libtest/stats.rs
+++ b/src/libtest/stats.rs
@@ -1027,10 +1027,9 @@ mod tests {
     #[test]
     fn test_boxplot_nonpositive() {
         fn t(s: &Summary<f64>, expected: String) {
-            use std::io::MemWriter;
-            let mut m = MemWriter::new();
+            let mut m = Vec::new();
             write_boxplot(&mut m as &mut io::Writer, s, 30).unwrap();
-            let out = String::from_utf8(m.unwrap()).unwrap();
+            let out = String::from_utf8(m).unwrap();
             assert_eq!(out, expected);
         }