Skip to content

Commit

Permalink
Fixup style of test cases for rust-lang#7083
Browse files Browse the repository at this point in the history
  • Loading branch information
bblum committed Aug 20, 2013
1 parent 95089d3 commit 4fd404f
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/test/auxiliary/trait_superkinds_in_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
3 changes: 3 additions & 0 deletions src/test/compile-fail/builtin-superkinds-double-superkind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/test/compile-fail/builtin-superkinds-in-metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
3 changes: 3 additions & 0 deletions src/test/compile-fail/builtin-superkinds-simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/builtin-superkinds-typaram-not-send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }

Expand Down
11 changes: 7 additions & 4 deletions src/test/run-pass/builtin-superkinds-capabilities-xc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions src/test/run-pass/builtin-superkinds-capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down
8 changes: 5 additions & 3 deletions src/test/run-pass/builtin-superkinds-in-metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
Original file line number Diff line number Diff line change
Expand Up @@ -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>(());
Expand Down
2 changes: 2 additions & 0 deletions src/test/run-pass/builtin-superkinds-simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down
3 changes: 3 additions & 0 deletions src/test/run-pass/builtin-superkinds-typaram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down

0 comments on commit 4fd404f

Please sign in to comment.