|
| 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 | +extern mod std; |
| 12 | +use core::io::WriterUtil; |
| 13 | + |
| 14 | +enum Token { |
| 15 | + Text(@~str), |
| 16 | + ETag(@~[~str], @~str), |
| 17 | + UTag(@~[~str], @~str), |
| 18 | + Section(@~[~str], bool, @~[Token], @~str, @~str, @~str, @~str, @~str), |
| 19 | + IncompleteSection(@~[~str], bool, @~str, bool), |
| 20 | + Partial(@~str, @~str, @~str), |
| 21 | +} |
| 22 | + |
| 23 | +fn check_strs(actual: &str, expected: &str) -> bool |
| 24 | +{ |
| 25 | + if actual != expected |
| 26 | + { |
| 27 | + io::stderr().write_line(fmt!("Found %s, but expected %s", actual, expected)); |
| 28 | + return false; |
| 29 | + } |
| 30 | + return true; |
| 31 | +} |
| 32 | + |
| 33 | +fn main() |
| 34 | +{ |
| 35 | + // fail_unless!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")")); |
| 36 | + // fail_unless!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")")); |
| 37 | + |
| 38 | + let t = Text(@~"foo"); |
| 39 | + let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo"); |
| 40 | + let v = fmt!("%?", u); // this is the line that causes the seg fault |
| 41 | + fail_unless!(v.len() > 0); |
| 42 | +} |
0 commit comments