Fixup style of test cases for #7083

This commit is contained in:
Ben Blum 2013-08-19 17:15:25 -04:00
parent 95089d3793
commit 4fd404f2ca
12 changed files with 50 additions and 12 deletions

View File

@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test library crate for cross-crate usages of traits inheriting
// from the builtin kinds. Mostly tests metadata correctness.
#[crate_type="lib"];
pub trait Bar : Freeze { }
pub trait Foo : Bar + Send { }
pub trait RequiresFreeze : Freeze { }
pub trait RequiresRequiresFreezeAndSend : RequiresFreeze + Send { }

View File

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test for traits that inherit from multiple builtin kinds at once,
// testing that all such kinds must be present on implementing types.
trait Foo : Send+Freeze { }
impl <T: Freeze> Foo for (T,) { } //~ ERROR cannot implement this trait

View File

@ -10,13 +10,16 @@
// aux-build:trait_superkinds_in_metadata.rs
// Test for traits inheriting from the builtin kinds cross-crate.
// Mostly tests correctness of metadata.
extern mod trait_superkinds_in_metadata;
use trait_superkinds_in_metadata::{Foo, Bar};
use trait_superkinds_in_metadata::{RequiresRequiresFreezeAndSend, RequiresFreeze};
struct X<T>(T);
impl <T:Freeze> Bar for X<T> { }
impl <T:Freeze> RequiresFreeze for X<T> { }
impl <T:Freeze> Foo for X<T> { } //~ ERROR cannot implement this trait
impl <T:Freeze> RequiresRequiresFreezeAndSend for X<T> { } //~ ERROR cannot implement this trait
fn main() { }

View File

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Basic test for traits inheriting from the builtin kinds, checking
// the type contents of the implementing type (that's not a typaram).
trait Foo : Send { }
impl <'self> Foo for &'self mut () { } //~ ERROR cannot implement this trait

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Basic test for traits inheriting from the builtin kinds.
trait Foo : Send { }
impl <T: Freeze> Foo for T { } //~ ERROR cannot implement this trait

View File

@ -8,6 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Tests "transitivity" of super-builtin-kinds on traits. Here, if
// we have a Foo, we know we have a Bar, and if we have a Bar, we
// know we have a Send. So if we have a Foo we should know we have
// a Send. Basically this just makes sure rustc is using
// each_bound_trait_and_supertraits in type_contents correctly.
trait Bar : Send { }
trait Foo : Bar { }

View File

@ -10,16 +10,19 @@
// aux-build:trait_superkinds_in_metadata.rs
// Tests "capabilities" granted by traits with super-builtin-kinds,
// even when using them cross-crate.
extern mod trait_superkinds_in_metadata;
use trait_superkinds_in_metadata::{Foo, Bar};
use trait_superkinds_in_metadata::{RequiresRequiresFreezeAndSend, RequiresFreeze};
#[deriving(Eq)]
struct X<T>(T);
impl <T: Freeze> Bar for X<T> { }
impl <T: Freeze+Send> Foo for X<T> { }
impl <T: Freeze> RequiresFreeze for X<T> { }
impl <T: Freeze+Send> RequiresRequiresFreezeAndSend for X<T> { }
fn foo<T: Foo>(val: T, chan: std::comm::Chan<T>) {
fn foo<T: RequiresRequiresFreezeAndSend>(val: T, chan: std::comm::Chan<T>) {
chan.send(val);
}

View File

@ -8,6 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Tests "capabilities" granted by traits that inherit from super-
// builtin-kinds, e.g., if a trait requires Send to implement, then
// at usage site of that trait, we know we have the Send capability.
trait Foo : Send { }
impl <T: Send> Foo for T { }

View File

@ -10,13 +10,15 @@
// aux-build:trait_superkinds_in_metadata.rs
// Tests (correct) usage of trait super-builtin-kinds cross-crate.
extern mod trait_superkinds_in_metadata;
use trait_superkinds_in_metadata::{Foo, Bar};
use trait_superkinds_in_metadata::{RequiresRequiresFreezeAndSend, RequiresFreeze};
struct X<T>(T);
impl <T:Freeze> Bar for X<T> { }
impl <T:Freeze> RequiresFreeze for X<T> { }
impl <T:Freeze+Send> Foo for X<T> { }
impl <T:Freeze+Send> RequiresRequiresFreezeAndSend for X<T> { }
fn main() { }

View File

@ -8,6 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Tests that even when a type paramenter doesn't implement a required
// super-builtin-kind of a trait, if the type parameter is never used,
// the type can implement the trait anyway.
trait Foo : Send { }
struct X<T>(());

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Simple test case of implementing a trait with super-builtin-kinds.
trait Foo : Send { }
impl Foo for int { }

View File

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Tests correct implementation of traits with super-builtin-kinds
// using a bounded type parameter.
trait Foo : Send { }
impl <T: Send> Foo for T { }