2013-06-17 19:23:18 -05:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2013-05-06 10:32:34 -05:00
|
|
|
// 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(struct_variant)]
|
2013-10-02 22:00:54 -05:00
|
|
|
|
2014-02-19 20:56:33 -06:00
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
#[deriving(Show)]
|
2013-06-17 19:23:18 -05:00
|
|
|
enum A {}
|
2014-02-19 20:56:33 -06:00
|
|
|
#[deriving(Show)]
|
2013-06-17 19:23:18 -05:00
|
|
|
enum B { B1, B2, B3 }
|
2014-02-19 20:56:33 -06:00
|
|
|
#[deriving(Show)]
|
2014-05-12 19:56:43 -05:00
|
|
|
enum C { C1(int), C2(B), C3(StrBuf) }
|
2014-02-19 20:56:33 -06:00
|
|
|
#[deriving(Show)]
|
2013-06-17 19:23:18 -05:00
|
|
|
enum D { D1{ a: int } }
|
2014-02-19 20:56:33 -06:00
|
|
|
#[deriving(Show)]
|
2013-06-17 19:23:18 -05:00
|
|
|
struct E;
|
2014-02-19 20:56:33 -06:00
|
|
|
#[deriving(Show)]
|
2013-06-17 19:23:18 -05:00
|
|
|
struct F(int);
|
2014-02-19 20:56:33 -06:00
|
|
|
#[deriving(Show)]
|
2013-06-17 19:23:18 -05:00
|
|
|
struct G(int, int);
|
2014-02-19 20:56:33 -06:00
|
|
|
#[deriving(Show)]
|
2013-06-17 19:23:18 -05:00
|
|
|
struct H { a: int }
|
2014-02-19 20:56:33 -06:00
|
|
|
#[deriving(Show)]
|
2013-06-17 19:23:18 -05:00
|
|
|
struct I { a: int, b: int }
|
2014-02-19 20:56:33 -06:00
|
|
|
#[deriving(Show)]
|
2013-06-17 19:23:18 -05:00
|
|
|
struct J(Custom);
|
2013-05-24 21:35:29 -05:00
|
|
|
|
2013-06-17 19:23:18 -05:00
|
|
|
struct Custom;
|
2014-02-19 20:56:33 -06:00
|
|
|
impl fmt::Show for Custom {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
2014-05-10 16:05:06 -05:00
|
|
|
write!(f, "yay")
|
2014-02-19 20:56:33 -06:00
|
|
|
}
|
2013-05-06 10:32:34 -05:00
|
|
|
}
|
|
|
|
|
2013-09-25 02:43:37 -05:00
|
|
|
pub fn main() {
|
2014-05-16 12:45:16 -05:00
|
|
|
assert_eq!(B1.to_str(), "B1".to_strbuf());
|
|
|
|
assert_eq!(B2.to_str(), "B2".to_strbuf());
|
|
|
|
assert_eq!(C1(3).to_str(), "C1(3)".to_strbuf());
|
|
|
|
assert_eq!(C2(B2).to_str(), "C2(B2)".to_strbuf());
|
|
|
|
assert_eq!(D1{ a: 2 }.to_str(), "D1 { a: 2 }".to_strbuf());
|
|
|
|
assert_eq!(E.to_str(), "E".to_strbuf());
|
|
|
|
assert_eq!(F(3).to_str(), "F(3)".to_strbuf());
|
|
|
|
assert_eq!(G(3, 4).to_str(), "G(3, 4)".to_strbuf());
|
|
|
|
assert_eq!(G(3, 4).to_str(), "G(3, 4)".to_strbuf());
|
|
|
|
assert_eq!(I{ a: 2, b: 4 }.to_str(), "I { a: 2, b: 4 }".to_strbuf());
|
|
|
|
assert_eq!(J(Custom).to_str(), "J(yay)".to_strbuf());
|
2013-05-24 21:35:29 -05:00
|
|
|
}
|