diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2017-11-22 16:21:11 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2017-11-22 16:25:17 +0100 |
commit | b1ce298d4b20065bb77f62974a4c4106e9cd91e1 (patch) | |
tree | 37b66ac10803de39e12534dbdf711601bebd7a9b /tests/unit | |
parent | d96f0ff6a77e309682898cc7e1905a7bd0feb3cf (diff) | |
download | servo-b1ce298d4b20065bb77f62974a4c4106e9cd91e1.tar.gz servo-b1ce298d4b20065bb77f62974a4c4106e9cd91e1.zip |
Replace compiletest suite by doc-tests with `compile_fail`
compiletest-rs use internal rustc APIs and is broken in today’s Nightly.
rustdoc however is maintained with rustc and so much less fragile.
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/deny_public_fields/Cargo.toml | 12 | ||||
-rw-r--r-- | tests/unit/deny_public_fields/lib.rs | 33 | ||||
-rw-r--r-- | tests/unit/malloc_size_of/Cargo.toml | 13 | ||||
-rw-r--r-- | tests/unit/malloc_size_of/lib.rs | 109 | ||||
-rw-r--r-- | tests/unit/script/Cargo.toml | 1 | ||||
-rw-r--r-- | tests/unit/script/lib.rs | 22 | ||||
-rw-r--r-- | tests/unit/script_plugins/Cargo.toml | 12 | ||||
-rw-r--r-- | tests/unit/script_plugins/lib.rs | 63 |
8 files changed, 259 insertions, 6 deletions
diff --git a/tests/unit/deny_public_fields/Cargo.toml b/tests/unit/deny_public_fields/Cargo.toml new file mode 100644 index 00000000000..679069d2c1b --- /dev/null +++ b/tests/unit/deny_public_fields/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "deny_public_fields_tests" +version = "0.0.1" +authors = ["The Servo Project Developers"] +license = "MPL-2.0" + +[lib] +path = "lib.rs" +test = false + +[dependencies] +deny_public_fields = {path = "../../../components/deny_public_fields"} diff --git a/tests/unit/deny_public_fields/lib.rs b/tests/unit/deny_public_fields/lib.rs new file mode 100644 index 00000000000..1fcb1314cf3 --- /dev/null +++ b/tests/unit/deny_public_fields/lib.rs @@ -0,0 +1,33 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** +```compile_fail +#[macro_use] extern crate deny_public_fields; + +#[derive(DenyPublicFields)] +struct Foo { + pub v1: i32, + v2: i32 +} + +fn main() {} +``` +*/ +pub fn deny_public_fields_failing() {} + +/** +``` +#[macro_use] extern crate deny_public_fields; + +#[derive(DenyPublicFields)] +struct Foo { + v1: i32, + v2: i32 +} + +fn main() {} +``` +*/ +pub fn deny_public_fields_ok() {} diff --git a/tests/unit/malloc_size_of/Cargo.toml b/tests/unit/malloc_size_of/Cargo.toml new file mode 100644 index 00000000000..80668d5ba61 --- /dev/null +++ b/tests/unit/malloc_size_of/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "malloc_size_of_tests" +version = "0.0.1" +authors = ["The Servo Project Developers"] +license = "MPL-2.0" + +[lib] +path = "lib.rs" +test = false + +[dependencies] +malloc_size_of = {path = "../../../components/malloc_size_of"} +servo_arc = {path = "../../../components/servo_arc"} diff --git a/tests/unit/malloc_size_of/lib.rs b/tests/unit/malloc_size_of/lib.rs new file mode 100644 index 00000000000..8aae5a40310 --- /dev/null +++ b/tests/unit/malloc_size_of/lib.rs @@ -0,0 +1,109 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** +``` +extern crate malloc_size_of; +extern crate servo_arc; + +fn sizeable<T: malloc_size_of::MallocSizeOf>() {} +fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {} +fn cloneable<T: Clone>() {} + +fn main() { + cloneable::<servo_arc::Arc<i32>>(); + cloneable::<std::sync::Arc<i32>>(); + cloneable::<std::rc::Rc<i32>>(); +} +``` +*/ +pub fn imports_ok() {} + +pub mod does_not_impl_malloc_size_of { + /** + ```compile_fail,E0277 + extern crate malloc_size_of; + extern crate servo_arc; + + fn sizeable<T: malloc_size_of::MallocSizeOf>() {} + + fn main() { + sizeable::<servo_arc::Arc<i32>>(); + } + ``` + */ + pub fn servo_arc() {} + + + /** + ```compile_fail,E0277 + extern crate malloc_size_of; + + fn sizeable<T: malloc_size_of::MallocSizeOf>() {} + + fn main() { + sizeable::<std::sync::Arc<i32>>(); + } + ``` + */ + pub fn std_arc() {} + + + /** + ```compile_fail,E0277 + extern crate malloc_size_of; + + fn sizeable<T: malloc_size_of::MallocSizeOf>() {} + + fn main() { + sizeable::<std::rc::Rc<i32>>(); + } + ``` + */ + pub fn rc() {} +} + +pub mod does_not_impl_malloc_shallow_size_of { + /** + ```compile_fail,E0277 + extern crate malloc_size_of; + extern crate servo_arc; + + fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {} + + fn main() { + shallow_sizeable::<servo_arc::Arc<i32>>(); + } + ``` + */ + pub fn servo_arc() {} + + + /** + ```compile_fail,E0277 + extern crate malloc_size_of; + + fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {} + + fn main() { + shallow_sizeable::<std::sync::Arc<i32>>(); + } + ``` + */ + pub fn std_arc() {} + + + /** + ```compile_fail,E0277 + extern crate malloc_size_of; + + fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {} + + fn main() { + shallow_sizeable::<std::rc::Rc<i32>>(); + } + ``` + */ + pub fn rc() {} +} diff --git a/tests/unit/script/Cargo.toml b/tests/unit/script/Cargo.toml index 7785cced6a9..7983d119f38 100644 --- a/tests/unit/script/Cargo.toml +++ b/tests/unit/script/Cargo.toml @@ -7,7 +7,6 @@ license = "MPL-2.0" [lib] name = "script_tests" path = "lib.rs" -doctest = false [dependencies] euclid = "0.15" diff --git a/tests/unit/script/lib.rs b/tests/unit/script/lib.rs index 21b89a304c5..6d724db5358 100644 --- a/tests/unit/script/lib.rs +++ b/tests/unit/script/lib.rs @@ -2,11 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -extern crate euclid; -extern crate msg; -extern crate script; -extern crate servo_url; -extern crate style; +#[cfg(test)] extern crate euclid; +#[cfg(test)] extern crate msg; +#[cfg(test)] extern crate script; +#[cfg(test)] extern crate servo_url; +#[cfg(test)] extern crate style; #[cfg(test)] mod origin; #[cfg(all(test, target_pointer_width = "64"))] mod size_of; @@ -15,3 +15,15 @@ extern crate style; #[cfg(test)] mod htmlareaelement; #[cfg(test)] mod htmlimageelement; +/** +```compile_fail,E0277 +extern crate script; + +fn cloneable<T: Clone>() {} + +fn main() { + cloneable::<script::test::TrustedPromise>(); +} +``` +*/ +pub fn trustedpromise_does_not_impl_clone() {} diff --git a/tests/unit/script_plugins/Cargo.toml b/tests/unit/script_plugins/Cargo.toml new file mode 100644 index 00000000000..8a41b62aa8f --- /dev/null +++ b/tests/unit/script_plugins/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "script_plugins_tests" +version = "0.0.1" +authors = ["The Servo Project Developers"] +license = "MPL-2.0" + +[lib] +path = "lib.rs" +test = false + +[dependencies] +script_plugins = {path = "../../../components/script_plugins"} diff --git a/tests/unit/script_plugins/lib.rs b/tests/unit/script_plugins/lib.rs new file mode 100644 index 00000000000..35a1c0dff11 --- /dev/null +++ b/tests/unit/script_plugins/lib.rs @@ -0,0 +1,63 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +pub mod unrooted_must_root { + /** + ``` + #![feature(plugin)] + #![plugin(script_plugins)] + + #[must_root] struct Foo(i32); + #[must_root] struct Bar(Foo); + + fn foo1(_: &Foo) {} + fn foo2(_: &()) -> &Foo { unimplemented!() } + + fn main() {} + ``` + */ + pub fn ok() {} + + /** + ```compile_fail + #![feature(plugin)] + #![plugin(script_plugins)] + + #[must_root] struct Foo(i32); + struct Bar(Foo); + + fn main() {} + ``` + */ + pub fn struct_field() {} + + /** + ```compile_fail + #![feature(plugin)] + #![plugin(script_plugins)] + + #[must_root] struct Foo(i32); + + fn foo1(_: Foo) {} + + fn main() {} + ``` + */ + pub fn parameter() {} + + /** + ```compile_fail + #![feature(plugin)] + #![plugin(script_plugins)] + + #[must_root] struct Foo(i32); + + fn foo2() -> Foo { unimplemented!() } + + fn main() {} + ``` + */ + pub fn return_type() {} + +} |