]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-3556.rs
auto merge of #19648 : mquandalle/rust/patch-1, r=alexcrichton
[rust.git] / src / test / run-pass / issue-3556.rs
1 // Copyright 2013 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
12 #[deriving(Show)]
13 enum Token {
14     Text(String),
15     ETag(Vec<String>, String),
16     UTag(Vec<String>, String),
17     Section(Vec<String>, bool, Vec<Token>, String,
18             String, String, String, String),
19     IncompleteSection(Vec<String>, bool, String, bool),
20     Partial(String, String, String),
21 }
22
23 fn check_strs(actual: &str, expected: &str) -> bool
24 {
25     if actual != expected
26     {
27         println!("Found {}, but expected {}", actual, expected);
28         return false;
29     }
30     return true;
31 }
32
33 pub fn main()
34 {
35 // assert!(check_strs(fmt!("%?", Text(@"foo".to_string())), "Text(@~\"foo\")"));
36 // assert!(check_strs(fmt!("%?", ETag(@~["foo".to_string()], @"bar".to_string())),
37 //                    "ETag(@~[ ~\"foo\" ], @~\"bar\")"));
38
39     let t = Token::Text("foo".to_string());
40     let u = Token::Section(vec!["alpha".to_string()],
41                     true,
42                     vec![t],
43                     "foo".to_string(),
44                     "foo".to_string(), "foo".to_string(), "foo".to_string(),
45                     "foo".to_string());
46     let v = format!("{}", u);    // this is the line that causes the seg fault
47     assert!(v.len() > 0);
48 }