]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-2904.rs
test: Make manual changes to deal with the fallout from removal of
[rust.git] / src / test / run-pass / issue-2904.rs
1 // ignore-fast
2
3 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
4 // file at the top-level directory of this distribution and at
5 // http://rust-lang.org/COPYRIGHT.
6 //
7 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10 // option. This file may not be copied, modified, or distributed
11 // except according to those terms.
12
13 #[feature(managed_boxes)];
14
15 /// Map representation
16
17 use std::io;
18 use std::fmt;
19 use std::vec_ng::Vec;
20
21 enum square {
22     bot,
23     wall,
24     rock,
25     lambda,
26     closed_lift,
27     open_lift,
28     earth,
29     empty
30 }
31
32 impl fmt::Show for square {
33     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
34         write!(f.buf, "{}", match *self {
35           bot => { ~"R" }
36           wall => { ~"#" }
37           rock => { ~"*" }
38           lambda => { ~"\\" }
39           closed_lift => { ~"L" }
40           open_lift => { ~"O" }
41           earth => { ~"." }
42           empty => { ~" " }
43         })
44     }
45 }
46
47 fn square_from_char(c: char) -> square {
48     match c  {
49       'R'  => { bot }
50       '#'  => { wall }
51       '*'  => { rock }
52       '\\' => { lambda }
53       'L'  => { closed_lift }
54       'O'  => { open_lift }
55       '.'  => { earth }
56       ' '  => { empty }
57       _ => {
58         println!("invalid square: {:?}", c);
59         fail!()
60       }
61     }
62 }
63
64 fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr)
65                    -> Vec<Vec<square>> {
66     let mut input: &mut io::Reader = &mut input;
67     let mut grid = Vec::new();
68     let mut line = [0, ..10];
69     input.read(line);
70     let mut row = Vec::new();
71     for c in line.iter() {
72         row.push(square_from_char(*c as char))
73     }
74     grid.push(row);
75     let width = grid.get(0).len();
76     for row in grid.iter() { assert!(row.len() == width) }
77     grid
78 }
79
80 mod test {
81     #[test]
82     pub fn trivial_to_str() {
83         assert!(lambda.to_str() == "\\")
84     }
85 }
86
87 pub fn main() {}