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