From 4fd404f2ca1b3a246872521a606d749ae5a11258 Mon Sep 17 00:00:00 2001 From: Ben Blum Date: Mon, 19 Aug 2013 17:15:25 -0400 Subject: [PATCH] Fixup style of test cases for #7083 --- src/test/auxiliary/trait_superkinds_in_metadata.rs | 7 +++++-- .../builtin-superkinds-double-superkind.rs | 3 +++ .../compile-fail/builtin-superkinds-in-metadata.rs | 9 ++++++--- src/test/compile-fail/builtin-superkinds-simple.rs | 3 +++ .../builtin-superkinds-typaram-not-send.rs | 2 ++ .../builtin-superkinds-capabilities-transitive.rs | 6 ++++++ .../run-pass/builtin-superkinds-capabilities-xc.rs | 11 +++++++---- src/test/run-pass/builtin-superkinds-capabilities.rs | 4 ++++ src/test/run-pass/builtin-superkinds-in-metadata.rs | 8 +++++--- ...param.rs => builtin-superkinds-phantom-typaram.rs} | 4 ++++ src/test/run-pass/builtin-superkinds-simple.rs | 2 ++ src/test/run-pass/builtin-superkinds-typaram.rs | 3 +++ 12 files changed, 50 insertions(+), 12 deletions(-) rename src/test/run-pass/{builtin-superkinds-shadow-typaram.rs => builtin-superkinds-phantom-typaram.rs} (74%) diff --git a/src/test/auxiliary/trait_superkinds_in_metadata.rs b/src/test/auxiliary/trait_superkinds_in_metadata.rs index 02d2a6b8af4..dfb0c0310ec 100644 --- a/src/test/auxiliary/trait_superkinds_in_metadata.rs +++ b/src/test/auxiliary/trait_superkinds_in_metadata.rs @@ -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 { } diff --git a/src/test/compile-fail/builtin-superkinds-double-superkind.rs b/src/test/compile-fail/builtin-superkinds-double-superkind.rs index c5dbcd9bb23..15fa0b66433 100644 --- a/src/test/compile-fail/builtin-superkinds-double-superkind.rs +++ b/src/test/compile-fail/builtin-superkinds-double-superkind.rs @@ -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 Foo for (T,) { } //~ ERROR cannot implement this trait diff --git a/src/test/compile-fail/builtin-superkinds-in-metadata.rs b/src/test/compile-fail/builtin-superkinds-in-metadata.rs index 3fa7c5a28ba..a52a3765889 100644 --- a/src/test/compile-fail/builtin-superkinds-in-metadata.rs +++ b/src/test/compile-fail/builtin-superkinds-in-metadata.rs @@ -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); -impl Bar for X { } +impl RequiresFreeze for X { } -impl Foo for X { } //~ ERROR cannot implement this trait +impl RequiresRequiresFreezeAndSend for X { } //~ ERROR cannot implement this trait fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-simple.rs b/src/test/compile-fail/builtin-superkinds-simple.rs index 472bef715e9..c1011f1368a 100644 --- a/src/test/compile-fail/builtin-superkinds-simple.rs +++ b/src/test/compile-fail/builtin-superkinds-simple.rs @@ -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 diff --git a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs index ec10ba09104..2a3d3c7df61 100644 --- a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs +++ b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs @@ -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 Foo for T { } //~ ERROR cannot implement this trait diff --git a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs index 8b9cd057457..ab5e58285d4 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs @@ -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 { } diff --git a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs index 85012896253..1e24c121f5a 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs @@ -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); -impl Bar for X { } -impl Foo for X { } +impl RequiresFreeze for X { } +impl RequiresRequiresFreezeAndSend for X { } -fn foo(val: T, chan: std::comm::Chan) { +fn foo(val: T, chan: std::comm::Chan) { chan.send(val); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities.rs b/src/test/run-pass/builtin-superkinds-capabilities.rs index 639c78bd657..ebbb3d38694 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities.rs @@ -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 Foo for T { } diff --git a/src/test/run-pass/builtin-superkinds-in-metadata.rs b/src/test/run-pass/builtin-superkinds-in-metadata.rs index fc445058c04..9f68976a4a4 100644 --- a/src/test/run-pass/builtin-superkinds-in-metadata.rs +++ b/src/test/run-pass/builtin-superkinds-in-metadata.rs @@ -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); -impl Bar for X { } +impl RequiresFreeze for X { } -impl Foo for X { } +impl RequiresRequiresFreezeAndSend for X { } fn main() { } diff --git a/src/test/run-pass/builtin-superkinds-shadow-typaram.rs b/src/test/run-pass/builtin-superkinds-phantom-typaram.rs similarity index 74% rename from src/test/run-pass/builtin-superkinds-shadow-typaram.rs rename to src/test/run-pass/builtin-superkinds-phantom-typaram.rs index 193efb06d39..b6e58bfbf3d 100644 --- a/src/test/run-pass/builtin-superkinds-shadow-typaram.rs +++ b/src/test/run-pass/builtin-superkinds-phantom-typaram.rs @@ -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(()); diff --git a/src/test/run-pass/builtin-superkinds-simple.rs b/src/test/run-pass/builtin-superkinds-simple.rs index 5ecac6a0f7a..61a22d97498 100644 --- a/src/test/run-pass/builtin-superkinds-simple.rs +++ b/src/test/run-pass/builtin-superkinds-simple.rs @@ -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 { } diff --git a/src/test/run-pass/builtin-superkinds-typaram.rs b/src/test/run-pass/builtin-superkinds-typaram.rs index eda04a780ee..7dfd1e0629f 100644 --- a/src/test/run-pass/builtin-superkinds-typaram.rs +++ b/src/test/run-pass/builtin-superkinds-typaram.rs @@ -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 Foo for T { }