diff options
| author | bors <bors@rust-lang.org> | 2014-01-03 12:16:48 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-03 12:16:48 -0800 |
| commit | 08321f1c49d75e60a2c56320a3f1483e7bf79a91 (patch) | |
| tree | fd429cf0c3cd63379bef08c36fd9acf0f3e0d82a /src/libextra | |
| parent | 11ce6b709ace233e473eddb26e3e23c2c4c16cdd (diff) | |
| parent | 4bea679dbe3ba98049ac700d84ad48271753ce40 (diff) | |
| download | rust-08321f1c49d75e60a2c56320a3f1483e7bf79a91.tar.gz rust-08321f1c49d75e60a2c56320a3f1483e7bf79a91.zip | |
auto merge of #11149 : alexcrichton/rust/remove-either, r=brson
Had to change some stuff in typeck to bootstrap (getting methods in fmt off of Either), but other than that not so painful. Closes #9157
Diffstat (limited to 'src/libextra')
| -rw-r--r-- | src/libextra/test.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/libextra/test.rs b/src/libextra/test.rs index 3d6dfd612f2..63e19df9519 100644 --- a/src/libextra/test.rs +++ b/src/libextra/test.rs @@ -337,9 +337,14 @@ pub enum TestResult { TrBench(BenchSamples), } +enum OutputLocation<T> { + Pretty(term::Terminal<T>), + Raw(T), +} + struct ConsoleTestState<T> { log_out: Option<File>, - out: Either<term::Terminal<T>, T>, + out: OutputLocation<T>, use_color: bool, total: uint, passed: uint, @@ -358,8 +363,8 @@ impl<T: Writer> ConsoleTestState<T> { None => None }; let out = match term::Terminal::new(io::stdout()) { - Err(_) => Right(io::stdout()), - Ok(t) => Left(t) + Err(_) => Raw(io::stdout()), + Ok(t) => Pretty(t) }; ConsoleTestState { out: out, @@ -416,7 +421,7 @@ impl<T: Writer> ConsoleTestState<T> { word: &str, color: term::color::Color) { match self.out { - Left(ref mut term) => { + Pretty(ref mut term) => { if self.use_color { term.fg(color); } @@ -425,14 +430,14 @@ impl<T: Writer> ConsoleTestState<T> { term.reset(); } } - Right(ref mut stdout) => stdout.write(word.as_bytes()) + Raw(ref mut stdout) => stdout.write(word.as_bytes()) } } pub fn write_plain(&mut self, s: &str) { match self.out { - Left(ref mut term) => term.write(s.as_bytes()), - Right(ref mut stdout) => stdout.write(s.as_bytes()) + Pretty(ref mut term) => term.write(s.as_bytes()), + Raw(ref mut stdout) => stdout.write(s.as_bytes()) } } @@ -683,7 +688,7 @@ fn should_sort_failures_before_printing_them() { let mut st = ConsoleTestState { log_out: None, - out: Right(MemWriter::new()), + out: Raw(MemWriter::new()), use_color: false, total: 0u, passed: 0u, @@ -697,8 +702,8 @@ fn should_sort_failures_before_printing_them() { st.write_failures(); let s = match st.out { - Right(ref m) => str::from_utf8(*m.inner_ref()), - Left(_) => unreachable!() + Raw(ref m) => str::from_utf8(*m.inner_ref()), + Pretty(_) => unreachable!() }; let apos = s.find_str("a").unwrap(); |
