rust/src/test/run-pass/issue-3556.rs

48 lines
1.6 KiB
Rust
Raw Normal View History

// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(managed_boxes)]
2013-10-23 03:49:18 -05:00
enum Token {
Text(@String),
ETag(@Vec<String> , @String),
UTag(@Vec<String> , @String),
Section(@Vec<String> , bool, @Vec<Token> , @String, @String, @String, @String, @String),
IncompleteSection(@Vec<String> , bool, @String, bool),
Partial(@String, @String, @String),
}
fn check_strs(actual: &str, expected: &str) -> bool
{
2014-02-05 16:33:10 -06:00
if actual != expected
{
println!("Found {}, but expected {}", actual, expected);
return false;
}
return true;
}
2013-03-27 11:58:28 -05:00
pub fn main()
{
2014-04-15 20:17:48 -05:00
// assert!(check_strs(fmt!("%?", Text(@"foo".to_owned())), "Text(@~\"foo\")"));
// assert!(check_strs(fmt!("%?", ETag(@~["foo".to_owned()], @"bar".to_owned())),
// "ETag(@~[ ~\"foo\" ], @~\"bar\")"));
let t = Text(@"foo".to_strbuf());
let u = Section(@vec!("alpha".to_strbuf()),
true,
@vec!(t),
@"foo".to_strbuf(),
@"foo".to_strbuf(), @"foo".to_strbuf(), @"foo".to_strbuf(),
@"foo".to_strbuf());
2014-02-05 16:33:10 -06:00
let v = format!("{:?}", u); // this is the line that causes the seg fault
assert!(v.len() > 0);
}