Test fixes and merge conflicts

This commit is contained in:
Alex Crichton 2013-10-17 21:08:48 -07:00
parent 279c351820
commit 620ab3853a
19 changed files with 151 additions and 141 deletions

View file

@ -111,6 +111,7 @@ fn acid(ch: char, prob: u32) -> AminoAcids {
}
fn main() {
use std::rt::io::file::FileInfo;
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
// alioth tests k-nucleotide with this data at 25,000,000
@ -122,7 +123,7 @@ fn main() {
};
let writer = if os::getenv("RUST_BENCH").is_some() {
let file = "./shootout-fasta.data".open_writer(io::CreateOrTruncate);
let file = Path::new("./shootout-fasta.data").open_writer(io::CreateOrTruncate);
@mut file as @mut io::Writer
} else {
@mut io::stdout() as @mut io::Writer

View file

@ -20,6 +20,7 @@ use std::comm;
use std::hashmap::HashMap;
use std::option;
use std::os;
use std::rt::io;
use std::str;
use std::task;
use std::util;
@ -193,48 +194,48 @@ fn main() {
let mut proc_mode = false;
loop {
let line = match rdr.read_line() {
Some(ln) => ln, None => break,
};
let line = line.trim().to_owned();
let line = match io::ignore_io_error(|| rdr.read_line()) {
Some(ln) => ln, None => break,
};
let line = line.trim().to_owned();
if line.len() == 0u { continue; }
if line.len() == 0u { continue; }
match (line[0] as char, proc_mode) {
match (line[0] as char, proc_mode) {
// start processing if this is the one
('>', false) => {
match line.slice_from(1).find_str("THREE") {
option::Some(_) => { proc_mode = true; }
option::None => { }
}
}
// start processing if this is the one
('>', false) => {
match line.slice_from(1).find_str("THREE") {
option::Some(_) => { proc_mode = true; }
option::None => { }
}
}
// break our processing
('>', true) => { break; }
// break our processing
('>', true) => { break; }
// process the sequence for k-mers
(_, true) => {
let line_bytes = line.as_bytes();
// process the sequence for k-mers
(_, true) => {
let line_bytes = line.as_bytes();
for (ii, _sz) in sizes.iter().enumerate() {
let lb = line_bytes.to_owned();
to_child[ii].send(lb);
}
}
for (ii, _sz) in sizes.iter().enumerate() {
let lb = line_bytes.to_owned();
to_child[ii].send(lb);
}
}
// whatever
_ => { }
}
// whatever
_ => { }
}
}
// finish...
for (ii, _sz) in sizes.iter().enumerate() {
to_child[ii].send(~[]);
for (ii, _sz) in sizes.iter().enumerate() {
to_child[ii].send(~[]);
}
// now fetch and print result messages
for (ii, _sz) in sizes.iter().enumerate() {
println(from_child[ii].recv());
for (ii, _sz) in sizes.iter().enumerate() {
println(from_child[ii].recv());
}
}

View file

@ -15,6 +15,8 @@
extern mod extra;
use std::rt::io;
use std::rt::io::stdio::StdReader;
use std::rt::io::buffered::BufferedReader;
use std::os;
use std::uint;
use std::unstable::intrinsics::cttz16;
@ -66,12 +68,14 @@ impl Sudoku {
return true;
}
pub fn read(reader: @mut io::Reader) -> Sudoku {
assert!(reader.read_line() == ~"9,9"); /* assert first line is exactly "9,9" */
pub fn read(mut reader: BufferedReader<StdReader>) -> Sudoku {
assert!(reader.read_line().unwrap() == ~"9,9"); /* assert first line is exactly "9,9" */
let mut g = vec::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] });
while !reader.eof() {
let line = reader.read_line();
loop {
let line = match reader.read_line() {
Some(ln) => ln, None => break
};
let comps: ~[&str] = line.trim().split_iter(',').collect();
if comps.len() == 3u {
@ -88,11 +92,11 @@ impl Sudoku {
pub fn write(&self, writer: @mut io::Writer) {
for row in range(0u8, 9u8) {
writer.write_str(format!("{}", self.grid[row][0] as uint));
write!(writer, "{}", self.grid[row][0]);
for col in range(1u8, 9u8) {
writer.write_str(format!(" {}", self.grid[row][col] as uint));
write!(writer, " {}", self.grid[row][col]);
}
writer.write_char('\n');
write!(writer, "\n");
}
}
@ -277,7 +281,7 @@ fn main() {
let mut sudoku = if use_default {
Sudoku::from_vec(&DEFAULT_SUDOKU)
} else {
Sudoku::read(@mut io::stdin() as @mut io::Reader)
Sudoku::read(BufferedReader::new(io::stdin()))
};
sudoku.solve();
sudoku.write(@mut io::stdout() as @mut io::Writer);