2013-03-21 17:00:29 -05:00
|
|
|
// 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.
|
|
|
|
|
2014-04-14 10:30:31 -05:00
|
|
|
#![feature(managed_boxes)]
|
2013-10-23 03:49:18 -05:00
|
|
|
|
2013-03-21 17:00:29 -05:00
|
|
|
enum Token {
|
2014-05-22 18:57:53 -05:00
|
|
|
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),
|
2013-03-21 17:00:29 -05:00
|
|
|
}
|
2013-05-03 18:25:04 -05:00
|
|
|
|
2013-03-21 17:00:29 -05:00
|
|
|
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-21 17:00:29 -05:00
|
|
|
}
|
2013-05-03 18:25:04 -05:00
|
|
|
|
2013-03-27 11:58:28 -05:00
|
|
|
pub fn main()
|
2013-03-21 17:00:29 -05:00
|
|
|
{
|
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\")"));
|
2013-05-03 18:25:04 -05:00
|
|
|
|
2014-05-12 19:56:43 -05:00
|
|
|
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);
|
2013-03-21 17:00:29 -05:00
|
|
|
}
|