Skip to content

Commit

Permalink
Add compile tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGVSV committed Apr 28, 2023
1 parent d5c13d6 commit 8182fa4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ serde_yaml = { version = "0.9", optional = true, default-features = false }
ron = "0.8"
bevy = "0.10.1"
bevy_prototype_lyon = "0.8.0"
trybuild = "1.0.71"

[[example]]
name = "basic_schematic"
Expand Down Expand Up @@ -110,3 +111,7 @@ required-features = ["ron", "auto_name"]
name = "templates"
path = "examples/templates.rs"
required-features = ["ron", "auto_name", "custom_schematics", "bevy_sprite", "yaml"]

[[test]]
name = "compile_tests"
path = "tests/compile_tests.rs"
6 changes: 6 additions & 0 deletions tests/compile_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[test]
fn test() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/compile_tests/*.fail.rs");
t.pass("tests/compile_tests/*.pass.rs");
}
36 changes: 36 additions & 0 deletions tests/compile_tests/generics.pass.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use bevy::asset::Asset;
use bevy::prelude::*;
use bevy_proto::prelude::*;
use std::borrow::Cow;

#[derive(Component, Schematic, Reflect)]
#[reflect(Schematic)]
struct TupleStructWithGenerics<'a: 'static, T: Asset, const N: usize>(
#[schematic(asset)] Handle<T>,
Cow<'a, str>,
[i32; N],
);

#[derive(Component, Schematic, Reflect)]
#[reflect(Schematic)]
struct StructWithGenerics<'a: 'static, T: Asset, const N: usize> {
#[schematic(asset)]
asset: Handle<T>,
string: Cow<'a, str>,
array: [i32; N],
}

#[derive(Component, Schematic, Reflect)]
#[reflect(Schematic)]
enum EnumWithGenerics<'a: 'static, T: Asset, const N: usize> {
Unit,
Tuple(#[schematic(asset)] Handle<T>, Cow<'a, str>, [i32; N]),
Struct {
#[schematic(asset)]
asset: Handle<T>,
string: Cow<'a, str>,
array: [i32; N],
},
}

fn main() {}

0 comments on commit 8182fa4

Please sign in to comment.