Skip to content

Commit 7095cd4

Browse files
committed
Add compilation tests
1 parent 078e517 commit 7095cd4

File tree

6 files changed

+45
-0
lines changed

6 files changed

+45
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# will have compiled files and executables
33
debug/
44
target/
5+
wip/
56

67
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
78
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html

rust/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ rand = "0.7.3"
2525

2626
[dev-dependencies]
2727
criterion = "0.3.3"
28+
trybuild = "1.0.30"
2829

2930
[profile.dev]
3031
opt-level = 0

rust/tests/trybuild.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// This is a test-suite for testing if compilation fails or succeeds
2+
#[test]
3+
fn trybuild() {
4+
let t = trybuild::TestCases::new();
5+
t.compile_fail("tests/trybuild_*.fail");
6+
t.pass("tests/trybuild_*.pass");
7+
}

rust/tests/trybuild_soe_max.fail

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
mod common;
2+
use common::*;
3+
use swag::soe::*;
4+
5+
/// Should not compile since Max is not invertible
6+
fn main() {
7+
SoE::<Int, Max>::new();
8+
}

rust/tests/trybuild_soe_max.stderr

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0599]: no function or associated item named `new` found for struct `swag::soe::SoE<common::Int, common::Max>` in the current scope
2+
--> $DIR/trybuild_soe_max.fail:7:22
3+
|
4+
7 | SoE::<Int, Max>::new();
5+
| ^^^ function or associated item not found in `swag::soe::SoE<common::Int, common::Max>`
6+
7+
error[E0277]: the trait bound `common::Int: alga::general::one_operator::AbstractGroup<common::Max>` is not satisfied
8+
--> $DIR/trybuild_soe_max.fail:7:5
9+
|
10+
7 | SoE::<Int, Max>::new();
11+
| ^^^^^^^^^^^^^^^^^^^^ the trait `alga::general::one_operator::AbstractGroup<common::Max>` is not implemented for `common::Int`
12+
|
13+
::: $WORKSPACE/src/soe/mod.rs:10:12
14+
|
15+
10 | Value: AbstractGroup<BinOp> + Clone,
16+
| -------------------- required by this bound in `swag::soe::SoE`
17+
|
18+
= help: the following implementations were found:
19+
<common::Int as alga::general::one_operator::AbstractGroup<common::Sum>>

rust/tests/trybuild_soe_sum.pass

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mod common;
2+
use common::*;
3+
use swag::FifoWindow;
4+
use swag::soe::*;
5+
6+
/// Should compile since Sum is invertible
7+
fn main() {
8+
SoE::<Int, Sum>::new();
9+
}

0 commit comments

Comments
 (0)